Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Queue, SMS, timezone, and permalink fixes for wp-mail from MooKitty.

git-svn-id: http://core.svn.wordpress.org/trunk@1484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit 3f7cd011660cccb7c08481ee8519f271e6057326 1 parent f17b0ab
authored July 26, 2004

Showing 1 changed file with 31 additions and 13 deletions. Show diff stats Hide diff stats

  1. 44  wp-mail.php
44  wp-mail.php
@@ -5,7 +5,7 @@
5 5
 
6 6
 error_reporting(2037);
7 7
 
8  
-$time_difference = get_settings('gmt_offset');
  8
+$time_difference = get_settings('gmt_offset') * 3600;
9 9
 
10 10
 $pop3 = new POP3();
11 11
 
@@ -59,6 +59,10 @@
59 59
 				if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $subject)) {
60 60
 				  $subject = wp_iso_descrambler($subject);
61 61
 				}
  62
+				// Captures any text in the subject before :: as the subject
  63
+				$subject = explode('::', $subject);
  64
+				$subject = $subject[0];
  65
+
62 66
 			}
63 67
 			if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
64 68
 				$ddate = trim($line);
@@ -76,23 +80,32 @@
76 80
 				$ddate_m = $date_arr[1];
77 81
 				$ddate_d = $date_arr[0];
78 82
 				$ddate_Y = $date_arr[2];
79  
-				for ($i=0; $i<12; $i++) {
80  
-					if ($ddate_m == $dmonths[$i]) {
81  
-						$ddate_m = $i+1;
  83
+
  84
+				for ($j=0; $j<12; $j++) {
  85
+					if ($ddate_m == $dmonths[$j]) {
  86
+						$ddate_m = $j+1;
82 87
 					}
83 88
 				}
84  
-				$ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
85 89
 
86  
-				$post_date = gmdate('Y-m-d H:i:s', $ddate_U + ($time_difference * 3600));
  90
+				$time_zn = intval($date_arr[4]) * 36;
  91
+				if ( $time_zn < 0 ) {
  92
+					if (abs($time_difference) > abs($time_zn)) {
  93
+						$time_zn = abs($time_difference) - abs($time_zn);
  94
+					} else {
  95
+						$time_zn = abs($time_zn) - abs($time_difference);
  96
+					}
  97
+				} else {
  98
+					$time_zn = abs($time_zn) + abs($time_difference);
  99
+				}
  100
+
  101
+				$ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
  102
+				$ddate_U = $ddate_U - $time_zn;
  103
+				$post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
87 104
 				$post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
88 105
 			}
89 106
 		}
90 107
 	endforeach;
91 108
 
92  
-	$ddate_today = time() + ($time_difference * 3600);
93  
-	$ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
94  
-
95  
-
96 109
 	$subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
97 110
 
98 111
 	if ($content_type == 'multipart/alternative') {
@@ -102,6 +115,9 @@
102 115
 		$content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
103 116
 	}
104 117
 	$content = trim($content);
  118
+	// Captures any text in the body after :: as the body
  119
+	$content = explode('::', $content);
  120
+	$content = $content[1];
105 121
 
106 122
 	echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
107 123
 	echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
@@ -117,11 +133,13 @@
117 133
 	if (empty($post_categories)) $post_categories[] = get_settings('default_email_category');
118 134
 
119 135
 	$post_title = addslashes(trim($post_title));
  136
+	// Make sure that we get a nice post-slug
  137
+	$post_name = sanitize_title( $post_title );
120 138
 	$content = preg_replace("|\n([^\n])|", " $1", $content);
121 139
 	$content = addslashes(trim($content));
122 140
 
123 141
 
124  
-	$sql = "INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES (1, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')";
  142
+	$sql = "INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_name, post_modified, post_modified_gmt) VALUES (1, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_name', '$post_date', '$post_date_gmt')";
125 143
 
126 144
 	$result = $wpdb->query($sql);
127 145
 	$post_ID = $wpdb->insert_id;
@@ -133,8 +151,8 @@
133 151
 	echo "\n<p><b>Posted title:</b> $post_title<br />";
134 152
 	echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>';
135 153
 
136  
-if (!$post_categories) $post_categories[] = 1;
137  
-foreach ($post_categories as $post_category) :
  154
+	if (!$post_categories) $post_categories[] = 1;
  155
+	foreach ($post_categories as $post_category) :
138 156
 	$post_category = intval($post_category);
139 157
 
140 158
 	// Double check it's not there already

0 notes on commit 3f7cd01

Please sign in to comment.
Something went wrong with that request. Please try again.