/
postie_test.php
138 lines (125 loc) · 5.23 KB
/
postie_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
// try to connect to server with different protocols/ and userids
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . "wp-config.php");
require_once("postie-functions.php");
$config = config_Read();
extract($config);
$title = __("Postie Diagnosis");
$parent_file = 'options-general.php?page=postie/postie.php';
get_currentuserinfo();
if (!current_user_can('manage_options')) {
LogInfo("non-admin tried to set options");
echo "<h2> Sorry only admin can run this file</h2>";
exit();
}
DebugEcho("Error log: " . ini_get('error_log'));
?>
<div class="wrap">
<h1>Postie Configuration Test</h1>
<?php
if (isMarkdownInstalled()) {
EchoInfo("You currently have the Markdown plugin installed. It will cause problems if you send in HTML email. Please turn it off if you intend to send email using HTML.");
}
if (!isPostieInCorrectDirectory()) {
EchoInfo("Warning! Postie expects to be in its own directory named postie.");
} else {
EchoInfo("Postie is in " . dirname(__FILE__));
}
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
EchoInfo("Alternate cron is enabled");
}
if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
EchoInfo("WordPress cron is disabled. Postie will not run unless you have an external cron set up.");
}
EchoInfo("Cron: " . (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true ? "Of" : "On"));
EchoInfo("Alternate Cron: " . (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON === true ? "On" : "Off"));
if (defined('WP_CRON_LOCK_TIMEOUT') && WP_CRON_LOCK_TIMEOUT === true) {
EchoInfo("Cron lock timeout is:" . WP_CRON_LOCK_TIMEOUT);
}
?>
<br/>
<h2>International support</h2>
<?php
if (HasIconvInstalled()) {
EchoInfo("iconv: installed");
} else {
EchoInfo("Warning! Postie requires that iconv be enabled.");
}
if (function_exists('imap_mime_header_decode')) {
EchoInfo("imap: installed");
} else {
EchoInfo("Warning! Postie requires that imap be enabled if you are using IMAP, IMAP-SSL or POP3-SSL.");
}
if (HasMbStringInstalled()) {
EchoInfo("mbstring: installed");
} else {
EchoInfo("Warning! Postie requires that mbstring be enabled.");
}
?>
<h2>Clock Tests</h2>
<p>This shows what time it would be if you posted right now</p>
<?php
$content = "";
$data = filter_Delay($content);
EchoInfo("GMT: $data[1]");
EchoInfo("Current: $data[0]");
?>
<h2>Connect to Mail Host</h2>
<?php
if (!$mail_server || !$mail_server_port || !$mail_userid) {
EchoInfo("NO - check server settings");
} else {
DebugEcho("checking");
}
switch (strtolower($config["input_protocol"])) {
case 'imap':
case 'imap-ssl':
case 'pop3-ssl':
if (!HasIMAPSupport()) {
EchoInfo("Sorry - you do not have IMAP php module installed - it is required for this mail setting.");
} else {
require_once("postieIMAP.php");
$mail_server = &PostieIMAP::Factory($config["input_protocol"]);
if ($email_tls) {
$mail_server->TLSOn();
}
if (!$mail_server->connect($config["mail_server"], $config["mail_server_port"], $config["mail_userid"], $config["mail_password"])) {
EchoInfo("Unable to connect. The server said:");
EchoInfo($mail_server->error());
} else {
EchoInfo("Successful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
EchoInfo("# of waiting messages: " . $mail_server->getNumberOfMessages());
}
}
break;
case 'pop3':
default:
require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'class-pop3.php');
$pop3 = new POP3();
if (defined('POSTIE_DEBUG')) {
$pop3->DEBUG = POSTIE_DEBUG;
}
if (!$pop3->connect($config["mail_server"], $config["mail_server_port"])) {
EchoInfo("Unable to connect. The server said:" . $pop3->ERROR);
} else {
EchoInfo("Sucessful " . strtoupper($config['input_protocol']) . " connection on port {$config["mail_server_port"]}");
$msgs = $pop3->login($config["mail_userid"], $config["mail_password"]);
if ($msgs === false) {
//workaround for bug reported here Apr 12, 2013
//https://sourceforge.net/tracker/?func=detail&atid=100311&aid=3610701&group_id=311
//originally repoted here:
//https://core.trac.wordpress.org/ticket/10587
if (empty($pop3->ERROR))
EchoInfo("No waiting messages");
else
EchoInfo("Unable to login. The server said:" . $pop3->ERROR);
} else {
EchoInfo("# of waiting messages: $msgs");
}
$pop3->quit();
}
break;
}
?>
</div>