Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 289 lines (237 sloc) 8.503 kb
b43564c *** empty log message ***
saxmatt authored
1 <?php
43e4a8a The great renaming.
saxmatt authored
2 require(dirname(__FILE__) . '/wp-config.php');
b43564c *** empty log message ***
saxmatt authored
3
99a7358 Renaming Reloaded.
saxmatt authored
4 require_once(ABSPATH.WPINC.'/class-pop3.php');
b43564c *** empty log message ***
saxmatt authored
5
6
7 timer_start();
8
9 $use_cache = 1;
10 $output_debugging_info = 0; # =1 if you want to output debugging info
11 $time_difference = get_settings('time_difference');
12
13 if ($use_phoneemail) {
14 // if you're using phone email, the email will already be in your timezone
15 $time_difference = 0;
16 }
17
18 error_reporting(2037);
19
20
21
22 $pop3 = new POP3();
23
24 if(!$pop3->connect($mailserver_url, $mailserver_port)) {
25 echo "Ooops $pop3->ERROR <br />\n";
26 exit;
27 }
28
29 $Count = $pop3->login($mailserver_login, $mailserver_pass);
30 if((!$Count) || ($Count == -1)) {
31 echo "<h1>Login Failed: $pop3->ERROR</h1>\n";
32 $pop3->quit();
33 exit;
34 }
35
36
37 // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
38 //register_shutdown_function($pop3->quit());
39
40 for ($iCount=1; $iCount<=$Count; $iCount++) {
41
42 $MsgOne = $pop3->get($iCount);
43 if((!$MsgOne) || (gettype($MsgOne) != 'array')) {
44 echo "oops, $pop3->ERROR<br />\n";
45 $pop3->quit();
46 exit;
47 }
48
49 $content = '';
50 $content_type = '';
51 $boundary = '';
52 $bodysignal = 0;
53 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
54 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
55 while ( list ( $lineNum,$line ) = each ($MsgOne) ) {
56 if (strlen($line) < 3) {
57 $bodysignal = 1;
58 }
59 if ($bodysignal) {
60 $content .= $line;
61 } else {
62 if (preg_match('/Content-Type: /', $line)) {
63 $content_type = trim($line);
64 $content_type = substr($content_type, 14, strlen($content_type)-14);
65 $content_type = explode(';', $content_type);
66 $content_type = $content_type[0];
67 }
68 if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
69 $boundary = trim($line);
70 $boundary = explode('"', $boundary);
71 $boundary = $boundary[1];
72 }
73 if (preg_match('/Subject: /', $line)) {
74 $subject = trim($line);
75 $subject = substr($subject, 9, strlen($subject)-9);
76 if ($use_phoneemail) {
77 $subject = explode($phoneemail_separator, $subject);
78 $subject = trim($subject[0]);
79 }
80 if (!ereg($subjectprefix, $subject)) {
81 continue;
82 }
83 }
84 if (preg_match('/Date: /', $line)) { // of the form '20 Mar 2002 20:32:37'
85 $ddate = trim($line);
86 $ddate = str_replace('Date: ', '', $ddate);
87 if (strpos($ddate, ',')) {
88 $ddate = trim(substr($ddate, strpos($ddate, ',')+1, strlen($ddate)));
89 }
90 $date_arr = explode(' ', $ddate);
91 $date_time = explode(':', $date_arr[3]);
92
93 $ddate_H = $date_time[0];
94 $ddate_i = $date_time[1];
95 $ddate_s = $date_time[2];
96
97 $ddate_m = $date_arr[1];
98 $ddate_d = $date_arr[0];
99 $ddate_Y = $date_arr[2];
100 for ($i=0; $i<12; $i++) {
101 if ($ddate_m == $dmonths[$i]) {
102 $ddate_m = $i+1;
103 }
104 }
105 $ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
106 $ddate_U = $ddate_U + ($time_difference * 3600);
107 $post_date = date('Y-m-d H:i:s', $ddate_U);
108 }
109 }
110 }
111
112 $ddate_today = time() + ($time_difference * 3600);
113 $ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
114
115
116 # starts buffering the output
117 ob_start();
118
119 if ($ddate_difference_days > 14) {
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
120 echo 'Too old<br />';
b43564c *** empty log message ***
saxmatt authored
121 continue;
122 }
123
124 if (preg_match('/'.$subjectprefix.'/', $subject)) {
125
126 $userpassstring = '';
127
128 echo '<div style="border: 1px dashed #999; padding: 10px; margin: 10px;">';
129 echo "<p><b>$iCount</b></p><p><b>Subject: </b>$subject</p>\n";
130
131 $subject = trim(str_replace($subjectprefix, '', $subject));
132
133 if ($content_type == 'multipart/alternative') {
134 $content = explode('--'.$boundary, $content);
135 $content = $content[2];
136 $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
137 $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
138 }
139 $content = trim($content);
140
141 echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
142 echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
b43564c *** empty log message ***
saxmatt authored
143
144 $btpos = strpos($content, $bodyterminator);
145 if ($btpos) {
146 $content = substr($content, 0, $btpos);
147 }
148 $content = trim($content);
149
150 $blah = explode("\n", $content);
151 $firstline = $blah[0];
af9b7ab Changes for new geourl functionality.
mikelittle authored
152 $secondline = $blah[1];
b43564c *** empty log message ***
saxmatt authored
153
154 if ($use_phoneemail) {
155 $btpos = strpos($firstline, $phoneemail_separator);
156 if ($btpos) {
157 $userpassstring = trim(substr($firstline, 0, $btpos));
158 $content = trim(substr($content, $btpos+strlen($phoneemail_separator), strlen($content)));
159 $btpos = strpos($content, $phoneemail_separator);
160 if ($btpos) {
161 $userpassstring = trim(substr($content, 0, $btpos));
162 $content = trim(substr($content, $btpos+strlen($phoneemail_separator), strlen($content)));
163 }
164 }
165 $contentfirstline = $blah[1];
166 } else {
167 $userpassstring = $firstline;
168 $contentfirstline = '';
169 }
170
af9b7ab Changes for new geourl functionality.
mikelittle authored
171 $flat = 999.0;
172 $flon = 999.0;
173 $secondlineParts = explode(':',$secondline);
174 if(strncmp($secondlineParts[0],"POS",3)==0) {
175 echo "Found POS:<br>\n";
176 //echo "Second parts is:".$secondlineParts[1];
177 // the second line is the postion listing line
178 $secLineParts = explode(',',$secondlineParts[1]);
179 $flatStr = $secLineParts[0];
180 $flonStr = $secLineParts[1];
181 //echo "String are ".$flatStr.$flonStr;
182 $flat = floatval($secLineParts[0]);
183 $flon = floatval($secLineParts[1]);
184 //echo "values are ".$flat." and ".$flon;
185 // ok remove that position... we should not have it in the final output
186 $content = str_replace($secondline,'',$content);
187 }
188
b43564c *** empty log message ***
saxmatt authored
189 $blah = explode(':', $userpassstring);
190 $user_login = $blah[0];
191 $user_pass = $blah[1];
192
193 $content = $contentfirstline.str_replace($firstline, '', $content);
194 $content = trim($content);
195
196 echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
197
198 $sql = "SELECT ID, user_level FROM $tableusers WHERE user_login='$user_login' AND user_pass='$user_pass' ORDER BY ID DESC LIMIT 1";
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
199 $result = $wpdb->get_row($sql);
b43564c *** empty log message ***
saxmatt authored
200
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
201 if (!$result) {
b43564c *** empty log message ***
saxmatt authored
202 echo '<p><b>Wrong login or password.</b></p></div>';
203 continue;
204 }
205
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
206 $user_level = $result->user_level;
207 $post_author = $result->ID;
b43564c *** empty log message ***
saxmatt authored
208
209 if ($user_level > 0) {
210
211 $post_title = xmlrpc_getposttitle($content);
5624ca0 Fix ups.
saxmatt authored
212 $post_categories[] = xmlrpc_getpostcategory($content);
b43564c *** empty log message ***
saxmatt authored
213
214 if ($post_title == '') {
215 $post_title = $subject;
216 }
5624ca0 Fix ups.
saxmatt authored
217 if (empty($post_categories)) {
218 $post_categories[] = $default_category;
b43564c *** empty log message ***
saxmatt authored
219 }
220
221 if (!$thisisforfunonly) {
222 $post_title = addslashes(trim($post_title));
5624ca0 Fix ups.
saxmatt authored
223 $content = preg_replace("|\n([^\n])|", " $1", $content);
b43564c *** empty log message ***
saxmatt authored
224 $content = addslashes(trim($content));
af9b7ab Changes for new geourl functionality.
mikelittle authored
225 if($flat > 500) {
226 $sql = "INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category) VALUES ($post_author, '$post_date', '$content', '$post_title', $post_category)";
227 } else {
228 $sql = "INSERT INTO $tableposts (post_author, post_date, post_content, post_title, post_category, post_lat, post_lon) VALUES ($post_author, '$post_date', '$content', '$post_title', $post_category, $flat, $flon)";
229 }
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
230 $result = $wpdb->query($sql);
e092dcd EzSQL
mikelittle authored
231 $post_ID = $wpdb->insert_id;
b43564c *** empty log message ***
saxmatt authored
232
233 if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
234 sleep($sleep_after_edit);
235 }
236
237 $blog_ID = 1;
af9b7ab Changes for new geourl functionality.
mikelittle authored
238 if($flat < 500) {
239 pingGeoUrl($post_ID);
240 }
5624ca0 Fix ups.
saxmatt authored
241
b43564c *** empty log message ***
saxmatt authored
242 pingWeblogs($blog_ID);
243 pingBlogs($blog_ID);
244 pingback($content, $post_ID);
245 }
246 echo "\n<p><b>Posted title:</b> $post_title<br />";
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
247 echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>';
b43564c *** empty log message ***
saxmatt authored
248
5624ca0 Fix ups.
saxmatt authored
249 if (!$post_categories) $post_categories[] = 1;
250 foreach ($post_categories as $post_category) {
251 // Double check it's not there already
252 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category");
253
254 if (!$exists && $result) {
255 $wpdb->query("
256 INSERT INTO $tablepost2cat
257 (post_id, category_id)
258 VALUES
259 ($post_ID, $post_category)
260 ");
261 }
262 }
263
b43564c *** empty log message ***
saxmatt authored
264 if(!$pop3->delete($iCount)) {
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
265 echo '<p>Oops '.$pop3->ERROR.'</p></div>';
b43564c *** empty log message ***
saxmatt authored
266 $pop3->reset();
267 exit;
268 } else {
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
269 echo "<p>Mission complete, message <strong>$iCount</strong> deleted.</p>";
b43564c *** empty log message ***
saxmatt authored
270 }
271
272 } else {
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
273 echo '<p><strong>Level 0 users can\'t post.</strong></p>';
b43564c *** empty log message ***
saxmatt authored
274 }
275 echo '</div>';
276 if ($output_debugging_info) {
277 ob_end_flush();
278 } else {
279 ob_end_clean();
280 }
281 }
282 }
283
284 $pop3->quit();
285
286 timer_stop($output_debugging_info);
287 exit;
288
527b31e Added ezSQL and small HTML fixes.
saxmatt authored
289 ?>
Something went wrong with that request. Please try again.