Changeset 1153 for trunk/wp-mail.php
- Timestamp:
- 04/24/2004 10:43:47 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-mail.php
r1150 r1153 4 4 require_once(ABSPATH.WPINC.'/class-pop3.php'); 5 5 6 7 timer_start();8 9 $output_debugging_info = 0; # =1 if you want to output debugging info10 11 if (get_settings('use_phoneemail')) {12 // if you're using phone email, the email will already be in your timezone13 $time_difference = 0;14 }15 16 6 error_reporting(2037); 17 18 19 7 20 8 $pop3 = new POP3(); 21 9 22 if (!$pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {10 if (!$pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) : 23 11 echo "Ooops $pop3->ERROR <br />\n"; 24 12 exit; 25 } 13 endif; 26 14 27 $Count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); 28 if((!$Count) || ($Count == -1)) { 29 echo "<h1>Login Failed: $pop3->ERROR</h1>\n"; 30 $pop3->quit(); 31 exit; 32 } 15 $count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); 16 if (0 == $count) die(__('There doesn’t seem to be any new mail.')); 33 17 34 18 35 // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT! 36 //register_shutdown_function($pop3->quit()); 19 for ($i=1; $i <= $count; $i++) : 37 20 38 for ($iCount=1; $iCount<=$Count; $iCount++) { 21 $message = $pop3->get($i); 39 22 40 $MsgOne = $pop3->get($iCount); 41 if((!$MsgOne) || (gettype($MsgOne) != 'array')) { 42 echo "oops, $pop3->ERROR<br />\n"; 43 $pop3->quit(); 23 if(!$pop3->delete($i)) { 24 echo '<p>Oops '.$pop3->ERROR.'</p></div>'; 25 $pop3->reset(); 44 26 exit; 27 } else { 28 echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>"; 45 29 } 46 30 … … 51 35 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 52 36 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 53 while ( list ( $lineNum,$line ) = each ($MsgOne) ) { 54 if (strlen($line) < 3) { 55 $bodysignal = 1; 56 } 37 foreach ($message as $line) : 38 if (strlen($line) < 3) $bodysignal = 1; 39 57 40 if ($bodysignal) { 58 41 $content .= $line; … … 74 57 if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $subject)) { 75 58 $subject = wp_iso_descrambler($subject); 76 }77 if (get_settings('use_phoneemail')) {78 $subject = explode(get_settings('phoneemail_separator'), $subject);79 $subject = trim($subject[0]);80 }81 if (!ereg(get_settings('subjectprefix'), $subject)) {82 continue;83 59 } 84 60 } … … 110 86 } 111 87 } 112 }88 endforeach; 113 89 114 90 $ddate_today = time() + ($time_difference * 3600); … … 116 92 117 93 118 # starts buffering the output 119 ob_start(); 94 $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject)); 120 95 121 if ($ddate_difference_days > 14) { 122 echo 'Too old<br />'; 123 continue; 96 if ($content_type == 'multipart/alternative') { 97 $content = explode('--'.$boundary, $content); 98 $content = $content[2]; 99 $content = explode('Content-Transfer-Encoding: quoted-printable', $content); 100 $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); 124 101 } 102 $content = trim($content); 125 103 126 if (preg_match('/'.get_settings('subjectprefix').'/', $subject)) { 104 echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n"; 105 echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; 127 106 128 $userpassstring = '';107 $content = trim($content); 129 108 130 echo '<div style="border: 1px dashed #999; padding: 10px; margin: 10px;">'; 131 echo "<p><b>$iCount</b></p><p><b>Subject: </b>$subject</p>\n"; 109 $content = trim($content); 132 110 133 $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));111 $post_title = xmlrpc_getposttitle($content); 134 112 135 if ($content_type == 'multipart/alternative') { 136 $content = explode('--'.$boundary, $content); 137 $content = $content[2]; 138 $content = explode('Content-Transfer-Encoding: quoted-printable', $content); 139 $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); 140 } 141 $content = trim($content); 113 if ($post_title == '') $post_title = $subject; 142 114 143 echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n"; 144 echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; 145 146 $btpos = strpos($content, get_settings('bodyterminator')); 147 if ($btpos) { 148 $content = substr($content, 0, $btpos); 149 } 150 $content = trim($content); 115 if (empty($post_categories)) $post_categories[] = get_settings('default_category'); 151 116 152 $blah = explode("\n", $content);153 $firstline = $blah[0];154 $secondline = $blah[1];117 $post_title = addslashes(trim($post_title)); 118 $content = preg_replace("|\n([^\n])|", " $1", $content); 119 $content = addslashes(trim($content)); 155 120 156 if (get_settings('use_phoneemail')) {157 $btpos = strpos($firstline, get_settings('phoneemail_separator'));158 if ($btpos) {159 $userpassstring = trim(substr($firstline, 0, $btpos));160 $content = trim(substr($content, $btpos+strlen(get_settings('phoneemail_separator')), strlen($content)));161 $btpos = strpos($content, get_settings('phoneemail_separator'));162 if ($btpos) {163 $userpassstring = trim(substr($content, 0, $btpos));164 $content = trim(substr($content, $btpos+strlen(get_settings('phoneemail_separator')), strlen($content)));165 }166 }167 $contentfirstline = $blah[1];168 } else {169 $userpassstring = $firstline;170 $contentfirstline = '';171 }172 121 173 $flat = 999.0; 174 $flon = 999.0; 175 $secondlineParts = explode(':',$secondline); 176 if(strncmp($secondlineParts[0],"POS",3)==0) { 177 echo "Found POS:<br>\n"; 178 //echo "Second parts is:".$secondlineParts[1]; 179 // the second line is the postion listing line 180 $secLineParts = explode(',',$secondlineParts[1]); 181 $flatStr = $secLineParts[0]; 182 $flonStr = $secLineParts[1]; 183 //echo "String are ".$flatStr.$flonStr; 184 $flat = floatval($secLineParts[0]); 185 $flon = floatval($secLineParts[1]); 186 //echo "values are ".$flat." and ".$flon; 187 // ok remove that position... we should not have it in the final output 188 $content = str_replace($secondline,'',$content); 189 } 122 $sql = "INSERT INTO $tableposts (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')"; 190 123 191 $blah = explode(':', $userpassstring); 192 $user_login = $blah[0]; 193 $user_pass = md5($blah[1]); 124 $result = $wpdb->query($sql); 125 $post_ID = $wpdb->insert_id; 194 126 195 $content = $contentfirstline.str_replace($firstline, '', $content);196 $content = trim($content);197 127 198 echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";128 pingback($content, $post_ID); 199 129 200 $sql = "SELECT ID, user_level FROM $tableusers WHERE user_login='$user_login' AND user_pass='$user_pass' ORDER BY ID DESC LIMIT 1";201 $result = $wpdb->get_row($sql);130 echo "\n<p><b>Posted title:</b> $post_title<br />"; 131 echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>'; 202 132 203 if (!$result) { 204 echo '<p><b>Wrong login or password.</b></p></div>'; 205 continue; 206 } 133 if (!$post_categories) $post_categories[] = 1; 134 foreach ($post_categories as $post_category) : 135 $post_category = intval($post_category); 207 136 208 $user_level = $result->user_level;209 $post_author = $result->ID;137 // Double check it's not there already 138 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category"); 210 139 211 if ($user_level > 0) { 140 if (!$exists && $result) { 141 $wpdb->query(" 142 INSERT INTO $tablepost2cat 143 (post_id, category_id) 144 VALUES 145 ($post_ID, $post_category) 146 "); 147 } 148 endforeach; 212 149 213 $post_title = xmlrpc_getposttitle($content); 214 $post_categories[] = xmlrpc_getpostcategory($content); 215 216 if ($post_title == '') { 217 $post_title = $subject; 218 } 219 if (empty($post_categories)) { 220 $post_categories[] = get_settings('default_category'); 221 } 222 223 if (!$thisisforfunonly) { 224 $post_title = addslashes(trim($post_title)); 225 $content = preg_replace("|\n([^\n])|", " $1", $content); 226 $content = addslashes(trim($content)); 227 if($flat > 500) { 228 $sql = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES ($post_author, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')"; 229 } else { 230 $sql = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt, post_lat, post_lon) VALUES ($post_author, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt', $flat, $flon)"; 231 } 232 $result = $wpdb->query($sql); 233 $post_ID = $wpdb->insert_id; 234 235 if (isset($sleep_after_edit) && $sleep_after_edit > 0) { 236 sleep($sleep_after_edit); 237 } 238 239 $blog_ID = 1; 240 if($flat < 500) { 241 pingGeoUrl($post_ID); 242 } 243 244 pingback($content, $post_ID); 245 } 246 echo "\n<p><b>Posted title:</b> $post_title<br />"; 247 echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>'; 248 249 if (!$post_categories) $post_categories[] = 1; 250 foreach ($post_categories as $post_category) { 251 $post_category = intval($post_category); 252 253 // Double check it's not there already 254 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category"); 255 256 if (!$exists && $result) { 257 $wpdb->query(" 258 INSERT INTO $tablepost2cat 259 (post_id, category_id) 260 VALUES 261 ($post_ID, $post_category) 262 "); 263 } 264 } 265 266 if(!$pop3->delete($iCount)) { 267 echo '<p>Oops '.$pop3->ERROR.'</p></div>'; 268 $pop3->reset(); 269 exit; 270 } else { 271 echo "<p>Mission complete, message <strong>$iCount</strong> deleted.</p>"; 272 } 273 274 } else { 275 echo '<p><strong>Level 0 users can\'t post.</strong></p>'; 276 } 277 echo '</div>'; 278 if ($output_debugging_info) { 279 ob_end_flush(); 280 } else { 281 ob_end_clean(); 282 } 283 } 284 } 150 endfor; 285 151 286 152 $pop3->quit(); 287 153 288 timer_stop($output_debugging_info);289 exit;290 291 154 ?>
Note: See TracChangeset
for help on using the changeset viewer.