Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 164 lines (128 sloc) 5.09 kb
416ef54d » m
2003-04-01 *** empty log message ***
1 <?php
f97fc341 » m
2003-12-11 The great renaming.
2 require(dirname(__FILE__) . '/wp-config.php');
416ef54d » m
2003-04-01 *** empty log message ***
3
1349ebdf » m
2003-12-18 Renaming Reloaded.
4 require_once(ABSPATH.WPINC.'/class-pop3.php');
416ef54d » m
2003-04-01 *** empty log message ***
5
6 error_reporting(2037);
7
4e09b013 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
8 $time_difference = get_option('gmt_offset') * 3600;
ba1450cb » m
2004-05-19 Timezone fix from Kimmo Suominen.
9
84db5807 » m
2004-09-05 Massive options cleanup and another step of cleaning up the upgrade/i…
10 $phone_delim = '::';
e841a2dd » ryan
2004-07-27 More wp-mail timezone and delimiter fixes from Kitten.
11
416ef54d » m
2003-04-01 *** empty log message ***
12 $pop3 = new POP3();
13
4e09b013 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
14 if (!$pop3->connect(get_option('mailserver_url'), get_option('mailserver_port')))
cca24087 » ryan
2006-07-10 wp_die() improvements from Sewar. fixes #2902
15 wp_die($pop3->ERROR);
416ef54d » m
2003-04-01 *** empty log message ***
16
4e09b013 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
17 $count = $pop3->login(get_option('mailserver_login'), get_option('mailserver_pass'));
86f88749 » ryan
2006-07-05 Use wp_die(). Props filosofo. fixes #2914
18 if (0 == $count) wp_die(__('There doesn&#8217;t seem to be any new mail.'));
416ef54d » m
2003-04-01 *** empty log message ***
19
20
00cb612e » m
2004-04-24 New mail functionality.
21 for ($i=1; $i <= $count; $i++) :
416ef54d » m
2003-04-01 *** empty log message ***
22
00cb612e » m
2004-04-24 New mail functionality.
23 $message = $pop3->get($i);
416ef54d » m
2003-04-01 *** empty log message ***
24
25 $content = '';
26 $content_type = '';
27 $boundary = '';
28 $bodysignal = 0;
29 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
30 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
00cb612e » m
2004-04-24 New mail functionality.
31 foreach ($message as $line) :
32 if (strlen($line) < 3) $bodysignal = 1;
33
416ef54d » m
2003-04-01 *** empty log message ***
34 if ($bodysignal) {
35 $content .= $line;
36 } else {
ba1450cb » m
2004-05-19 Timezone fix from Kimmo Suominen.
37 if (preg_match('/Content-Type: /i', $line)) {
416ef54d » m
2003-04-01 *** empty log message ***
38 $content_type = trim($line);
39 $content_type = substr($content_type, 14, strlen($content_type)-14);
40 $content_type = explode(';', $content_type);
41 $content_type = $content_type[0];
42 }
43 if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) {
44 $boundary = trim($line);
45 $boundary = explode('"', $boundary);
46 $boundary = $boundary[1];
47 }
ba1450cb » m
2004-05-19 Timezone fix from Kimmo Suominen.
48 if (preg_match('/Subject: /i', $line)) {
416ef54d » m
2003-04-01 *** empty log message ***
49 $subject = trim($line);
50 $subject = substr($subject, 9, strlen($subject)-9);
204af253 » m
2005-11-14 Fixes #1515
51 $subject = wp_iso_descrambler($subject);
e841a2dd » ryan
2004-07-27 More wp-mail timezone and delimiter fixes from Kitten.
52 // Captures any text in the subject before $phone_delim as the subject
53 $subject = explode($phone_delim, $subject);
3f7cd011 » ryan
2004-07-26 Queue, SMS, timezone, and permalink fixes for wp-mail from MooKitty.
54 $subject = $subject[0];
416ef54d » m
2003-04-01 *** empty log message ***
55 }
230cd124 » m
2004-09-08 Have WP mailed post come from author if email matches author in DB. H…
56
57 // Set the author using the email address (To or Reply-To, the last used)
58 // otherwise use the site admin
59 if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) {
60 $author=trim($line);
61 if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) {
8580a90e » ryan
2006-01-23 wp-mail quote escaping fix from majelbstoat. fixes #2209
62 $author = $regs[1];
63 echo "Author = {$author} <p>";
64 $author = $wpdb->escape($author);
65 $result = $wpdb->get_row("SELECT ID FROM $wpdb->users WHERE user_email='$author' LIMIT 1");
230cd124 » m
2004-09-08 Have WP mailed post come from author if email matches author in DB. H…
66 if (!$result)
67 $post_author = 1;
68 else
69 $post_author = $result->ID;
70 } else
71 $post_author = 1;
72 }
73
ba1450cb » m
2004-05-19 Timezone fix from Kimmo Suominen.
74 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
416ef54d » m
2003-04-01 *** empty log message ***
75 $ddate = trim($line);
76 $ddate = str_replace('Date: ', '', $ddate);
77 if (strpos($ddate, ',')) {
78 $ddate = trim(substr($ddate, strpos($ddate, ',')+1, strlen($ddate)));
79 }
80 $date_arr = explode(' ', $ddate);
81 $date_time = explode(':', $date_arr[3]);
7b2e2c34 » ryan
2006-02-12 Death to trailing tabs. Props Mark J. fixes #2405
82
416ef54d » m
2003-04-01 *** empty log message ***
83 $ddate_H = $date_time[0];
84 $ddate_i = $date_time[1];
85 $ddate_s = $date_time[2];
7b2e2c34 » ryan
2006-02-12 Death to trailing tabs. Props Mark J. fixes #2405
86
416ef54d » m
2003-04-01 *** empty log message ***
87 $ddate_m = $date_arr[1];
88 $ddate_d = $date_arr[0];
89 $ddate_Y = $date_arr[2];
3f7cd011 » ryan
2004-07-26 Queue, SMS, timezone, and permalink fixes for wp-mail from MooKitty.
90 for ($j=0; $j<12; $j++) {
91 if ($ddate_m == $dmonths[$j]) {
92 $ddate_m = $j+1;
416ef54d » m
2003-04-01 *** empty log message ***
93 }
94 }
fd285bc1 » michelvaldrighi
2004-02-23 big leap to GMT dates
95
3f7cd011 » ryan
2004-07-26 Queue, SMS, timezone, and permalink fixes for wp-mail from MooKitty.
96 $time_zn = intval($date_arr[4]) * 36;
e841a2dd » ryan
2004-07-27 More wp-mail timezone and delimiter fixes from Kitten.
97 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
3f7cd011 » ryan
2004-07-26 Queue, SMS, timezone, and permalink fixes for wp-mail from MooKitty.
98 $ddate_U = $ddate_U - $time_zn;
99 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
0b3ee13e » michelvaldrighi
2004-03-25 now storing emailed posts as localtime+gmt
100 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
416ef54d » m
2003-04-01 *** empty log message ***
101 }
102 }
00cb612e » m
2004-04-24 New mail functionality.
103 endforeach;
416ef54d » m
2003-04-01 *** empty log message ***
104
4e09b013 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
105 $subject = trim(str_replace(get_option('subjectprefix'), '', $subject));
416ef54d » m
2003-04-01 *** empty log message ***
106
00cb612e » m
2004-04-24 New mail functionality.
107 if ($content_type == 'multipart/alternative') {
108 $content = explode('--'.$boundary, $content);
109 $content = $content[2];
110 $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
111 $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
416ef54d » m
2003-04-01 *** empty log message ***
112 }
00cb612e » m
2004-04-24 New mail functionality.
113 $content = trim($content);
e841a2dd » ryan
2004-07-27 More wp-mail timezone and delimiter fixes from Kitten.
114 // Captures any text in the body after $phone_delim as the body
115 $content = explode($phone_delim, $content);
116 $content[1] ? $content = $content[1] : $content = $content[0];
416ef54d » m
2003-04-01 *** empty log message ***
117
00cb612e » m
2004-04-24 New mail functionality.
118 echo "<p><b>Content-type:</b> $content_type, <b>boundary:</b> $boundary</p>\n";
119 echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
416ef54d » m
2003-04-01 *** empty log message ***
120
00cb612e » m
2004-04-24 New mail functionality.
121 $content = trim($content);
416ef54d » m
2003-04-01 *** empty log message ***
122
22a580ad » m
2004-09-05 Set GUID when posting.
123 $post_content = apply_filters('phone_content', $content);
416ef54d » m
2003-04-01 *** empty log message ***
124
00cb612e » m
2004-04-24 New mail functionality.
125 $post_title = xmlrpc_getposttitle($content);
416ef54d » m
2003-04-01 *** empty log message ***
126
00cb612e » m
2004-04-24 New mail functionality.
127 if ($post_title == '') $post_title = $subject;
416ef54d » m
2003-04-01 *** empty log message ***
128
4e09b013 » ryan
2006-08-30 Use get_option instead of get_settings. Just 'cause.
129 if (empty($post_categories)) $post_categories[] = get_option('default_email_category');
416ef54d » m
2003-04-01 *** empty log message ***
130
22a580ad » m
2004-09-05 Set GUID when posting.
131 $post_category = $post_categories;
416ef54d » m
2003-04-01 *** empty log message ***
132
88486b54 » michelvaldrighi
2005-02-01 set emailed posts to be published. won't do no good moblogging if in …
133 // or maybe we should leave the choice to email drafts? propose a way
134 $post_status = 'publish';
135
136 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
cef26e6c » ryan
2005-10-20 Give wp-mail a little love.
137 $post_data = add_magic_quotes($post_data);
416ef54d » m
2003-04-01 *** empty log message ***
138
a738b423 » m
2007-03-23 Ryan slays the dragon. (Some of these return WP_Error objects.)
139 $post_ID = wp_insert_post($post_data);
416ef54d » m
2003-04-01 *** empty log message ***
140
18c87010 » michelvaldrighi
2005-01-31 moving the pop3->delete call to the end of the loop so that emails ar…
141 if (!$post_ID) {
142 // we couldn't post, for whatever reason. better move forward to the next email
143 continue;
144 }
145
1355366b » m
2004-04-25 Added filter and action hooks.
146 do_action('publish_phone', $post_ID);
26b05224 » m
2004-01-13 Fix ups.
147
230cd124 » m
2004-09-08 Have WP mailed post come from author if email matches author in DB. H…
148 echo "\n<p><b>Author:</b> $post_author</p>";
00cb612e » m
2004-04-24 New mail functionality.
149 echo "\n<p><b>Posted title:</b> $post_title<br />";
150 echo "\n<b>Posted content:</b><br /><pre>".$content.'</pre></p>';
26b05224 » m
2004-01-13 Fix ups.
151
18c87010 » michelvaldrighi
2005-01-31 moving the pop3->delete call to the end of the loop so that emails ar…
152 if(!$pop3->delete($i)) {
153 echo '<p>Oops '.$pop3->ERROR.'</p></div>';
154 $pop3->reset();
155 exit;
156 } else {
157 echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>";
416ef54d » m
2003-04-01 *** empty log message ***
158 }
159
00cb612e » m
2004-04-24 New mail functionality.
160 endfor;
416ef54d » m
2003-04-01 *** empty log message ***
161
00cb612e » m
2004-04-24 New mail functionality.
162 $pop3->quit();
416ef54d » m
2003-04-01 *** empty log message ***
163
6fa32439 » m
2003-06-14 Added ezSQL and small HTML fixes.
164 ?>
Something went wrong with that request. Please try again.