Version Description
(2010.04.25)
Download this release
Release Info
Developer | robfelty |
Plugin | Postie |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.4
- Revision +2 -2
- config_form.php +254 -196
- cronless_postie.php +0 -84
- faq.html +16 -10
- fetchmails.php +43 -28
- filterPostie.php → filterPostie.php.sample +1 -1
- get_mail.php +39 -55
- postie-functions.php +407 -328
- postie.php +116 -10
- postie_test.php +5 -5
- readme.html +16 -25
- readme.txt +51 -31
- templates/audio_templates.php +2 -2
- templates/image_templates.php +2 -2
- templates/video1_templates.php +2 -2
- templates/video2_templates.php +2 -2
Revision
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
Revision:
|
2 |
-
Last Changed Date:
|
1 |
+
Revision: 233507
|
2 |
+
Last Changed Date: 2010-04-25 13:52:31 -0400 (Sun, 25 Apr 2010)
|
config_form.php
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
<div class="wrap">
|
2 |
-
<h2
|
3 |
-
'
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
<?php
|
6 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
|
7 |
if (isset($_POST["action"])) {
|
@@ -23,14 +27,6 @@ if (isset($_POST["action"])) {
|
|
23 |
include('get_mail.php');
|
24 |
exit;
|
25 |
break;
|
26 |
-
case "config":
|
27 |
-
if( UpdatePostieConfig($_POST)) {
|
28 |
-
$message = 1;
|
29 |
-
}
|
30 |
-
else {
|
31 |
-
$message = 2;
|
32 |
-
}
|
33 |
-
break;
|
34 |
default:
|
35 |
$message = 2;
|
36 |
break;
|
@@ -40,7 +36,22 @@ global $wpdb,$wp_roles;
|
|
40 |
|
41 |
$title = __('Postie Options', 'postie');
|
42 |
$parent_file = 'options-general.php';
|
43 |
-
$config =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
$messages[1] = __("Configuration successfully updated!",'postie');
|
45 |
$messages[2] = __("Error - unable to save configuration",'postie');
|
46 |
|
@@ -50,19 +61,21 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
50 |
<?php endif; ?>
|
51 |
<form name="postie-options" method="post">
|
52 |
<input type="hidden" name="action" value="reset" />
|
53 |
-
|
54 |
</form>
|
55 |
<form name="postie-options" method='post'>
|
56 |
<input type="hidden" name="action" value="runpostie" />
|
57 |
-
|
58 |
-
|
59 |
</form>
|
60 |
<form name="postie-options" method="post">
|
61 |
<input type="hidden" name="action" value="test" />
|
62 |
-
|
63 |
-
|
64 |
</form>
|
65 |
-
<form name="postie-options" method="post"
|
|
|
|
|
66 |
<div id="simpleTabs">
|
67 |
<div class="simpleTabs-nav">
|
68 |
<ul>
|
@@ -78,36 +91,23 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
78 |
</div>
|
79 |
<div id="simpleTabs-content-1" class="simpleTabs-content">
|
80 |
<table class='form-table'>
|
81 |
-
<tr><td colspan=2>
|
82 |
-
<?php if (isset($config['CRONLESS']) && $config['CRONLESS']!='') {
|
83 |
-
?>
|
84 |
-
<p><?php _e('Cronless postie should check for mail', 'postie') ?>
|
85 |
-
<select name='CRONLESS' id='CRONLESS'>
|
86 |
-
<option value="weekly" <?php if($config["CRONLESS"] == "weekly") { echo "selected='selected'";} ?>><?php _e('Once weekly', 'postie') ?></option>
|
87 |
-
<option value="daily"<?php if($config["CRONLESS"] == "daily") { echo "selected='selected'";} ?>><?php _e('daily', 'postie') ?></option>
|
88 |
-
<option value="hourly" <?php if($config["CRONLESS"] == "hourly") { echo "selected='selected'";} ?>><?php _e('hourly', 'postie') ?></option>
|
89 |
-
<option value="twiceperhour" <?php if($config["CRONLESS"] == "twiceperhour") { echo "selected='selected'";} ?>><?php _e('twice per hour', 'postie') ?></option>
|
90 |
-
<option value="tenminutes" <?php if($config["CRONLESS"] == "tenminutes") { echo "selected='selected'";} ?>><?php _e('every ten minutes', 'postie') ?></option>
|
91 |
-
</select>
|
92 |
-
</p>
|
93 |
-
<?php
|
94 |
-
}
|
95 |
-
?>
|
96 |
-
|
97 |
|
98 |
<tr>
|
99 |
<th scope="row"><?php _e('Mail Protocol:', 'postie') ?> </th>
|
100 |
<td>
|
101 |
-
<select name=
|
102 |
-
<option value="pop3"
|
103 |
<?php if (HasIMAPSupport(false)):?>
|
104 |
-
<option value="imap" <?php if($
|
105 |
-
<option value="pop3-ssl" <?php if($
|
106 |
-
<option value="imap-ssl" <?php if($
|
|
|
107 |
<?php else:?>
|
108 |
-
|
|
|
109 |
<?php endif;?>
|
110 |
</select>
|
|
|
111 |
</td>
|
112 |
</tr>
|
113 |
<tr>
|
@@ -120,7 +120,7 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
120 |
</span>
|
121 |
</th>
|
122 |
<td>
|
123 |
-
<input name=
|
124 |
</td>
|
125 |
</tr>
|
126 |
<tr>
|
@@ -128,32 +128,50 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
128 |
<br />
|
129 |
<span class='recommendation'><?php _e("Should be the same as your normal offset - but this lets you adjust it in cases where that doesn't work.", 'postie');?></span>
|
130 |
</th>
|
131 |
-
<td><input name=
|
132 |
<?php _e('hours', 'postie') ?>
|
133 |
|
134 |
</td>
|
135 |
</tr>
|
136 |
<tr valign="top">
|
137 |
<th scope="row"><?php _e('Mail Server:', 'postie') ?></th>
|
138 |
-
<td><input name=
|
139 |
</td>
|
140 |
</tr>
|
141 |
<tr valign="top">
|
142 |
<th width="33%" scope="row"><?php _e('Mail Userid:', 'postie') ?></th>
|
143 |
-
<td><input name=
|
144 |
</tr>
|
145 |
<tr valign="top">
|
146 |
<th scope="row"><?php _e('Mail Password:', 'postie') ?></th>
|
147 |
<td>
|
148 |
-
<input name=
|
149 |
</td>
|
150 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
</table>
|
152 |
</div>
|
153 |
<div id="simpleTabs-content-2" class="simpleTabs-content">
|
154 |
<table class='form-table'>
|
155 |
|
156 |
-
<?php echo BuildBooleanSelect("Allow Anyone To Post Via
|
|
|
157 |
<tr>
|
158 |
<th scope="row"><?php _e('Roles That Can Post:', 'postie') ?>
|
159 |
<br />
|
@@ -165,15 +183,15 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
165 |
foreach($wp_roles->role_names as $roleId => $name) {
|
166 |
$name=translate_with_context($name);
|
167 |
$role = &$wp_roles->get_role($roleId);
|
168 |
-
if ($
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
}
|
178 |
?>
|
179 |
</table>
|
@@ -182,24 +200,25 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
182 |
<tr>
|
183 |
<th width="33%" valign="top" scope="row"><?php _e('Post status:', 'postie') ?> </th>
|
184 |
<td>
|
185 |
-
<select name=
|
186 |
-
<option value="publish" <?php if($
|
187 |
-
"
|
188 |
-
<option value="draft" <?php if($
|
189 |
-
"
|
190 |
-
<option value="pending" <?php if($
|
191 |
-
"
|
192 |
-
<option value="private" <?php if($
|
193 |
-
"
|
194 |
</select> </td>
|
195 |
</tr>
|
196 |
-
<?php echo BuildTextArea("Authorized
|
|
|
197 |
<tr>
|
198 |
<th width="33%" valign="top" scope="row">
|
199 |
<?php _e('Admin username:') ?> </th>
|
200 |
<td>
|
201 |
-
<input name=
|
202 |
-
value="<?php echo $
|
203 |
</tr>
|
204 |
</table>
|
205 |
</div>
|
@@ -209,23 +228,23 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
209 |
<th scope="row"><?php _e('Default post by mail category:', 'postie') ?></th>
|
210 |
<td>
|
211 |
<?php
|
212 |
-
$defaultCat=$
|
213 |
-
wp_dropdown_categories("name=
|
214 |
</tr>
|
215 |
<tr valign="top">
|
216 |
<th scope="row">
|
217 |
<?php _e('Default post by mail tag(s)', 'postie') ?><br /><span
|
218 |
class='recommendation'><?php _e('separated by commas', 'postie')
|
219 |
?></span></th>
|
220 |
-
<td><input type='text' name=
|
221 |
-
id=
|
222 |
-
$
|
223 |
</td>
|
224 |
</tr>
|
225 |
<tr>
|
226 |
<th width="33%" valign="top" scope="row"><?php _e('Default Title:', 'postie') ?> </th>
|
227 |
<td>
|
228 |
-
<input name=
|
229 |
<br />
|
230 |
</td>
|
231 |
</tr>
|
@@ -233,22 +252,22 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
233 |
<th width="33%" valign="top" scope="row"><?php _e('Preferred
|
234 |
Text Type:', 'postie') ?> </th>
|
235 |
<td>
|
236 |
-
<select name=
|
237 |
<option value="plain">plain</option>
|
238 |
-
<option value="html" <?php if($
|
239 |
</select><br />
|
240 |
</td>
|
241 |
</tr>
|
242 |
-
<?php echo BuildBooleanSelect("Forward Rejected Mail","
|
243 |
-
<?php echo BuildBooleanSelect("Allow Subject In Mail","
|
244 |
-
<?php echo BuildBooleanSelect("Allow HTML In Mail Subject","
|
245 |
-
<?php echo BuildBooleanSelect("Allow HTML In Mail Body","
|
246 |
<tr>
|
247 |
<th width="33%" valign="top" scope="row"><?php _e('Tag Of
|
248 |
Message Start:', 'postie') ?> <br />
|
249 |
<span class='recommendation'><?php _e('Use to remove any text from a message that the email provider puts at the top of the message', 'postie') ?></span></th>
|
250 |
<td>
|
251 |
-
<input name=
|
252 |
</td>
|
253 |
</tr>
|
254 |
<tr>
|
@@ -256,38 +275,57 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
256 |
Message End:', 'postie') ?> <br />
|
257 |
<span class='recommendation'><?php _e('Use to remove any text from a message that the email provider puts at the end of the message', 'postie') ?></span></th>
|
258 |
<td>
|
259 |
-
<input name=
|
260 |
</td>
|
261 |
</tr>
|
262 |
</table>
|
263 |
<a style='cursor:pointer' onclick='showAdvanced("message-advanced", "message-advanced-arrow");'><span id="message-advanced-arrow">▶</span> Advanced options</a>
|
264 |
<div id="message-advanced" style='display:none;'>
|
265 |
<table class='form-table'>
|
266 |
-
<?php echo BuildBooleanSelect("Wrap content in pre tags","
|
267 |
-
<?php echo BuildBooleanSelect("Filter newlines",
|
268 |
-
"FILTERNEWLINES",$config["FILTERNEWLINES"],
|
269 |
"Set to no if using markdown or textitle syntax");?>
|
270 |
-
<?php echo BuildBooleanSelect("Replace newline characters with
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
<?php
|
275 |
-
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
<tr>
|
278 |
<th width="33%" valign="top" scope="row"><?php _e('Encoding for pages and feeds:', 'postie') ?> </th>
|
279 |
<td>
|
280 |
-
<input name=
|
281 |
<span class='recommendation'>UTF-8 <?php _e("should handle ISO-8859-1 as well", 'postie');?></span>
|
282 |
</td>
|
283 |
</tr>
|
284 |
-
<?php echo BuildBooleanSelect("Decode Quoted Printable
|
285 |
-
|
286 |
-
<?php echo BuildTextArea("
|
287 |
-
|
288 |
-
<?php echo BuildTextArea("
|
|
|
|
|
|
|
|
|
289 |
<?php echo BuildTextArea("Allowed SMTP
|
290 |
-
servers","
|
291 |
</table>
|
292 |
</div> <!-- advanced options -->
|
293 |
</div>
|
@@ -295,13 +333,17 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
295 |
<table class='form-table'>
|
296 |
|
297 |
|
298 |
-
<?php echo BuildBooleanSelect("
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
301 |
<tr>
|
302 |
<th width="33%" valign="top" scope="row"><?php _e('Image Place Holder Tag:', 'postie') ?> </th>
|
303 |
<td>
|
304 |
-
<input name=
|
305 |
</td>
|
306 |
</tr>
|
307 |
<tr>
|
@@ -313,16 +355,15 @@ $messages[2] = __("Error - unable to save configuration",'postie');
|
|
313 |
<span class='recommendation'><?php _e('Sizes for thumbnail, medium, and large images can be chosen in the <a href="options-media.php">Media Settings</a>. The samples here use the default sizes, and will not reflect the sizes you have chosen.', 'postie');?></span>
|
314 |
</th>
|
315 |
<td>
|
316 |
-
<input type='hidden' id='
|
317 |
-
value="<?php echo attribute_escape($
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
onchange="changeStyle('imageTemplatePreview','IMAGETEMPLATE',
|
322 |
-
'IMAGETEMPLATESELECT', 'SELECTED_IMAGETEMPLATE','smiling.jpg');" />
|
323 |
<?php
|
324 |
-
|
325 |
-
|
|
|
326 |
foreach ($styleOptions as $key=>$value) {
|
327 |
if ($key!='selected') {
|
328 |
if ($key==$selected) {
|
@@ -330,6 +371,8 @@ attribute_escape($config['IMAGETEMPLATE']) ?>" />
|
|
330 |
} else {
|
331 |
$select=' ';
|
332 |
}
|
|
|
|
|
333 |
echo '<option' . $select . 'value="'.
|
334 |
attribute_escape($value) . '" >'.$key . '</option>';
|
335 |
}
|
@@ -339,12 +382,13 @@ attribute_escape($config['IMAGETEMPLATE']) ?>" />
|
|
339 |
|
340 |
<?php _e('Preview', 'postie'); ?>
|
341 |
<span id='imageTemplatePreview' alt='preview'></span>
|
342 |
-
<textarea onchange='changeStyle("imageTemplatePreview", "
|
343 |
-
"
|
344 |
-
name=
|
345 |
</td>
|
346 |
</tr>
|
347 |
-
<?php echo BuildBooleanSelect("Use custom image
|
|
|
348 |
</table>
|
349 |
</div>
|
350 |
|
@@ -359,15 +403,15 @@ attribute_escape($config['IMAGETEMPLATE']) ?>" />
|
|
359 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
360 |
<?php $templateDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/templates'; ?>
|
361 |
<td>
|
362 |
-
<input type='hidden' id='
|
363 |
-
value="<?php echo attribute_escape($
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
onchange="changeStyle('video1TemplatePreview','VIDEO1TEMPLATE', 'VIDEO1TEMPLATESELECT', 'SELECTED_VIDEO1TEMPLATE','hi.mp4');" />
|
368 |
<?php
|
369 |
-
|
370 |
-
$
|
|
|
371 |
foreach ($styleOptions as $key=>$value) {
|
372 |
if ($key!='selected') {
|
373 |
if ($key==$selected) {
|
@@ -375,6 +419,8 @@ attribute_escape($config['VIDEO1TEMPLATE']) ?>" />
|
|
375 |
} else {
|
376 |
$select=' ';
|
377 |
}
|
|
|
|
|
378 |
echo '<option' . $select . 'value="'.
|
379 |
attribute_escape($value) . '" >'.$key . '</option>';
|
380 |
}
|
@@ -384,9 +430,9 @@ attribute_escape($config['VIDEO1TEMPLATE']) ?>" />
|
|
384 |
|
385 |
<?php _e('Preview', 'postie'); ?>
|
386 |
<span id='video1TemplatePreview' alt='preview'></span>
|
387 |
-
<textarea onchange="changeStyle('video1TemplatePreview','
|
388 |
-
'
|
389 |
-
name=
|
390 |
</td>
|
391 |
</tr>
|
392 |
<tr>
|
@@ -395,21 +441,21 @@ attribute_escape($config['VIDEO1TEMPLATE']) ?>" />
|
|
395 |
<?php _e('Use the video template 1 for these files types (separated by
|
396 |
commas)', 'postie') ?></span> </th>
|
397 |
<td>
|
398 |
-
<input name=
|
399 |
-
value="<?php if ($
|
400 |
</tr>
|
401 |
<tr><th scope='row'><?php _e('Video template 2', 'postie') ?><br />
|
402 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
403 |
<td>
|
404 |
-
<input type='hidden' id='
|
405 |
-
value="<?php echo attribute_escape($
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
onchange="changeStyle('video2TemplatePreview','VIDEO2TEMPLATE', 'VIDEO2TEMPLATESELECT', 'SELECTED_VIDEO2TEMPLATE','hi.flv');" />
|
410 |
<?php
|
411 |
-
|
412 |
-
$
|
|
|
413 |
foreach ($styleOptions as $key=>$value) {
|
414 |
if ($key!='selected') {
|
415 |
if ($key==$selected) {
|
@@ -417,6 +463,8 @@ attribute_escape($config['VIDEO2TEMPLATE']) ?>" />
|
|
417 |
} else {
|
418 |
$select=' ';
|
419 |
}
|
|
|
|
|
420 |
echo '<option' . $select . 'value="'.
|
421 |
attribute_escape($value) . '" >'.$key . '</option>';
|
422 |
}
|
@@ -426,9 +474,9 @@ attribute_escape($config['VIDEO2TEMPLATE']) ?>" />
|
|
426 |
|
427 |
<?php _e('Preview', 'postie'); ?>
|
428 |
<span id='video2TemplatePreview' alt='preview'></span>
|
429 |
-
<textarea onchange="changeStyle('video2TemplatePreview','
|
430 |
-
'
|
431 |
-
name=
|
432 |
</td>
|
433 |
</tr>
|
434 |
<tr>
|
@@ -437,23 +485,21 @@ attribute_escape($config['VIDEO2TEMPLATE']) ?>" />
|
|
437 |
<?php _e('Use the video template 2 for these files types (separated by
|
438 |
commas)', 'postie') ?></span> </th>
|
439 |
<td>
|
440 |
-
<input name=
|
441 |
-
value="<?php if ($
|
442 |
</tr>
|
443 |
<tr><th scope='row'><?php _e('Audio template', 'postie') ?><br />
|
444 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
445 |
<td>
|
446 |
-
<input type='hidden' id='
|
447 |
-
value="<?php echo attribute_escape($
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
onchange="changeStyle('audioTemplatePreview','AUDIOTEMPLATE',
|
452 |
-
'AUDIOTEMPLATESELECT', 'SELECTED_AUDIOTEMPLATE','funky.mp3', false);" />
|
453 |
<?php
|
454 |
-
|
455 |
-
|
456 |
-
$selected=$
|
457 |
foreach ($styleOptions as $key=>$value) {
|
458 |
if ($key!='selected') {
|
459 |
if ($key==$selected) {
|
@@ -461,6 +507,8 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
461 |
} else {
|
462 |
$select=' ';
|
463 |
}
|
|
|
|
|
464 |
echo '<option' . $select . 'value="'.
|
465 |
attribute_escape($value) . '" >'.$key . '</option>';
|
466 |
}
|
@@ -470,9 +518,9 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
470 |
|
471 |
<?php _e('Preview', 'postie'); ?>
|
472 |
<span id='audioTemplatePreview' alt='preview'></span>
|
473 |
-
<textarea onchange="changeStyle('audioTemplatePreview','
|
474 |
-
'
|
475 |
-
name=
|
476 |
</td>
|
477 |
</tr>
|
478 |
<tr>
|
@@ -481,8 +529,8 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
481 |
<?php _e('Use the audio template for these files types (separated by
|
482 |
commas)', 'postie') ?></span> </th>
|
483 |
<td>
|
484 |
-
<input name=
|
485 |
-
value="<?php if ($
|
486 |
</tr>
|
487 |
</table>
|
488 |
</td>
|
@@ -494,13 +542,18 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
494 |
|
495 |
<tr><th scope='row'><?php _e('Attachment icon set', 'postie') ?><br />
|
496 |
<td>
|
497 |
-
<input type='hidden' id='
|
498 |
-
value="<?php echo attribute_escape($
|
499 |
-
|
|
|
|
|
|
|
|
|
|
|
500 |
onchange="changeIconSet(this);" />
|
501 |
<?php
|
502 |
-
$styleOptions=$
|
503 |
-
$selected=$
|
504 |
foreach ($styleOptions as $key) {
|
505 |
if ($key!='selected') {
|
506 |
if ($key==$selected) {
|
@@ -518,13 +571,13 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
518 |
</tr>
|
519 |
<tr><th scope='row'><?php _e('Attachment icon size (in pixels)', 'postie') ?><br />
|
520 |
<td>
|
521 |
-
<input type='hidden' id='
|
522 |
-
value="<?php echo attribute_escape($
|
523 |
-
<select name='
|
524 |
onchange="changeIconSet(this, true);" />
|
525 |
<?php
|
526 |
-
$styleOptions=$
|
527 |
-
$selected=$
|
528 |
foreach ($styleOptions as $key) {
|
529 |
if ($key!='selected') {
|
530 |
if ($key==$selected) {
|
@@ -545,7 +598,7 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
545 |
<?php _e('Preview', 'postie'); ?>
|
546 |
</th>
|
547 |
<td>
|
548 |
-
<span id='
|
549 |
</td>
|
550 |
</tr>
|
551 |
</tr>
|
@@ -556,18 +609,27 @@ attribute_escape($config['AUDIOTEMPLATE']) ?>" />
|
|
556 |
</div>
|
557 |
<div id="simpleTabs-content-8" class="simpleTabs-content">
|
558 |
<?php include('faq.html'); ?>
|
559 |
-
</div>
|
560 |
-
|
561 |
-
|
562 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
</form>
|
564 |
-
<div id="w3c">
|
565 |
-
<a href="http://validator.w3.org/check?uri=referer"><img src="<?php echo '../wp-content/plugins/postie/images/valid-xhtml10-blue.png'; ?>" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
|
566 |
-
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="<?php echo '../wp-content/plugins/postie/images/vcss-blue.gif'; ?>" alt="Valid CSS!" /></a>
|
567 |
-
</div>
|
568 |
-
Postie Version:
|
569 |
-
$Id: config_form.php 149134 2009-08-26 02:26:46Z robfelty $
|
570 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
<?php $iconDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/icons'; ?>
|
573 |
<script type="text/javascript">
|
@@ -581,9 +643,9 @@ jQuery(document).ready(function() {
|
|
581 |
|
582 |
});
|
583 |
function changeIconSet(selectBox, size) {
|
584 |
-
var iconSet=document.getElementById('
|
585 |
-
var iconSize=document.getElementById('
|
586 |
-
var preview=document.getElementById('
|
587 |
var iconDir = '<?php echo $iconDir ?>/';
|
588 |
if (size==true) {
|
589 |
var hiddenInput=iconSize
|
@@ -601,7 +663,7 @@ function changeIconSet(selectBox, size) {
|
|
601 |
preview.innerHTML+="<img src='" + iconDir + iconSet.value + '/' +
|
602 |
fileTypes[j] + '-' + iconSize.value + ".png' />";
|
603 |
}
|
604 |
-
preview.innerHTML+='<br />Here is some sample text with a link to a' +
|
605 |
'word document that I think you might find interesting<br />' +
|
606 |
"<a href='#'><img style='text-decoration:none' src='" +
|
607 |
iconDir + iconSet.value + '/doc' +
|
@@ -643,11 +705,6 @@ function changeStyle(preview,template,select,selected,sample,custom) {
|
|
643 |
preview.innerHTML=previewHTML;
|
644 |
pageStyle.value=selectedStyle.value;
|
645 |
}
|
646 |
-
function restoreStyle(current,template) {
|
647 |
-
var defaultStyle = document.getElementById(current).value;
|
648 |
-
var pageStyle = document.getElementById(template);
|
649 |
-
pageStyle.value=defaultStyle;
|
650 |
-
}
|
651 |
|
652 |
function showAdvanced(advancedId, arrowId) {
|
653 |
var advanced = document.getElementById(advancedId);
|
@@ -660,14 +717,15 @@ function showAdvanced(advancedId, arrowId) {
|
|
660 |
arrow.innerHTML='▶';
|
661 |
}
|
662 |
}
|
663 |
-
|
664 |
-
|
665 |
-
'
|
666 |
-
|
667 |
-
'
|
668 |
-
changeStyle('video1TemplatePreview','
|
669 |
-
'
|
670 |
-
changeStyle('video2TemplatePreview','
|
671 |
-
'
|
672 |
-
|
|
|
673 |
</script>
|
1 |
<div class="wrap">
|
2 |
+
<h2>
|
3 |
+
<a style='text-decoration:none' href='options-general.php?page=postie/postie.php'>
|
4 |
+
<img src="<?php
|
5 |
+
echo ' ../wp-content/plugins/postie/images/mail.png'; ?>" alt="postie" /><?php
|
6 |
+
_e('Postie Options', 'postie');
|
7 |
+
?></a>
|
8 |
+
</h2>
|
9 |
<?php
|
10 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
|
11 |
if (isset($_POST["action"])) {
|
27 |
include('get_mail.php');
|
28 |
exit;
|
29 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
default:
|
31 |
$message = 2;
|
32 |
break;
|
36 |
|
37 |
$title = __('Postie Options', 'postie');
|
38 |
$parent_file = 'options-general.php';
|
39 |
+
$config = get_option( 'postie-settings');
|
40 |
+
if ( empty ($config) ) $config = ResetPostieConfig();
|
41 |
+
if ( defined ( 'POSTIE_DEBUG' ) ) var_dump( $config );
|
42 |
+
$arrays = get_arrayed_settings();
|
43 |
+
// some fields are stored as arrays, because that makes back-end processing much easier
|
44 |
+
// and we need to convert those fields to strings here, for the options form
|
45 |
+
foreach ( $arrays as $sep => $fields ) {
|
46 |
+
foreach ( $fields as $field ) {
|
47 |
+
$config[$field] = implode( $sep, $config[$field] );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
extract($config);
|
51 |
+
if ($interval=='manual') {
|
52 |
+
wp_clear_scheduled_hook('check_postie_hook');
|
53 |
+
}
|
54 |
+
|
55 |
$messages[1] = __("Configuration successfully updated!",'postie');
|
56 |
$messages[2] = __("Error - unable to save configuration",'postie');
|
57 |
|
61 |
<?php endif; ?>
|
62 |
<form name="postie-options" method="post">
|
63 |
<input type="hidden" name="action" value="reset" />
|
64 |
+
<input name="Submit" value="<?php _e("Reset Settings To Defaults", 'postie')?> »" type="submit" class='button'>
|
65 |
</form>
|
66 |
<form name="postie-options" method='post'>
|
67 |
<input type="hidden" name="action" value="runpostie" />
|
68 |
+
<input name="Submit" value="<?php _e("Run Postie", 'postie');?> »" type="submit" class='button'>
|
69 |
+
<?php _e("(To run the check mail script manually)", 'postie');?>
|
70 |
</form>
|
71 |
<form name="postie-options" method="post">
|
72 |
<input type="hidden" name="action" value="test" />
|
73 |
+
<input name="Submit" value="<?php _e("Test Config", 'postie');?>»" type="submit" class='button'>
|
74 |
+
<?php _e("this will run a special script to test your configuration options", 'postie');?>
|
75 |
</form>
|
76 |
+
<form name="postie-options" method="post" action='options.php'>
|
77 |
+
<?php settings_fields( 'postie-settings' ); ?>
|
78 |
+
<input type="hidden" name="action" value="config" />
|
79 |
<div id="simpleTabs">
|
80 |
<div class="simpleTabs-nav">
|
81 |
<ul>
|
91 |
</div>
|
92 |
<div id="simpleTabs-content-1" class="simpleTabs-content">
|
93 |
<table class='form-table'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
<tr>
|
96 |
<th scope="row"><?php _e('Mail Protocol:', 'postie') ?> </th>
|
97 |
<td>
|
98 |
+
<select name='postie-settings[input_protocol]' id='postie-settings-input_protocol'>
|
99 |
+
<option value="pop3" <?php if( $input_protocol == "pop3" ) { echo " selected='selected' ";} ?>>POP3</option>
|
100 |
<?php if (HasIMAPSupport(false)):?>
|
101 |
+
<option value="imap" <?php if($input_protocol == "imap") { echo "selected";} ?>>IMAP</option>
|
102 |
+
<option value="pop3-ssl" <?php if($input_protocol == "pop3-ssl") { echo "selected";} ?>>POP3-SSL</option>
|
103 |
+
<option value="imap-ssl" <?php if($input_protocol == "imap-ssl") { echo "selected";} ?>>IMAP-SSL</option>
|
104 |
+
</select>
|
105 |
<?php else:?>
|
106 |
+
</select>
|
107 |
+
<span class="recommendation">IMAP/IMAP-SSL/POP3-SSL unavailable</span>
|
108 |
<?php endif;?>
|
109 |
</select>
|
110 |
+
|
111 |
</td>
|
112 |
</tr>
|
113 |
<tr>
|
120 |
</span>
|
121 |
</th>
|
122 |
<td>
|
123 |
+
<input name='postie-settings[mail_server_port]' type="text" id='postie-settings-mail_server_port' value="<?php echo $mail_server_port;?>" size="6" />
|
124 |
</td>
|
125 |
</tr>
|
126 |
<tr>
|
128 |
<br />
|
129 |
<span class='recommendation'><?php _e("Should be the same as your normal offset - but this lets you adjust it in cases where that doesn't work.", 'postie');?></span>
|
130 |
</th>
|
131 |
+
<td><input name='postie-settings[time_offset]' type="text" id='postie-settings-time_offset' size="2" value="<?php echo $time_offset; ?>" />
|
132 |
<?php _e('hours', 'postie') ?>
|
133 |
|
134 |
</td>
|
135 |
</tr>
|
136 |
<tr valign="top">
|
137 |
<th scope="row"><?php _e('Mail Server:', 'postie') ?></th>
|
138 |
+
<td><input name='postie-settings[mail_server]' type="text" id='postie-settings-mail_server' value="<?php echo $mail_server;?>" size="40" />
|
139 |
</td>
|
140 |
</tr>
|
141 |
<tr valign="top">
|
142 |
<th width="33%" scope="row"><?php _e('Mail Userid:', 'postie') ?></th>
|
143 |
+
<td><input name='postie-settings[mail_userid]' type="text" id='postie-settings-mail_userid' value="<?php echo $mail_userid; ?>" size="40" /></td>
|
144 |
</tr>
|
145 |
<tr valign="top">
|
146 |
<th scope="row"><?php _e('Mail Password:', 'postie') ?></th>
|
147 |
<td>
|
148 |
+
<input name='postie-settings[mail_password]' type="text" id='postie-settings-mail_password' value="<?php echo $mail_password; ?>" size="40" />
|
149 |
</td>
|
150 |
</tr>
|
151 |
+
<tr><th>
|
152 |
+
<?php _e('Check for mail every', 'postie') ?>
|
153 |
+
</th>
|
154 |
+
<td>
|
155 |
+
<select name='postie-settings[interval]' id='postie-settings-interval'>
|
156 |
+
<option value="weekly" <?php if($interval == "weekly") { echo "selected='selected'";} ?>><?php _e('Once weekly', 'postie') ?></option>
|
157 |
+
<option value="daily"<?php if($interval == "daily") { echo "selected='selected'";} ?>><?php _e('daily', 'postie') ?></option>
|
158 |
+
<option value="hourly" <?php if($interval == "hourly") { echo "selected='selected'";} ?>><?php _e('hourly', 'postie') ?></option>
|
159 |
+
<option value="twiceperhour" <?php if($interval == "twiceperhour") { echo "selected='selected'";} ?>><?php _e('twice per hour', 'postie') ?></option>
|
160 |
+
<option value="tenminutes" <?php if($interval == "tenminutes") { echo "selected='selected'";} ?>><?php _e('every ten minutes', 'postie') ?></option>
|
161 |
+
<option value="manual" <?php if($interval == "manual") { echo
|
162 |
+
"selected='selected'";} ?>><?php _e('check manually', 'postie') ?></option>
|
163 |
+
</select>
|
164 |
+
</td>
|
165 |
+
</tr>
|
166 |
+
<?php echo BuildBooleanSelect("Delete email after
|
167 |
+
posting",'postie-settings[delete_mail_after_processing]',$delete_mail_after_processing,"Only set to yes for testing purposes");?>
|
168 |
</table>
|
169 |
</div>
|
170 |
<div id="simpleTabs-content-2" class="simpleTabs-content">
|
171 |
<table class='form-table'>
|
172 |
|
173 |
+
<?php echo BuildBooleanSelect("Allow Anyone To Post Via
|
174 |
+
Email","postie-settings[turn_authorization_off]",$turn_authorization_off,"Changing this to yes is NOT RECOMMEDED - anything that gets sent in will automatically be posted. This could make it easier to compromise your server - YOU HAVE BEEN WARNED.");?>
|
175 |
<tr>
|
176 |
<th scope="row"><?php _e('Roles That Can Post:', 'postie') ?>
|
177 |
<br />
|
183 |
foreach($wp_roles->role_names as $roleId => $name) {
|
184 |
$name=translate_with_context($name);
|
185 |
$role = &$wp_roles->get_role($roleId);
|
186 |
+
if ($roleId != "administrator") { ?>
|
187 |
+
<tr><td>
|
188 |
+
<input type='checkbox' value='1' name='postie-settings[role_access][<?php
|
189 |
+
echo $roleId;
|
190 |
+
?>]' <?php echo checked($role->has_cap("post_via_postie")); ?> >
|
191 |
+
<?php echo $name; ?>
|
192 |
+
</td></tr>
|
193 |
+
<?php
|
194 |
+
}
|
195 |
}
|
196 |
?>
|
197 |
</table>
|
200 |
<tr>
|
201 |
<th width="33%" valign="top" scope="row"><?php _e('Post status:', 'postie') ?> </th>
|
202 |
<td>
|
203 |
+
<select name='postie-settings[post_status]' id='postie-settings-post_status'>
|
204 |
+
<option value="publish" <?php if($post_status == "publish") { echo
|
205 |
+
"selected";} ?>>Published</option>
|
206 |
+
<option value="draft" <?php if($post_status == "draft") { echo
|
207 |
+
"selected";} ?>>Draft</option>
|
208 |
+
<option value="pending" <?php if($post_status == "pending") { echo
|
209 |
+
"selected";} ?>>Pending Review</option>
|
210 |
+
<option value="private" <?php if($post_status == "private") { echo
|
211 |
+
"selected";} ?>>Private</option>
|
212 |
</select> </td>
|
213 |
</tr>
|
214 |
+
<?php echo BuildTextArea("Authorized
|
215 |
+
Addresses","postie-settings[authorized_addresses]",$authorized_addresses,"Put each email address on a single line. Posts from emails in this list will be treated as if they came from the admin. If you would prefer to have users post under their own name - create a WordPress user with the correct access level.");?>
|
216 |
<tr>
|
217 |
<th width="33%" valign="top" scope="row">
|
218 |
<?php _e('Admin username:') ?> </th>
|
219 |
<td>
|
220 |
+
<input name='postie-settings[admin_username]' type="text" id='postie-settings-admin_username'
|
221 |
+
value="<?php echo $admin_username; ?>" size="50" /> </td>
|
222 |
</tr>
|
223 |
</table>
|
224 |
</div>
|
228 |
<th scope="row"><?php _e('Default post by mail category:', 'postie') ?></th>
|
229 |
<td>
|
230 |
<?php
|
231 |
+
$defaultCat=$default_post_category;
|
232 |
+
wp_dropdown_categories("name=postie-settings[default_post_category]&hierarchical=1&selected=$defaultCat&hide_empty=0"); ?>
|
233 |
</tr>
|
234 |
<tr valign="top">
|
235 |
<th scope="row">
|
236 |
<?php _e('Default post by mail tag(s)', 'postie') ?><br /><span
|
237 |
class='recommendation'><?php _e('separated by commas', 'postie')
|
238 |
?></span></th>
|
239 |
+
<td><input type='text' name='postie-settings[default_post_tags]'
|
240 |
+
id='postie-settings-default_post_tags' value='<?php echo
|
241 |
+
$default_post_tags ?>' />
|
242 |
</td>
|
243 |
</tr>
|
244 |
<tr>
|
245 |
<th width="33%" valign="top" scope="row"><?php _e('Default Title:', 'postie') ?> </th>
|
246 |
<td>
|
247 |
+
<input name='postie-settings[default_title]' type="text" id='postie-settings-default_title' value="<?php echo $default_title; ?>" size="50" /><br />
|
248 |
<br />
|
249 |
</td>
|
250 |
</tr>
|
252 |
<th width="33%" valign="top" scope="row"><?php _e('Preferred
|
253 |
Text Type:', 'postie') ?> </th>
|
254 |
<td>
|
255 |
+
<select name='postie-settings[prefer_text_type]' id='postie-settings-prefer_text_type'>
|
256 |
<option value="plain">plain</option>
|
257 |
+
<option value="html" <?php if($prefer_text_type == "html") { echo "selected";} ?>>html</option>
|
258 |
</select><br />
|
259 |
</td>
|
260 |
</tr>
|
261 |
+
<?php echo BuildBooleanSelect("Forward Rejected Mail","postie-settings[forward_rejected_mail]",$forward_rejected_mail);?>
|
262 |
+
<?php echo BuildBooleanSelect("Allow Subject In Mail","postie-settings[allow_subject_in_mail]",$allow_subject_in_mail);?>
|
263 |
+
<?php echo BuildBooleanSelect("Allow HTML In Mail Subject","postie-settings[allow_html_in_subject]",$allow_html_in_subject);?>
|
264 |
+
<?php echo BuildBooleanSelect("Allow HTML In Mail Body","postie-settings[allow_html_in_body]",$allow_html_in_body);?>
|
265 |
<tr>
|
266 |
<th width="33%" valign="top" scope="row"><?php _e('Tag Of
|
267 |
Message Start:', 'postie') ?> <br />
|
268 |
<span class='recommendation'><?php _e('Use to remove any text from a message that the email provider puts at the top of the message', 'postie') ?></span></th>
|
269 |
<td>
|
270 |
+
<input name='postie-settings[message_start]' type="text" id='postie-settings-message_start' value="<?php echo $message_start; ?>" size="20" /><br />
|
271 |
</td>
|
272 |
</tr>
|
273 |
<tr>
|
275 |
Message End:', 'postie') ?> <br />
|
276 |
<span class='recommendation'><?php _e('Use to remove any text from a message that the email provider puts at the end of the message', 'postie') ?></span></th>
|
277 |
<td>
|
278 |
+
<input name='postie-settings[message_end]' type="text" id='postie-settings-message_end' value="<?php echo $message_end; ?>" size="20" /><br />
|
279 |
</td>
|
280 |
</tr>
|
281 |
</table>
|
282 |
<a style='cursor:pointer' onclick='showAdvanced("message-advanced", "message-advanced-arrow");'><span id="message-advanced-arrow">▶</span> Advanced options</a>
|
283 |
<div id="message-advanced" style='display:none;'>
|
284 |
<table class='form-table'>
|
285 |
+
<?php echo BuildBooleanSelect("Wrap content in pre tags","postie-settings[wrap_pre]",$wrap_pre);?>
|
286 |
+
<?php echo BuildBooleanSelect("Filter newlines", "postie-settings[filternewlines]",$filternewlines,
|
|
|
287 |
"Set to no if using markdown or textitle syntax");?>
|
288 |
+
<?php echo BuildBooleanSelect("Replace newline characters with html line breaks (<br />)","postie-settings[convertnewline]",$convertnewline);?>
|
289 |
+
<?php echo BuildBooleanSelect("Return rejected mail to sender","postie-settings[return_to_sender]",$return_to_sender);?>
|
290 |
+
<tr>
|
291 |
+
<th>
|
292 |
+
<?php _e("Send post confirmation e-mail to" , 'postie') ?>
|
293 |
+
</th>
|
294 |
+
<td>
|
295 |
+
<select name='postie-settings[confirmation_email]'
|
296 |
+
id='postie-settings-confirmation_email'>
|
297 |
+
<option value="sender" <?php if($confirmation_email == "sender") {
|
298 |
+
echo "selected";} ?>><?php _e('sender', 'postie') ?></option>
|
299 |
+
<option value="admin" <?php if($confirmation_email == "admin") { echo
|
300 |
+
"selected";} ?>><?php _e('administrator', 'postie') ?></option>
|
301 |
+
<option value="both" <?php if($confirmation_email == "both") { echo
|
302 |
+
"selected";} ?>><?php _e('sender and administrator', 'postie') ?></option>
|
303 |
+
<option value="" <?php if($confirmation_email == "") { echo
|
304 |
+
"selected";} ?>><?php _e('none', 'postie') ?></option>
|
305 |
+
</select>
|
306 |
+
</td>
|
307 |
+
</tr>
|
308 |
+
|
309 |
+
<?php echo BuildBooleanSelect("Automatically convert urls to links","postie-settings[converturls]",$converturls);?>
|
310 |
+
<?php echo BuildBooleanSelect("Use shortcode for embedding video (youtube and others)","postie-settings[shortcode]",$shortcode);?>
|
311 |
<tr>
|
312 |
<th width="33%" valign="top" scope="row"><?php _e('Encoding for pages and feeds:', 'postie') ?> </th>
|
313 |
<td>
|
314 |
+
<input name='postie-settings[message_encoding]' type="text" id='postie-settings-message_encoding' value="<?php echo $message_encoding; ?>" size="10" />
|
315 |
<span class='recommendation'>UTF-8 <?php _e("should handle ISO-8859-1 as well", 'postie');?></span>
|
316 |
</td>
|
317 |
</tr>
|
318 |
+
<?php echo BuildBooleanSelect("Decode Quoted Printable
|
319 |
+
Data","postie-settings[message_dequote]",$message_dequote);?>
|
320 |
+
<?php echo BuildTextArea("Supported File
|
321 |
+
Types","postie-settings[supported_file_types]",$supported_file_types,"Put each type on a single line.");?>
|
322 |
+
<?php echo BuildTextArea("Banned File
|
323 |
+
Names","postie-settings[banned_files_list]",$banned_files_list,"Put each file name on a single line.Files matching this list will never be posted to your blog. You can use wildcards such as *.xls, or *.* for all files");?>
|
324 |
+
<?php echo BuildBooleanSelect("Drop The Signature From Mail","postie-settings[drop_signature]",$drop_signature);?>
|
325 |
+
<?php echo BuildTextArea("Signature
|
326 |
+
Patterns","postie-settings[sig_pattern_list]",$sig_pattern_list,"Put each pattern on a separate line and make sure to escape any special characters.");?>
|
327 |
<?php echo BuildTextArea("Allowed SMTP
|
328 |
+
servers","postie-settings[smtp]",$smtp,"Only allow messages which have been sent throught the following smtp servers. Put each server on a separate line. Leave blank to not check smtp servers.");?>
|
329 |
</table>
|
330 |
</div> <!-- advanced options -->
|
331 |
</div>
|
333 |
<table class='form-table'>
|
334 |
|
335 |
|
336 |
+
<?php echo BuildBooleanSelect("Automatically insert image
|
337 |
+
gallery","postie-settings[auto_gallery]",$auto_gallery,"If any
|
338 |
+
images are attached, they will automatically be inserted as a
|
339 |
+
gallery");?>
|
340 |
+
<?php echo BuildBooleanSelect("Post Images At End","postie-settings[images_append]",$images_append,"No means they will be put before the text of the message.");?>
|
341 |
+
<?php echo BuildBooleanSelect("Start Image Count At
|
342 |
+
0","postie-settings[start_image_count_at_zero]",$start_image_count_at_zero);?>
|
343 |
<tr>
|
344 |
<th width="33%" valign="top" scope="row"><?php _e('Image Place Holder Tag:', 'postie') ?> </th>
|
345 |
<td>
|
346 |
+
<input name='postie-settings[image_placeholder]' type="text" id='postie-settings-image_placeholder' value="<?php echo $image_placeholder; ?>" size="50" /><br />
|
347 |
</td>
|
348 |
</tr>
|
349 |
<tr>
|
355 |
<span class='recommendation'><?php _e('Sizes for thumbnail, medium, and large images can be chosen in the <a href="options-media.php">Media Settings</a>. The samples here use the default sizes, and will not reflect the sizes you have chosen.', 'postie');?></span>
|
356 |
</th>
|
357 |
<td>
|
358 |
+
<input type='hidden' id='postie-settings-selected_imagetemplate' name='postie-settings[selected_imagetemplate]'
|
359 |
+
value="<?php echo attribute_escape($selected_imagetemplate) ?>" />
|
360 |
+
<select name='imagetemplateselect' id='imagetemplateselect'
|
361 |
+
onchange="changeStyle('imageTemplatePreview','postie-settings-imagetemplate',
|
362 |
+
'imagetemplateselect', 'postie-settings-selected_imagetemplate','smiling.jpg');" />
|
|
|
|
|
363 |
<?php
|
364 |
+
include('templates/image_templates.php');
|
365 |
+
$styleOptions = $imageTemplates;
|
366 |
+
$selected=$selected_imagetemplate;
|
367 |
foreach ($styleOptions as $key=>$value) {
|
368 |
if ($key!='selected') {
|
369 |
if ($key==$selected) {
|
371 |
} else {
|
372 |
$select=' ';
|
373 |
}
|
374 |
+
if ($key=='custom')
|
375 |
+
$value = $imagetemplate;
|
376 |
echo '<option' . $select . 'value="'.
|
377 |
attribute_escape($value) . '" >'.$key . '</option>';
|
378 |
}
|
382 |
|
383 |
<?php _e('Preview', 'postie'); ?>
|
384 |
<span id='imageTemplatePreview' alt='preview'></span>
|
385 |
+
<textarea onchange='changeStyle("imageTemplatePreview", "postie-settings-imagetemplate",
|
386 |
+
"imagetemplateselect", "postie-settings-selected_imagetemplate", "smiling.jpg", true);' cols='70' rows='7' id='postie-settings-imagetemplate'
|
387 |
+
name='postie-settings[imagetemplate]'><?php echo attribute_escape($imagetemplate) ?></textarea>
|
388 |
</td>
|
389 |
</tr>
|
390 |
+
<?php echo BuildBooleanSelect("Use custom image
|
391 |
+
field","postie-settings[custom_image_field]",$custom_image_field,"When true, images will not appear in the post. Instead the url to the image will be input into a custom field named 'image'.");?>
|
392 |
</table>
|
393 |
</div>
|
394 |
|
403 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
404 |
<?php $templateDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/templates'; ?>
|
405 |
<td>
|
406 |
+
<input type='hidden' id='postie-settings-selected_video1template' name='postie-settings[selected_video1template]'
|
407 |
+
value="<?php echo attribute_escape($selected_video1template) ?>" />
|
408 |
+
<select name='video1templateselect' id='video1templateselect'
|
409 |
+
onchange="changeStyle('video1TemplatePreview','postie-settings-video1template',
|
410 |
+
'video1templateselect', 'postie-settings-selected_video1template','hi.mp4');" />
|
|
|
411 |
<?php
|
412 |
+
include('templates/video1_templates.php');
|
413 |
+
$styleOptions=$video1Templates;
|
414 |
+
$selected=$selected_video1template;
|
415 |
foreach ($styleOptions as $key=>$value) {
|
416 |
if ($key!='selected') {
|
417 |
if ($key==$selected) {
|
419 |
} else {
|
420 |
$select=' ';
|
421 |
}
|
422 |
+
if ($key=='custom')
|
423 |
+
$value = $video1template;
|
424 |
echo '<option' . $select . 'value="'.
|
425 |
attribute_escape($value) . '" >'.$key . '</option>';
|
426 |
}
|
430 |
|
431 |
<?php _e('Preview', 'postie'); ?>
|
432 |
<span id='video1TemplatePreview' alt='preview'></span>
|
433 |
+
<textarea onchange="changeStyle('video1TemplatePreview','postie-settings-video1template',
|
434 |
+
'video1templateselect', 'postie-settings-selected_video1template','hi.mp4',true);" cols='70' rows='7' id='postie-settings-video1template'
|
435 |
+
name='postie-settings[video1template]'><?php echo attribute_escape($video1template) ?></textarea>
|
436 |
</td>
|
437 |
</tr>
|
438 |
<tr>
|
441 |
<?php _e('Use the video template 1 for these files types (separated by
|
442 |
commas)', 'postie') ?></span> </th>
|
443 |
<td>
|
444 |
+
<input name='postie-settings[video1types]' type="text" id='postie-settings-video1types'
|
445 |
+
value="<?php if ($video1types!='') echo $video1types; ?>" size="40" /> </td>
|
446 |
</tr>
|
447 |
<tr><th scope='row'><?php _e('Video template 2', 'postie') ?><br />
|
448 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
449 |
<td>
|
450 |
+
<input type='hidden' id='postie-settings-selected_video2template' name='postie-settings[selected_video2template]'
|
451 |
+
value="<?php echo attribute_escape($selected_video2template) ?>" />
|
452 |
+
<select name='video2templateselect' id='video2templateselect'
|
453 |
+
onchange="changeStyle('video2TemplatePreview','postie-settings-video2template',
|
454 |
+
'video2templateselect', 'postie-settings-selected_video2template','hi.flv');" />
|
|
|
455 |
<?php
|
456 |
+
include('templates/video2_templates.php');
|
457 |
+
$styleOptions=$video2Templates;
|
458 |
+
$selected=$selected_video2template;
|
459 |
foreach ($styleOptions as $key=>$value) {
|
460 |
if ($key!='selected') {
|
461 |
if ($key==$selected) {
|
463 |
} else {
|
464 |
$select=' ';
|
465 |
}
|
466 |
+
if ($key=='custom')
|
467 |
+
$value = $video2template;
|
468 |
echo '<option' . $select . 'value="'.
|
469 |
attribute_escape($value) . '" >'.$key . '</option>';
|
470 |
}
|
474 |
|
475 |
<?php _e('Preview', 'postie'); ?>
|
476 |
<span id='video2TemplatePreview' alt='preview'></span>
|
477 |
+
<textarea onchange="changeStyle('video2TemplatePreview','postie-settings-video2template',
|
478 |
+
'video2templateselect', 'postie-settings-selected_video2template','hi.flv',true);" cols='70' rows='7' id='postie-settings-video2template'
|
479 |
+
name='postie-settings[video2template]'><?php echo attribute_escape($video2template) ?></textarea>
|
480 |
</td>
|
481 |
</tr>
|
482 |
<tr>
|
485 |
<?php _e('Use the video template 2 for these files types (separated by
|
486 |
commas)', 'postie') ?></span> </th>
|
487 |
<td>
|
488 |
+
<input name='postie-settings[video2types]' type="text" id='postie-settings-video2types'
|
489 |
+
value="<?php if ($video2types!='') echo $video2types; ?>" size="40" /> </td>
|
490 |
</tr>
|
491 |
<tr><th scope='row'><?php _e('Audio template', 'postie') ?><br />
|
492 |
<span class='recommendation'><?php _e('Choose a default template, then customize to your liking in the text box', 'postie') ?></span></th>
|
493 |
<td>
|
494 |
+
<input type='hidden' id='postie-settings-selected_audiotemplate' name='postie-settings[selected_audiotemplate]'
|
495 |
+
value="<?php echo attribute_escape($selected_audiotemplate) ?>" />
|
496 |
+
<select name='audiotemplateselect' id='audiotemplateselect'
|
497 |
+
onchange="changeStyle('audioTemplatePreview','postie-settings-audiotemplate',
|
498 |
+
'audiotemplateselect', 'postie-settings-selected_audiotemplate','funky.mp3', false);" />
|
|
|
|
|
499 |
<?php
|
500 |
+
include('templates/audio_templates.php');
|
501 |
+
$styleOptions=$audioTemplates;
|
502 |
+
$selected=$selected_audiotemplate;
|
503 |
foreach ($styleOptions as $key=>$value) {
|
504 |
if ($key!='selected') {
|
505 |
if ($key==$selected) {
|
507 |
} else {
|
508 |
$select=' ';
|
509 |
}
|
510 |
+
if ($key=='custom')
|
511 |
+
$value = $audiotemplate;
|
512 |
echo '<option' . $select . 'value="'.
|
513 |
attribute_escape($value) . '" >'.$key . '</option>';
|
514 |
}
|
518 |
|
519 |
<?php _e('Preview', 'postie'); ?>
|
520 |
<span id='audioTemplatePreview' alt='preview'></span>
|
521 |
+
<textarea onchange="changeStyle('audioTemplatePreview','postie-settings-audiotemplate',
|
522 |
+
'audiotemplateselect', 'postie-settings-selected_audiotemplate','funky.mp3', true);" cols='70' rows='7' id='postie-settings-audiotemplate'
|
523 |
+
name='postie-settings[audiotemplate]'><?php echo attribute_escape($audiotemplate) ?></textarea>
|
524 |
</td>
|
525 |
</tr>
|
526 |
<tr>
|
529 |
<?php _e('Use the audio template for these files types (separated by
|
530 |
commas)', 'postie') ?></span> </th>
|
531 |
<td>
|
532 |
+
<input name='postie-settings[audiotypes]' type="text" id='postie-settings-audiotypes'
|
533 |
+
value="<?php if ($audiotypes!='') echo $audiotypes; ?>" size="40" /> </td>
|
534 |
</tr>
|
535 |
</table>
|
536 |
</td>
|
542 |
|
543 |
<tr><th scope='row'><?php _e('Attachment icon set', 'postie') ?><br />
|
544 |
<td>
|
545 |
+
<input type='hidden' id='postie-settings-icon_set' name='postie-settings[icon_set]'
|
546 |
+
value="<?php echo attribute_escape($icon_set) ?>" />
|
547 |
+
|
548 |
+
<?php
|
549 |
+
$icon_sets=array('silver','black','white','custom', 'none');
|
550 |
+
$icon_sizes=array(32,48,64);
|
551 |
+
?>
|
552 |
+
<select name='icon_set_select' id='icon_set_select'
|
553 |
onchange="changeIconSet(this);" />
|
554 |
<?php
|
555 |
+
$styleOptions=$icon_sets;
|
556 |
+
$selected=$icon_set;
|
557 |
foreach ($styleOptions as $key) {
|
558 |
if ($key!='selected') {
|
559 |
if ($key==$selected) {
|
571 |
</tr>
|
572 |
<tr><th scope='row'><?php _e('Attachment icon size (in pixels)', 'postie') ?><br />
|
573 |
<td>
|
574 |
+
<input type='hidden' id='postie-settings-icon_size' name='postie-settings[icon_size]'
|
575 |
+
value="<?php echo attribute_escape($icon_size) ?>" />
|
576 |
+
<select name='icon_size_select' id='icon_size_select'
|
577 |
onchange="changeIconSet(this, true);" />
|
578 |
<?php
|
579 |
+
$styleOptions=$icon_sizes;
|
580 |
+
$selected=$icon_size;
|
581 |
foreach ($styleOptions as $key) {
|
582 |
if ($key!='selected') {
|
583 |
if ($key==$selected) {
|
598 |
<?php _e('Preview', 'postie'); ?>
|
599 |
</th>
|
600 |
<td>
|
601 |
+
<span id='postie-settings-attachment_preview'></span>
|
602 |
</td>
|
603 |
</tr>
|
604 |
</tr>
|
609 |
</div>
|
610 |
<div id="simpleTabs-content-8" class="simpleTabs-content">
|
611 |
<?php include('faq.html'); ?>
|
612 |
+
</div>
|
613 |
+
|
614 |
+
<p class="submit">
|
615 |
+
<input type="hidden" name="action" value="update" />
|
616 |
+
|
617 |
+
<input type="hidden" name="page_options"
|
618 |
+
value="postie-settings" />
|
619 |
+
|
620 |
+
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
|
621 |
+
|
622 |
+
</p>
|
623 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
624 |
</div>
|
625 |
+
<p>
|
626 |
+
<a href="http://validator.w3.org/check?uri=referer"><img
|
627 |
+
src="/images/valid-xhtml10.png" alt="Valid XHTML 1.0!" style="height:20px;
|
628 |
+
width:65px; border:0;" /></a> <a
|
629 |
+
href="http://jigsaw.w3.org/css-validator/check/referer"><img
|
630 |
+
style="border:0;width:65px;height:20px;" src="/images/vcss.gif" alt="Valid
|
631 |
+
CSS!" /></a><br />
|
632 |
+
</p>
|
633 |
|
634 |
<?php $iconDir = get_option('siteurl') . '/' . PLUGINDIR . '/postie/icons'; ?>
|
635 |
<script type="text/javascript">
|
643 |
|
644 |
});
|
645 |
function changeIconSet(selectBox, size) {
|
646 |
+
var iconSet=document.getElementById('postie-settings-icon_set');
|
647 |
+
var iconSize=document.getElementById('postie-settings-icon_size');
|
648 |
+
var preview=document.getElementById('postie-settings-attachment_preview');
|
649 |
var iconDir = '<?php echo $iconDir ?>/';
|
650 |
if (size==true) {
|
651 |
var hiddenInput=iconSize
|
663 |
preview.innerHTML+="<img src='" + iconDir + iconSet.value + '/' +
|
664 |
fileTypes[j] + '-' + iconSize.value + ".png' />";
|
665 |
}
|
666 |
+
preview.innerHTML+='<br />Here is some sample text with a link to a ' +
|
667 |
'word document that I think you might find interesting<br />' +
|
668 |
"<a href='#'><img style='text-decoration:none' src='" +
|
669 |
iconDir + iconSet.value + '/doc' +
|
705 |
preview.innerHTML=previewHTML;
|
706 |
pageStyle.value=selectedStyle.value;
|
707 |
}
|
|
|
|
|
|
|
|
|
|
|
708 |
|
709 |
function showAdvanced(advancedId, arrowId) {
|
710 |
var advanced = document.getElementById(advancedId);
|
717 |
arrow.innerHTML='▶';
|
718 |
}
|
719 |
}
|
720 |
+
changeStyle('imageTemplatePreview','postie-settings-imagetemplate', 'imagetemplateselect',
|
721 |
+
'postie-settings-selected_imagetemplate','smiling.jpg', false);
|
722 |
+
changeStyle('audioTemplatePreview','postie-settings-audiotemplate',
|
723 |
+
'audiotemplateselect',
|
724 |
+
'postie-settings-selected_audiotemplate','funky.mp3', false);
|
725 |
+
changeStyle('video1TemplatePreview','postie-settings-video1template', 'video1templateselect',
|
726 |
+
'postie-settings-selected_video1template','hi.mp4', false);
|
727 |
+
changeStyle('video2TemplatePreview','postie-settings-video2template',
|
728 |
+
'video2templateselect',
|
729 |
+
'postie-settings-selected_video2template','hi.flv', false);
|
730 |
+
changeIconSet(document.getElementById('icon_set_select'));
|
731 |
</script>
|
cronless_postie.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Cronless Postie
|
4 |
-
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
-
Description: Checks e-mail periodically using wordpress's built-in scheduling mechanism
|
6 |
-
Author: Robert Felty
|
7 |
-
Version: 1.3.4
|
8 |
-
Author URI: http://blog.robfelty.com
|
9 |
-
*/
|
10 |
-
|
11 |
-
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
|
12 |
-
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
13 |
-
function check_postie() {
|
14 |
-
$host = get_option('siteurl');
|
15 |
-
preg_match("/http:\/\/(.[^\/]*)(.*)/",$host,$matches);
|
16 |
-
$host = $matches[1];
|
17 |
-
$url = "";
|
18 |
-
if (isset($matches[2])) {
|
19 |
-
$url .= $matches[2];
|
20 |
-
}
|
21 |
-
$url .= "/wp-content/plugins/postie/get_mail.php";
|
22 |
-
$port = 80;
|
23 |
-
$fp=fsockopen($host,$port,$errno,$errstr);
|
24 |
-
fputs($fp,"GET $url HTTP/1.0\r\n");
|
25 |
-
fputs($fp,"User-Agent: Cronless-Postie\r\n");
|
26 |
-
fputs($fp,"Host: $host\r\n");
|
27 |
-
fputs($fp,"\r\n");
|
28 |
-
$page = '';
|
29 |
-
while(!feof($fp)) {
|
30 |
-
$page.=fgets($fp,128);
|
31 |
-
}
|
32 |
-
#var_dump($page);
|
33 |
-
fclose($fp);
|
34 |
-
}
|
35 |
-
if (isset($_GET["cronless_postie_read_me"])) {
|
36 |
-
include_once(ABSPATH . "wp-admin/admin.php");
|
37 |
-
$title = __("Edit Plugins");
|
38 |
-
$parent_file = 'plugins.php';
|
39 |
-
include(ABSPATH . 'wp-admin/admin-header.php');
|
40 |
-
cronless_read_me();
|
41 |
-
include(ABSPATH . 'wp-admin/admin-footer.php');
|
42 |
-
exit();
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
function postie_cron() {
|
47 |
-
global $wpdb;
|
48 |
-
$config=GetConfig();
|
49 |
-
if (!$config['CRONLESS'] || $config['CRONLESS']=='') {
|
50 |
-
$config['CRONLESS']='hourly';
|
51 |
-
$theQuery=$wpdb->prepare("INSERT INTO ". POSTIE_TABLE . "
|
52 |
-
(label,value) VALUES
|
53 |
-
('CRONLESS','". $config['CRONLESS'] ."');");
|
54 |
-
$q = $wpdb->query($theQuery);
|
55 |
-
//WriteConfig($config);
|
56 |
-
}
|
57 |
-
wp_schedule_event(time(),$config['CRONLESS'],'check_postie_hook');
|
58 |
-
}
|
59 |
-
function postie_decron() {
|
60 |
-
global $wpdb;
|
61 |
-
wp_clear_scheduled_hook('check_postie_hook');
|
62 |
-
$config=GetConfig();
|
63 |
-
$config['CRONLESS']='';
|
64 |
-
$theQuery=$wpdb->prepare("INSERT INTO ". POSTIE_TABLE . "
|
65 |
-
(label,value) VALUES
|
66 |
-
('CRONLESS','". $config['CRONLESS'] ."');");
|
67 |
-
$q = $wpdb->query($theQuery);
|
68 |
-
//WriteConfig($config);
|
69 |
-
}
|
70 |
-
|
71 |
-
/* here we add some more options for how often to check for e-mail */
|
72 |
-
function more_reccurences() {
|
73 |
-
return array(
|
74 |
-
'weekly' => array('interval' => 604800, 'display' => 'Once Weekly'),
|
75 |
-
'twiceperhour' => array('interval' => 1800, 'display' => 'Twice per hour '),
|
76 |
-
'tenminutes' =>array('interval' => 600, 'display' => 'Every 10 minutes')
|
77 |
-
);
|
78 |
-
}
|
79 |
-
add_filter('cron_schedules', 'more_reccurences');
|
80 |
-
register_activation_hook(__FILE__,'postie_cron');
|
81 |
-
register_deactivation_hook(__FILE__,'postie_decron');
|
82 |
-
add_action('check_postie_hook', 'check_postie');
|
83 |
-
//add_action('init','postie_cron');
|
84 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
faq.html
CHANGED
@@ -11,6 +11,7 @@
|
|
11 |
<li id='question-10'><a href='#answer-10'>Can I add special text to the body of the post when using postie?</a></li>
|
12 |
<li id='question-11'><a href='#answer-11'>Can I add special text to the title of the post when using postie?</a></li>
|
13 |
<li id='question-12'><a href='#answer-12'>Is the IMAP extension required for postie?</a></li>
|
|
|
14 |
<h3>Frequently Asked Questions</h3>
|
15 |
<h4 id='answer-0'>Mail is not showing up right when I send html (rich formatted) e-mail!</h4>
|
16 |
|
@@ -18,7 +19,7 @@
|
|
18 |
|
19 |
<h4 id='answer-1'>Do I need to any code to my theme for postie to work?</h4>
|
20 |
|
21 |
-
<p>No
|
22 |
|
23 |
<h4 id='answer-2'>I read somewhere to add an iframe to my footer. Should I do this?</h4>
|
24 |
|
@@ -44,7 +45,7 @@ gmail preferences.</p>
|
|
44 |
<li>protocol - pop3-ssl</li>
|
45 |
<li>server - pop.gmail.com</li>
|
46 |
<li>port - 995</li>
|
47 |
-
<li>userid - your username (e.g. if your e-mail address is foo@gmail.com
|
48 |
this would be just foo)</li>
|
49 |
<li>password - your password </li>
|
50 |
</ul></li>
|
@@ -54,7 +55,7 @@ this would be just foo)</li>
|
|
54 |
<li>protocol - imap-ssl</li>
|
55 |
<li>server - imap.gmail.com</li>
|
56 |
<li>port - 993</li>
|
57 |
-
<li>userid - your username (e.g. if your e-mail address is foo@gmail.com
|
58 |
this would be just foo)</li>
|
59 |
<li>password - your password </li>
|
60 |
</ul></li>
|
@@ -62,12 +63,12 @@ this would be just foo)</li>
|
|
62 |
|
63 |
<h4 id='answer-5'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
|
64 |
|
65 |
-
<p>If your admin account is linked to bar@gmail.com
|
66 |
-
bar@gmail.com
|
67 |
-
wordpress user named "John Doe", which is linked to johndoe@gmail.com
|
68 |
-
sure that you send e-mails from johndoe@gmail.com. It doesn't matter which
|
69 |
e-mail address postie is checking. That is, if you send mail from
|
70 |
-
johndoe@gmail.com to foo@gmail.com
|
71 |
|
72 |
<p>If you send an e-mail to your postie address from an e-mail address that is no
|
73 |
t linked to a wordpress user, it will get posted as admin.</p>
|
@@ -146,7 +147,7 @@ Two short examples are included in the filterPostie.php file</p>
|
|
146 |
<p>The IMAP extension is not required, but it is strongly recommended, especially
|
147 |
is you are using non-English text. There is more information on php.net about
|
148 |
installing the IMAP extension. If you have control over your server, it is
|
149 |
-
often not hard to install
|
150 |
|
151 |
<p>On Ubuntu, try
|
152 |
sudo apt-get install php5-imap</p>
|
@@ -155,4 +156,9 @@ sudo apt-get install php5-imap</p>
|
|
155 |
sudo yuminstall php-imap</p>
|
156 |
|
157 |
<p>The IMAP extension is known to be installed on the following popular webhosts:
|
158 |
-
* Dreamhost</p>
|
|
|
|
|
|
|
|
|
|
11 |
<li id='question-10'><a href='#answer-10'>Can I add special text to the body of the post when using postie?</a></li>
|
12 |
<li id='question-11'><a href='#answer-11'>Can I add special text to the title of the post when using postie?</a></li>
|
13 |
<li id='question-12'><a href='#answer-12'>Is the IMAP extension required for postie?</a></li>
|
14 |
+
<li id='question-13'><a href='#answer-13'>How can I embed youtube or vimeo videos?</a></li>
|
15 |
<h3>Frequently Asked Questions</h3>
|
16 |
<h4 id='answer-0'>Mail is not showing up right when I send html (rich formatted) e-mail!</h4>
|
17 |
|
19 |
|
20 |
<h4 id='answer-1'>Do I need to any code to my theme for postie to work?</h4>
|
21 |
|
22 |
+
<p>No.</p>
|
23 |
|
24 |
<h4 id='answer-2'>I read somewhere to add an iframe to my footer. Should I do this?</h4>
|
25 |
|
45 |
<li>protocol - pop3-ssl</li>
|
46 |
<li>server - pop.gmail.com</li>
|
47 |
<li>port - 995</li>
|
48 |
+
<li>userid - your username (e.g. if your e-mail address is <a href="mailto:foo@gmail.com">foo@gmail.com</a>,
|
49 |
this would be just foo)</li>
|
50 |
<li>password - your password </li>
|
51 |
</ul></li>
|
55 |
<li>protocol - imap-ssl</li>
|
56 |
<li>server - imap.gmail.com</li>
|
57 |
<li>port - 993</li>
|
58 |
+
<li>userid - your username (e.g. if your e-mail address is <a href="mailto:foo@gmail.com">foo@gmail.com</a>,
|
59 |
this would be just foo)</li>
|
60 |
<li>password - your password </li>
|
61 |
</ul></li>
|
63 |
|
64 |
<h4 id='answer-5'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
|
65 |
|
66 |
+
<p>If your admin account is linked to <a href="mailto:bar@gmail.com">bar@gmail.com</a>, and you send mail from
|
67 |
+
<a href="mailto:bar@gmail.com">bar@gmail.com</a>, it will show up as being posted by admin. If you have a
|
68 |
+
wordpress user named "John Doe", which is linked to <a href="mailto:johndoe@gmail.com">johndoe@gmail.com</a>, make
|
69 |
+
sure that you send e-mails from <a href="mailto:johndoe@gmail.com">johndoe@gmail.com</a>. It doesn't matter which
|
70 |
e-mail address postie is checking. That is, if you send mail from
|
71 |
+
<a href="mailto:johndoe@gmail.com">johndoe@gmail.com</a> to <a href="mailto:foo@gmail.com">foo@gmail.com</a>, it gets posted as "John Doe".</p>
|
72 |
|
73 |
<p>If you send an e-mail to your postie address from an e-mail address that is no
|
74 |
t linked to a wordpress user, it will get posted as admin.</p>
|
147 |
<p>The IMAP extension is not required, but it is strongly recommended, especially
|
148 |
is you are using non-English text. There is more information on php.net about
|
149 |
installing the IMAP extension. If you have control over your server, it is
|
150 |
+
often not hard to install.</p>
|
151 |
|
152 |
<p>On Ubuntu, try
|
153 |
sudo apt-get install php5-imap</p>
|
156 |
sudo yuminstall php-imap</p>
|
157 |
|
158 |
<p>The IMAP extension is known to be installed on the following popular webhosts:
|
159 |
+
* Dreamhost</p>
|
160 |
+
|
161 |
+
<h4 id='answer-13'>How can I embed youtube or vimeo videos?</h4>
|
162 |
+
|
163 |
+
<p>Simply put the url in the body of your e-mail. (Make sure that you have the
|
164 |
+
option to convert url into links turned on)</p>
|
fetchmails.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-config.php");
|
4 |
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . '../postie/mimedecode.php');
|
5 |
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . '../postie/postie-functions.php');
|
|
|
6 |
fetch_mails();
|
7 |
exit;
|
8 |
//}
|
@@ -11,55 +12,65 @@ function init() {
|
|
11 |
global $wpdb, $aandcpostie_version;
|
12 |
$table_name=$wpdb->prefix . 'postie_addresses';
|
13 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
|
|
|
14 |
$sql = "CREATE TABLE " . $table_name . " (
|
15 |
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
16 |
server text NOT NULL,
|
17 |
port smallint(4) DEFAULT '110' NOT NULL,
|
18 |
email text NOT NULL,
|
19 |
-
|
20 |
protocol text NOT NULL,
|
21 |
offset text NOT NULL,
|
|
|
22 |
UNIQUE KEY id (id)
|
23 |
);";
|
24 |
|
25 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
26 |
dbDelta($sql);
|
|
|
27 |
$addresses = array(
|
28 |
0=> array(
|
29 |
-
'server'=>'
|
30 |
-
'port' =>'995',
|
31 |
-
'email' => 'username',
|
32 |
-
'password' => 'mypassword',
|
33 |
-
'protocol' => 'pop3-ssl',
|
34 |
-
'offset' => '-5'
|
35 |
-
),
|
36 |
-
1=> array(
|
37 |
-
'server'=>'another.com',
|
38 |
'port' =>'993',
|
39 |
-
'email' => '
|
40 |
-
'
|
41 |
'protocol' => 'imap-ssl',
|
42 |
-
'offset' => '-5'
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
);
|
45 |
insert_new_addresses($table_name, $addresses);
|
46 |
}
|
47 |
function insert_new_addresses($table_name, $addresses) {
|
48 |
/* insert addresses into table */
|
49 |
global $wpdb;
|
50 |
-
$fetch_query = 'SELECT
|
51 |
-
$existingAddresses=$wpdb->
|
|
|
|
|
|
|
|
|
52 |
foreach ($addresses as $address) {
|
53 |
extract($address);
|
54 |
-
|
|
|
55 |
$query = "INSERT INTO " . $table_name .
|
56 |
-
" (server, port, email,
|
57 |
-
"VALUES ('$server', $port, '$email',
|
58 |
-
'$offset')";
|
59 |
} else {
|
|
|
60 |
$query = "UPDATE $table_name set server='$server', port='$port',
|
61 |
-
email='$email',
|
62 |
-
protocol='$protocol', offset='$offset'
|
|
|
63 |
}
|
64 |
$results = $wpdb->query($wpdb->prepare($query));
|
65 |
}
|
@@ -71,12 +82,13 @@ function fetch_mails() {
|
|
71 |
//Load up some usefull libraries
|
72 |
|
73 |
//Retreive emails
|
74 |
-
$fetch_query = 'SELECT * FROM ' . $wpdb->prefix . '
|
75 |
$mailboxes=$wpdb->get_results($fetch_query);
|
76 |
-
|
|
|
77 |
foreach ($mailboxes as $mailbox) {
|
78 |
$emails = FetchMail($mailbox->server, $mailbox->port,
|
79 |
-
$mailbox->email, $mailbox->
|
80 |
//loop through messages
|
81 |
foreach ($emails as $email) {
|
82 |
//sanity check to see if there is any info in the message
|
@@ -90,10 +102,13 @@ function fetch_mails() {
|
|
90 |
trim($mimeDecodedEmail->headers["from"]));
|
91 |
|
92 |
//Check poster to see if a valid person
|
93 |
-
$poster = ValidatePoster($mimeDecodedEmail);
|
94 |
if (!empty($poster)) {
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
}
|
98 |
else {
|
99 |
print("<p>Ignoring email - not authorized.\n");
|
3 |
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-config.php");
|
4 |
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . '../postie/mimedecode.php');
|
5 |
require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . '../postie/postie-functions.php');
|
6 |
+
init();
|
7 |
fetch_mails();
|
8 |
exit;
|
9 |
//}
|
12 |
global $wpdb, $aandcpostie_version;
|
13 |
$table_name=$wpdb->prefix . 'postie_addresses';
|
14 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
|
15 |
+
echo "creating table\n";
|
16 |
$sql = "CREATE TABLE " . $table_name . " (
|
17 |
id mediumint(9) NOT NULL AUTO_INCREMENT,
|
18 |
server text NOT NULL,
|
19 |
port smallint(4) DEFAULT '110' NOT NULL,
|
20 |
email text NOT NULL,
|
21 |
+
passwd VARCHAR(64) NOT NULL,
|
22 |
protocol text NOT NULL,
|
23 |
offset text NOT NULL,
|
24 |
+
category mediumint(9) NOT NULL,
|
25 |
UNIQUE KEY id (id)
|
26 |
);";
|
27 |
|
28 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
29 |
dbDelta($sql);
|
30 |
+
}
|
31 |
$addresses = array(
|
32 |
0=> array(
|
33 |
+
'server'=>'yourserver.com',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
'port' =>'993',
|
35 |
+
'email' => 'youruser',
|
36 |
+
'passwd' => 'yourpword',
|
37 |
'protocol' => 'imap-ssl',
|
38 |
+
'offset' => '-5',
|
39 |
+
'category' => 5
|
40 |
+
)
|
41 |
+
# 1=> array(
|
42 |
+
# 'server'=>'another.com',
|
43 |
+
# 'port' =>'993',
|
44 |
+
# 'email' => 'anotheruser',
|
45 |
+
# 'passwd' => 'anotherpasswd',
|
46 |
+
# 'protocol' => 'imap-ssl',
|
47 |
+
# 'offset' => '-5'
|
48 |
+
# )
|
49 |
);
|
50 |
insert_new_addresses($table_name, $addresses);
|
51 |
}
|
52 |
function insert_new_addresses($table_name, $addresses) {
|
53 |
/* insert addresses into table */
|
54 |
global $wpdb;
|
55 |
+
$fetch_query = 'SELECT email, server FROM ' . $table_name;
|
56 |
+
$existingAddresses=$wpdb->get_results($fetch_query);
|
57 |
+
$existingArray=array();
|
58 |
+
foreach ($existingAddresses as $existAdd) {
|
59 |
+
array_push($existingArray, $existAdd->email . '@' . $existAdd->server);
|
60 |
+
}
|
61 |
foreach ($addresses as $address) {
|
62 |
extract($address);
|
63 |
+
$emailAddress = "$email@$server";
|
64 |
+
if (!in_array($emailAddress, $existingArray)) {
|
65 |
$query = "INSERT INTO " . $table_name .
|
66 |
+
" (server, port, email, passwd, protocol, offset, category) " .
|
67 |
+
"VALUES ('$server', $port, '$email', '$passwd', '$protocol', '$offset', '$category')";
|
|
|
68 |
} else {
|
69 |
+
echo "updating\n";
|
70 |
$query = "UPDATE $table_name set server='$server', port='$port',
|
71 |
+
email='$email', passwd='$passwd',
|
72 |
+
protocol='$protocol', offset='$offset', category='$category' WHERE
|
73 |
+
email='$email' AND server='$server'";
|
74 |
}
|
75 |
$results = $wpdb->query($wpdb->prepare($query));
|
76 |
}
|
82 |
//Load up some usefull libraries
|
83 |
|
84 |
//Retreive emails
|
85 |
+
$fetch_query = 'SELECT * FROM ' . $wpdb->prefix . 'postie_addresses';
|
86 |
$mailboxes=$wpdb->get_results($fetch_query);
|
87 |
+
print_r($mailboxes);
|
88 |
+
$config=get_config();
|
89 |
foreach ($mailboxes as $mailbox) {
|
90 |
$emails = FetchMail($mailbox->server, $mailbox->port,
|
91 |
+
$mailbox->email, $mailbox->passwd, $mailbox->protocol);
|
92 |
//loop through messages
|
93 |
foreach ($emails as $email) {
|
94 |
//sanity check to see if there is any info in the message
|
102 |
trim($mimeDecodedEmail->headers["from"]));
|
103 |
|
104 |
//Check poster to see if a valid person
|
105 |
+
$poster = ValidatePoster($mimeDecodedEmail, $config);
|
106 |
if (!empty($poster)) {
|
107 |
+
if ($config['TEST_EMAIL'])
|
108 |
+
DebugEmailOutput($email,$mimeDecodedEmail);
|
109 |
+
if ($mailbox->category)
|
110 |
+
$config['DEFAULT_POST_CATEGORY'] = $mailbox->category;
|
111 |
+
PostEmail($poster,$mimeDecodedEmail, $config);
|
112 |
}
|
113 |
else {
|
114 |
print("<p>Ignoring email - not authorized.\n");
|
filterPostie.php → filterPostie.php.sample
RENAMED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Postie Filter
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Description: Adds my own custom filter to messages posted by postie
|
6 |
-
Version: 1.
|
7 |
Author: Robert Felty
|
8 |
Author URI: http://blog.robfelty.com/
|
9 |
*/
|
3 |
Plugin Name: Postie Filter
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Description: Adds my own custom filter to messages posted by postie
|
6 |
+
Version: 1.4
|
7 |
Author: Robert Felty
|
8 |
Author URI: http://blog.robfelty.com/
|
9 |
*/
|
get_mail.php
CHANGED
@@ -1,12 +1,3 @@
|
|
1 |
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
2 |
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3 |
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
4 |
-
<head>
|
5 |
-
<meta http-equiv="content-type"
|
6 |
-
content="application/xhtml+xml; charset=utf-8" />
|
7 |
-
<title>Postie - fetching mail</title>
|
8 |
-
</head>
|
9 |
-
<body>
|
10 |
<?php
|
11 |
|
12 |
//Load up some usefull libraries
|
@@ -24,57 +15,50 @@ print("<pre>\n");
|
|
24 |
print("This is the postie plugin\n");
|
25 |
print("time:" . time() . "\n");
|
26 |
include('Revision');
|
27 |
-
$config =
|
28 |
-
|
29 |
-
$emails = FetchMail($
|
30 |
-
$
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
if
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
continue;
|
46 |
-
|
47 |
-
|
48 |
-
$mimeDecodedEmail = DecodeMimeMail($email, true);
|
49 |
-
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
50 |
-
/*
|
51 |
-
if ($from != "") {
|
52 |
-
continue;
|
53 |
-
}
|
54 |
-
*/
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
} else {
|
70 |
-
$message = "\n" . __("There does not seem to be any new mail.", 'postie');
|
71 |
-
}
|
72 |
print $message;
|
73 |
print("</pre>\n");
|
74 |
|
75 |
/* END PROGRAM */
|
76 |
|
77 |
// end of script
|
78 |
-
?>
|
79 |
-
</body>
|
80 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
//Load up some usefull libraries
|
15 |
print("This is the postie plugin\n");
|
16 |
print("time:" . time() . "\n");
|
17 |
include('Revision');
|
18 |
+
$config = get_option('postie-settings');
|
19 |
+
extract($config);
|
20 |
+
$emails = FetchMail($mail_server, $mail_server_port, $mail_userid,
|
21 |
+
$mail_password, $input_protocol, $time_offset, $test_email,
|
22 |
+
$delete_mail_after_processing);
|
23 |
+
//loop through messages
|
24 |
+
foreach ($emails as $email) {
|
25 |
+
if (function_exists('memory_get_usage'))
|
26 |
+
echo "memory at start of e-mail processing:" . memory_get_usage() . "\n";
|
27 |
+
//sanity check to see if there is any info in the message
|
28 |
+
if ($email == NULL ) {
|
29 |
+
$message= __('Dang, message is empty!', 'postie');
|
30 |
+
continue;
|
31 |
+
} else if ($email=='already read') {
|
32 |
+
$message = "\n" . __("There does not seem to be any new mail.", 'postie') .
|
33 |
+
"\n";
|
34 |
+
continue;
|
35 |
+
}
|
36 |
+
$message='';
|
37 |
+
$mimeDecodedEmail = DecodeMIMEMail($email, true);
|
38 |
+
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
39 |
+
/*
|
40 |
+
if ($from != "") {
|
41 |
continue;
|
42 |
+
}
|
43 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
//Check poster to see if a valid person
|
46 |
+
$poster = ValidatePoster($mimeDecodedEmail, $config);
|
47 |
+
if (!empty($poster)) {
|
48 |
+
if ($test_email)
|
49 |
+
DebugEmailOutput($email,$mimeDecodedEmail);
|
50 |
+
PostEmail($poster,$mimeDecodedEmail, $config);
|
51 |
+
}
|
52 |
+
else {
|
53 |
+
print("<p>Ignoring email - not authorized.\n");
|
54 |
+
}
|
55 |
+
if (function_exists('memory_get_usage'))
|
56 |
+
echo "memory at end of e-mail processing:" . memory_get_usage() . "\n";
|
57 |
+
} // end looping over messages
|
|
|
|
|
|
|
58 |
print $message;
|
59 |
print("</pre>\n");
|
60 |
|
61 |
/* END PROGRAM */
|
62 |
|
63 |
// end of script
|
64 |
+
?>
|
|
|
|
postie-functions.php
CHANGED
@@ -1,33 +1,27 @@
|
|
1 |
<?php
|
2 |
$revisions= WP_POST_REVISIONS;
|
3 |
define('WP_POST_REVISIONS', false);
|
|
|
4 |
$original_mem_limit = ini_get('memory_limit');
|
5 |
-
ini_set('memory_limit', -1);
|
6 |
|
7 |
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
|
8 |
/*
|
9 |
-
$Id: postie-functions.php
|
10 |
*/
|
11 |
|
12 |
/*TODO
|
13 |
* html purify
|
14 |
* USE built-in php message decoding to improve speed
|
15 |
* Add custom fields
|
16 |
-
* fix delay
|
17 |
* support for flexible upload plugin
|
18 |
-
* confirm post
|
19 |
-
* return reject to sender
|
20 |
-
* icons
|
21 |
* iso 8859-2 support
|
22 |
* add private post function
|
23 |
http://forum.robfelty.com/topic/how-to-private-posts-from-postie?replies=2#post-1515
|
|
|
24 |
*/
|
25 |
-
#global $config,$debug;
|
26 |
-
#$debug=true;
|
27 |
-
#$config=GetConfig();
|
28 |
|
29 |
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . "wp-config.php");
|
30 |
-
define("POSTIE_TABLE",$GLOBALS["table_prefix"]. "postie_config");
|
31 |
|
32 |
/* this function is necessary for wildcard matching on non-posix systems */
|
33 |
if (!function_exists('fnmatch')) {
|
@@ -45,7 +39,8 @@ if (!function_exists('fnmatch')) {
|
|
45 |
* This is the main handler for all of the processing
|
46 |
*/
|
47 |
function PostEmail($poster,$mimeDecodedEmail,$config) {
|
48 |
-
$
|
|
|
49 |
|
50 |
$attachments = array(
|
51 |
"html" => array(), //holds the html for each image
|
@@ -54,31 +49,34 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
54 |
);
|
55 |
print("<p>Message Id is :" .
|
56 |
htmlentities($mimeDecodedEmail->headers["message-id"]) . "</p><br/>\n");
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
62 |
$tmpPost=array('post_title'=> 'tmptitle',
|
63 |
'post_content'=>'tmpPost');
|
64 |
/* in order to do attachments correctly, we need to associate the
|
65 |
attachments with a post. So we add the post here, then update it
|
66 |
*/
|
67 |
$post_id = wp_insert_post($tmpPost);
|
68 |
-
if (
|
69 |
echo "the id is $post_id\n";
|
70 |
}
|
71 |
-
$content = GetContent($mimeDecodedEmail,$attachments,$post_id, $config);
|
72 |
-
if (
|
73 |
echo "the content is $content\n";
|
74 |
}
|
75 |
$subject = GetSubject($mimeDecodedEmail,$content, $config);
|
76 |
-
if (
|
77 |
echo "the subject is $subject, right after calling GetSubject\n";
|
78 |
}
|
79 |
$customImages = SpecialMessageParsing($content,$attachments, $config);
|
80 |
-
$post_excerpt = GetPostExcerpt($content, $
|
81 |
-
$
|
82 |
$postAuthorDetails=getPostAuthorDetails($subject,$content,
|
83 |
$mimeDecodedEmail);
|
84 |
$message_date = NULL;
|
@@ -87,30 +85,29 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
87 |
$message_date=HandleMessageEncoding(
|
88 |
$mimeDecodedEmail->headers["content-transfer-encoding"],
|
89 |
$mimeDecodedEmail->ctype_parameters["charset"],
|
90 |
-
$mimeDecodedEmail->headers["date"], $
|
91 |
//$message_date = $mimeDecodedEmail->headers['date'];
|
92 |
}
|
93 |
list($post_date,$post_date_gmt, $delay) = DeterminePostDate($content,
|
94 |
-
$message_date,$
|
95 |
-
|
96 |
ubb2HTML($content);
|
97 |
|
98 |
-
if ($
|
99 |
-
$content=clickableLink($content, $
|
100 |
|
101 |
//$content = FixEmailQuotes($content);
|
102 |
|
103 |
$id=checkReply($subject);
|
104 |
$post_categories = GetPostCategories($subject,
|
105 |
-
$
|
106 |
-
$post_tags = postie_get_tags($content, $
|
107 |
$comment_status = AllowCommentsOnPost($content);
|
108 |
|
109 |
if ((empty($id) || is_null($id))) {
|
110 |
$id=$post_id;
|
111 |
$isReply=false;
|
112 |
-
if ($
|
113 |
-
if ($
|
114 |
$content = $postAuthorDetails['content'] . "<pre>\n" . $content . "</pre>\n";
|
115 |
$content = "<pre>\n" . $content . "</pre>\n";
|
116 |
} else {
|
@@ -118,7 +115,7 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
118 |
$content = $content;
|
119 |
}
|
120 |
} else {
|
121 |
-
if ($
|
122 |
$content = "<pre>\n" . $content . "</pre>\n";
|
123 |
}
|
124 |
}
|
@@ -142,15 +139,16 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
142 |
$content=$newContents;
|
143 |
wp_delete_post($post_id);
|
144 |
}
|
145 |
-
if ($
|
146 |
-
$content = FilterNewLines($content, $
|
147 |
|
148 |
|
149 |
-
if ($delay!=0 && $
|
150 |
$post_status='future';
|
151 |
} else {
|
152 |
-
$post_status=$
|
153 |
}
|
|
|
154 |
$details = array(
|
155 |
'post_author' => $poster,
|
156 |
'comment_author' => $postAuthorDetails['author'],
|
@@ -159,7 +157,8 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
159 |
'email_author' => $postAuthorDetails['email'],
|
160 |
'post_date' => $post_date,
|
161 |
// 'post_date_gmt' => $post_date_gmt,
|
162 |
-
|
|
|
163 |
'post_title' => $subject,
|
164 |
// 'post_modified' => $post_date,
|
165 |
// 'post_modified_gmt' => $post_date_gmt,
|
@@ -174,32 +173,75 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
|
|
174 |
'post_status' => $post_status
|
175 |
);
|
176 |
$details = apply_filters('postie_post', $details);
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
/** FUNCTIONS **/
|
185 |
|
186 |
|
187 |
function clickableLink($text, $shortcode=false) {
|
188 |
# this functions deserves credit to the fine folks at phpbb.com
|
|
|
189 |
|
190 |
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:",
|
191 |
$text);
|
192 |
|
193 |
// pad it with a space so we can match things at the start of the 1st line.
|
194 |
$ret = ' ' . $text;
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
-
$ret = preg_replace($youtube,$youtube_replace, $ret);
|
203 |
|
204 |
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
|
205 |
// xxxx can only be alpha characters.
|
@@ -385,8 +427,7 @@ function FetchMail($server=NULL, $port=NULL, $email=NULL, $password=NULL,
|
|
385 |
}
|
386 |
}
|
387 |
if (!$emails)
|
388 |
-
|
389 |
-
$emails=false;
|
390 |
return($emails);
|
391 |
}
|
392 |
/**
|
@@ -394,12 +435,13 @@ function FetchMail($server=NULL, $port=NULL, $email=NULL, $password=NULL,
|
|
394 |
*/
|
395 |
function TestIMAPMessageFetch ( ) {
|
396 |
print("**************RUNING IN TESTING MODE************\n");
|
397 |
-
$config =
|
398 |
-
|
399 |
-
$
|
400 |
-
|
401 |
-
|
402 |
-
$
|
|
|
403 |
|
404 |
}
|
405 |
/**
|
@@ -439,12 +481,13 @@ function IMAPMessageFetch ($server=NULL, $port=NULL, $email=NULL,
|
|
439 |
}
|
440 |
function TestPOP3MessageFetch ( ) {
|
441 |
print("**************RUNING IN TESTING MODE************\n");
|
442 |
-
$config =
|
443 |
-
|
444 |
-
$
|
445 |
-
|
446 |
-
|
447 |
-
$
|
|
|
448 |
}
|
449 |
/**
|
450 |
*Retrieves email via POP3
|
@@ -504,7 +547,6 @@ function POP3MessageFetch ($server=NULL, $port=NULL, $email=NULL,
|
|
504 |
*/
|
505 |
function PostToDB($details,$isReply, $postToDb=true, $customImageField=false) {
|
506 |
if ($postToDb) {
|
507 |
-
//generate sql for insertion
|
508 |
//$_POST['publish'] = true; //Added to make subscribe2 work - it will only handle it if the global varilable _POST is set
|
509 |
if (!$isReply) {
|
510 |
$post_ID = wp_insert_post($details);
|
@@ -547,9 +589,10 @@ function PostToDB($details,$isReply, $postToDb=true, $customImageField=false) {
|
|
547 |
* @return boolean
|
548 |
*/
|
549 |
function BannedFileName($filename, $bannedFiles) {
|
|
|
550 |
foreach ($bannedFiles as $bannedFile) {
|
551 |
if (fnmatch($bannedFile, $filename)) {
|
552 |
-
print("<p>
|
553 |
return(true);
|
554 |
}
|
555 |
}
|
@@ -557,7 +600,8 @@ function BannedFileName($filename, $bannedFiles) {
|
|
557 |
}
|
558 |
|
559 |
//tear apart the meta part for useful information
|
560 |
-
function GetContent ($part,&$attachments, $post_id, $config) {
|
|
|
561 |
global $charset, $encoding;
|
562 |
/*
|
563 |
if (!function_exists(imap_mime_header_decode))
|
@@ -567,7 +611,7 @@ function GetContent ($part,&$attachments, $post_id, $config) {
|
|
567 |
echo "primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary . "\n";
|
568 |
DecodeBase64Part($part);
|
569 |
if (BannedFileName($part->ctype_parameters['name'],
|
570 |
-
$
|
571 |
return(NULL);
|
572 |
if ($part->ctype_primary == "application"
|
573 |
&& $part->ctype_secondary == "octet-stream") {
|
@@ -582,26 +626,26 @@ function GetContent ($part,&$attachments, $post_id, $config) {
|
|
582 |
}
|
583 |
} else {
|
584 |
$mimeDecodedEmail = DecodeMIMEMail($part->body);
|
585 |
-
FilterTextParts($mimeDecodedEmail, $
|
586 |
foreach($mimeDecodedEmail->parts as $section) {
|
587 |
-
$meta_return .= GetContent($section,$attachments,$post_id, $config);
|
588 |
}
|
589 |
}
|
590 |
}
|
591 |
if ($part->ctype_primary == "multipart"
|
592 |
&& $part->ctype_secondary == "appledouble") {
|
593 |
$mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=".$part->ctype_parameters["boundary"]."\n".$part->body);
|
594 |
-
FilterTextParts($mimeDecodedEmail, $
|
595 |
FilterAppleFile($mimeDecodedEmail);
|
596 |
foreach($mimeDecodedEmail->parts as $section) {
|
597 |
-
$meta_return .= GetContent($section,$attachments,$post_id, $config);
|
598 |
}
|
599 |
} else {
|
600 |
switch ( strtolower($part->ctype_primary) ) {
|
601 |
case 'multipart':
|
602 |
-
FilterTextParts($part, $
|
603 |
foreach ($part->parts as $section) {
|
604 |
-
$meta_return .= GetContent($section,$attachments,$post_id, $config);
|
605 |
}
|
606 |
break;
|
607 |
case 'text':
|
@@ -614,7 +658,7 @@ function GetContent ($part,&$attachments, $post_id, $config) {
|
|
614 |
|
615 |
$part->body=HandleMessageEncoding($part->headers["content-transfer-encoding"],
|
616 |
$part->ctype_parameters["charset"],
|
617 |
-
$part->body, $
|
618 |
|
619 |
//go through each sub-section
|
620 |
if ($part->ctype_secondary=='enriched') {
|
@@ -637,67 +681,67 @@ function GetContent ($part,&$attachments, $post_id, $config) {
|
|
637 |
|
638 |
case 'image':
|
639 |
echo "looking at an image\n";
|
640 |
-
$file_id = postie_media_handle_upload($part, $post_id);
|
641 |
$file = wp_get_attachment_url($file_id);
|
642 |
|
643 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
644 |
$the_post=get_post($file_id);
|
645 |
/* TODO make these options */
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
|
|
|
|
|
|
650 |
}
|
651 |
break;
|
652 |
case 'audio':
|
653 |
-
$file_id = postie_media_handle_upload($part, $post_id);
|
654 |
$file = wp_get_attachment_url($file_id);
|
655 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
656 |
-
if (in_array($part->ctype_secondary,
|
657 |
-
|
658 |
-
$audioTemplate=$config['AUDIOTEMPLATE'];
|
659 |
} else {
|
660 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
661 |
-
$part->ctype_secondary, $
|
662 |
-
$
|
663 |
$audioTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
664 |
}
|
665 |
$attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
|
666 |
$audioTemplate);
|
667 |
break;
|
668 |
case 'video':
|
669 |
-
$file_id = postie_media_handle_upload($part, $post_id);
|
670 |
$file = wp_get_attachment_url($file_id);
|
671 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
672 |
-
if (in_array($part->ctype_secondary,
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
$config['VIDEO2TYPES'])) {
|
677 |
-
$videoTemplate=$config['VIDEO2TEMPLATE'];
|
678 |
} else {
|
679 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
680 |
-
$part->ctype_secondary, $
|
681 |
-
$
|
682 |
$videoTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
683 |
}
|
684 |
$attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
|
685 |
$videoTemplate);
|
|
|
686 |
break;
|
687 |
|
688 |
default:
|
689 |
-
if (in_array(strtolower($part->ctype_primary),
|
690 |
-
$config["SUPPORTED_FILE_TYPES"])) {
|
691 |
//pgp signature - then forget it
|
692 |
if ( $part->ctype_secondary == 'pgp-signature' )
|
693 |
break;
|
694 |
-
$file_id = postie_media_handle_upload($part, $post_id);
|
695 |
$file = wp_get_attachment_url($file_id);
|
696 |
echo "file=$file\n";
|
697 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
698 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
699 |
-
$part->ctype_secondary, $
|
700 |
-
$
|
701 |
$attachments["html"][] = '<a href="' . $file .
|
702 |
'" style="text-decoration:none">' . $icon .
|
703 |
$part->ctype_parameters['name'] . '</a>' . "\n";
|
@@ -830,6 +874,7 @@ $replace = array (
|
|
830 |
* @return integer|NULL
|
831 |
*/
|
832 |
function ValidatePoster( &$mimeDecodedEmail, $config ) {
|
|
|
833 |
global $wpdb;
|
834 |
$poster = NULL;
|
835 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
@@ -846,28 +891,27 @@ if ( empty($from) ) {
|
|
846 |
$sql = 'SELECT id FROM '. $wpdb->users.' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;";
|
847 |
$user_ID= $wpdb->get_var($sql);
|
848 |
$user = new WP_User($user_ID);
|
849 |
-
if ($
|
850 |
-
|
851 |
-
|
852 |
-
|
|
|
853 |
print("$from is authorized to post as the administrator\n");
|
854 |
$from = get_option("admin_email");
|
855 |
-
$adminUser=$
|
856 |
echo "adminUser='$adminUser'";
|
857 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE
|
858 |
user_login = '$adminUser'");
|
859 |
-
} else {
|
860 |
-
$poster = $user_ID;
|
861 |
-
}
|
862 |
} else if ($user->has_cap("post_via_postie")) {
|
863 |
$poster = $user_ID;
|
864 |
}
|
865 |
-
$validSMTP=checkSMTP($mimeDecodedEmail, $
|
866 |
if (!$poster || !$validSMTP) {
|
867 |
echo 'Invalid sender: ' . htmlentities($from) . "! Not adding email!\n";
|
868 |
-
if ($
|
869 |
-
|
870 |
-
|
|
|
871 |
echo "A copy of the message has been forwarded to the administrator.\n";
|
872 |
} else {
|
873 |
echo "The message was unable to be forwarded to the adminstrator.\n";
|
@@ -879,15 +923,13 @@ if ( empty($from) ) {
|
|
879 |
}
|
880 |
|
881 |
function checkSMTP($mimeDecodedEmail, $smtpservers) {
|
882 |
-
if (empty($smtpservers))
|
883 |
-
|
884 |
-
foreach ($mimeDecodedEmail->headers['received'] as $received) {
|
885 |
foreach ($smtpservers as $smtp) {
|
886 |
-
if (stristr($received, $smtp))
|
887 |
-
return(true);
|
888 |
}
|
889 |
-
|
890 |
-
return
|
891 |
}
|
892 |
|
893 |
/**
|
@@ -910,25 +952,23 @@ function StartFilter(&$content,$start) {
|
|
910 |
* @param string
|
911 |
* @param array - a list of patterns to determine if it is a sig block
|
912 |
*/
|
913 |
-
function
|
914 |
if (empty($filterList))
|
915 |
-
return;
|
916 |
-
$arrcontent = explode("\n", $content);
|
917 |
-
$
|
918 |
-
$pattern='/^(';
|
919 |
-
$
|
920 |
-
$
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
$strcontent
|
930 |
-
}
|
931 |
-
$content = $strcontent;
|
932 |
}
|
933 |
/**
|
934 |
* Looks at the content for the given tag and removes all text
|
@@ -936,19 +976,11 @@ for ($i = 0; $i<=count($arrcontent); $i++) {
|
|
936 |
* @param string
|
937 |
* @param filter
|
938 |
*/
|
939 |
-
function EndFilter( &$content
|
940 |
-
$
|
941 |
-
$
|
942 |
-
|
943 |
-
|
944 |
-
$nextline = $arrcontent[$i+1];
|
945 |
-
if (preg_match("/^$filter/",trim($line))) {
|
946 |
-
//print("<p>Found in $line");
|
947 |
-
break;
|
948 |
-
}
|
949 |
-
$strcontent .= $line ."\n";
|
950 |
-
}
|
951 |
-
$content = $strcontent;
|
952 |
}
|
953 |
|
954 |
//filter content for new lines
|
@@ -976,12 +1008,12 @@ function FilterNewLines ( $content, $convertNewLines=false ) {
|
|
976 |
//$newContent=preg_replace('/<p>LINEBREAK$/', '', $newContent);
|
977 |
if ($convertNewLines) {
|
978 |
$newContent= preg_replace('/LINEBREAK/',"<br />\n",$newContent);
|
979 |
-
if (
|
980 |
echo "converting newlines\n";
|
981 |
}
|
982 |
} else {
|
983 |
$newContent= preg_replace('/LINEBREAK/'," ",$newContent);
|
984 |
-
if (
|
985 |
echo "not converting newlines\n";
|
986 |
}
|
987 |
}
|
@@ -1155,7 +1187,7 @@ function AllowCommentsOnPost(&$content) {
|
|
1155 |
*/
|
1156 |
function DeterminePostDate(&$content, $message_date = NULL, $offset=0) {
|
1157 |
$delay = 0;
|
1158 |
-
if (
|
1159 |
echo "inside Determine Post Date, message_date = $message_date\n";
|
1160 |
}
|
1161 |
if (eregi("delay:(-?[0-9dhm]+)",$content,$matches)
|
@@ -1225,7 +1257,7 @@ function FilterAppleFile(&$mimeDecodedEmail) {
|
|
1225 |
$mimeDecodedEmail->parts = $newParts; //This is now the filtered list of just the preferred type.
|
1226 |
}
|
1227 |
}
|
1228 |
-
function postie_media_handle_upload($part, $post_id, $post_data = array()) {
|
1229 |
$overrides = array('test_form'=>false);
|
1230 |
//$overrides = array('test_form'=>false, 'test_size'=>false,
|
1231 |
// 'test_type'=>false);
|
@@ -1242,9 +1274,9 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
|
|
1242 |
echo "could not write to temp file: '$tmpFile' ";
|
1243 |
}
|
1244 |
echo "wrote to temp file\n";
|
1245 |
-
//print_r($part
|
1246 |
if ($part->ctype_parameters['name']=='') {
|
1247 |
-
if ($part->
|
1248 |
$name = $part->d_parameters['filename'];
|
1249 |
} else {
|
1250 |
$name = 'postie-media.'. $part->ctype_secondary;
|
@@ -1305,6 +1337,7 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
|
|
1305 |
'post_title' => $title,
|
1306 |
'post_excerpt' => $content,
|
1307 |
'post_content' => $content,
|
|
|
1308 |
), $post_data );
|
1309 |
|
1310 |
// Save the data
|
@@ -1463,12 +1496,14 @@ function MailToRecipients( &$mail_content,$testEmail=false,
|
|
1463 |
if ($testEmail) {
|
1464 |
return;
|
1465 |
}
|
|
|
1466 |
$user = get_userdata('1');
|
1467 |
$myname = $user->user_nicename;
|
1468 |
$myemailadd = get_option("admin_email");
|
1469 |
$blogname = get_option("blogname");
|
1470 |
$blogurl = get_option("siteurl");
|
1471 |
-
array_push($recipients, $myemailadd);
|
|
|
1472 |
if (count($recipients) == 0) {
|
1473 |
return false;
|
1474 |
}
|
@@ -1480,6 +1515,12 @@ function MailToRecipients( &$mail_content,$testEmail=false,
|
|
1480 |
}
|
1481 |
|
1482 |
$headers = "From: Wordpress <" .$myemailadd .">\r\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
1483 |
// Set email subject
|
1484 |
if ($reject) {
|
1485 |
$alert_subject = $blogname . ": Unauthorized Post Attempt from $from";
|
@@ -1500,12 +1541,6 @@ function MailToRecipients( &$mail_content,$testEmail=false,
|
|
1500 |
|
1501 |
$headers.="Content-Type:multipart/alternative; boundary=\"$boundary\"\r\n";
|
1502 |
// SDM 20041123
|
1503 |
-
foreach ($recipients as $recipient) {
|
1504 |
-
$recipient = trim($recipient);
|
1505 |
-
if (! empty($recipient)) {
|
1506 |
-
$headers .= "Cc: " . $recipient . "\r\n";
|
1507 |
-
}
|
1508 |
-
}
|
1509 |
// construct mail message
|
1510 |
$message = "An unauthorized message has been sent to $blogname.\n";
|
1511 |
$message .= "Sender: $from\n";
|
@@ -1560,7 +1595,9 @@ function DecodeMIMEMail($email, $decodeHeaders=false) {
|
|
1560 |
$params['decode_headers'] = $decodeHeaders;
|
1561 |
$params['input'] = $email;
|
1562 |
//$decoded = imap_mime_header_decode($email);
|
1563 |
-
|
|
|
|
|
1564 |
}
|
1565 |
|
1566 |
/**
|
@@ -1578,11 +1615,7 @@ function DisplayMIMEPartTypes($mimeDecodedEmail) {
|
|
1578 |
* @return boolean
|
1579 |
*/
|
1580 |
function CheckEmailAddress($address, $authorized) {
|
1581 |
-
|
1582 |
-
if (!is_array($authorized) || !count($authorized)) {
|
1583 |
-
return false;
|
1584 |
-
}
|
1585 |
-
return(in_array($address,$authorized));
|
1586 |
}
|
1587 |
/**
|
1588 |
*This method works around a problemw with email address with extra <> in the email address
|
@@ -1623,7 +1656,7 @@ function GetNameFromEmail($address) {
|
|
1623 |
*/
|
1624 |
function chooseAttachmentIcon($file, $primary, $secondary, $iconSet='silver',
|
1625 |
$size='32') {
|
1626 |
-
if ($
|
1627 |
return('');
|
1628 |
$fileName=basename($file);
|
1629 |
$parts=explode('.', $fileName);
|
@@ -1772,11 +1805,20 @@ function ReplaceImageCIDs(&$content,&$attachments) {
|
|
1772 |
* @param array - array of HTML for images for post
|
1773 |
*/
|
1774 |
function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
|
1775 |
-
|
1776 |
-
($
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1777 |
foreach ( $attachments as $i => $value ) {
|
1778 |
// looks for ' #img1# ' etc... and replaces with image
|
1779 |
-
$img_placeholder_temp = str_replace("%", intval($startIndex + $i), $
|
1780 |
$eimg_placeholder_temp = str_replace("%", intval($startIndex + $i),
|
1781 |
"#eimg%#");
|
1782 |
$img_placeholder_temp=rtrim($img_placeholder_temp,'#');
|
@@ -1785,11 +1827,12 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
|
|
1785 |
stristr($content, $eimg_placeholder_temp) ) {
|
1786 |
// look for caption
|
1787 |
$caption='';
|
1788 |
-
|
|
|
|
|
1789 |
$caption =$matches[1];
|
1790 |
-
$img_placeholder_temp
|
1791 |
-
$eimg_placeholder_temp
|
1792 |
-
// echo "caption=$caption\n";
|
1793 |
}
|
1794 |
$value = str_replace('{CAPTION}', $caption, $value);
|
1795 |
$img_placeholder_temp.='#';
|
@@ -1801,8 +1844,8 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
|
|
1801 |
} else {
|
1802 |
$value = str_replace('{CAPTION}', '', $value);
|
1803 |
/* if using the gallery shortcode, don't add pictures at all */
|
1804 |
-
if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches))
|
1805 |
-
if ($
|
1806 |
$content .= $value;
|
1807 |
} else {
|
1808 |
$content = $value . $content;
|
@@ -1816,15 +1859,16 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
|
|
1816 |
* @return array - (subject,content)
|
1817 |
*/
|
1818 |
function GetSubject(&$mimeDecodedEmail,&$content, $config) {
|
|
|
1819 |
global $charset;
|
1820 |
//assign the default title/subject
|
1821 |
if ( $mimeDecodedEmail->headers['subject'] == NULL ) {
|
1822 |
-
if ($
|
1823 |
list($subject,$content) =
|
1824 |
-
ParseInMessageSubject($content,$
|
1825 |
}
|
1826 |
else {
|
1827 |
-
$subject = $
|
1828 |
}
|
1829 |
$mimeDecodedEmail->headers['subject'] = $subject;
|
1830 |
} else {
|
@@ -1851,8 +1895,8 @@ function GetSubject(&$mimeDecodedEmail,&$content, $config) {
|
|
1851 |
//echo "Charset: {$thischarset}\n";
|
1852 |
//echo "Text: ". utf8_encode($elements[$i]->text). "\n\n";
|
1853 |
$subject.=HandleMessageEncoding($encoding, $thischarset,
|
1854 |
-
$elements[$i]->text, $
|
1855 |
-
$
|
1856 |
//echo "subject=$subject\n";
|
1857 |
}
|
1858 |
//echo "now subject= $subject\n";
|
@@ -1861,7 +1905,7 @@ function GetSubject(&$mimeDecodedEmail,&$content, $config) {
|
|
1861 |
//echo "charset='$charset'\n";
|
1862 |
// }
|
1863 |
}
|
1864 |
-
if (!$
|
1865 |
$subject = htmlentities($subject);
|
1866 |
}
|
1867 |
}
|
@@ -1878,15 +1922,14 @@ function GetSubject(&$mimeDecodedEmail,&$content, $config) {
|
|
1878 |
*
|
1879 |
*/
|
1880 |
function postie_get_tags(&$content, $defaultTags) {
|
1881 |
-
global $wpdb;
|
1882 |
$post_tags = array();
|
1883 |
//try and determine tags
|
1884 |
if ( preg_match('/tags: ?(.*)\n/i', $content, $matches)) {
|
1885 |
$content = str_replace($matches[0], "", $content);
|
1886 |
$post_tags = preg_split("/,\s*/", $matches[1]);
|
1887 |
}
|
1888 |
-
if (!count($post_tags) && $defaultTags
|
1889 |
-
$post_tags =
|
1890 |
}
|
1891 |
return($post_tags);
|
1892 |
}
|
@@ -1963,7 +2006,7 @@ function GetPostCategories(&$subject, $defaultCategory) {
|
|
1963 |
*This function just outputs a simple html report about what is being posted in
|
1964 |
*/
|
1965 |
function DisplayEmailPost($details) {
|
1966 |
-
if (
|
1967 |
print_r($config);
|
1968 |
print_r($details);
|
1969 |
}
|
@@ -2022,6 +2065,7 @@ function BuildTextArea($label,$id,$current_value,$recommendation = NULL) {
|
|
2022 |
$string.="</th>";
|
2023 |
|
2024 |
$string .="<td><textarea cols=40 rows=3 name=\"$id\" id=\"$id\">";
|
|
|
2025 |
if (is_array($current_value)) {
|
2026 |
foreach($current_value as $item) {
|
2027 |
$string .= "$item\n";
|
@@ -2031,145 +2075,124 @@ function BuildTextArea($label,$id,$current_value,$recommendation = NULL) {
|
|
2031 |
</tr>";
|
2032 |
return($string);
|
2033 |
}
|
2034 |
-
/**
|
2035 |
-
*Handles the creation of the table needed to store all the data
|
2036 |
-
*/
|
2037 |
-
function SetupConfiguration() {
|
2038 |
-
if (! function_exists('maybe_create_table')) {
|
2039 |
-
function maybe_create_table($table_name, $create_ddl) {
|
2040 |
-
global $wpdb;
|
2041 |
-
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
|
2042 |
-
if ($table == $table_name) {
|
2043 |
-
return true;
|
2044 |
-
}
|
2045 |
-
}
|
2046 |
-
//didn't find it try to create it.
|
2047 |
-
$wpdb->query($create_ddl);
|
2048 |
-
// we cannot directly tell that whether this succeeded!
|
2049 |
-
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
|
2050 |
-
if ($table == $table_name) {
|
2051 |
-
return true;
|
2052 |
-
}
|
2053 |
-
}
|
2054 |
-
return false;
|
2055 |
-
}
|
2056 |
-
}
|
2057 |
-
$create_table_sql = "CREATE TABLE ".POSTIE_TABLE ." (
|
2058 |
-
label text NOT NULL,
|
2059 |
-
value text not NULL
|
2060 |
-
);";
|
2061 |
-
|
2062 |
-
maybe_create_table(POSTIE_TABLE,$create_table_sql);
|
2063 |
-
}
|
2064 |
/**
|
2065 |
*This function resets all the configuration options to the default
|
2066 |
*/
|
2067 |
function ResetPostieConfig() {
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
$
|
2074 |
-
|
2075 |
-
|
2076 |
-
}
|
2077 |
-
UpdatePostieConfig($config);
|
2078 |
}
|
2079 |
|
2080 |
-
function UpdateArrayConfig() {
|
2081 |
-
global $wpdb;
|
2082 |
-
$key_arrays = GetListOfArrayConfig();
|
2083 |
-
$data = $wpdb->get_results("SELECT label,value FROM ". POSTIE_TABLE .";");
|
2084 |
-
if (is_array($data)) {
|
2085 |
-
foreach($data as $row) {
|
2086 |
-
if (in_array($row->label,$key_arrays)) {
|
2087 |
-
if (unserialize($row->value)) {
|
2088 |
-
if ($row->value=='a:1:{i:0;s:6:"a:0:{}";}') {
|
2089 |
-
$config[$row->label] = array();
|
2090 |
-
} else {
|
2091 |
-
$config[$row->label] = unserialize($row->value);
|
2092 |
-
}
|
2093 |
-
} else {
|
2094 |
-
if (!is_array($config[$row->label]))
|
2095 |
-
$config[$row->label] = array();
|
2096 |
-
if ($row->value!='a:0:{}')
|
2097 |
-
$config[$row->label][] = $row->value;
|
2098 |
-
}
|
2099 |
-
} else {
|
2100 |
-
$config[$row->label] = $row->value;
|
2101 |
-
}
|
2102 |
-
}
|
2103 |
-
}
|
2104 |
-
WriteConfig($config);
|
2105 |
-
echo "updating database";
|
2106 |
-
}
|
2107 |
/**
|
2108 |
-
* This function
|
2109 |
*@return boolean
|
2110 |
*/
|
2111 |
function UpdatePostieConfig($data) {
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
foreach($config as $key => $value) {
|
2116 |
-
if (isset($data[$key])) {
|
2117 |
-
if (in_array($key,$key_arrays)) { //This is stored as an array
|
2118 |
-
$data[$key]=trim($data[$key]);
|
2119 |
-
if (strstr($data[$key], "\n")) {
|
2120 |
-
$delim = "\n";
|
2121 |
-
} else {
|
2122 |
-
$delim = ',';
|
2123 |
-
}
|
2124 |
-
$config[$key] = array();
|
2125 |
-
$values = explode($delim,$data[$key]);
|
2126 |
-
foreach($values as $item) {
|
2127 |
-
if (trim($item)) {
|
2128 |
-
$config[$key][] = trim($item);
|
2129 |
-
}
|
2130 |
-
}
|
2131 |
-
} else {
|
2132 |
-
$config[$key] = FilterNewLines($data[$key]);
|
2133 |
-
}
|
2134 |
-
}
|
2135 |
-
}
|
2136 |
-
WriteConfig($config);
|
2137 |
-
UpdatePostiePermissions($data["ROLE_ACCESS"]);
|
2138 |
-
// If we are using cronless, we also update the cronless events
|
2139 |
-
if ($config['CRONLESS']!='') {
|
2140 |
postie_decron();
|
2141 |
-
|
|
|
|
|
2142 |
}
|
2143 |
return(1);
|
2144 |
}
|
2145 |
/**
|
2146 |
-
|
2147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2148 |
*/
|
2149 |
-
function
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
$q = $wpdb->query($wpdb->prepare("DELETE FROM ". POSTIE_TABLE . "
|
2154 |
-
WHERE label = '$label';"));
|
2155 |
-
if (is_array($value)) {
|
2156 |
-
$value=serialize($value);
|
2157 |
-
}
|
2158 |
-
$theQuery=$wpdb->prepare("INSERT INTO ". POSTIE_TABLE . "
|
2159 |
-
(label,value) VALUES
|
2160 |
-
('$label','". $value ."');");
|
2161 |
-
$q = $wpdb->query($theQuery);
|
2162 |
-
}
|
2163 |
}
|
2164 |
/**
|
2165 |
-
*This
|
2166 |
* @return array
|
2167 |
*/
|
2168 |
function ReadDBConfig() {
|
2169 |
-
SetupConfiguration();
|
2170 |
$config = array();
|
2171 |
global $wpdb;
|
2172 |
-
$data = $wpdb->get_results("SELECT label,value FROM ".
|
2173 |
if (is_array($data)) {
|
2174 |
foreach($data as $row) {
|
2175 |
if (in_array($row->label,GetListOfArrayConfig())) {
|
@@ -2182,8 +2205,7 @@ function ReadDBConfig() {
|
|
2182 |
return($config);
|
2183 |
}
|
2184 |
/**
|
2185 |
-
* This
|
2186 |
-
* You should never call this outside of the library
|
2187 |
* @return array
|
2188 |
* @access private
|
2189 |
*/
|
@@ -2214,7 +2236,7 @@ function GetDBConfig() {
|
|
2214 |
if (!isset($config["RETURN_TO_SENDER"]))
|
2215 |
$config["RETURN_TO_SENDER"] = false;
|
2216 |
if (!isset($config["CONFIRMATION_EMAIL"]))
|
2217 |
-
$config["CONFIRMATION_EMAIL"] =
|
2218 |
if (!isset($config["ALLOW_HTML_IN_SUBJECT"]))
|
2219 |
$config["ALLOW_HTML_IN_SUBJECT"] = true;
|
2220 |
if (!isset($config["ALLOW_HTML_IN_BODY"]))
|
@@ -2281,9 +2303,9 @@ function GetDBConfig() {
|
|
2281 |
$config["VIDEO1TEMPLATE"] = $simple_link;
|
2282 |
if (!isset($config["VIDEO1TYPES"]))
|
2283 |
$config['VIDEO1TYPES'] = array('mp4', 'mpeg4', '3gp', '3gpp', '3gpp2',
|
2284 |
-
'3gp2', 'mov');
|
2285 |
if (!isset($config["AUDIOTYPES"]))
|
2286 |
-
$config['AUDIOTYPES'] = array('m4a', 'mp3', 'ogg', 'wav');
|
2287 |
if (!isset($config["SELECTED_VIDEO2TEMPLATE"]))
|
2288 |
$config['SELECTED_VIDEO2TEMPLATE'] = 'simple_link';
|
2289 |
include('templates/video2_templates.php');
|
@@ -2309,7 +2331,7 @@ function GetDBConfig() {
|
|
2309 |
return($config);
|
2310 |
}
|
2311 |
/**
|
2312 |
-
* This function
|
2313 |
* @return array
|
2314 |
*/
|
2315 |
function GetConfig() {
|
@@ -2332,14 +2354,33 @@ function GetConfig() {
|
|
2332 |
}
|
2333 |
return $config;
|
2334 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2335 |
/**
|
2336 |
* Returns a list of config keys that should be arrays
|
2337 |
*@return array
|
2338 |
*/
|
2339 |
-
function
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
|
|
2343 |
}
|
2344 |
/**
|
2345 |
* Detects if they can do IMAP
|
@@ -2394,18 +2435,55 @@ function TestForMarkdown() {
|
|
2394 |
return(false);
|
2395 |
|
2396 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2397 |
/**
|
2398 |
* This function handles setting up the basic permissions
|
2399 |
*/
|
2400 |
-
function
|
2401 |
global $wp_roles;
|
2402 |
$admin = $wp_roles->get_role("administrator");
|
2403 |
$admin->add_cap("config_postie");
|
2404 |
$admin->add_cap("post_via_postie");
|
2405 |
-
}
|
2406 |
-
function UpdatePostiePermissions($role_access, $unfiltered=true) {
|
2407 |
-
global $wp_roles;
|
2408 |
-
PostieAdminPermissions();
|
2409 |
if (!is_array($role_access)) {
|
2410 |
$role_access = array();
|
2411 |
}
|
@@ -2433,24 +2511,25 @@ function DebugEmailOutput(&$email,&$mimeDecodedEmail) {
|
|
2433 |
* If you want to extend this functionality - write a new function and call it from here
|
2434 |
*/
|
2435 |
function SpecialMessageParsing(&$content, &$attachments, $config){
|
|
|
2436 |
if ( preg_match('/You have been sent a message from Vodafone mobile/',$content)) {
|
2437 |
VodafoneHandler($content, $attachments); //Everything for this type of message is handled below
|
2438 |
return;
|
2439 |
}
|
2440 |
-
if ( $
|
2441 |
-
StartFilter($content,$
|
2442 |
}
|
2443 |
-
if ( $
|
2444 |
-
EndFilter($content,$
|
2445 |
}
|
2446 |
-
if ( $
|
2447 |
-
|
2448 |
}
|
2449 |
-
if ($
|
2450 |
&& count($attachments["cids"])) {
|
2451 |
ReplaceImageCIDs($content,$attachments);
|
2452 |
}
|
2453 |
-
if (!$
|
2454 |
ReplaceImagePlaceHolders($content,$attachments["html"], $config);
|
2455 |
} else {
|
2456 |
$customImages=array();
|
1 |
<?php
|
2 |
$revisions= WP_POST_REVISIONS;
|
3 |
define('WP_POST_REVISIONS', false);
|
4 |
+
//define('POSTIE_DEBUG', true);
|
5 |
$original_mem_limit = ini_get('memory_limit');
|
6 |
+
//ini_set('memory_limit', -1);
|
7 |
|
8 |
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
|
9 |
/*
|
10 |
+
$Id: postie-functions.php 230537 2010-04-18 17:20:49Z robfelty $
|
11 |
*/
|
12 |
|
13 |
/*TODO
|
14 |
* html purify
|
15 |
* USE built-in php message decoding to improve speed
|
16 |
* Add custom fields
|
|
|
17 |
* support for flexible upload plugin
|
|
|
|
|
|
|
18 |
* iso 8859-2 support
|
19 |
* add private post function
|
20 |
http://forum.robfelty.com/topic/how-to-private-posts-from-postie?replies=2#post-1515
|
21 |
+
* category per e-mail address
|
22 |
*/
|
|
|
|
|
|
|
23 |
|
24 |
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . "wp-config.php");
|
|
|
25 |
|
26 |
/* this function is necessary for wildcard matching on non-posix systems */
|
27 |
if (!function_exists('fnmatch')) {
|
39 |
* This is the main handler for all of the processing
|
40 |
*/
|
41 |
function PostEmail($poster,$mimeDecodedEmail,$config) {
|
42 |
+
extract($config);
|
43 |
+
$post_to_db=true;
|
44 |
|
45 |
$attachments = array(
|
46 |
"html" => array(), //holds the html for each image
|
49 |
);
|
50 |
print("<p>Message Id is :" .
|
51 |
htmlentities($mimeDecodedEmail->headers["message-id"]) . "</p><br/>\n");
|
52 |
+
if ( defined ( 'POSTIE_DEBUG' ) ){
|
53 |
+
foreach($mimeDecodedEmail->parts as $parts) {
|
54 |
+
print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."</p>\n";
|
55 |
+
}
|
56 |
+
echo "<p>Email is:</p>";
|
57 |
+
var_dump($mimeDecodedEmail);
|
58 |
+
}
|
59 |
+
FilterTextParts($mimeDecodedEmail, $prefer_text_type);
|
60 |
$tmpPost=array('post_title'=> 'tmptitle',
|
61 |
'post_content'=>'tmpPost');
|
62 |
/* in order to do attachments correctly, we need to associate the
|
63 |
attachments with a post. So we add the post here, then update it
|
64 |
*/
|
65 |
$post_id = wp_insert_post($tmpPost);
|
66 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
67 |
echo "the id is $post_id\n";
|
68 |
}
|
69 |
+
$content = GetContent($mimeDecodedEmail,$attachments,$post_id, $poster, $config);
|
70 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
71 |
echo "the content is $content\n";
|
72 |
}
|
73 |
$subject = GetSubject($mimeDecodedEmail,$content, $config);
|
74 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
75 |
echo "the subject is $subject, right after calling GetSubject\n";
|
76 |
}
|
77 |
$customImages = SpecialMessageParsing($content,$attachments, $config);
|
78 |
+
$post_excerpt = GetPostExcerpt($content, $filternewlines,
|
79 |
+
$convertnewline);
|
80 |
$postAuthorDetails=getPostAuthorDetails($subject,$content,
|
81 |
$mimeDecodedEmail);
|
82 |
$message_date = NULL;
|
85 |
$message_date=HandleMessageEncoding(
|
86 |
$mimeDecodedEmail->headers["content-transfer-encoding"],
|
87 |
$mimeDecodedEmail->ctype_parameters["charset"],
|
88 |
+
$mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
|
89 |
//$message_date = $mimeDecodedEmail->headers['date'];
|
90 |
}
|
91 |
list($post_date,$post_date_gmt, $delay) = DeterminePostDate($content,
|
92 |
+
$message_date,$time_offset);
|
|
|
93 |
ubb2HTML($content);
|
94 |
|
95 |
+
if ($converturls)
|
96 |
+
$content=clickableLink($content, $shortcode);
|
97 |
|
98 |
//$content = FixEmailQuotes($content);
|
99 |
|
100 |
$id=checkReply($subject);
|
101 |
$post_categories = GetPostCategories($subject,
|
102 |
+
$default_post_category);
|
103 |
+
$post_tags = postie_get_tags($content, $default_post_tags);
|
104 |
$comment_status = AllowCommentsOnPost($content);
|
105 |
|
106 |
if ((empty($id) || is_null($id))) {
|
107 |
$id=$post_id;
|
108 |
$isReply=false;
|
109 |
+
if ($add_meta=='yes') {
|
110 |
+
if ($wrap_pre=='yes') {
|
111 |
$content = $postAuthorDetails['content'] . "<pre>\n" . $content . "</pre>\n";
|
112 |
$content = "<pre>\n" . $content . "</pre>\n";
|
113 |
} else {
|
115 |
$content = $content;
|
116 |
}
|
117 |
} else {
|
118 |
+
if ($wrap_pre=='yes') {
|
119 |
$content = "<pre>\n" . $content . "</pre>\n";
|
120 |
}
|
121 |
}
|
139 |
$content=$newContents;
|
140 |
wp_delete_post($post_id);
|
141 |
}
|
142 |
+
if ($filternewlines)
|
143 |
+
$content = FilterNewLines($content, $convertnewline);
|
144 |
|
145 |
|
146 |
+
if ($delay!=0 && $post_status=='publish') {
|
147 |
$post_status='future';
|
148 |
} else {
|
149 |
+
$post_status=$post_status;
|
150 |
}
|
151 |
+
// DEBUG
|
152 |
$details = array(
|
153 |
'post_author' => $poster,
|
154 |
'comment_author' => $postAuthorDetails['author'],
|
157 |
'email_author' => $postAuthorDetails['email'],
|
158 |
'post_date' => $post_date,
|
159 |
// 'post_date_gmt' => $post_date_gmt,
|
160 |
+
// 'post_content' => apply_filters('content_save_pre',$content),
|
161 |
+
'post_content' => $content,
|
162 |
'post_title' => $subject,
|
163 |
// 'post_modified' => $post_date,
|
164 |
// 'post_modified_gmt' => $post_date_gmt,
|
173 |
'post_status' => $post_status
|
174 |
);
|
175 |
$details = apply_filters('postie_post', $details);
|
176 |
+
if ( empty( $details ) ) {
|
177 |
+
// It is possible that the filter has removed the post, in which case, it should not be posted.
|
178 |
+
// And if we created a placeholder post (because this was not a reply to an existing post),
|
179 |
+
// then it should be removed
|
180 |
+
if ( !$is_reply ) {
|
181 |
+
wp_delete_post($post_id);
|
182 |
+
}
|
183 |
+
} else {
|
184 |
+
DisplayEmailPost($details);
|
185 |
+
PostToDB($details,$isReply, $post_to_db,
|
186 |
+
$custom_image_field);
|
187 |
+
if ($confirmation_email!='') {
|
188 |
+
if ($confirmation_email=='sender') {
|
189 |
+
$recipients = array($postAuthorDetails['email']);
|
190 |
+
} elseif ($confirmation_email=='admin') {
|
191 |
+
$recipients = array(get_option("admin_email"));
|
192 |
+
} elseif ($confirmation_email=='both') {
|
193 |
+
$recipients = array($postAuthorDetails['email'],
|
194 |
+
get_option("admin_email"));
|
195 |
+
}
|
196 |
+
MailToRecipients($mimeDecodedEmail, false,
|
197 |
+
$recipients, false, false);
|
198 |
+
}
|
199 |
+
}
|
200 |
}
|
201 |
/** FUNCTIONS **/
|
202 |
|
203 |
|
204 |
function clickableLink($text, $shortcode=false) {
|
205 |
# this functions deserves credit to the fine folks at phpbb.com
|
206 |
+
# It turns urls into links, and video urls into embedded players
|
207 |
|
208 |
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:",
|
209 |
$text);
|
210 |
|
211 |
// pad it with a space so we can match things at the start of the 1st line.
|
212 |
$ret = ' ' . $text;
|
213 |
+
if (strpos($ret, 'youtube') !== false) {
|
214 |
+
// try to embed youtube videos
|
215 |
+
$youtube="#(^|[\n ]|>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
|
216 |
+
#$youtube="#(^|[\n ]|<p[^<]*>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9]+).*?([ \n]|$|</p>)#is";
|
217 |
+
if ($shortcode) {
|
218 |
+
$youtube_replace= "\\1[youtube \\3]\\4";
|
219 |
+
} else {
|
220 |
+
$youtube_replace= "\\1<embed width='425' height='344' allowfullscreen='true' allowscriptaccess='always' type='application/x-shockwave-flash' src=\"http://www.youtube.com/v/\\3&hl=en&fs=1\" />\\4";
|
221 |
+
}
|
222 |
+
$ret = preg_replace($youtube,$youtube_replace, $ret);
|
223 |
+
}
|
224 |
+
|
225 |
+
if (strpos($ret, 'vimeo') !== false) {
|
226 |
+
// try to embed vimeo videos
|
227 |
+
# : http://vimeo.com/6348141
|
228 |
+
$vimeo="#(^|[\n ]|>)[\w]+?://(www\.)?vimeo\.com/([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
|
229 |
+
#$youtube="#(^|[\n ]|<p[^<]*>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9]+).*?([ \n]|$|</p>)#is";
|
230 |
+
if ($shortcode) {
|
231 |
+
$vimeo_replace= "\\1[vimeo \\3]\\4";
|
232 |
+
} else {
|
233 |
+
$vimeo_replace = "\\1<object width='400' height='300'><param name='allowfullscreen'
|
234 |
+
value='true' /><param name='allowscriptaccess' value='always' /><param
|
235 |
+
name='movie'
|
236 |
+
value='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'
|
237 |
+
/><embed
|
238 |
+
src='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'
|
239 |
+
type='application/x-shockwave-flash' allowfullscreen='true'
|
240 |
+
allowscriptaccess='always' width='400' height='300'></embed></object>\\4";
|
241 |
+
//$vimeo_replace= "\\1<embed width='425' height='344' allowfullscreen='true' allowscriptaccess='always' type='application/x-shockwave-flash' src=\"http://www.youtube.com/v/\\3&hl=en&fs=1\" />\\4";
|
242 |
+
}
|
243 |
+
$ret = preg_replace($vimeo,$vimeo_replace, $ret);
|
244 |
}
|
|
|
245 |
|
246 |
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
|
247 |
// xxxx can only be alpha characters.
|
427 |
}
|
428 |
}
|
429 |
if (!$emails)
|
430 |
+
die("\n" . __('There does not seem to be any new mail.', 'postie') . "\n");
|
|
|
431 |
return($emails);
|
432 |
}
|
433 |
/**
|
435 |
*/
|
436 |
function TestIMAPMessageFetch ( ) {
|
437 |
print("**************RUNING IN TESTING MODE************\n");
|
438 |
+
$config = get_config();
|
439 |
+
extract( $config );
|
440 |
+
$email = $test_email_account;
|
441 |
+
$password = $test_email_password;
|
442 |
+
return(IMAPMessageFetch($mail_server, $mail_server_port,
|
443 |
+
$email, $password, $input_protocol,
|
444 |
+
$time_offset, $test_email));
|
445 |
|
446 |
}
|
447 |
/**
|
481 |
}
|
482 |
function TestPOP3MessageFetch ( ) {
|
483 |
print("**************RUNING IN TESTING MODE************\n");
|
484 |
+
$config = get_config();
|
485 |
+
extract( $config );
|
486 |
+
$email = $test_email_account;
|
487 |
+
$password = $test_email_password;
|
488 |
+
return(POP3MessageFetch($mail_server, $mail_server_port,
|
489 |
+
$email, $password, $input_protocol,
|
490 |
+
$time_offset, $test_email));
|
491 |
}
|
492 |
/**
|
493 |
*Retrieves email via POP3
|
547 |
*/
|
548 |
function PostToDB($details,$isReply, $postToDb=true, $customImageField=false) {
|
549 |
if ($postToDb) {
|
|
|
550 |
//$_POST['publish'] = true; //Added to make subscribe2 work - it will only handle it if the global varilable _POST is set
|
551 |
if (!$isReply) {
|
552 |
$post_ID = wp_insert_post($details);
|
589 |
* @return boolean
|
590 |
*/
|
591 |
function BannedFileName($filename, $bannedFiles) {
|
592 |
+
if ( empty( $filename ) || empty( $bannedFiles ) ) return false;
|
593 |
foreach ($bannedFiles as $bannedFile) {
|
594 |
if (fnmatch($bannedFile, $filename)) {
|
595 |
+
print("<p>Ignoring $filename - it is on the banned files list.");
|
596 |
return(true);
|
597 |
}
|
598 |
}
|
600 |
}
|
601 |
|
602 |
//tear apart the meta part for useful information
|
603 |
+
function GetContent ($part,&$attachments, $post_id, $poster, $config) {
|
604 |
+
extract($config);
|
605 |
global $charset, $encoding;
|
606 |
/*
|
607 |
if (!function_exists(imap_mime_header_decode))
|
611 |
echo "primary= " . $part->ctype_primary . ", secondary = " . $part->ctype_secondary . "\n";
|
612 |
DecodeBase64Part($part);
|
613 |
if (BannedFileName($part->ctype_parameters['name'],
|
614 |
+
$banned_files_list))
|
615 |
return(NULL);
|
616 |
if ($part->ctype_primary == "application"
|
617 |
&& $part->ctype_secondary == "octet-stream") {
|
626 |
}
|
627 |
} else {
|
628 |
$mimeDecodedEmail = DecodeMIMEMail($part->body);
|
629 |
+
FilterTextParts($mimeDecodedEmail, $prefer_text_type);
|
630 |
foreach($mimeDecodedEmail->parts as $section) {
|
631 |
+
$meta_return .= GetContent($section,$attachments,$post_id, $poster, $config);
|
632 |
}
|
633 |
}
|
634 |
}
|
635 |
if ($part->ctype_primary == "multipart"
|
636 |
&& $part->ctype_secondary == "appledouble") {
|
637 |
$mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=".$part->ctype_parameters["boundary"]."\n".$part->body);
|
638 |
+
FilterTextParts($mimeDecodedEmail, $prefer_text_type);
|
639 |
FilterAppleFile($mimeDecodedEmail);
|
640 |
foreach($mimeDecodedEmail->parts as $section) {
|
641 |
+
$meta_return .= GetContent($section,$attachments,$post_id, $poster, $config);
|
642 |
}
|
643 |
} else {
|
644 |
switch ( strtolower($part->ctype_primary) ) {
|
645 |
case 'multipart':
|
646 |
+
FilterTextParts($part, $prefer_text_type);
|
647 |
foreach ($part->parts as $section) {
|
648 |
+
$meta_return .= GetContent($section,$attachments,$post_id, $poster, $config);
|
649 |
}
|
650 |
break;
|
651 |
case 'text':
|
658 |
|
659 |
$part->body=HandleMessageEncoding($part->headers["content-transfer-encoding"],
|
660 |
$part->ctype_parameters["charset"],
|
661 |
+
$part->body, $message_encoding, $message_dequote);
|
662 |
|
663 |
//go through each sub-section
|
664 |
if ($part->ctype_secondary=='enriched') {
|
681 |
|
682 |
case 'image':
|
683 |
echo "looking at an image\n";
|
684 |
+
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
685 |
$file = wp_get_attachment_url($file_id);
|
686 |
|
687 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
688 |
$the_post=get_post($file_id);
|
689 |
/* TODO make these options */
|
690 |
+
if (!$auto_gallery) {
|
691 |
+
$attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
|
692 |
+
$imagetemplate);
|
693 |
+
if ($cid) {
|
694 |
+
$attachments["cids"][$cid] = array($file,
|
695 |
+
count($attachments["html"]) - 1);
|
696 |
+
}
|
697 |
}
|
698 |
break;
|
699 |
case 'audio':
|
700 |
+
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
701 |
$file = wp_get_attachment_url($file_id);
|
702 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
703 |
+
if ( in_array( $part->ctype_secondary, $audiotypes ) ) {
|
704 |
+
$audioTemplate=$audiotemplate;
|
|
|
705 |
} else {
|
706 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
707 |
+
$part->ctype_secondary, $icon_set,
|
708 |
+
$icon_size);
|
709 |
$audioTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
710 |
}
|
711 |
$attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
|
712 |
$audioTemplate);
|
713 |
break;
|
714 |
case 'video':
|
715 |
+
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
716 |
$file = wp_get_attachment_url($file_id);
|
717 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
718 |
+
if ( in_array( strtolower( $part->ctype_secondary ), $video1types ) ) {
|
719 |
+
$videoTemplate=$video1template;
|
720 |
+
} elseif ( in_array( strtolower( $part->ctype_secondary ), $video2types ) ) {
|
721 |
+
$videoTemplate=$video2template;
|
|
|
|
|
722 |
} else {
|
723 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
724 |
+
$part->ctype_secondary, $icon_set,
|
725 |
+
$icon_size);
|
726 |
$videoTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
|
727 |
}
|
728 |
$attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
|
729 |
$videoTemplate);
|
730 |
+
//echo "videoTemplate = $videoTemplate\n";
|
731 |
break;
|
732 |
|
733 |
default:
|
734 |
+
if ( in_array( strtolower( $part->ctype_primary ), $supported_file_types ) ) {
|
|
|
735 |
//pgp signature - then forget it
|
736 |
if ( $part->ctype_secondary == 'pgp-signature' )
|
737 |
break;
|
738 |
+
$file_id = postie_media_handle_upload($part, $post_id, $poster);
|
739 |
$file = wp_get_attachment_url($file_id);
|
740 |
echo "file=$file\n";
|
741 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
742 |
$icon=chooseAttachmentIcon($file, $part->ctype_primary,
|
743 |
+
$part->ctype_secondary, $icon_set,
|
744 |
+
$icon_size);
|
745 |
$attachments["html"][] = '<a href="' . $file .
|
746 |
'" style="text-decoration:none">' . $icon .
|
747 |
$part->ctype_parameters['name'] . '</a>' . "\n";
|
874 |
* @return integer|NULL
|
875 |
*/
|
876 |
function ValidatePoster( &$mimeDecodedEmail, $config ) {
|
877 |
+
extract($config);
|
878 |
global $wpdb;
|
879 |
$poster = NULL;
|
880 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
891 |
$sql = 'SELECT id FROM '. $wpdb->users.' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;";
|
892 |
$user_ID= $wpdb->get_var($sql);
|
893 |
$user = new WP_User($user_ID);
|
894 |
+
if (!empty($user_ID)) {
|
895 |
+
$poster = $user_ID;
|
896 |
+
} elseif ($turn_authorization_off ||
|
897 |
+
CheckEmailAddress($from, $authorized_addresses) ||
|
898 |
+
CheckEmailAddress($resentFrom, $authorized_addresses)) {
|
899 |
print("$from is authorized to post as the administrator\n");
|
900 |
$from = get_option("admin_email");
|
901 |
+
$adminUser=$admin_username;
|
902 |
echo "adminUser='$adminUser'";
|
903 |
$poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE
|
904 |
user_login = '$adminUser'");
|
|
|
|
|
|
|
905 |
} else if ($user->has_cap("post_via_postie")) {
|
906 |
$poster = $user_ID;
|
907 |
}
|
908 |
+
$validSMTP=checkSMTP($mimeDecodedEmail, $smtp);
|
909 |
if (!$poster || !$validSMTP) {
|
910 |
echo 'Invalid sender: ' . htmlentities($from) . "! Not adding email!\n";
|
911 |
+
if ($forward_rejected_mail) {
|
912 |
+
$admin_email = get_option("admin_email");
|
913 |
+
if (MailToRecipients($mimeDecodedEmail, $test_email,
|
914 |
+
array($admin_email), $return_to_sender)) {
|
915 |
echo "A copy of the message has been forwarded to the administrator.\n";
|
916 |
} else {
|
917 |
echo "The message was unable to be forwarded to the adminstrator.\n";
|
923 |
}
|
924 |
|
925 |
function checkSMTP($mimeDecodedEmail, $smtpservers) {
|
926 |
+
if ( empty( $smtpservers ) ) return true;
|
927 |
+
foreach ( (array) $mimeDecodedEmail->headers['received'] as $received ) {
|
|
|
928 |
foreach ($smtpservers as $smtp) {
|
929 |
+
if ( stristr( $received, $smtp ) !== false ) return true;
|
|
|
930 |
}
|
931 |
+
}
|
932 |
+
return false;
|
933 |
}
|
934 |
|
935 |
/**
|
952 |
* @param string
|
953 |
* @param array - a list of patterns to determine if it is a sig block
|
954 |
*/
|
955 |
+
function remove_signature( $content, $filterList ) {
|
956 |
if (empty($filterList))
|
957 |
+
return $content;
|
958 |
+
$arrcontent = explode("\n", $content);
|
959 |
+
$strcontent = '';
|
960 |
+
$pattern='/^(' . implode( '|', $filterList ) . ')/';
|
961 |
+
for ($i = 0; $i<=count($arrcontent); $i++) {
|
962 |
+
$line = trim($arrcontent[$i]);
|
963 |
+
$nextline = $arrcontent[$i+1];
|
964 |
+
if (preg_match($pattern,trim($line))) {
|
965 |
+
//if (!strpos(trim($line), $pattern)==0) {
|
966 |
+
//print("<p>Found in $line");
|
967 |
+
break;
|
968 |
+
}
|
969 |
+
$strcontent .= $line ."\n";
|
970 |
+
}
|
971 |
+
return $strcontent;
|
|
|
|
|
972 |
}
|
973 |
/**
|
974 |
* Looks at the content for the given tag and removes all text
|
976 |
* @param string
|
977 |
* @param filter
|
978 |
*/
|
979 |
+
function EndFilter( &$content, $end ) {
|
980 |
+
$pos = strpos( $content, $end );
|
981 |
+
if ( $pos === false )
|
982 |
+
return $content;
|
983 |
+
return $content = substr($content, 0, $pos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
984 |
}
|
985 |
|
986 |
//filter content for new lines
|
1008 |
//$newContent=preg_replace('/<p>LINEBREAK$/', '', $newContent);
|
1009 |
if ($convertNewLines) {
|
1010 |
$newContent= preg_replace('/LINEBREAK/',"<br />\n",$newContent);
|
1011 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
1012 |
echo "converting newlines\n";
|
1013 |
}
|
1014 |
} else {
|
1015 |
$newContent= preg_replace('/LINEBREAK/'," ",$newContent);
|
1016 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
1017 |
echo "not converting newlines\n";
|
1018 |
}
|
1019 |
}
|
1187 |
*/
|
1188 |
function DeterminePostDate(&$content, $message_date = NULL, $offset=0) {
|
1189 |
$delay = 0;
|
1190 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
1191 |
echo "inside Determine Post Date, message_date = $message_date\n";
|
1192 |
}
|
1193 |
if (eregi("delay:(-?[0-9dhm]+)",$content,$matches)
|
1257 |
$mimeDecodedEmail->parts = $newParts; //This is now the filtered list of just the preferred type.
|
1258 |
}
|
1259 |
}
|
1260 |
+
function postie_media_handle_upload($part, $post_id, $poster, $post_data = array()) {
|
1261 |
$overrides = array('test_form'=>false);
|
1262 |
//$overrides = array('test_form'=>false, 'test_size'=>false,
|
1263 |
// 'test_type'=>false);
|
1274 |
echo "could not write to temp file: '$tmpFile' ";
|
1275 |
}
|
1276 |
echo "wrote to temp file\n";
|
1277 |
+
//print_r($part);
|
1278 |
if ($part->ctype_parameters['name']=='') {
|
1279 |
+
if ($part->d_parameters['filename']!='') {
|
1280 |
$name = $part->d_parameters['filename'];
|
1281 |
} else {
|
1282 |
$name = 'postie-media.'. $part->ctype_secondary;
|
1337 |
'post_title' => $title,
|
1338 |
'post_excerpt' => $content,
|
1339 |
'post_content' => $content,
|
1340 |
+
'post_author' => $poster
|
1341 |
), $post_data );
|
1342 |
|
1343 |
// Save the data
|
1496 |
if ($testEmail) {
|
1497 |
return;
|
1498 |
}
|
1499 |
+
echo "mailing to ";
|
1500 |
$user = get_userdata('1');
|
1501 |
$myname = $user->user_nicename;
|
1502 |
$myemailadd = get_option("admin_email");
|
1503 |
$blogname = get_option("blogname");
|
1504 |
$blogurl = get_option("siteurl");
|
1505 |
+
//array_push($recipients, $myemailadd);
|
1506 |
+
print_r($recipients);
|
1507 |
if (count($recipients) == 0) {
|
1508 |
return false;
|
1509 |
}
|
1515 |
}
|
1516 |
|
1517 |
$headers = "From: Wordpress <" .$myemailadd .">\r\n";
|
1518 |
+
foreach ($recipients as $recipient) {
|
1519 |
+
$recipient = trim($recipient);
|
1520 |
+
if (! empty($recipient)) {
|
1521 |
+
$headers .= "Cc: " . $recipient . "\r\n";
|
1522 |
+
}
|
1523 |
+
}
|
1524 |
// Set email subject
|
1525 |
if ($reject) {
|
1526 |
$alert_subject = $blogname . ": Unauthorized Post Attempt from $from";
|
1541 |
|
1542 |
$headers.="Content-Type:multipart/alternative; boundary=\"$boundary\"\r\n";
|
1543 |
// SDM 20041123
|
|
|
|
|
|
|
|
|
|
|
|
|
1544 |
// construct mail message
|
1545 |
$message = "An unauthorized message has been sent to $blogname.\n";
|
1546 |
$message .= "Sender: $from\n";
|
1595 |
$params['decode_headers'] = $decodeHeaders;
|
1596 |
$params['input'] = $email;
|
1597 |
//$decoded = imap_mime_header_decode($email);
|
1598 |
+
$decoded = Mail_mimeDecode::decode($params);
|
1599 |
+
if ( empty($decoded->parts) ) $decoded->parts = array(); // have an empty array at minimum, so that it is safe for "foreach"
|
1600 |
+
return $decoded;
|
1601 |
}
|
1602 |
|
1603 |
/**
|
1615 |
* @return boolean
|
1616 |
*/
|
1617 |
function CheckEmailAddress($address, $authorized) {
|
1618 |
+
return in_array( strtolower($address), $authorized );
|
|
|
|
|
|
|
|
|
1619 |
}
|
1620 |
/**
|
1621 |
*This method works around a problemw with email address with extra <> in the email address
|
1656 |
*/
|
1657 |
function chooseAttachmentIcon($file, $primary, $secondary, $iconSet='silver',
|
1658 |
$size='32') {
|
1659 |
+
if ($iconSet=='none')
|
1660 |
return('');
|
1661 |
$fileName=basename($file);
|
1662 |
$parts=explode('.', $fileName);
|
1805 |
* @param array - array of HTML for images for post
|
1806 |
*/
|
1807 |
function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
|
1808 |
+
extract($config);
|
1809 |
+
($start_image_count_at_zero ? $startIndex = 0 :$startIndex = 1);
|
1810 |
+
if (!empty($attachments) && $auto_gallery) {
|
1811 |
+
$value = '[gallery]';
|
1812 |
+
if ($images_append) {
|
1813 |
+
$content .= $value;
|
1814 |
+
} else {
|
1815 |
+
$content = "$value\n". $content;
|
1816 |
+
}
|
1817 |
+
return;
|
1818 |
+
}
|
1819 |
foreach ( $attachments as $i => $value ) {
|
1820 |
// looks for ' #img1# ' etc... and replaces with image
|
1821 |
+
$img_placeholder_temp = str_replace("%", intval($startIndex + $i), $image_placeholder);
|
1822 |
$eimg_placeholder_temp = str_replace("%", intval($startIndex + $i),
|
1823 |
"#eimg%#");
|
1824 |
$img_placeholder_temp=rtrim($img_placeholder_temp,'#');
|
1827 |
stristr($content, $eimg_placeholder_temp) ) {
|
1828 |
// look for caption
|
1829 |
$caption='';
|
1830 |
+
$content = preg_replace("/�?39;/", "'", $content);
|
1831 |
+
$content = preg_replace("/&(#0?34|quot);/", "\"", $content);
|
1832 |
+
if ( preg_match("/$img_placeholder_temp caption=['\"]?(.*)['\"]?#/", $content, $matches)) {
|
1833 |
$caption =$matches[1];
|
1834 |
+
$img_placeholder_temp = substr($matches[0], 0, -1);
|
1835 |
+
$eimg_placeholder_temp = substr($matches[0], 0, -1);
|
|
|
1836 |
}
|
1837 |
$value = str_replace('{CAPTION}', $caption, $value);
|
1838 |
$img_placeholder_temp.='#';
|
1844 |
} else {
|
1845 |
$value = str_replace('{CAPTION}', '', $value);
|
1846 |
/* if using the gallery shortcode, don't add pictures at all */
|
1847 |
+
if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
|
1848 |
+
if ($images_append) {
|
1849 |
$content .= $value;
|
1850 |
} else {
|
1851 |
$content = $value . $content;
|
1859 |
* @return array - (subject,content)
|
1860 |
*/
|
1861 |
function GetSubject(&$mimeDecodedEmail,&$content, $config) {
|
1862 |
+
extract($config);
|
1863 |
global $charset;
|
1864 |
//assign the default title/subject
|
1865 |
if ( $mimeDecodedEmail->headers['subject'] == NULL ) {
|
1866 |
+
if ($allow_subject_in_mail) {
|
1867 |
list($subject,$content) =
|
1868 |
+
ParseInMessageSubject($content,$default_title);
|
1869 |
}
|
1870 |
else {
|
1871 |
+
$subject = $default_title;
|
1872 |
}
|
1873 |
$mimeDecodedEmail->headers['subject'] = $subject;
|
1874 |
} else {
|
1895 |
//echo "Charset: {$thischarset}\n";
|
1896 |
//echo "Text: ". utf8_encode($elements[$i]->text). "\n\n";
|
1897 |
$subject.=HandleMessageEncoding($encoding, $thischarset,
|
1898 |
+
$elements[$i]->text, $message_encoding,
|
1899 |
+
$message_dequote);
|
1900 |
//echo "subject=$subject\n";
|
1901 |
}
|
1902 |
//echo "now subject= $subject\n";
|
1905 |
//echo "charset='$charset'\n";
|
1906 |
// }
|
1907 |
}
|
1908 |
+
if (!$allow_html_in_subject) {
|
1909 |
$subject = htmlentities($subject);
|
1910 |
}
|
1911 |
}
|
1922 |
*
|
1923 |
*/
|
1924 |
function postie_get_tags(&$content, $defaultTags) {
|
|
|
1925 |
$post_tags = array();
|
1926 |
//try and determine tags
|
1927 |
if ( preg_match('/tags: ?(.*)\n/i', $content, $matches)) {
|
1928 |
$content = str_replace($matches[0], "", $content);
|
1929 |
$post_tags = preg_split("/,\s*/", $matches[1]);
|
1930 |
}
|
1931 |
+
if ( !count( $post_tags ) && !empty( $defaultTags ) ) {
|
1932 |
+
$post_tags = $defaultTags;
|
1933 |
}
|
1934 |
return($post_tags);
|
1935 |
}
|
2006 |
*This function just outputs a simple html report about what is being posted in
|
2007 |
*/
|
2008 |
function DisplayEmailPost($details) {
|
2009 |
+
if( defined( 'POSTIE_DEBUG' ) ) {
|
2010 |
print_r($config);
|
2011 |
print_r($details);
|
2012 |
}
|
2065 |
$string.="</th>";
|
2066 |
|
2067 |
$string .="<td><textarea cols=40 rows=3 name=\"$id\" id=\"$id\">";
|
2068 |
+
$current_value = preg_split("/[,\r\n]+/", trim($current_value));
|
2069 |
if (is_array($current_value)) {
|
2070 |
foreach($current_value as $item) {
|
2071 |
$string .= "$item\n";
|
2075 |
</tr>";
|
2076 |
return($string);
|
2077 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2078 |
/**
|
2079 |
*This function resets all the configuration options to the default
|
2080 |
*/
|
2081 |
function ResetPostieConfig() {
|
2082 |
+
$newconfig = get_config_defaults();
|
2083 |
+
$config = get_option( 'postie-settings' ) ;
|
2084 |
+
$save_keys=array( 'mail_password', 'mail_server', 'mail_server_port', 'mail_userid', 'iinput_protocol' );
|
2085 |
+
foreach ( $save_keys as $key )
|
2086 |
+
$newconfig[$key] = $config[$key];
|
2087 |
+
update_option( 'postie-settings', $newconfig );
|
2088 |
+
UpdatePostieConfig( $newconfig );
|
2089 |
+
return $newconfig;
|
|
|
|
|
2090 |
}
|
2091 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2092 |
/**
|
2093 |
+
* This function used to handle updating the configuration.
|
2094 |
*@return boolean
|
2095 |
*/
|
2096 |
function UpdatePostieConfig($data) {
|
2097 |
+
UpdatePostiePermissions( $data["role_access"] );
|
2098 |
+
// We also update the cron settings
|
2099 |
+
if ($data['interval']!='') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2100 |
postie_decron();
|
2101 |
+
if ($data['interval']!='manual') {
|
2102 |
+
postie_cron($interval=$data['interval']);
|
2103 |
+
}
|
2104 |
}
|
2105 |
return(1);
|
2106 |
}
|
2107 |
/**
|
2108 |
+
* return an array of the config defaults
|
2109 |
+
*/
|
2110 |
+
function get_config_defaults() {
|
2111 |
+
include('templates/audio_templates.php');
|
2112 |
+
include('templates/image_templates.php');
|
2113 |
+
include('templates/video1_templates.php');
|
2114 |
+
include('templates/video2_templates.php');
|
2115 |
+
return array(
|
2116 |
+
'add_meta' => 'no',
|
2117 |
+
'admin_username' => 'admin',
|
2118 |
+
'allow_html_in_body' => true,
|
2119 |
+
'allow_html_in_subject' => true,
|
2120 |
+
'allow_subject_in_mail' => true,
|
2121 |
+
'audiotemplate' =>$simple_link,
|
2122 |
+
'audiotypes' => array( 'm4a', 'mp3','ogg', 'wav', 'mpeg' ),
|
2123 |
+
'authorized_addresses' => array(),
|
2124 |
+
'banned_files_list' => array(),
|
2125 |
+
'confirmation_email' => '',
|
2126 |
+
'convertnewline' => false,
|
2127 |
+
'converturls' => true,
|
2128 |
+
'custom_image_field' => false,
|
2129 |
+
'default_post_category' => NULL,
|
2130 |
+
'default_post_tags' => array(),
|
2131 |
+
'default_title' => "Live From The Field",
|
2132 |
+
'delete_mail_after_processing' => true,
|
2133 |
+
'drop_signature' => true,
|
2134 |
+
'filternewlines' => true,
|
2135 |
+
'forward_rejected_mail' => true,
|
2136 |
+
'icon_set' => 'silver',
|
2137 |
+
'icon_size' => 32,
|
2138 |
+
'auto_gallery' => false,
|
2139 |
+
'image_new_window' => false,
|
2140 |
+
'image_placeholder' => "#img%#",
|
2141 |
+
'images_append' => true,
|
2142 |
+
'imagetemplate' => $wordpress_default,
|
2143 |
+
'imagetemplates' => $imageTemplates,
|
2144 |
+
'input_protocol' => "pop3",
|
2145 |
+
'interval' => 'twiceperhour',
|
2146 |
+
'mail_server' => NULL,
|
2147 |
+
'mail_server_port' => NULL,
|
2148 |
+
'mail_userid' => NULL,
|
2149 |
+
'mail_password' => NULL,
|
2150 |
+
'message_start' => ":start",
|
2151 |
+
'message_end' => ":end",
|
2152 |
+
'message_encoding' => "UTF-8",
|
2153 |
+
'message_dequote' => true,
|
2154 |
+
'post_status' => 'publish',
|
2155 |
+
'prefer_text_type' => "plain",
|
2156 |
+
'return_to_sender' => false,
|
2157 |
+
'role_access' => array(),
|
2158 |
+
'selected_audiotemplate' => 'simple_link',
|
2159 |
+
'selected_imagetemplate' => 'wordpress_default',
|
2160 |
+
'selected_video1template' => 'simple_link',
|
2161 |
+
'selected_video2template' => 'simple_link',
|
2162 |
+
'shortcode' => false,
|
2163 |
+
'sig_pattern_list' => array( '--', '- --' ),
|
2164 |
+
'smtp' => array(),
|
2165 |
+
'start_image_count_at_zero' => false,
|
2166 |
+
'supported_file_types' => array( 'video', 'application' ),
|
2167 |
+
'turn_authorization_off' => false,
|
2168 |
+
'time_offset' => get_option('gmt_offset'),
|
2169 |
+
'video1template' => $simple_link,
|
2170 |
+
'video1types' => array( 'mp4', 'mpeg4', '3gp', '3gpp', '3gpp2', '3gp2', 'mov', 'mpeg' ),
|
2171 |
+
'video2template' => $simple_link,
|
2172 |
+
'video2types' => array( 'x-flv' ),
|
2173 |
+
'video1templates' => $video1Templates,
|
2174 |
+
'video2templates' => $video2Templates,
|
2175 |
+
'wrap_pre' => 'no'
|
2176 |
+
);
|
2177 |
+
}
|
2178 |
+
/**
|
2179 |
+
*=======================================================
|
2180 |
+
* the following functions are only used to retrieve the old (pre 1.4) config, to convert it
|
2181 |
+
* to the new format
|
2182 |
*/
|
2183 |
+
function GetListOfArrayConfig() {
|
2184 |
+
return(array('SUPPORTED_FILE_TYPES','AUTHORIZED_ADDRESSES',
|
2185 |
+
'SIG_PATTERN_LIST','BANNED_FILES_LIST', 'VIDEO1TYPES',
|
2186 |
+
'VIDEO2TYPES', 'AUDIOTYPES', 'SMTP'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2187 |
}
|
2188 |
/**
|
2189 |
+
*This function retrieves the old-format config (pre 1.4) from the database
|
2190 |
* @return array
|
2191 |
*/
|
2192 |
function ReadDBConfig() {
|
|
|
2193 |
$config = array();
|
2194 |
global $wpdb;
|
2195 |
+
$data = $wpdb->get_results("SELECT label,value FROM ". $GLOBALS["table_prefix"] . "postie_config;");
|
2196 |
if (is_array($data)) {
|
2197 |
foreach($data as $row) {
|
2198 |
if (in_array($row->label,GetListOfArrayConfig())) {
|
2205 |
return($config);
|
2206 |
}
|
2207 |
/**
|
2208 |
+
* This function processes the old-format config (pre 1.4) for conversion to the 1.4 format
|
|
|
2209 |
* @return array
|
2210 |
* @access private
|
2211 |
*/
|
2236 |
if (!isset($config["RETURN_TO_SENDER"]))
|
2237 |
$config["RETURN_TO_SENDER"] = false;
|
2238 |
if (!isset($config["CONFIRMATION_EMAIL"]))
|
2239 |
+
$config["CONFIRMATION_EMAIL"] = '';
|
2240 |
if (!isset($config["ALLOW_HTML_IN_SUBJECT"]))
|
2241 |
$config["ALLOW_HTML_IN_SUBJECT"] = true;
|
2242 |
if (!isset($config["ALLOW_HTML_IN_BODY"]))
|
2303 |
$config["VIDEO1TEMPLATE"] = $simple_link;
|
2304 |
if (!isset($config["VIDEO1TYPES"]))
|
2305 |
$config['VIDEO1TYPES'] = array('mp4', 'mpeg4', '3gp', '3gpp', '3gpp2',
|
2306 |
+
'3gp2', 'mov', 'mpeg');
|
2307 |
if (!isset($config["AUDIOTYPES"]))
|
2308 |
+
$config['AUDIOTYPES'] = array('m4a', 'mp3', 'ogg', 'wav', 'mpeg');
|
2309 |
if (!isset($config["SELECTED_VIDEO2TEMPLATE"]))
|
2310 |
$config['SELECTED_VIDEO2TEMPLATE'] = 'simple_link';
|
2311 |
include('templates/video2_templates.php');
|
2331 |
return($config);
|
2332 |
}
|
2333 |
/**
|
2334 |
+
* This function returns the old-format config (pre 1.4)
|
2335 |
* @return array
|
2336 |
*/
|
2337 |
function GetConfig() {
|
2354 |
}
|
2355 |
return $config;
|
2356 |
}
|
2357 |
+
/**
|
2358 |
+
* end of functions used to retrieve the old (pre 1.4) config
|
2359 |
+
*=======================================================
|
2360 |
+
*/
|
2361 |
+
/**
|
2362 |
+
* This function returns the current config
|
2363 |
+
* @return array
|
2364 |
+
*/
|
2365 |
+
function get_config() {
|
2366 |
+
$config = get_option( 'postie-settings' );
|
2367 |
+
if (file_exists(POSTIE_ROOT . '/postie_test_variables.php')) {
|
2368 |
+
include(POSTIE_ROOT . '/postie_test_variables.php');
|
2369 |
+
}
|
2370 |
+
// These are computed
|
2371 |
+
$config["time_offset"] = get_option('gmt_offset');
|
2372 |
+
$config["postie_root"] = POSTIE_ROOT;
|
2373 |
+
return $config;
|
2374 |
+
}
|
2375 |
/**
|
2376 |
* Returns a list of config keys that should be arrays
|
2377 |
*@return array
|
2378 |
*/
|
2379 |
+
function get_arrayed_settings() {
|
2380 |
+
return array(
|
2381 |
+
',' => array('audiotypes', 'video1types', 'video2types', 'default_post_tags'),
|
2382 |
+
"\n" => array('smtp', 'authorized_addresses', 'supported_file_types',
|
2383 |
+
'banned_files_list', 'sig_pattern_list') );
|
2384 |
}
|
2385 |
/**
|
2386 |
* Detects if they can do IMAP
|
2435 |
return(false);
|
2436 |
|
2437 |
}
|
2438 |
+
/**
|
2439 |
+
* validates the config form output, fills in any gaps by using the defaults,
|
2440 |
+
* and ensures that arrayed items are stored as such
|
2441 |
+
*/
|
2442 |
+
function postie_validate_settings( $in ) {
|
2443 |
+
if ( defined ( 'POSTIE_DEBUG' ) ) var_dump( $in );
|
2444 |
+
$out = array();
|
2445 |
+
|
2446 |
+
// use the default as a template:
|
2447 |
+
// if a field is present in the defaults, we want to store it; otherwise we discard it
|
2448 |
+
$allowed_keys = get_config_defaults();
|
2449 |
+
foreach ( $allowed_keys as $key => $default )
|
2450 |
+
$out[$key] = array_key_exists( $key, $in ) ? $in[$key] : $default;
|
2451 |
+
|
2452 |
+
// some fields are always forced to lower case:
|
2453 |
+
$lowercase = array( 'authorized_addresses', 'smtp', 'supported_file_types', 'video1types', 'video2types', 'audiotypes' );
|
2454 |
+
foreach ($lowercase as $field) {
|
2455 |
+
$out[$field] = ( is_array( $out[$field] ) ) ? array_map( strtolower, $out[$field] ) : strtolower( $out[$field] );
|
2456 |
+
}
|
2457 |
+
$arrays = get_arrayed_settings();
|
2458 |
+
|
2459 |
+
foreach ( $arrays as $sep => $fields ) {
|
2460 |
+
foreach ( $fields as $field ) {
|
2461 |
+
if ( !is_array( $out[$field] ) )
|
2462 |
+
$out[$field] = explode( $sep, trim( $out[$field] ) );
|
2463 |
+
foreach ( $out[$field] as $key => $val ) {
|
2464 |
+
$tst = trim($val);
|
2465 |
+
if ( empty( $tst ) ) unset( $out[$field][$key] );
|
2466 |
+
}
|
2467 |
+
}
|
2468 |
+
}
|
2469 |
+
|
2470 |
+
UpdatePostieConfig( $out );
|
2471 |
+
return $out;
|
2472 |
+
}
|
2473 |
+
/**
|
2474 |
+
* registers the settings and the admin optionspage
|
2475 |
+
*/
|
2476 |
+
function postie_admin_settings() {
|
2477 |
+
register_setting( 'postie-settings', 'postie-settings', 'postie_validate_settings' );
|
2478 |
+
}
|
2479 |
/**
|
2480 |
* This function handles setting up the basic permissions
|
2481 |
*/
|
2482 |
+
function UpdatePostiePermissions( $role_access ) {
|
2483 |
global $wp_roles;
|
2484 |
$admin = $wp_roles->get_role("administrator");
|
2485 |
$admin->add_cap("config_postie");
|
2486 |
$admin->add_cap("post_via_postie");
|
|
|
|
|
|
|
|
|
2487 |
if (!is_array($role_access)) {
|
2488 |
$role_access = array();
|
2489 |
}
|
2511 |
* If you want to extend this functionality - write a new function and call it from here
|
2512 |
*/
|
2513 |
function SpecialMessageParsing(&$content, &$attachments, $config){
|
2514 |
+
extract($config);
|
2515 |
if ( preg_match('/You have been sent a message from Vodafone mobile/',$content)) {
|
2516 |
VodafoneHandler($content, $attachments); //Everything for this type of message is handled below
|
2517 |
return;
|
2518 |
}
|
2519 |
+
if ( $message_start ) {
|
2520 |
+
StartFilter($content,$message_start);
|
2521 |
}
|
2522 |
+
if ( $message_end ) {
|
2523 |
+
EndFilter($content,$message_end);
|
2524 |
}
|
2525 |
+
if ( $drop_signature ) {
|
2526 |
+
$content = remove_signature( $content, $sig_pattern_list );
|
2527 |
}
|
2528 |
+
if ($prefer_text_type == "html"
|
2529 |
&& count($attachments["cids"])) {
|
2530 |
ReplaceImageCIDs($content,$attachments);
|
2531 |
}
|
2532 |
+
if (!$custom_image_field) {
|
2533 |
ReplaceImagePlaceHolders($content,$attachments["html"], $config);
|
2534 |
} else {
|
2535 |
$customImages=array();
|
postie.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
Plugin Name: Postie
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://forum.robfelty.com/forum/postie'>postie forum</a> for support.
|
6 |
-
Version: 1.
|
7 |
Author: Robert Felty
|
8 |
Author URI: http://blog.robfelty.com/
|
9 |
*/
|
10 |
|
11 |
/*
|
12 |
-
$Id: postie.php
|
13 |
* -= Requests Pending =-
|
14 |
* German Umlats don't work
|
15 |
* Problems under PHP5
|
@@ -37,7 +37,7 @@ $Id: postie.php 160759 2009-10-05 20:25:31Z robfelty $
|
|
37 |
*/
|
38 |
|
39 |
//Older Version History is in the HISTORY file
|
40 |
-
//error_reporting(E_ALL);
|
41 |
//ini_set("display_errors", 1);
|
42 |
|
43 |
define("POSTIE_ROOT",dirname(__FILE__));
|
@@ -73,6 +73,7 @@ if (isset($_GET["postie_read_me"])) {
|
|
73 |
if (is_admin()) {
|
74 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
75 |
//add_action("admin_menu","PostieMenu");
|
|
|
76 |
add_action('admin_menu', 'postie_loadjs_add_page');
|
77 |
if(function_exists('load_plugin_textdomain')){
|
78 |
$plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
|
@@ -84,13 +85,53 @@ if (is_admin()) {
|
|
84 |
}
|
85 |
postie_warnings();
|
86 |
}
|
87 |
-
|
88 |
-
|
89 |
-
$
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
function postie_enter_info() {
|
95 |
echo "
|
96 |
<div id='postie-info-warning' class='updated fade'><p><strong>".
|
@@ -99,6 +140,7 @@ function postie_warnings() {
|
|
99 |
}
|
100 |
add_action('admin_notices', 'postie_enter_info');
|
101 |
}
|
|
|
102 |
if (!function_exists('imap_mime_header_decode') && $_GET['activate']==true) {
|
103 |
function postie_imap_warning() {
|
104 |
echo "<div id='postie-imap-warning' class='error'><p><strong>";
|
@@ -110,5 +152,69 @@ function postie_warnings() {
|
|
110 |
}
|
111 |
add_action('admin_notices', 'postie_imap_warning');
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
|
|
|
|
|
|
|
|
114 |
?>
|
3 |
Plugin Name: Postie
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://forum.robfelty.com/forum/postie'>postie forum</a> for support.
|
6 |
+
Version: 1.4
|
7 |
Author: Robert Felty
|
8 |
Author URI: http://blog.robfelty.com/
|
9 |
*/
|
10 |
|
11 |
/*
|
12 |
+
$Id: postie.php 219674 2010-03-19 17:58:46Z robfelty $
|
13 |
* -= Requests Pending =-
|
14 |
* German Umlats don't work
|
15 |
* Problems under PHP5
|
37 |
*/
|
38 |
|
39 |
//Older Version History is in the HISTORY file
|
40 |
+
//error_reporting(E_ALL & ~E_NOTICE);
|
41 |
//ini_set("display_errors", 1);
|
42 |
|
43 |
define("POSTIE_ROOT",dirname(__FILE__));
|
73 |
if (is_admin()) {
|
74 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
75 |
//add_action("admin_menu","PostieMenu");
|
76 |
+
add_action( 'admin_init', 'postie_admin_settings' );
|
77 |
add_action('admin_menu', 'postie_loadjs_add_page');
|
78 |
if(function_exists('load_plugin_textdomain')){
|
79 |
$plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
|
85 |
}
|
86 |
postie_warnings();
|
87 |
}
|
88 |
+
|
89 |
+
function activate_postie() {
|
90 |
+
static $init = false;
|
91 |
+
$options = get_option( 'postie-settings' );
|
92 |
+
|
93 |
+
if ( $init ) return;
|
94 |
+
|
95 |
+
if(!$options) {
|
96 |
+
$options = array();
|
97 |
+
}
|
98 |
+
$default_options = get_config_defaults();
|
99 |
+
$old_config = array();
|
100 |
+
$updated = false;
|
101 |
+
$migration = false;
|
102 |
+
|
103 |
+
/*
|
104 |
+
global $wpdb;
|
105 |
+
$GLOBALS["table_prefix"]. "postie_config";
|
106 |
+
$result = $wpdb->get_results("SELECT label,value FROM $postietable ;");
|
107 |
+
*/
|
108 |
+
$result = GetConfig();
|
109 |
+
if (is_array($result)) {
|
110 |
+
foreach ( $result as $key => $val ) {
|
111 |
+
$old_config[strtolower( $key )] = $val;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
// overlay the options on top of each other:
|
116 |
+
// the current value of $options takes priority over the $old_config, which takes priority over the $default_options
|
117 |
+
$options = array_merge( $default_options, $old_config, $options );
|
118 |
+
$options = postie_validate_settings( $options );
|
119 |
+
update_option( 'postie-settings', $options );
|
120 |
+
$init = true;
|
121 |
+
// $wpdb->query("DROP TABLE IF EXISTS $postietable"); // safely updated options, so we can remove the old table
|
122 |
+
return $options;
|
123 |
+
}
|
124 |
+
register_activation_hook(__FILE__, 'activate_postie');
|
125 |
+
|
126 |
+
/**
|
127 |
+
* set up actions to show relevant warnings,
|
128 |
+
* if mail server is not set, or if IMAP extension is not available
|
129 |
+
*/
|
130 |
+
function postie_warnings() {
|
131 |
+
|
132 |
+
$config = get_option( 'postie-settings' );
|
133 |
+
|
134 |
+
if ( empty( $config['mail_server'] ) && !isset($_POST['submit'] ) ) {
|
135 |
function postie_enter_info() {
|
136 |
echo "
|
137 |
<div id='postie-info-warning' class='updated fade'><p><strong>".
|
140 |
}
|
141 |
add_action('admin_notices', 'postie_enter_info');
|
142 |
}
|
143 |
+
|
144 |
if (!function_exists('imap_mime_header_decode') && $_GET['activate']==true) {
|
145 |
function postie_imap_warning() {
|
146 |
echo "<div id='postie-imap-warning' class='error'><p><strong>";
|
152 |
}
|
153 |
add_action('admin_notices', 'postie_imap_warning');
|
154 |
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
function disable_kses_content() {
|
159 |
+
remove_filter('content_save_pre', 'wp_filter_post_kses');
|
160 |
+
}
|
161 |
+
add_action('init','disable_kses_content',20);
|
162 |
+
function postie_whitelist($options) {
|
163 |
+
$added = array( 'postie-settings' => array( 'postie-settings' ) );
|
164 |
+
$options = add_option_whitelist( $added, $options );
|
165 |
+
return $options;
|
166 |
+
}
|
167 |
+
add_filter('whitelist_options', 'postie_whitelist');
|
168 |
+
|
169 |
+
function check_postie() {
|
170 |
+
$host = get_option('siteurl');
|
171 |
+
preg_match("/https?:\/\/(.[^\/]*)(.*)/",$host,$matches);
|
172 |
+
$host = $matches[1];
|
173 |
+
$url = "";
|
174 |
+
if (isset($matches[2])) {
|
175 |
+
$url .= $matches[2];
|
176 |
+
}
|
177 |
+
$url .= "/wp-content/plugins/postie/get_mail.php";
|
178 |
+
$port = 80;
|
179 |
+
$fp=fsockopen($host,$port,$errno,$errstr);
|
180 |
+
fputs($fp,"GET $url HTTP/1.0\r\n");
|
181 |
+
fputs($fp,"User-Agent: Cronless-Postie\r\n");
|
182 |
+
fputs($fp,"Host: $host\r\n");
|
183 |
+
fputs($fp,"\r\n");
|
184 |
+
$page = '';
|
185 |
+
while(!feof($fp)) {
|
186 |
+
$page.=fgets($fp,128);
|
187 |
+
}
|
188 |
+
fclose($fp);
|
189 |
+
}
|
190 |
+
|
191 |
+
function postie_cron($interval=false) {
|
192 |
+
if (!$interval) {
|
193 |
+
$config=get_option('postie-settings');
|
194 |
+
$interval = $config['interval'];
|
195 |
+
}
|
196 |
+
if (!$interval || $interval=='')
|
197 |
+
$interval='hourly';
|
198 |
+
if ($interval=='manual') {
|
199 |
+
wp_clear_scheduled_hook('check_postie_hook');
|
200 |
+
} else {
|
201 |
+
wp_schedule_event(time(),$interval,'check_postie_hook');
|
202 |
+
}
|
203 |
+
}
|
204 |
+
function postie_decron() {
|
205 |
+
wp_clear_scheduled_hook('check_postie_hook');
|
206 |
+
}
|
207 |
+
|
208 |
+
/* here we add some more options for how often to check for e-mail */
|
209 |
+
function more_reccurences() {
|
210 |
+
return array(
|
211 |
+
'weekly' => array('interval' => 604800, 'display' => 'Once Weekly'),
|
212 |
+
'twiceperhour' => array('interval' => 1800, 'display' => 'Twice per hour '),
|
213 |
+
'tenminutes' =>array('interval' => 600, 'display' => 'Every 10 minutes')
|
214 |
+
);
|
215 |
}
|
216 |
+
add_filter('cron_schedules', 'more_reccurences');
|
217 |
+
register_activation_hook(__FILE__,'postie_cron');
|
218 |
+
register_deactivation_hook(__FILE__,'postie_decron');
|
219 |
+
add_action('check_postie_hook', 'check_postie');
|
220 |
?>
|
postie_test.php
CHANGED
@@ -4,7 +4,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
|
4 |
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
|
5 |
//require_once('admin.php');
|
6 |
require_once("postie-functions.php");
|
7 |
-
$config =
|
8 |
$title = __("Postie Diagnosis");
|
9 |
$parent_file = 'options-general.php?page=postie/postie.php';
|
10 |
get_currentuserinfo();
|
@@ -69,7 +69,7 @@ get_currentuserinfo();
|
|
69 |
<th>Connect to Mail Host</th>
|
70 |
<td>
|
71 |
<?php
|
72 |
-
switch( strtolower($config["
|
73 |
case 'imap':
|
74 |
case 'imap-ssl':
|
75 |
case 'pop3-ssl':
|
@@ -78,8 +78,8 @@ get_currentuserinfo();
|
|
78 |
}
|
79 |
else {
|
80 |
require_once("postieIMAP.php");
|
81 |
-
$mail_server = &PostieIMAP::Factory($config["
|
82 |
-
if (!$mail_server->connect($config["
|
83 |
print("Unable to connect. The server said - ".$mail_server->error());
|
84 |
print("<br/>Try putting in your full email address as a userid and try again.");
|
85 |
}
|
@@ -92,7 +92,7 @@ get_currentuserinfo();
|
|
92 |
default:
|
93 |
require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
|
94 |
$pop3 = &new POP3();
|
95 |
-
if (!$pop3->connect($config["
|
96 |
print("Unable to connect. The server said - ".$pop3->ERROR);
|
97 |
print("<br/>Try putting in your full email address as a userid and try again.");
|
98 |
}
|
4 |
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
|
5 |
//require_once('admin.php');
|
6 |
require_once("postie-functions.php");
|
7 |
+
$config = get_config();
|
8 |
$title = __("Postie Diagnosis");
|
9 |
$parent_file = 'options-general.php?page=postie/postie.php';
|
10 |
get_currentuserinfo();
|
69 |
<th>Connect to Mail Host</th>
|
70 |
<td>
|
71 |
<?php
|
72 |
+
switch( strtolower($config["input_protocol"]) ) {
|
73 |
case 'imap':
|
74 |
case 'imap-ssl':
|
75 |
case 'pop3-ssl':
|
78 |
}
|
79 |
else {
|
80 |
require_once("postieIMAP.php");
|
81 |
+
$mail_server = &PostieIMAP::Factory($config["input_protocol"]);
|
82 |
+
if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"],$config["mail_userid"],$config["mail_password"])) {
|
83 |
print("Unable to connect. The server said - ".$mail_server->error());
|
84 |
print("<br/>Try putting in your full email address as a userid and try again.");
|
85 |
}
|
92 |
default:
|
93 |
require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
|
94 |
$pop3 = &new POP3();
|
95 |
+
if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
|
96 |
print("Unable to connect. The server said - ".$pop3->ERROR);
|
97 |
print("<br/>Try putting in your full email address as a userid and try again.");
|
98 |
}
|
readme.html
CHANGED
@@ -28,36 +28,26 @@ of connection and the port number. Common port configurations:
|
|
28 |
|
29 |
<h4>Automating checking e-mail</h4>
|
30 |
|
31 |
-
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
enable mail checking using cron; if you don't know anything about cron, skip
|
33 |
to the cronless postie section.</p>
|
34 |
|
35 |
-
<p>Setup a cronjob to pull down the
|
36 |
Examples:</p>
|
37 |
|
38 |
-
<p>*/5 * * * * /usr/bin/lynx --source http://blog.robfelty.com/wp-content/plugins/postie/
|
39 |
-
|
40 |
-
<p>This fetches the mail every five minutes with lynx </p>
|
41 |
-
|
42 |
-
<p>*/10 * * * * /usr/bin/wget -O /dev/null http://blog.robfelty.com/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1</p>
|
43 |
-
|
44 |
-
<p>This fetches the mail every ten minutes with wget </p>
|
45 |
|
46 |
-
<
|
47 |
|
48 |
-
<p
|
49 |
|
50 |
-
<
|
51 |
-
<li>Activate the cronless postie plugin (it is included with the postie plugin,
|
52 |
-
so if you have downloaded postie, you don't need to download anything else</li>
|
53 |
-
<li>By default, cronless postie checks for new e-mail once every hour. To select
|
54 |
-
a different rate, change the cronless postie setting in the postie settings
|
55 |
-
page. </li>
|
56 |
-
<li>Note that timing with cronless postie is not very accurate. It depends
|
57 |
-
on people visiting your website. If you select to check every 10 minutes, but
|
58 |
-
you only get one visit every 30 minutes, then it might take 30 minutes for a
|
59 |
-
post to show up.</li>
|
60 |
-
</ul> <hr />
|
61 |
|
62 |
<h3>Usage</h3>
|
63 |
<ul>
|
@@ -136,9 +126,10 @@ them to your blog</li>
|
|
136 |
you attached</li>
|
137 |
<li><p>Captions - you can also add a caption like so:</p>
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
img2 caption='bar'
|
|
|
142 |
|
143 |
<p>Or, if you use IPTC captions, this caption will be used (adding a caption
|
144 |
in many photo editing programs (for example Picasa), will add an IPTC caption)</p></li>
|
28 |
|
29 |
<h4>Automating checking e-mail</h4>
|
30 |
|
31 |
+
<p>By default, postie checks for new e-mail every 30 minutes. You can select from
|
32 |
+
a number of different checking intervals in the settings page, under the
|
33 |
+
mailserver tab.</p>
|
34 |
+
|
35 |
+
<p>If you would prefer to have more fine-grained control of how postie checks
|
36 |
+
for mail, you can also set up a crontab. This is for advanced users only.
|
37 |
+
If your site runs on a UNIX/linux server, and you have shell access, you can
|
38 |
enable mail checking using cron; if you don't know anything about cron, skip
|
39 |
to the cronless postie section.</p>
|
40 |
|
41 |
+
<p>Setup a cronjob to pull down the get_mail.php
|
42 |
Examples:</p>
|
43 |
|
44 |
+
<p>*/5 * * * * /usr/bin/lynx --source <a href="http://blog.robfelty.com/wp-content/plugins/postie/get_mail.php" rel="nofollow">http://blog.robfelty.com/wp-content/plugins/postie/get_mail.php</a> >/dev/null 2>&1</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
<p>This fetches the mail every five minutes with lynx</p>
|
47 |
|
48 |
+
<p>*/10 * * * * /usr/bin/wget -O /dev/null <a href="http://blog.robfelty.com/wp-content/plugins/postie/get_mail.php" rel="nofollow">http://blog.robfelty.com/wp-content/plugins/postie/get_mail.php</a> >/dev/null 2>&1</p>
|
49 |
|
50 |
+
<p>This fetches the mail every ten minutes with wget</p> <hr />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
<h3>Usage</h3>
|
53 |
<ul>
|
126 |
you attached</li>
|
127 |
<li><p>Captions - you can also add a caption like so:</p>
|
128 |
|
129 |
+
<ul>
|
130 |
+
<li>#img1 caption='foo'#</li>
|
131 |
+
<li>#img2 caption='bar'#</li>
|
132 |
+
</ul>
|
133 |
|
134 |
<p>Or, if you use IPTC captions, this caption will be used (adding a caption
|
135 |
in many photo editing programs (for example Picasa), will add an IPTC caption)</p></li>
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: http://blog.robfelty.com/plugins/postie
|
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Tags: e-mail, email
|
6 |
Requires at least: 2.3
|
7 |
-
Tested up to:
|
8 |
-
Stable tag: 1.
|
9 |
|
10 |
The Postie plugin allows you to blog via e-mail, including many advanced
|
11 |
features not found in wordpress's default post by e-mail feature.
|
@@ -19,17 +19,23 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
|
|
19 |
|
20 |
= What's new? =
|
21 |
|
22 |
-
* 1.
|
23 |
-
*
|
24 |
-
*
|
25 |
-
|
26 |
-
*
|
27 |
-
* Fixed problem with
|
28 |
-
*
|
29 |
-
*
|
30 |
-
|
31 |
-
*
|
32 |
-
* Fixed
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
== Installation ==
|
35 |
* Either:
|
@@ -50,6 +56,12 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
|
|
50 |
|
51 |
= Automating checking e-mail =
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
If your site runs on a UNIX/linux server, and you have shell access, you can
|
54 |
enable mail checking using cron; if you don't know anything about cron, skip
|
55 |
to the cronless postie section.
|
@@ -65,21 +77,6 @@ This fetches the mail every five minutes with lynx
|
|
65 |
|
66 |
This fetches the mail every ten minutes with wget
|
67 |
|
68 |
-
= Cronless Postie =
|
69 |
-
|
70 |
-
If you don't have access to cron, you can run postie without it.
|
71 |
-
|
72 |
-
* Activate the cronless postie plugin (it is included with the postie plugin,
|
73 |
-
so if you have downloaded postie, you don't need to download anything else
|
74 |
-
* By default, cronless postie checks for new e-mail once every hour. To select
|
75 |
-
a different rate, change the cronless postie setting in the postie settings
|
76 |
-
page.
|
77 |
-
* Note that timing with cronless postie is not very accurate. It depends
|
78 |
-
on people visiting your website. If you select to check every 10 minutes, but
|
79 |
-
you only get one visit every 30 minutes, then it might take 30 minutes for a
|
80 |
-
post to show up.
|
81 |
-
|
82 |
-
|
83 |
== Usage ==
|
84 |
* If you put in :start - the message processing won't start until it sees that string
|
85 |
* If you put in :end - the message processing will stop once it sees that string
|
@@ -139,8 +136,9 @@ If you don't have access to cron, you can run postie without it.
|
|
139 |
#img2# - each one will be replaced with the HTML for the image
|
140 |
you attached
|
141 |
* Captions - you can also add a caption like so:
|
142 |
-
|
143 |
-
|
|
|
144 |
|
145 |
Or, if you use IPTC captions, this caption will be used (adding a caption
|
146 |
in many photo editing programs (for example Picasa), will add an IPTC caption)
|
@@ -314,9 +312,31 @@ sudo yuminstall php-imap
|
|
314 |
The IMAP extension is known to be installed on the following popular webhosts:
|
315 |
* Dreamhost
|
316 |
|
|
|
|
|
|
|
|
|
317 |
|
318 |
== CHANGELOG ==
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
= 1.3.4 (2009.10.05) =
|
321 |
* Fixed problem with images not posting under cron
|
322 |
* Fixed issue with disappearing password
|
4 |
Plugin URI: http://blog.robfelty.com/plugins/postie
|
5 |
Tags: e-mail, email
|
6 |
Requires at least: 2.3
|
7 |
+
Tested up to: 3.0.alpha
|
8 |
+
Stable tag: 1.4
|
9 |
|
10 |
The Postie plugin allows you to blog via e-mail, including many advanced
|
11 |
features not found in wordpress's default post by e-mail feature.
|
19 |
|
20 |
= What's new? =
|
21 |
|
22 |
+
* 1.4 (2010.04.25)
|
23 |
+
* Now using wordpress settings api (thanks for much help from Andrew S)
|
24 |
+
* Cronless postie is now integrated with postie instead of a plugin
|
25 |
+
* filterPostie.php moved to filterPostie.php.sample
|
26 |
+
* Can use fetchmails.php to fetch mail from multiple mailboxes
|
27 |
+
* Fixed problem with embedding youtube videos from html (richtext) e-mail
|
28 |
+
* Added support for embedding vimeo vidoes
|
29 |
+
* Fixed problem with selecting "none" as icon set for attachments (thanks
|
30 |
+
tonyvitali)
|
31 |
+
* Fixed problems with cronless postie settings
|
32 |
+
* Fixed bug with embedding youtube and vimeo videos whose ID contains a -
|
33 |
+
(thanks Jim Kehoe)
|
34 |
+
* Post_author is now included with attachments
|
35 |
+
* fixed confirmation_email settings so that now you can select between
|
36 |
+
sender, admin, both, or none (thanks to redsalmon for pointing out bug)
|
37 |
+
* Added option to automatically insert galleries
|
38 |
+
* Updated FAQ and readme
|
39 |
|
40 |
== Installation ==
|
41 |
* Either:
|
56 |
|
57 |
= Automating checking e-mail =
|
58 |
|
59 |
+
By default, postie checks for new e-mail every 30 minutes. You can select from
|
60 |
+
a number of different checking intervals in the settings page, under the
|
61 |
+
mailserver tab.
|
62 |
+
|
63 |
+
If you would prefer to have more fine-grained control of how postie checks
|
64 |
+
for mail, you can also set up a crontab. This is for advanced users only.
|
65 |
If your site runs on a UNIX/linux server, and you have shell access, you can
|
66 |
enable mail checking using cron; if you don't know anything about cron, skip
|
67 |
to the cronless postie section.
|
77 |
|
78 |
This fetches the mail every ten minutes with wget
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
== Usage ==
|
81 |
* If you put in :start - the message processing won't start until it sees that string
|
82 |
* If you put in :end - the message processing will stop once it sees that string
|
136 |
#img2# - each one will be replaced with the HTML for the image
|
137 |
you attached
|
138 |
* Captions - you can also add a caption like so:
|
139 |
+
|
140 |
+
* #img1 caption='foo'#
|
141 |
+
* #img2 caption='bar'#
|
142 |
|
143 |
Or, if you use IPTC captions, this caption will be used (adding a caption
|
144 |
in many photo editing programs (for example Picasa), will add an IPTC caption)
|
312 |
The IMAP extension is known to be installed on the following popular webhosts:
|
313 |
* Dreamhost
|
314 |
|
315 |
+
= How can I embed youtube or vimeo videos? =
|
316 |
+
|
317 |
+
Simply put the url in the body of your e-mail. (Make sure that you have the
|
318 |
+
option to convert url into links turned on)
|
319 |
|
320 |
== CHANGELOG ==
|
321 |
+
|
322 |
+
= 1.4 (2010.04.25) =
|
323 |
+
* Now using wordpress settings api (thanks for much help from Andrew S)
|
324 |
+
* Cronless postie is now integrated with postie instead of a separate plugin
|
325 |
+
* filterPostie.php moved to filterPostie.php.sample
|
326 |
+
* Can use fetchmails.php to fetch mail from multiple mailboxes
|
327 |
+
* Fixed problem with embedding youtube videos from html (richtext) e-mail
|
328 |
+
* Added support for embedding vimeo vidoes
|
329 |
+
* Fixed problem with selecting "none" as icon set for attachments (thanks
|
330 |
+
tonyvitali)
|
331 |
+
* Fixed problems with cronless postie settings
|
332 |
+
* Fixed bug with embedding youtube and vimeo videos whose ID contains a -
|
333 |
+
(thanks Jim Kehoe)
|
334 |
+
* Post_author is now included with attachments
|
335 |
+
* fixed confirmation_email settings so that now you can select between sender,
|
336 |
+
admin, both, or none (thanks to redsalmon for pointing out bug)
|
337 |
+
* Added option to automatically insert galleries
|
338 |
+
* Updated FAQ and readme
|
339 |
+
|
340 |
= 1.3.4 (2009.10.05) =
|
341 |
* Fixed problem with images not posting under cron
|
342 |
* Fixed issue with disappearing password
|
templates/audio_templates.php
CHANGED
@@ -7,6 +7,6 @@ $google_reader = '<embed type="application/x-shockwave-flash" ' .
|
|
7 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
8 |
|
9 |
$custom=$config['AUDIOTEMPLATE'];
|
10 |
-
$audioTemplates=
|
11 |
-
'custom')
|
12 |
?>
|
7 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
8 |
|
9 |
$custom=$config['AUDIOTEMPLATE'];
|
10 |
+
$audioTemplates=compact('google_reader','simple_link',
|
11 |
+
'custom');
|
12 |
?>
|
templates/image_templates.php
CHANGED
@@ -9,6 +9,6 @@ style="width: {MEDIUMWIDTH};"><a rel="attachment wp-att-{ID}" href="{PAGELINK}">
|
|
9 |
$postie_legacy = '<div class="postie-image-div"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{FILENAME}" title="{FILENAME}" style="border:none" class="postie-image" /></a></div>';
|
10 |
|
11 |
$custom=$config['IMAGETEMPLATE'];
|
12 |
-
$imageTemplates=
|
13 |
-
'wordpress_default','thumbnail_left','thumbnail_right','robert_felty','postie_legacy','custom')
|
14 |
?>
|
9 |
$postie_legacy = '<div class="postie-image-div"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{FILENAME}" title="{FILENAME}" style="border:none" class="postie-image" /></a></div>';
|
10 |
|
11 |
$custom=$config['IMAGETEMPLATE'];
|
12 |
+
$imageTemplates=compact('simple_link','no_wrappers',
|
13 |
+
'wordpress_default','thumbnail_left','thumbnail_right','robert_felty','postie_legacy','custom');
|
14 |
?>
|
templates/video1_templates.php
CHANGED
@@ -78,6 +78,6 @@ $large_widescreen = '<object '.
|
|
78 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
79 |
|
80 |
$custom=$config['VIDEO1TEMPLATE'];
|
81 |
-
$video1Templates=
|
82 |
-
'medium_widescreen', 'large','large_widescreen', 'custom')
|
83 |
?>
|
78 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
79 |
|
80 |
$custom=$config['VIDEO1TEMPLATE'];
|
81 |
+
$video1Templates=compact('simple_link','small', 'medium',
|
82 |
+
'medium_widescreen', 'large','large_widescreen', 'custom');
|
83 |
?>
|
templates/video2_templates.php
CHANGED
@@ -79,6 +79,6 @@ $flv_embed = '[flv:{FILELINK} 480 270]';
|
|
79 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
80 |
|
81 |
$custom=$config['VIDEO2TEMPLATE'];
|
82 |
-
$video2Templates=
|
83 |
-
'medium_widescreen', 'large','large_widescreen', 'flv_embed', 'custom')
|
84 |
?>
|
79 |
$simple_link = '<a href="{FILELINK}">{FILENAME}</a>';
|
80 |
|
81 |
$custom=$config['VIDEO2TEMPLATE'];
|
82 |
+
$video2Templates=compact('simple_link','small', 'medium',
|
83 |
+
'medium_widescreen', 'large','large_widescreen', 'flv_embed', 'custom');
|
84 |
?>
|