Source for file configtest.php

Documentation is available at configtest.php

  1. <?php
  2. echo "Disallowed"die;
  3.  
  4. /**
  5.  * SquirrelMail configtest script
  6.  *
  7.  * @copyright 2003-2020 The SquirrelMail Project Team
  8.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9.  * @version $Id: configtest.php 14840 2020-01-07 07:42:38Z pdontthink $
  10.  * @package squirrelmail
  11.  * @subpackage config
  12.  */
  13.  
  14. /************************************************************
  15.  * NOTE: you do not need to change this script!             *
  16.  * If it throws errors you need to adjust your config.      *
  17.  ************************************************************/
  18.  
  19. function do_err($str$exit TRUE{
  20.     global $IND;
  21.     echo '<p>'.$IND.'<font color="red"><b>ERROR:</b></font> ' .$str"</p>\n";
  22.     if($exit{
  23.          echo '</body></html>';
  24.          exit;
  25.     }
  26. }
  27.  
  28. /** This is the configtest page */
  29. define('PAGE_NAME''configtest');
  30.  
  31. /** @ignore */
  32. define('SM_PATH''../');
  33.  
  34. /*
  35.  * Load config before output begins.
  36.  * functions/global.php cleans environment, then loads
  37.  * functions/strings.php and config/config.php
  38.  */
  39. if (file_exists(SM_PATH 'config/config.php')) {
  40.     include(SM_PATH 'functions/global.php');
  41. }
  42. $IND str_repeat('&nbsp;',4);
  43.  
  44. // this must be done before the output is started because it may use the
  45. // session
  46. $test_location get_location();
  47. ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  48. <html>
  49. <head>
  50.   <meta name="robots" content="noindex,nofollow">
  51.   <title>SquirrelMail configtest</title>
  52. </head>
  53. <body>
  54. <h1>SquirrelMail configtest</h1>
  55.  
  56. <p>This script will try to check some aspects of your SquirrelMail configuration
  57. and point you to errors whereever it can find them. You need to go run <tt>conf.pl</tt>
  58. in the <tt>config/</tt> directory first before you run this script.</p>
  59.  
  60. <?php
  61.  
  62. $included array_map('basename'get_included_files() );
  63. if(!in_array('config.php'$included)) {
  64.     if(!file_exists(SM_PATH 'config/config.php')) {
  65.         do_err('Config file '.SM_PATH 'config/config.php does not exist!<br />'.
  66.                 'You need to run <tt>conf.pl</tt> first.');
  67.     }
  68.     do_err('Could not read '.SM_PATH.'config/config.php! Check file permissions.');
  69. }
  70. if(!in_array('strings.php'$included)) {
  71.     do_err('Could not include '.SM_PATH.'functions/strings.php!<br />'.
  72.             'Check permissions on that file.');
  73. }
  74.  
  75. /* checking PHP specs */
  76.  
  77. echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" $version "</b></td></tr>\n" .
  78.      '<tr><td>Config file version:</td><td><b>' $config_version "</b></td></tr>\n" .
  79.      '<tr><td>Config file last modified:</td><td><b>' .
  80.          date ('d F Y H:i:s'filemtime(SM_PATH 'config/config.php')) .
  81.          "</b></td></tr>\n</table>\n</p>\n\n";
  82.  
  83. echo "Checking PHP configuration...<br />\n";
  84.  
  85. if(!check_php_version(4,1,0)) {
  86.     do_err('Insufficient PHP version: 'PHP_VERSION '! Minimum required: 4.1.0');
  87. }
  88.  
  89. echo $IND 'PHP version ' PHP_VERSION " OK.<br />\n";
  90.  
  91. // try to determine information about the user and group the web server is running as
  92. //
  93. $webOwnerID 'N/A';
  94. $webOwnerInfo array('name' => 'N/A');
  95. if (function_exists('posix_getuid'))
  96.     $webOwnerID posix_getuid();
  97. if ($webOwnerID === FALSE)
  98.     $webOwnerID 'N/A';
  99. if ($webOwnerID !== 'N/A' && function_exists('posix_getpwuid'))
  100.     $webOwnerInfo posix_getpwuid($webOwnerID);
  101. if (!$webOwnerInfo)
  102.     $webOwnerInfo array('name' => 'N/A');
  103. $webGroupID 'N/A';
  104. $webGroupInfo array('name' => 'N/A');
  105. if (function_exists('posix_getgid'))
  106.     $webGroupID posix_getgid();
  107. if ($webGroupID === FALSE)
  108.     $webGroupID 'N/A';
  109. if ($webGroupID !== 'N/A' && function_exists('posix_getgrgid'))
  110.     $webGroupInfo posix_getgrgid($webGroupID);
  111. if (!$webGroupInfo)
  112.     $webGroupInfo array('name' => 'N/A');
  113.  
  114. echo $IND 'Running as ' $webOwnerInfo['name''(' $webOwnerID
  115.           . ') / ' $webGroupInfo['name''(' $webGroupID ")<br />\n";
  116.  
  117. echo $IND 'display_errors: ' ini_get('display_errors'"<br />\n";
  118.  
  119. echo $IND 'error_reporting: ' ini_get('error_reporting'"<br />\n";
  120.  
  121. if ((bool) ini_get('session.auto_start'&& ini_get('session.auto_start'!= 'off'{
  122.     $msg 'session.auto_start is turned on in your PHP configuration, but SquirrelMail'
  123.          . ' 1.4.x will not work with it (otherwise valid logins will usually'
  124.          . ' result in "You must be logged in to access this page" errors).'
  125.          . ' You can disable session.auto_start only in the squirrelmail directory' 
  126.          . ' if you need to leave it turned on for other applications.';
  127.     do_err($msgtrue);
  128. }
  129.  
  130. $safe_mode ini_get('safe_mode');
  131. if ($safe_mode{
  132.     echo $IND 'safe_mode: ' $safe_mode;
  133.     if (empty($prefs_dsn|| empty($addrbook_dsn))
  134.         echo ' (<font color="red">double check data and attachment directory ownership, etc!</font>)';
  135.     if (!empty($addrbook_dsn|| !empty($prefs_dsn|| !empty($addrbook_global_dsn))
  136.         echo ' (<font color="red">does PHP have access to database interface?</font>)';
  137.     echo "<br />\n";
  138.     $safe_mode_exec_dir ini_get('safe_mode_exec_dir');
  139.     echo $IND 'safe_mode_exec_dir: ' $safe_mode_exec_dir "<br />\n";
  140. }
  141.  
  142. /* variables_order check */
  143.  
  144. // FIXME(?): Hmm, how do we distinguish between when an ini setting is
  145. //           not available (ini_set() returns empty string) and when
  146. //           the administrator set the value to an empty string?  The
  147. //           latter is sure to be highly rare, so for now, just assume
  148. //           that empty value means the setting isn't even available
  149. //           (could also check PHP version when this setting was implemented)
  150. //           although, we'll also warn the user if it is empty, with
  151. //           a non-fatal error
  152. $variables_order strtoupper(ini_get('variables_order'));
  153. if (empty($variables_order))
  154.     do_err('Your variables_order setting seems to be empty.  Make sure it is undefined in any PHP ini files, .htaccess files, etc. and not specifically set to an empty value or SquirrelMail may not function correctly'false);
  155. else if (strpos($variables_order'G'=== FALSE
  156.  || strpos($variables_order'P'=== FALSE
  157.  || strpos($variables_order'C'=== FALSE
  158.  || strpos($variables_order'S'=== FALSE{
  159.     do_err('Your variables_order setting is insufficient for SquirrelMail to function.  It needs at least "GPCS", but you have it set to "' sm_encode_html_special_chars($variables_order'"'true);
  160. else {
  161.     echo $IND "variables_order OK: $variables_order.<br />\n";
  162. }
  163.  
  164.  
  165. /* gpc_order check (removed from PHP as of v5.0) */
  166.  
  167. if (!check_php_version(5)) {
  168.     // FIXME(?): Hmm, how do we distinguish between when an ini setting is
  169.     //           not available (ini_set() returns empty string) and when
  170.     //           the administrator set the value to an empty string?  The
  171.     //           latter is sure to be highly rare, so for now, just assume
  172.     //           that empty value means the setting isn't even available
  173.     //           (could also check PHP version when this setting was implemented)
  174.     //           although, we'll also warn the user if it is empty, with
  175.     //           a non-fatal error
  176.     $gpc_order strtoupper(ini_get('gpc_order'));
  177.     if (empty($gpc_order))
  178.         do_err('Your gpc_order setting seems to be empty.  Make sure it is undefined in any PHP ini files, .htaccess files, etc. and not specifically set to an empty value or SquirrelMail may not function correctly'false);
  179.     else if (strpos($gpc_order'G'=== FALSE
  180.      || strpos($gpc_order'P'=== FALSE
  181.      || strpos($gpc_order'C'=== FALSE{
  182.         do_err('Your gpc_order setting is insufficient for SquirrelMail to function.  It needs to be set to "GPC", but you have it set to "' sm_encode_html_special_chars($gpc_order'"'true);
  183.     else {
  184.         echo $IND "gpc_order OK: $gpc_order.<br />\n";
  185.     }
  186. }
  187.  
  188.  
  189. $php_exts array('session','pcre');
  190. $diff array_diff($php_extsget_loaded_extensions());
  191. if(count($diff)) {
  192.     do_err('Required PHP extensions missing: '.implode(', ',$diff) );
  193. }
  194.  
  195. echo $IND "PHP extensions OK. Dynamic loading is ";
  196.  
  197. if (!(bool)ini_get('enable_dl'|| (bool)ini_get('safe_mode')) {
  198.     echo "disabled.<br />\n";
  199. else {
  200.     echo "enabled.<br />\n";
  201. }
  202.  
  203.  
  204. /* dangerous php settings */
  205. /** mbstring.func_overload<>0 fix. See cvs HEAD comments. */
  206. if (function_exists('mb_internal_encoding'&&
  207.     check_php_version(4,2,0&&
  208.     (int)ini_get('mbstring.func_overload')!=0{
  209.     $mb_error='You have enabled mbstring overloading.'
  210.         .' It can cause problems with SquirrelMail scripts that rely on single byte string functions.';
  211.     do_err($mb_error);
  212. }
  213.  
  214. /**
  215.  * We code with register_globals = off. SquirrelMail should work in such setup
  216.  * since 1.2.9 and 1.3.0. Running SquirrelMail with register_globals = on can
  217.  * cause variable corruption and security issues. Globals can be turned off in
  218.  * php.ini, webserver config and .htaccess files. Scripts can turn off globals only
  219.  * in php 4.2.3 or older.
  220.  */
  221. if ((bool) ini_get('register_globals'&&
  222.     ini_get('register_globals'!= 'off'{
  223.     $rg_error='You have enabled PHP register_globals.'
  224.         .' Running PHP installation with register_globals=on can cause problems.'
  225.         .' See <a href="http://www.php.net/manual/en/security.registerglobals.php">'
  226.         .'security information about register_globals</a>.';
  227.     do_err($rg_error,false);
  228. }
  229.  
  230. /**
  231.  * Do not use SquirrelMail with magic_quotes_* on.
  232.  */
  233. if ( (function_exists('get_magic_quotes_runtime'&&  @get_magic_quotes_runtime()) ||
  234.      (function_exists('get_magic_quotes_gpc'&& @get_magic_quotes_gpc()) ||
  235.     (bool) ini_get('magic_quotes_sybase'&& ini_get('magic_quotes_sybase'!= 'off' )
  236.     {
  237.     $magic_quotes_warning='You have enabled any one of <tt>magic_quotes_runtime</tt>, '
  238.         .'<tt>magic_quotes_gpc</tt> or <tt>magic_quotes_sybase</tt> in your PHP '
  239.         .'configuration. We recommend all those settings to be off. SquirrelMail '
  240.         .'may work with them on, but when experiencing stray backslashes in your mail '
  241.         .'or other strange behaviour, it may be advisable to turn them off.';
  242.     do_err($magic_quotes_warning,false);
  243. }
  244.  
  245. if (ini_get('short_open_tag'== 0{
  246.     $short_open_tag_warning 'You have configured PHP not to allow short tags '
  247.         . '(<tt>short_open_tag=off</tt>). This shouldn\'t be a problem with '
  248.         . 'SquirrelMail or any plugin coded coded according to the '
  249.         . 'SquirrelMail Coding Guidelines, but if you experience problems with '
  250.         . 'PHP code being displayed in some of the pages and changing setting '
  251.         . 'to "on" solves the problem, please file a bug report against the '
  252.         . 'failing plugin. The correct contact information is most likely '
  253.         . 'to be found in the plugin documentation.';
  254.     do_err($short_open_tag_warningfalse);
  255. }
  256.  
  257. /* checking paths */
  258.  
  259. echo "Checking paths...<br />\n";
  260.  
  261. if(!file_exists($data_dir)) {
  262.     do_err("Data dir ($data_dir) does not exist!");
  263. }
  264. if(!is_dir($data_dir)) {
  265.     do_err("Data dir ($data_dir) is not a directory!");
  266. }
  267. // datadir should be executable - but no clean way to test on that
  268. if(!is_writable($data_dir)) {
  269.     do_err("I cannot write to data dir ($data_dir)!");
  270. }
  271.  
  272. // todo_ornot: actually write something and read it back.
  273. echo $IND "Data dir OK.<br />\n";
  274.  
  275.  
  276. if($data_dir == $attachment_dir{
  277.     echo $IND "Attachment dir is the same as data dir.<br />\n";
  278. else {
  279.     if(!file_exists($attachment_dir)) {
  280.         do_err("Attachment dir ($attachment_dir) does not exist!");
  281.     }
  282.     if (!is_dir($attachment_dir)) {
  283.         do_err("Attachment dir ($attachment_dir) is not a directory!");
  284.     }
  285.     if (!is_writable($attachment_dir)) {
  286.         do_err("I cannot write to attachment dir ($attachment_dir)!");
  287.     }
  288.     echo $IND "Attachment dir OK.<br />\n";
  289. }
  290.  
  291.  
  292. /* check plugins and themes */
  293. if (isset($plugins[0])) {
  294.     foreach($plugins as $plugin{
  295.         if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
  296.             do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot find it.'FALSE);
  297.         elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
  298.             do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot read its setup.php file.'FALSE);
  299.         }
  300.     }
  301.     // load plugin functions
  302.     include_once(SM_PATH 'functions/i18n.php');  // so some plugins can run "normal" code that switches text domain
  303.     include_once(SM_PATH 'functions/plugin.php');
  304.     // turn on output buffering in order to prevent output of new lines
  305.     ob_start();
  306.     foreach ($plugins as $name{
  307.         use_plugin($name);
  308.     }
  309.     // get output and remove whitespace
  310.     $output trim(ob_get_contents());
  311.     ob_end_clean();
  312.     // if plugins output more than newlines and spacing, stop script execution.
  313.     if (!empty($output)) {
  314.         $plugin_load_error 'Some output is produced when plugins are loaded. Usually this means there is an error in one of the plugin setup or configuration files. The output was: '.sm_encode_html_special_chars($output);
  315.         do_err($plugin_load_error);
  316.     }
  317.     /**
  318.      * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
  319.      * message and return TRUE if there are any errors in its setup/configuration.
  320.      */
  321.     $plugin_err boolean_hook_function('configtest'NULL1);
  322.     if($plugin_err{
  323.         do_err('Some plugin tests failed.');
  324.     else {
  325.         echo $IND "Plugins OK.<br />\n";
  326.     }
  327. else {
  328.     echo $IND "Plugins are not enabled in config.<br />\n";
  329. }
  330. foreach($theme as $thm{
  331.     if(!file_exists($thm['PATH'])) {
  332.         do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').'FALSE);
  333.     elseif(!is_readable($thm['PATH'])) {
  334.         do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').'FALSE);
  335.     }
  336. }
  337.  
  338. echo $IND "Themes OK.<br />\n";
  339.  
  340. if $squirrelmail_default_language != 'en_US' {
  341.     $loc_path SM_PATH .'locale/'.$squirrelmail_default_language.'/LC_MESSAGES/squirrelmail.mo';
  342.     iffile_exists$loc_path ) ) {
  343.         do_err('You have set <i>' $squirrelmail_default_language .
  344.                 '</i> as your default language, but I cannot find this translation (should be '.
  345.                 'in <tt>' $loc_path '</tt>). Please note that you have to download translations '.
  346.                 'separately from the main SquirrelMail package.'FALSE);
  347.     elseif is_readable$loc_path ) ) {
  348.         do_err('You have set <i>' $squirrelmail_default_language .
  349.                 '</i> as your default language, but I cannot read this translation (file '.
  350.                 'in <tt>' $loc_path '</tt> unreadable).'FALSE);
  351.     else {
  352.         echo $IND "Default language OK.<br />\n";
  353.     }
  354. else {
  355.     echo $IND "Default language OK.<br />\n";
  356. }
  357.  
  358. echo $IND "Base URL detected as: <tt>" sm_encode_html_special_chars($test_location.
  359.     "</tt> (location base " (empty($config_location_base'autodetected' 'set to <tt>' .
  360.     sm_encode_html_special_chars($config_location_base)."</tt>"")<br />\n";
  361.  
  362. /* check minimal requirements for other security options */
  363.  
  364. /* imaps or ssmtp */
  365. if($use_smtp_tls == || $use_imap_tls == 1{
  366.     if(!check_php_version(4,3,0)) {
  367.         do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
  368.     }
  369.     if(!extension_loaded('openssl')) {
  370.         do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
  371.     }
  372. }
  373. /* starttls extensions */
  374. if($use_smtp_tls === || $use_imap_tls === 2{
  375.     if (function_exists('stream_socket_enable_crypto')) {
  376.         do_err('If you want to use STARTTLS extension, you need stream_socket_enable_crypto() function from PHP 5.1.0 and newer.');
  377.     }
  378. }
  379. /* digest-md5 */
  380. if ($smtp_auth_mech=='digest-md5' || $imap_auth_mech =='digest-md5'{
  381.     if (!extension_loaded('xml')) {
  382.         do_err('You need the PHP XML extension to use Digest-MD5 authentication!');
  383.     }
  384. }
  385.  
  386. /* check outgoing mail */
  387.  
  388. echo "Checking outgoing mail service....<br />\n";
  389.  
  390. if($useSendmail{
  391.     // is_executable also checks for existance, but we want to be as precise as possible with the errors
  392.     if(!file_exists($sendmail_path)) {
  393.         do_err("Location of sendmail program incorrect ($sendmail_path)!");
  394.     }
  395.     if(!is_executable($sendmail_path)) {
  396.         do_err("I cannot execute the sendmail program ($sendmail_path)!");
  397.     }
  398.  
  399.     echo $IND "sendmail OK<br />\n";
  400. else {
  401.     // NB: Using "ssl://" ensures the highest possible TLS version
  402.     // will be negotiated with the server (whereas "tls://" only
  403.     // uses TLS version 1.0)
  404.     $stream fsockopen( ($use_smtp_tls?'ssl://':'').$smtpServerAddress$smtpPort,
  405.             $errorNumber$errorString);
  406.     if(!$stream{
  407.         do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
  408.                 "Server error: ($errorNumber".sm_encode_html_special_chars($errorString));
  409.     }
  410.  
  411.     // check for SMTP code; should be 2xx to allow us access
  412.     $smtpline fgets($stream1024);
  413.     if(((int) $smtpline{0}3{
  414.         do_err("Error connecting to SMTP server. Server error: ".
  415.                 sm_encode_html_special_chars($smtpline));
  416.     }
  417.  
  418.     fputs($stream'QUIT');
  419.     fclose($stream);
  420.     echo $IND 'SMTP server OK (<tt><small>'.
  421.             trim(sm_encode_html_special_chars($smtpline))."</small></tt>)<br />\n";
  422.  
  423.     /* POP before SMTP */
  424.     if($pop_before_smtp{
  425.         if (empty($pop_before_smtp_host)) $pop_before_smtp_host $smtpServerAddress;
  426.         $stream fsockopen($pop_before_smtp_host110$err_no$err_str);
  427.         if (!$stream{
  428.             do_err("Error connecting to POP Server ($pop_before_smtp_host:110) "
  429.                 . $err_no ' : ' sm_encode_html_special_chars($err_str));
  430.         }
  431.  
  432.         $tmp fgets($stream1024);
  433.         if (substr($tmp03!= '+OK'{
  434.             do_err("Error connecting to POP Server ($pop_before_smtp_host:110)"
  435.                 . ' '.sm_encode_html_special_chars($tmp));
  436.         }
  437.         fputs($stream'QUIT');
  438.         fclose($stream);
  439.         echo $IND "POP-before-SMTP OK.<br />\n";
  440.     }
  441. }
  442.  
  443. /**
  444.  * Check the IMAP server
  445.  */
  446. echo "Checking IMAP service....<br />\n";
  447.  
  448. /** Can we open a connection? */
  449. // NB: Using "ssl://" ensures the highest possible TLS version
  450. // will be negotiated with the server (whereas "tls://" only
  451. // uses TLS version 1.0)
  452. $stream fsockopen( ($use_imap_tls?'ssl://':'').$imapServerAddress$imapPort,
  453.         $errorNumber$errorString);
  454. if(!$stream{
  455.     do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
  456.             "Server error: ($errorNumber".
  457.             sm_encode_html_special_chars($errorString));
  458. }
  459.  
  460. /** Is the first response 'OK'? */
  461. $imapline fgets($stream1024);
  462. if(substr($imapline0,4!= '* OK'{
  463.     do_err('Error connecting to IMAP server. Server error: '.
  464.             sm_encode_html_special_chars($imapline));
  465. }
  466.  
  467. echo $IND 'IMAP server ready (<tt><small>'.
  468.     sm_encode_html_special_chars(trim($imapline))."</small></tt>)<br />\n";
  469.  
  470. /** Check capabilities */
  471. fputs($stream"A001 CAPABILITY\r\n");
  472. $capline fgets($stream1024);
  473.  
  474. echo $IND 'Capabilities: <tt>'.sm_encode_html_special_chars($capline)."</tt><br />\n";
  475.  
  476. if($imap_auth_mech == 'login' && stristr($capline'LOGINDISABLED'!== FALSE{
  477.     do_err('Your server doesn\'t allow plaintext logins. '.
  478.             'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '.
  479.             'in the SquirrelMail configuration.'FALSE);
  480. }
  481.  
  482. if (stristr($capline'XMAGICTRASH'!== false{
  483.     $magic_trash 'It looks like IMAP_MOVE_EXPUNGE_TO_TRASH option is turned on '
  484.         .'in your Courier IMAP configuration. Courier does not provide tools that '
  485.         .'allow to detect folder used for Trash or commands are not documented. '
  486.         .'SquirrelMail can\'t detect special trash folder. SquirrelMail manages '
  487.         .'all message deletion or move operations internally and '
  488.         .'IMAP_MOVE_EXPUNGE_TO_TRASH option can cause errors in message and '
  489.         .'folder management operations. Please turn off IMAP_MOVE_EXPUNGE_TO_TRASH '
  490.         .'option in Courier imapd configuration.';
  491.     do_err($magic_trash,false);
  492. }
  493.  
  494. /* add warning about IMAP delivery */
  495. if (stristr($capline'XCOURIEROUTBOX'!== false{
  496.     $courier_outbox 'OUTBOX setting is enabled in your Courier imapd '
  497.         .'configuration. SquirrelMail uses standard SMTP protocol or sendmail '
  498.         .'binary to send emails. Courier IMAP delivery method is not supported'
  499.         .' and can create duplicate email messages.';
  500.     do_err($courier_outbox,false);
  501. }
  502.  
  503. /** OK, close connection */
  504. fputs($stream"A002 LOGOUT\r\n");
  505. fclose($stream);
  506.  
  507. echo "Checking internationalization (i18n) settings...<br />\n";
  508. echo "$IND gettext - ";
  509. if (function_exists('gettext')) {
  510.     echo 'Gettext functions are available.'
  511.         .' On some systems you must have appropriate system locales compiled.'
  512.         ."<br />\n";
  513. else {
  514.     echo 'Gettext functions are unavailable.'
  515.         .' SquirrelMail will use slower internal gettext functions.'
  516.         ."<br />\n";
  517. }
  518. echo "$IND mbstring - ";
  519. if (function_exists('mb_detect_encoding')) {
  520.     echo "Mbstring functions are available.<br />\n";
  521. else {
  522.     echo 'Mbstring functions are unavailable.'
  523.         ." Japanese translation won't work.<br />\n";
  524. }
  525. echo "$IND recode - ";
  526. if (function_exists('recode')) {
  527.     echo "Recode functions are available.<br />\n";
  528. elseif (isset($use_php_recode&& $use_php_recode{
  529.     echo "Recode functions are unavailable.<br />\n";
  530.     do_err('Your configuration requires recode support, but recode support is missing.');
  531. else {
  532.     echo "Recode functions are unavailable.<br />\n";
  533. }
  534. echo "$IND iconv - ";
  535. if (function_exists('iconv')) {
  536.     echo "Iconv functions are available.<br />\n";
  537. elseif (isset($use_php_iconv&& $use_php_iconv{
  538.     echo "Iconv functions are unavailable.<br />\n";
  539.     do_err('Your configuration requires iconv support, but iconv support is missing.');
  540. else {
  541.     echo "Iconv functions are unavailable.<br />\n";
  542. }
  543. // same test as in include/validate.php
  544. echo "$IND timezone - ";
  545. if ( (!ini_get('safe_mode')) ||
  546.     !strcmp(ini_get('safe_mode_allowed_env_vars'),''||
  547.     preg_match('/^([\w_]+,)*TZ/'ini_get('safe_mode_allowed_env_vars')) ) {
  548.         echo "Webmail users can change their time zone settings.<br />\n";
  549. else {
  550.     echo "Webmail users can't change their time zone settings.<br />\n";
  551. }
  552.  
  553. // Database tests
  554. echo "Checking database functions...<br />\n";
  555. if(!empty($addrbook_dsn|| !empty($prefs_dsn|| !empty($addrbook_global_dsn)) {
  556.     $dsns array();
  557.     if($prefs_dsn{
  558.         $dsns['preferences'$prefs_dsn;
  559.     }
  560.     if($addrbook_dsn{
  561.         $dsns['addressbook'$addrbook_dsn;
  562.     }
  563.     if($addrbook_global_dsn{
  564.         $dsns['global addressbook'$addrbook_global_dsn;
  565.     }
  566.  
  567.     global $disable_pdo$use_pdo;
  568.     if (empty($disable_pdo&& class_exists('PDO'))
  569.         $use_pdo TRUE;
  570.     else
  571.         $use_pdo FALSE;
  572.  
  573.     if ($use_pdo{
  574.  
  575.         // test connecting to each DSN
  576.         foreach($dsns as $type => $dsn{
  577.  
  578.             // parse and convert DSN to PDO style
  579.             // $matches will contain:
  580.             // 1: database type
  581.             // 2: username
  582.             // 3: password
  583.             // 4: hostname
  584.             // 5: database name
  585. //TODO: add support for unix_socket and charset
  586.             if (!preg_match('|^(.+)://(.+):(.+)@(.+)/(.+)$|i'$dsn$matches)) {
  587.                 return $this->set_error(_("Could not parse prefs DSN"));
  588.                 do_err('DSN parse error in ' .$type .' DSN.');
  589.             }
  590.             if (preg_match('|^(.+):(\d+)$|'$matches[4]$host_port_matches)) {
  591.                 $matches[4$host_port_matches[1];
  592.                 $matches[6$host_port_matches[2];
  593.             else
  594.                 $matches[6NULL;
  595.             $pdo_prefs_dsn $matches[1':host=' $matches[4(!empty($matches[6]';port=' $matches[6''';dbname=' $matches[5];
  596.             try {
  597.                 $dbh new PDO($pdo_prefs_dsn$matches[2]$matches[3]);
  598.             catch (Exception $e{
  599.                 do_err('Database error: 'sm_encode_html_special_chars($e->getMessage()) .
  600.                         ' in ' .$type .' DSN.');
  601.             }
  602.             echo "$IND$type database connect successful.<br />\n";
  603.         }
  604.  
  605.     else {
  606.         @include_once('DB.php');
  607.         if (class_exists('DB')) {
  608.             echo "$IND PHP Pear DB support is present, however it is deprecated and PHP PDO is recommended.<br />\n"
  609.                 .(!empty($disable_pdo"$IND You have set \$disable_pdo - if you experience errors below, try removing that.<br />\n'');
  610.             $db_functions=array(
  611.                     'dbase' => 'dbase_open',
  612.                     'fbsql' => 'fbsql_connect',
  613.                     'interbase' => 'ibase_connect',
  614.                     'informix' => 'ifx_connect',
  615.                     'msql' => 'msql_connect',
  616.                     'mssql' => 'mssql_connect',
  617.                     'mysql' => 'mysql_connect',
  618.                     'mysqli' => 'mysqli_connect',
  619.                     'oci8' => 'ocilogon',
  620.                     'odbc' => 'odbc_connect',
  621.                     'pgsql' => 'pg_connect',
  622.                     'sqlite' => 'sqlite_open',
  623.                     'sybase' => 'sybase_connect'
  624.                     );
  625.  
  626.             foreach($dsns as $type => $dsn{
  627.                 $aDsn explode(':'$dsn);
  628.                 $dbtype array_shift($aDsn);
  629.  
  630.                 if(isset($db_functions[$dbtype]&& function_exists($db_functions[$dbtype])) {
  631.                     echo "$IND$dbtype database support present.<br />\n";
  632.                 elseif(!(bool)ini_get('enable_dl'|| (bool)ini_get('safe_mode')) {
  633.                     do_err($dbtype.' database support not present!');
  634.                 else {
  635.                     // Non-fatal error
  636.                     do_err($dbtype.' database support not present or not configured!
  637.                         Trying to dynamically load '.$dbtype.' extension.
  638.                         Please note that it is advisable to not rely on dynamic loading of extensions.'FALSE);
  639.                 }
  640.  
  641.  
  642.                 // now, test this interface:
  643.  
  644.                 $dbh DB::connect($dsntrue);
  645.                 if (DB::isError($dbh)) {
  646.                     do_err('Database error: 'sm_encode_html_special_chars(DB::errorMessage($dbh)) .
  647.                             ' in ' .$type .' DSN.');
  648.                 }
  649.                 $dbh->disconnect();
  650.                 echo "$IND$type database connect successful.<br />\n";
  651.             }
  652.         else {
  653.             $db_error='Required PHP PDO or PEAR DB support is not available.'
  654.                 .(!empty($disable_pdo' You have set $disable_pdo - please try removing that.' '')
  655.                 .' PDO should come preinstalled with PHP version 5.1 or higher.'
  656.                 .' Otherwise, is PEAR installed and is the include path set correctly to find <tt>DB.php</tt>?'
  657.                 .' The include path is now: "<tt>' ini_get('include_path''</tt>".';
  658.             do_err($db_error);
  659.         }
  660.     }
  661. else {
  662.     echo $IND."not using database functionality.<br />\n";
  663. }
  664. ?>
  665.  
  666. <p>Congratulations, your SquirrelMail setup looks fine to me!</p>
  667.  
  668. <p><a href="login.php">Login now</a></p>
  669.  
  670. </body>
  671. </html>

Documentation generated on Mon, 13 Jan 2020 04:24:22 +0100 by phpDocumentor 1.4.3