comparison installer/test.php @ 8:bf99236cc5cd default tip

try to recover from upgrade fail
author Charlie Root
date Sat, 29 Dec 2018 07:07:34 -0500
parents 4681f974d28b
children
comparison
equal deleted inserted replaced
7:65fd7d441cf1 8:bf99236cc5cd
177 // more database tests 177 // more database tests
178 if ($db_working) { 178 if ($db_working) {
179 // write test 179 // write test
180 $insert_id = md5(uniqid()); 180 $insert_id = md5(uniqid());
181 $db_write = $DB->query("INSERT INTO " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') 181 $db_write = $DB->query("INSERT INTO " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session')
182 . " (`sess_id`, `created`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id); 182 . " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
183 183
184 if ($db_write) { 184 if ($db_write) {
185 $RCI->pass('DB Write'); 185 $RCI->pass('DB Write');
186 $DB->query("DELETE FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session') 186 $DB->query("DELETE FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session')
187 . " WHERE `sess_id` = ?", $insert_id); 187 . " WHERE `sess_id` = ?", $insert_id);
244 244
245 245
246 <h3>Test SMTP config</h3> 246 <h3>Test SMTP config</h3>
247 247
248 <p> 248 <p>
249 Server: <?php echo rcube_parse_host($RCI->getprop('smtp_server', 'PHP mail()')); ?><br /> 249 Server: <?php echo rcube_utils::parse_host($RCI->getprop('smtp_server', 'localhost')); ?><br />
250 Port: <?php echo $RCI->getprop('smtp_port'); ?><br /> 250 Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
251 251
252 <?php 252 <?php
253 253
254 if ($RCI->getprop('smtp_server')) { 254 if ($RCI->getprop('smtp_server')) {
255 $user = $RCI->getprop('smtp_user', '(none)'); 255 $user = $RCI->getprop('smtp_user', '(none)');
256 $pass = $RCI->getprop('smtp_pass', '(none)'); 256 $pass = $RCI->getprop('smtp_pass', '(none)');
257 257
258 if ($user == '%u') { 258 if ($user == '%u') {
259 $user_field = new html_inputfield(array('name' => '_smtp_user')); 259 $user_field = new html_inputfield(array('name' => '_smtp_user'));
260 $user = $user_field->show($_POST['_smtp_user']); 260 $user = $user_field->show($_POST['_smtp_user']);
261 } 261 }
262 if ($pass == '%p') { 262 if ($pass == '%p') {
263 $pass_field = new html_passwordfield(array('name' => '_smtp_pass')); 263 $pass_field = new html_passwordfield(array('name' => '_smtp_pass'));
264 $pass = $pass_field->show(); 264 $pass = $pass_field->show();
265 } 265 }
266 266
267 echo "User: $user<br />"; 267 echo "User: $user<br />";
268 echo "Password: $pass<br />"; 268 echo "Password: $pass<br />";
269 } 269 }
270 270
271 $from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom')); 271 $from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom'));
291 'To' => $to, 291 'To' => $to,
292 'Subject' => 'Test message from Roundcube', 292 'Subject' => 'Test message from Roundcube',
293 ); 293 );
294 294
295 $body = 'This is a test to confirm that Roundcube can send email.'; 295 $body = 'This is a test to confirm that Roundcube can send email.';
296 $smtp_response = array();
297 296
298 // send mail using configured SMTP server 297 // send mail using configured SMTP server
299 if ($RCI->getprop('smtp_server')) { 298 $CONFIG = $RCI->config;
300 $CONFIG = $RCI->config; 299
301 300 if (!empty($_POST['_smtp_user'])) {
302 if (!empty($_POST['_smtp_user'])) { 301 $CONFIG['smtp_user'] = $_POST['_smtp_user'];
303 $CONFIG['smtp_user'] = $_POST['_smtp_user']; 302 }
304 } 303 if (!empty($_POST['_smtp_pass'])) {
305 if (!empty($_POST['_smtp_pass'])) { 304 $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
306 $CONFIG['smtp_pass'] = $_POST['_smtp_pass']; 305 }
307 } 306
308 307 $mail_object = new Mail_mime();
309 $mail_object = new Mail_mime(); 308 $send_headers = $mail_object->headers($headers);
310 $send_headers = $mail_object->headers($headers); 309 $head = $mail_object->txtHeaders($send_headers);
311 310
312 $SMTP = new rcube_smtp(); 311 $SMTP = new rcube_smtp();
313 $SMTP->connect(rcube_parse_host($RCI->getprop('smtp_server')), 312 $SMTP->connect(rcube_utils::parse_host($RCI->getprop('smtp_server')),
314 $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']); 313 $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
315 314
316 $status = $SMTP->send_mail($headers['From'], $headers['To'], 315 $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body);
317 ($foo = $mail_object->txtHeaders($send_headers)), $body); 316 $smtp_response = $SMTP->get_response();
318
319 $smtp_response = $SMTP->get_response();
320 }
321 else { // use mail()
322 $header_str = 'From: ' . $headers['From'];
323
324 if (ini_get('safe_mode'))
325 $status = mail($headers['To'], $headers['Subject'], $body, $header_str);
326 else
327 $status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']);
328
329 if (!$status)
330 $smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
331 }
332 317
333 if ($status) { 318 if ($status) {
334 $RCI->pass('SMTP send'); 319 $RCI->pass('SMTP send');
335 } 320 }
336 else { 321 else {
338 } 323 }
339 } 324 }
340 else { 325 else {
341 $RCI->fail('SMTP send', 'Invalid sender or recipient'); 326 $RCI->fail('SMTP send', 'Invalid sender or recipient');
342 } 327 }
343 328
344 echo '</p>'; 329 echo '</p>';
345 } 330 }
346 331
347 ?> 332 ?>
348 333
403 388
404 <?php 389 <?php
405 390
406 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) { 391 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
407 392
408 echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />'; 393 echo '<p>Connecting to ' . rcube::Q($_POST['_host']) . '...<br />';
409 394
410 $imap_host = trim($_POST['_host']); 395 $imap_host = trim($_POST['_host']);
411 $imap_port = $RCI->getprop('default_port'); 396 $imap_port = $RCI->getprop('default_port');
412 $a_host = parse_url($imap_host); 397 $a_host = parse_url($imap_host);
413 398