| 1 |
<?php |
| 2 |
|
| 3 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-config.class.php'); |
| 4 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie.class.php'); |
| 5 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-message.php'); |
| 6 |
|
| 7 |
/* |
| 8 |
* These are the only official public methods for accessing postie functionality |
| 9 |
*/ |
| 10 |
|
| 11 |
function lookup_taxonomy($termid) { |
| 12 |
return postie_lookup_taxonomy_name($termid); |
| 13 |
} |
| 14 |
|
| 15 |
function lookup_category($trial_category, $category_match) { |
| 16 |
return postie_lookup_category_id($trial_category, $category_match); |
| 17 |
} |
| 18 |
|
| 19 |
function RemoveExtraCharactersInEmailAddress($address) { |
| 20 |
$c = new PostieConfig(); |
| 21 |
$m = new PostieMessage(array(), $c->config_read()); |
| 22 |
return $m->get_clean_emailaddress($address); |
| 23 |
} |
| 24 |
|
| 25 |
function EchoError($v) { |
| 26 |
global $g_postie; |
| 27 |
if (!empty($g_postie)) { |
| 28 |
$g_postie->log_error($v); |
| 29 |
} |
| 30 |
try { |
| 31 |
do_action('postie_log_debug', $v); |
| 32 |
} catch (Throwable $exc) { |
| 33 |
echo('postie_log_debug: ' . $exc->getMessage() . "\n" . $exc->getTraceAsString()); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
function DebugDump($v) { |
| 38 |
global $g_postie; |
| 39 |
$d = print_r($v, true); |
| 40 |
if (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG && !empty($g_postie)) { |
| 41 |
$g_postie->log_onscreen($d); |
| 42 |
} |
| 43 |
try { |
| 44 |
do_action('postie_log_debug', $d); |
| 45 |
} catch (Throwable $exc) { |
| 46 |
EchoError('postie_log_debug: ' . $exc->getMessage() . "\n" . $exc->getTraceAsString()); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
function DebugEcho($v, $force = false) { |
| 51 |
global $g_postie; |
| 52 |
if ($force || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) { |
| 53 |
if (!empty($g_postie)) { |
| 54 |
$g_postie->log_onscreen($v); |
| 55 |
} |
| 56 |
} |
| 57 |
try { |
| 58 |
do_action('postie_log_debug', $v); |
| 59 |
} catch (Throwable $exc) { |
| 60 |
EchoError('postie_log_debug: ' . $exc->getMessage() . "\n" . $exc->getTraceAsString()); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
function postie_config_read() { |
| 65 |
$pconfig = new PostieConfig(); |
| 66 |
return $pconfig->config_read(); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* called by WP cron |
| 71 |
*/ |
| 72 |
function postie_check() { |
| 73 |
//don't use DebugEcho or EchoInfo here as it is not defined when called as an action |
| 74 |
//error_log("check_postie"); |
| 75 |
global $g_postie; |
| 76 |
if (!empty($g_postie)) { |
| 77 |
$g_postie->get_mail(); |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
function postie_get_mail() { |
| 82 |
//don't use DebugEcho or EchoInfo here as it is not defined when called as an action |
| 83 |
//error_log("check_postie"); |
| 84 |
global $g_postie; |
| 85 |
if (!empty($g_postie)) { |
| 86 |
$g_postie->get_mail(); |
| 87 |
} |
| 88 |
} |
| 89 |
|