10 /** Make sure that the WordPress bootstrap has run before continuing. */ |
10 /** Make sure that the WordPress bootstrap has run before continuing. */ |
11 require(dirname(__FILE__) . '/wp-load.php'); |
11 require(dirname(__FILE__) . '/wp-load.php'); |
12 |
12 |
13 /** This filter is documented in wp-admin/options.php */ |
13 /** This filter is documented in wp-admin/options.php */ |
14 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) |
14 if ( ! apply_filters( 'enable_post_by_email_configuration', true ) ) |
15 wp_die( __( 'This action has been disabled by the administrator.' ) ); |
15 wp_die( __( 'This action has been disabled by the administrator.' ), 403 ); |
|
16 |
|
17 $mailserver_url = get_option( 'mailserver_url' ); |
|
18 |
|
19 if ( 'mail.example.com' === $mailserver_url || empty( $mailserver_url ) ) { |
|
20 wp_die( __( 'This action has been disabled by the administrator.' ), 403 ); |
|
21 } |
16 |
22 |
17 /** |
23 /** |
18 * Fires to allow a plugin to do a complete takeover of Post by Email. |
24 * Fires to allow a plugin to do a complete takeover of Post by Email. |
19 * |
25 * |
20 * @since 2.9.0 |
26 * @since 2.9.0 |
64 $content = ''; |
70 $content = ''; |
65 $content_type = ''; |
71 $content_type = ''; |
66 $content_transfer_encoding = ''; |
72 $content_transfer_encoding = ''; |
67 $post_author = 1; |
73 $post_author = 1; |
68 $author_found = false; |
74 $author_found = false; |
69 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
|
70 foreach ($message as $line) { |
75 foreach ($message as $line) { |
71 // Body signal. |
76 // Body signal. |
72 if ( strlen($line) < 3 ) |
77 if ( strlen($line) < 3 ) |
73 $bodysignal = true; |
78 $bodysignal = true; |
74 if ( $bodysignal ) { |
79 if ( $bodysignal ) { |
117 $author = $matches[0]; |
122 $author = $matches[0]; |
118 else |
123 else |
119 $author = trim($line); |
124 $author = trim($line); |
120 $author = sanitize_email($author); |
125 $author = sanitize_email($author); |
121 if ( is_email($author) ) { |
126 if ( is_email($author) ) { |
|
127 /* translators: Post author email address */ |
122 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>'; |
128 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>'; |
123 $userdata = get_user_by('email', $author); |
129 $userdata = get_user_by('email', $author); |
124 if ( ! empty( $userdata ) ) { |
130 if ( ! empty( $userdata ) ) { |
125 $post_author = $userdata->ID; |
131 $post_author = $userdata->ID; |
126 $author_found = true; |
132 $author_found = true; |
127 } |
133 } |
128 } |
134 } |
129 } |
135 } |
130 |
136 |
131 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' |
137 if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100' |
132 $ddate = trim($line); |
138 $ddate = str_replace( 'Date: ', '', trim( $line ) ); |
133 $ddate = str_replace('Date: ', '', $ddate); |
139 $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime |
134 if (strpos($ddate, ',')) { |
140 $ddate_U = strtotime( $ddate ); |
135 $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate))); |
141 $post_date = gmdate( 'Y-m-d H:i:s', $ddate_U + $time_difference ); |
136 } |
142 $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_U ); |
137 $date_arr = explode(' ', $ddate); |
|
138 $date_time = explode(':', $date_arr[3]); |
|
139 |
|
140 $ddate_H = $date_time[0]; |
|
141 $ddate_i = $date_time[1]; |
|
142 $ddate_s = $date_time[2]; |
|
143 |
|
144 $ddate_m = $date_arr[1]; |
|
145 $ddate_d = $date_arr[0]; |
|
146 $ddate_Y = $date_arr[2]; |
|
147 for ( $j = 0; $j < 12; $j++ ) { |
|
148 if ( $ddate_m == $dmonths[$j] ) { |
|
149 $ddate_m = $j+1; |
|
150 } |
|
151 } |
|
152 |
|
153 $time_zn = intval($date_arr[4]) * 36; |
|
154 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y); |
|
155 $ddate_U = $ddate_U - $time_zn; |
|
156 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference); |
|
157 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U); |
|
158 } |
143 } |
159 } |
144 } |
160 } |
145 } |
161 |
146 |
162 // Set $post_status based on $author_found and on author's publish_posts capability |
147 // Set $post_status based on $author_found and on author's publish_posts capability |
182 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); |
167 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>'); |
183 } |
168 } |
184 $content = trim($content); |
169 $content = trim($content); |
185 |
170 |
186 /** |
171 /** |
187 * Filter the original content of the email. |
172 * Filters the original content of the email. |
188 * |
173 * |
189 * Give Post-By-Email extending plugins full access to the content, either |
174 * Give Post-By-Email extending plugins full access to the content, either |
190 * the raw content, or the content of the last quoted-printable section. |
175 * the raw content, or the content of the last quoted-printable section. |
191 * |
176 * |
192 * @since 2.8.0 |
177 * @since 2.8.0 |
242 * |
227 * |
243 * @param int $post_ID The post ID. |
228 * @param int $post_ID The post ID. |
244 */ |
229 */ |
245 do_action( 'publish_phone', $post_ID ); |
230 do_action( 'publish_phone', $post_ID ); |
246 |
231 |
247 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>'; |
232 echo "\n<p><strong>" . __( 'Author:' ) . '</strong> ' . esc_html( $post_author ) . '</p>'; |
248 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>'; |
233 echo "\n<p><strong>" . __( 'Posted title:' ) . '</strong> ' . esc_html( $post_title ) . '</p>'; |
249 |
234 |
250 if(!$pop3->delete($i)) { |
235 if(!$pop3->delete($i)) { |
251 echo '<p>' . sprintf(__('Oops: %s'), esc_html($pop3->ERROR)) . '</p>'; |
236 echo '<p>' . sprintf( |
|
237 /* translators: %s: POP3 error */ |
|
238 __( 'Oops: %s' ), |
|
239 esc_html( $pop3->ERROR ) |
|
240 ) . '</p>'; |
252 $pop3->reset(); |
241 $pop3->reset(); |
253 exit; |
242 exit; |
254 } else { |
243 } else { |
255 echo '<p>' . sprintf(__('Mission complete. Message <strong>%s</strong> deleted.'), $i) . '</p>'; |
244 echo '<p>' . sprintf( |
|
245 /* translators: %s: the message ID */ |
|
246 __( 'Mission complete. Message %s deleted.' ), |
|
247 '<strong>' . $i . '</strong>' |
|
248 ) . '</p>'; |
256 } |
249 } |
257 |
250 |
258 } |
251 } |
259 |
252 |
260 $pop3->quit(); |
253 $pop3->quit(); |