Changeset 1988169 in github


Ignore:
Timestamp:
Feb 11, 2008 6:21:15 PM (5 years ago)
Author:
till <till@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
6f99263
Parents:
ddbdb85
Message:
  • removed check.php (security issue)
  • added check.php-dist
  • new in check(.php-dist): smtp check, prettyfied errors
File:
1 moved

Legend:

Unmodified
Added
Removed
  • check.php-dist

    r731e0e5 r1988169  
    3838 * @todo     HTML/CSS to make it pretty. 
    3939 * @todo     In devel-next, use bootstrap. 
     40 * @todo     Refactor to use RoundCube classes. 
     41 */ 
     42 
     43$rctest_config         = array(); 
     44$rctest_config['from'] = '_yourfrom_'; 
     45 
     46/* 
     47 ******************************************** 
     48 ******************************************** 
     49 ** Don't edit anything else in this file. ** 
     50 ** Unless (of course) you know what you   ** 
     51 ** are doing.                             ** 
     52 ******************************************** 
     53 ******************************************** 
    4054 */ 
    4155 
     
    5367$path = dirname(__FILE__) . '/'; 
    5468?> 
    55 <html> 
     69<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd"> 
     70<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    5671<head> 
    5772    <link rel="shortcut icon" href="skins/default/images/favicon.ico"/> 
    5873    <link rel="stylesheet" type="text/css" href="skins/default/common.css" /> 
     74    <style type="text/css"> 
     75    /* <![CDATA[ */ 
     76    label { display:block; } 
     77    .success { color:#006400;font-weight:bold !important; } 
     78    .fail { color:#ff0000 !important;font-weight:bold !important; } 
     79    /* ]]> */ 
     80    </style> 
    5981    <title>RoundCube :: check</title> 
    6082</head> 
     
    6284<img src="skins/default/images/roundcube_logo.png" width="165" height="55" border="0" alt="RoundCube Webmail" hspace="12" vspace="2"/> 
    6385 
     86<h3>Check <?php echo basename(__FILE__); ?> Configuration</h3> 
     87From correctly set: 
     88<?php 
     89if ($rctest_config['from'] == '_yourfrom_') { 
     90    echo '<span class="fail">NOT OK</span></span>'; 
     91} else { 
     92    echo $rctest_config['from'] . '<br /><br />'; 
     93    echo '<i>We do not check if this is a <b>valid</b> email address. Since this serves as from &amp; to, make sure it is correct!</i>'; 
     94} 
     95?> 
     96<br /> 
    6497<?php 
    6598echo '<h3>Check if directories are writable</h3>'; 
     
    69102    echo "Directory $dir: "; 
    70103    if (!is_writable($path . $dir)) { 
    71         echo 'NOT OK'; 
    72     } else { 
    73         echo 'OK'; 
     104        echo '<span class="fail">NOT OK</span></span>'; 
     105    } else { 
     106        echo '<span class="success">OK</span>'; 
    74107    } 
    75108    echo "<br />"; 
     
    82115    echo "File $file: "; 
    83116    if (file_exists($path . $file) && is_readable($path . $file)) { 
    84         echo 'OK'; 
    85     } else { 
    86         echo 'NOT OK'; 
     117        echo '<span class="success">OK</span>'; 
     118    } else { 
     119        echo '<span class="fail">NOT OK</span></span>'; 
    87120    } 
    88121    echo '<br />'; 
     
    98131    $db = MDB2::connect($rcmail_config['db_dsnw']); 
    99132    if (!MDB2::IsError($db)) { 
    100         echo 'OK'; 
     133        echo '<span class="success">OK</span>'; 
    101134        $db->disconnect(); 
    102135        $db_working = true; 
    103136    } else { 
    104         echo 'NOT OK'; 
     137        echo '<span class="fail">NOT OK</span></span>'; 
    105138    } 
    106139    echo '<br />'; 
     
    125158 
    126159    if ($tz_db != $tz_local) { 
    127         echo 'NOT OK'; 
    128     } else { 
    129         echo 'OK'; 
     160        echo '<span class="fail">NOT OK</span></span>'; 
     161    } else { 
     162        echo '<span class="success">OK</span>'; 
    130163    } 
    131164} else { 
     
    142175echo 'status: '; 
    143176if ($auto_start == 1) { 
    144     echo 'NOT OK'; 
    145 } else { 
    146     echo 'OK'; 
     177    echo '<span class="fail">NOT OK</span></span>'; 
     178} else { 
     179    echo '<span class="success">OK</span>'; 
    147180} 
    148181echo '<br />'; 
     
    151184echo 'status: '; 
    152185if ($file_uploads == 1) { 
    153     echo 'OK'; 
    154 } else { 
    155     echo 'NOT OK'; 
     186    echo '<span class="success">OK</span>'; 
     187} else { 
     188    echo '<span class="fail">NOT OK</span></span>'; 
    156189} 
    157190 
     
    162195$save_path = ini_get('session.save_path'); 
    163196if (empty($save_path)) { 
    164     echo 'NOT OK'; 
    165 } else { 
    166     echo "OK: $save_path"; 
     197    echo '<span class="fail">NOT OK</span></span>'; 
     198} else { 
     199    echo "<span class="success">OK</span>: $save_path"; 
    167200    if (!file_exists($save_path)) { 
    168201        echo ', but it does not exist'; 
     
    175208echo '<br />'; 
    176209 */ 
     210 
     211@include_once $path . '/config/main.inc.php'; 
     212?> 
     213<h3>Check email settings</h3> 
     214<h4>SMTP Settings</h4> 
     215<?php 
     216echo 'Fetch config from config/main.inc.php: '; 
     217if (is_array($rcmail_config) && count($rcmail_config)) { 
     218    echo '<span class="success">OK</span><br />'; 
     219    echo 'server: ' . $rcmail_config['smtp_server'] . '<br />'; 
     220    echo 'port: ' . $rcmail_config['smtp_port'] . '<br />'; 
     221    echo 'user: ' . (($rcmail_config['smtp_user'] == '%u')?'<i>use current session</i>':$rcmail_config['smtp_user']) . '<br />'; 
     222    echo 'pass: ' . (($rcmail_config['smtp_pass'] == '%p')?'<i>use current session</i>':$rcmail_config['smtp_pass']) . '<br />'; 
     223    //var_dump($rcmail_config); 
     224?> 
     225<h3>Test SMTP settings - send an email</h3> 
     226<p>Don't abuse this!</p> 
     227<form action="check.php" method="post"> 
     228<?php 
     229if ($rcmail_config['smtp_server'] != ''): 
     230    if ($rcmail_config['smtp_user'] == '%u'): 
     231?> 
     232<label>Username:</label><input type="text" name="smtp_test[user]" /> 
     233<label>Passwort:</label><input type="text" name="smtp_test[pass]" /><br /> 
     234<?php 
     235    endif; 
     236endif; 
     237?> 
     238Recipient:<br /> 
     239<?php echo $rctest_config['from']; ?><br /><br /> 
     240<input type="submit" value="send an email" /> 
     241</form> 
     242<?php 
     243    if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
     244 
     245        echo 'Trying to send email: '; 
     246        if ($rctest_config['from'] == '_yourfrom_') { 
     247            echo '<span class="fail">NOT OK</span></span><br />'; 
     248            echo '<i>Please edit $rctest_config in ' . basename(__FILE__) . '</i><br />'; 
     249        } else { 
     250 
     251            $data = $_POST['smtp_test']; 
     252 
     253            require_once 'Mail.php'; 
     254 
     255            $recipients = $rctest_config['from']; 
     256 
     257            $headers['From']    = $rctest_config['from']; 
     258            $headers['To']      = $recipients; 
     259            $headers['Subject'] = 'Test message from RoundCube'; 
     260 
     261            $body = 'This is a test to confirm that RoundCube can send email.'; 
     262 
     263            $params      = array(); 
     264            $mail_driver = ''; 
     265 
     266            if ($rcmail_config['smtp_server'] != '') { 
     267                $mail_driver = 'smtp'; 
     268 
     269                if (isset($data['user'])) { 
     270                    $params['username'] = $data['user']; 
     271                    $params['password'] = $data['pass']; 
     272                    $params['auth']     = true; 
     273                } 
     274 
     275                $params['host'] = $rcmail_config['smtp_server']; 
     276                $params['port'] = $rcmail_config['smtp_port']; 
     277 
     278            } else { 
     279                $mail_driver = 'mail'; 
     280            } 
     281 
     282            $mail_object =& Mail::factory($mail_driver, $params); 
     283            $status = $mail_object->send($recipients, $headers, $body); 
     284            if (!PEAR::isError($status)) { 
     285                echo '<span class="success">OK</span><br />'; 
     286            } else { 
     287                echo '<span class="fail">NOT OK</span></span>'; 
     288                echo '<br />' . $status->getMessage(); 
     289            } 
     290        } 
     291    } 
     292} else { 
     293    echo '<span class="fail">NOT OK</span></span>'; 
     294} 
    177295?> 
    178296</body> 
Note: See TracChangeset for help on using the changeset viewer.