Source for file configtest.php

Documentation is available at configtest.php

  1. <?php
  2.  
  3. /**
  4.  * SquirrelMail configtest script
  5.  *
  6.  * @copyright 2003-2020 The SquirrelMail Project Team
  7.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8.  * @version $Id: configtest.php 14845 2020-01-07 08:09:34Z pdontthink $
  9.  * @package squirrelmail
  10.  * @subpackage config
  11.  */
  12.  
  13. /************************************************************
  14.  * NOTE: you do not need to change this script!             *
  15.  * If it throws errors you need to adjust your config.      *
  16.  ************************************************************/
  17.  
  18. /** This is the configtest page */
  19. define('PAGE_NAME''configtest');
  20.  
  21. // This script could really use some restructuring as it has grown quite rapidly
  22. // but is not very 'clean'. Feel free to get some structure into this thing.
  23.  
  24. // force verbose error reporting and turn on display of errors, but not before
  25. // getting their original values
  26. $php_display_errors_original_value ini_get('display_errors');
  27. $php_error_reporting_original_value ini_get('error_reporting');
  28. ini_set('display_errors',1);
  29.  
  30. /** Blockcopy from init.php. Cleans globals. */
  31. if ((bool) ini_get('register_globals'&&
  32.     strtolower(ini_get('register_globals'))!='off'{
  33.     /**
  34.      * Remove all globals that are not reserved by PHP
  35.      * 'value' and 'key' are used by foreach. Don't unset them inside foreach.
  36.      */
  37.     foreach ($GLOBALS as $key => $value{
  38.         switch($key{
  39.         case 'HTTP_POST_VARS':
  40.         case '_POST':
  41.         case 'HTTP_GET_VARS':
  42.         case '_GET':
  43.         case 'HTTP_COOKIE_VARS':
  44.         case '_COOKIE':
  45.         case 'HTTP_SERVER_VARS':
  46.         case '_SERVER':
  47.         case 'HTTP_ENV_VARS':
  48.         case '_ENV':
  49.         case 'HTTP_POST_FILES':
  50.         case '_FILES':
  51.         case '_REQUEST':
  52.         case 'HTTP_SESSION_VARS':
  53.         case '_SESSION':
  54.         case 'GLOBALS':
  55.         case 'key':
  56.         case 'value':
  57.             break;
  58.         default:
  59.             unset($GLOBALS[$key]);
  60.         }
  61.     }
  62.     // Unset variables used in foreach
  63.     unset($GLOBALS['key']);
  64.     unset($GLOBALS['value']);
  65. }
  66.  
  67.  
  68. /**
  69.  * Displays error messages and warnings
  70.  * @param string $str message
  71.  * @param boolean $fatal fatal error or only warning
  72.  */
  73. function do_err($str$fatal TRUE{
  74.     global $IND$warnings;
  75.     $level $fatal 'FATAL ERROR:' 'WARNING:';
  76.     echo '<p>'.$IND.'<font color="red"><b>' $level '</b></font> ' .$str"</p>\n";
  77.     if($fatal{
  78.         echo '</body></html>';
  79.         exit;
  80.     else {
  81.         $warnings++;
  82.     }
  83. }
  84.  
  85. /** @ignore */
  86. define('SM_PATH''../');
  87. /** load minimal function set */
  88. require(SM_PATH 'include/constants.php');
  89. require(SM_PATH 'functions/global.php');
  90. require(SM_PATH 'functions/strings.php');
  91. require(SM_PATH 'functions/files.php');
  92. $SQM_INTERNAL_VERSION explode('.'SM_VERSION3);
  93. $SQM_INTERNAL_VERSION[2intval($SQM_INTERNAL_VERSION[2]);
  94.  
  95. /** set default value in order to block remote access */
  96. $allow_remote_configtest=false;
  97.  
  98. /** Load all configuration files before output begins */
  99.  
  100. /* load default configuration */
  101. require(SM_PATH 'config/config_default.php');
  102. /* reset arrays in default configuration */
  103. $ldap_server array();
  104. $plugins array();
  105. $fontsets array();
  106. $theme array();
  107. $theme[0]['PATH'SM_PATH 'themes/default_theme.php';
  108. $theme[0]['NAME''Default';
  109. $aTemplateSet array();
  110. $aTemplateSet[0]['ID''default';
  111. $aTemplateSet[0]['NAME''Default';
  112. /* load site configuration */
  113. if (file_exists(SM_PATH 'config/config.php')) {
  114.     require(SM_PATH 'config/config.php');
  115. }
  116. /* load local configuration overrides */
  117. if (file_exists(SM_PATH 'config/config_local.php')) {
  118.     require(SM_PATH 'config/config_local.php');
  119. }
  120.  
  121. sqGetGlobalVar('REMOTE_ADDR',$client_ip,SQ_SERVER);
  122. sqGetGlobalVar('SERVER_ADDR',$server_ip,SQ_SERVER);
  123.  
  124. /**
  125.  * Include Compatibility plugin if available.
  126.  */
  127. if (!$disable_plugins && file_exists(SM_PATH 'plugins/compatibility/functions.php'))
  128.     include_once(SM_PATH 'plugins/compatibility/functions.php');
  129.  
  130. /** Load plugins */
  131. global $disable_plugins;
  132. $squirrelmail_plugin_hooks array();
  133. if (!$disable_plugins && file_exists(SM_PATH 'config/plugin_hooks.php')) {
  134.     require(SM_PATH 'config/plugin_hooks.php');
  135. }
  136.  
  137. /** Warning counter */
  138. $warnings 0;
  139.  
  140. /** indent */
  141. $IND str_repeat('&nbsp;',4);
  142.  
  143. /**
  144.  * get_location starts session and must be run before output is started.
  145.  */
  146. $test_location get_location();
  147.  
  148. ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  149.   "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
  150. <html>
  151. <head>
  152.   <meta name="robots" content="noindex,nofollow">
  153.   <title>SquirrelMail configtest</title>
  154. </head>
  155. <body>
  156. <h1>SquirrelMail configtest</h1>
  157.  
  158. <p>This script will try to check some aspects of your SquirrelMail configuration
  159. and point you to errors whereever it can find them. You need to go run <tt>conf.pl</tt>
  160. in the <tt>config/</tt> directory first before you run this script.</p>
  161.  
  162. <?php
  163.  
  164. $included array_map('basename'get_included_files() );
  165. if(!in_array('config.php'$included)) {
  166.     if(!file_exists(SM_PATH 'config/config.php')) {
  167.         do_err('Config file '.SM_PATH 'config/config.php does not exist!<br />'.
  168.                 'You need to run <tt>conf.pl</tt> first.');
  169.     }
  170.     do_err('Could not read '.SM_PATH.'config/config.php! Check file permissions.');
  171. }
  172. if(!in_array('strings.php'$included)) {
  173.     do_err('Could not include '.SM_PATH.'functions/strings.php!<br />'.
  174.             'Check permissions on that file.');
  175. }
  176.  
  177. /* Block remote use of script */
  178. if ($allow_remote_configtest{
  179.  
  180.     if ((isset($client_ip|| $client_ip!='127.0.0.1'&&
  181.             (isset($client_ip|| isset($server_ip|| $client_ip!=$server_ip)) {
  182.         do_err('Enable "Allow remote configtest" option in squirrelmail configuration in order to use this script.');
  183.     }
  184. }
  185.  
  186. echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" SM_VERSION "</b></td></tr>\n" .
  187.     '<tr><td>Config file version:</td><td><b>' $config_version "</b></td></tr>\n" .
  188.     '<tr><td>Config file last modified:</td><td><b>' .
  189.     date ('d F Y H:i:s'filemtime(SM_PATH 'config/config.php')) .
  190.     "</b></td></tr>\n</table>\n</p>\n\n";
  191.  
  192. /* check $config_version */
  193. if ($config_version!='1.5.0'{
  194.     do_err('Configuration file version does not match required version. Please update your configuration file.');
  195. }
  196.  
  197.  
  198. /* checking PHP specs */
  199.  
  200. echo "Checking PHP configuration...<br />\n";
  201.  
  202. if(!check_php_version(4,1,0)) {
  203.     do_err('Insufficient PHP version: 'PHP_VERSION '! Minimum required: 4.1.0');
  204. }
  205.  
  206. echo $IND 'PHP version ' PHP_VERSION ' OK. (You have: ' phpversion(". Minimum: 4.1.0)<br />\n";
  207.  
  208. // try to determine information about the user and group the web server is running as
  209. //
  210. $webOwnerID 'N/A';
  211. $webOwnerInfo array('name' => 'N/A');
  212. if (function_exists('posix_getuid'))
  213.     $webOwnerID posix_getuid();
  214. if ($webOwnerID === FALSE)
  215.     $webOwnerID 'N/A';
  216. if ($webOwnerID !== 'N/A' && function_exists('posix_getpwuid'))
  217.     $webOwnerInfo posix_getpwuid($webOwnerID);
  218. if (!$webOwnerInfo)
  219.     $webOwnerInfo array('name' => 'N/A');
  220. $webGroupID 'N/A';
  221. $webGroupInfo array('name' => 'N/A');
  222. if (function_exists('posix_getgid'))
  223.     $webGroupID posix_getgid();
  224. if ($webGroupID === FALSE)
  225.     $webGroupID 'N/A';
  226. if ($webGroupID !== 'N/A' && function_exists('posix_getgrgid'))
  227.     $webGroupInfo posix_getgrgid($webGroupID);
  228. if (!$webGroupInfo)
  229.     $webGroupInfo array('name' => 'N/A');
  230.  
  231. echo $IND 'Running as ' $webOwnerInfo['name''(' $webOwnerID
  232.           . ') / ' $webGroupInfo['name''(' $webGroupID ")<br />\n";
  233.  
  234. echo $IND 'display_errors: ' $php_display_errors_original_value " (overridden with 1 for this page only)<br />\n";
  235.  
  236. echo $IND 'error_reporting: ' $php_error_reporting_original_value " (overridden with " E_ALL " for this page only)<br />\n";
  237.  
  238. $safe_mode ini_get('safe_mode');
  239. if ($safe_mode{
  240.     //FIXME: should show that safe_mode is off when it is (this only shows the safe_mode setting when it's on) (also might be generally helpful to show things like open_basedir, too or even add phpinfo() output or a link to another script that has phpinfo()
  241.     echo $IND 'safe_mode: ' $safe_mode;
  242.     if (empty($prefs_dsn|| empty($addrbook_dsn))
  243.         echo ' (<font color="red">double check data and attachment directory ownership, etc!</font>)';
  244.     if (!empty($addrbook_dsn|| !empty($prefs_dsn|| !empty($addrbook_global_dsn))
  245.         echo ' (<font color="red">does PHP have access to database interface?</font>)';
  246.     echo "<br />\n";
  247.     $safe_mode_exec_dir ini_get('safe_mode_exec_dir');
  248.     echo $IND 'safe_mode_exec_dir: ' $safe_mode_exec_dir "<br />\n";
  249. }
  250.  
  251. /* register_globals check: test for boolean false and any string that is not equal to 'off' */
  252.  
  253. if ((bool) ini_get('register_globals'&&
  254.     strtolower(ini_get('register_globals'))!='off'{
  255.     do_err('You have register_globals turned on. This is not an error, but it CAN be a security hazard. Consider turning register_globals off.'false);
  256. }
  257.  
  258.  
  259. /* variables_order check */
  260.  
  261. // FIXME(?): Hmm, how do we distinguish between when an ini setting is not available (ini_set() returns empty string) and when the administrator set the value to an empty string? The latter is sure to be highly rare, so for now, just assume that empty value means the setting isn't even available (could also check PHP version when this setting was implemented) although, we'll also warn the user if it is empty, with a non-fatal error
  262. $variables_order strtoupper(ini_get('variables_order'));
  263. if (empty($variables_order))
  264.     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);
  265. else if (strpos($variables_order'G'=== FALSE
  266.  || strpos($variables_order'P'=== FALSE
  267.  || strpos($variables_order'C'=== FALSE
  268.  || strpos($variables_order'S'=== FALSE{
  269.     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);
  270. else {
  271.     echo $IND "variables_order OK: $variables_order.<br />\n";
  272. }
  273.  
  274.  
  275. /* gpc_order check (removed from PHP as of v5.0) */
  276.  
  277. if (!check_php_version(5)) {
  278.     // FIXME(?): Hmm, how do we distinguish between when an ini setting is not available (ini_set() returns empty string) and when the administrator set the value to an empty string? The latter is sure to be highly rare, so for now, just assume that empty value means the setting isn't even available (could also check PHP version when this setting was implemented) although, we'll also warn the user if it is empty, with a non-fatal error
  279.     $gpc_order strtoupper(ini_get('gpc_order'));
  280.     if (empty($gpc_order))
  281.         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);
  282.     else if (strpos($gpc_order'G'=== FALSE
  283.      || strpos($gpc_order'P'=== FALSE
  284.      || strpos($gpc_order'C'=== FALSE{
  285.         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);
  286.     else {
  287.         echo $IND "gpc_order OK: $gpc_order.<br />\n";
  288.     }
  289. }
  290.  
  291.  
  292. /* check PHP extensions */
  293.  
  294. $php_exts array('session','pcre');
  295. $diff array_diff($php_extsget_loaded_extensions());
  296. if(count($diff)) {
  297.     do_err('Required PHP extensions missing: '.implode(', ',$diff) );
  298. }
  299.  
  300. echo $IND "PHP extensions OK. Dynamic loading is ";
  301.  
  302. if (!(bool)ini_get('enable_dl'|| (bool)ini_get('safe_mode')) {
  303.     echo "disabled.<br />\n";
  304. else {
  305.     echo "enabled.<br />\n";
  306. }
  307.  
  308.  
  309. /* dangerous php settings */
  310. /**
  311.  * mbstring.func_overload allows to replace original string and regexp functions
  312.  * with their equivalents from php mbstring extension. It causes problems when
  313.  * scripts analyze 8bit strings byte after byte or use 8bit strings in regexp tests.
  314.  * Setting can be controlled in php.ini (php 4.2.0), webserver config (php 4.2.0)
  315.  * and .htaccess files (php 4.3.5).
  316.  */
  317. if (function_exists('mb_internal_encoding'&&
  318.     check_php_version(4,2,0&&
  319.     (int)ini_get('mbstring.func_overload')!=0{
  320.     $mb_error='You have enabled mbstring overloading.'
  321.         .' It can cause problems with SquirrelMail scripts that rely on single byte string functions.';
  322.     do_err($mb_error);
  323. }
  324.  
  325. /**
  326.  * Do not use SquirrelMail with magic_quotes_* on.
  327.  */
  328. if ( (function_exists('get_magic_quotes_runtime'&&  @get_magic_quotes_runtime()) ||
  329.      (function_exists('get_magic_quotes_gpc'&& @get_magic_quotes_gpc()) ||
  330.     (bool) ini_get('magic_quotes_sybase'&& ini_get('magic_quotes_sybase'!= 'off' )
  331.     {
  332.     $magic_quotes_warning='You have enabled any one of <tt>magic_quotes_runtime</tt>, '
  333.         .'<tt>magic_quotes_gpc</tt> or <tt>magic_quotes_sybase</tt> in your PHP '
  334.         .'configuration. We recommend all those settings to be off. SquirrelMail '
  335.         .'may work with them on, but when experiencing stray backslashes in your mail '
  336.         .'or other strange behaviour, it may be advisable to turn them off.';
  337.     do_err($magic_quotes_warning,false);
  338. }
  339.  
  340. if (ini_get('short_open_tag'== 0{
  341.     $short_open_tag_warning 'You have configured PHP not to allow short tags '
  342.         . '(<tt>short_open_tag=off</tt>). This shouldn\'t be a problem with '
  343.         . 'SquirrelMail or any plugin coded coded according to the '
  344.         . 'SquirrelMail Coding Guidelines, but if you experience problems with '
  345.         . 'PHP code being displayed in some of the pages and changing setting '
  346.         . 'to "on" solves the problem, please file a bug report against the '
  347.         . 'failing plugin. The correct contact information is most likely '
  348.         . 'to be found in the plugin documentation.';
  349.     do_err($short_open_tag_warningfalse);
  350. }
  351.  
  352.  
  353. /* check who the web server is running as if possible */
  354.  
  355. if ($process_info get_process_owner_info()) {
  356.     echo $IND 'Web server is running as user: ' $process_info['name'' (' $process_info['uid'")<br />\n";
  357.     //echo $IND . 'Web server is running as effective user: ' . $process_info['ename'] . ' (' . $process_info['euid'] . ")<br />\n";
  358.     echo $IND 'Web server is running as group: ' $process_info['group'' (' $process_info['gid'")<br />\n";
  359.     //echo $IND . 'Web server is running as effective group: ' . $process_info['egroup'] . ' (' . $process_info['egid'] . ")<br />\n";
  360. }
  361.  
  362.  
  363. /* checking paths */
  364.  
  365. echo "Checking paths...<br />\n";
  366.  
  367. if(!file_exists($data_dir)) {
  368.     // data_dir is not that important in db_setups.
  369.     if (!empty($prefs_dsn)) {
  370.         $data_dir_error "Data dir ($data_dir) does not exist!\n";
  371.         echo $IND .'<font color="red"><b>ERROR:</b></font> ' $data_dir_error;
  372.     else {
  373.         do_err("Data dir ($data_dir) does not exist!");
  374.     }
  375. }
  376. // don't check if errors
  377. if(!isset($data_dir_error&& !is_dir($data_dir)) {
  378.     if (!empty($prefs_dsn)) {
  379.         $data_dir_error "Data dir ($data_dir) is not a directory!\n";
  380.         echo $IND '<font color="red"><b>ERROR:</b></font> ' $data_dir_error;
  381.     else {
  382.         do_err("Data dir ($data_dir) is not a directory!");
  383.     }
  384. }
  385. // datadir should be executable - but no clean way to test on that
  386. if(!isset($data_dir_error&& !sq_is_writable($data_dir)) {
  387.     if (!empty($prefs_dsn)) {
  388.         $data_dir_error "Data dir ($data_dir) is not writable!\n";
  389.         echo $IND '<font color="red"><b>ERROR:</b></font> ' $data_dir_error;
  390.     else {
  391.         do_err("Data dir ($data_dir) is not writable!");
  392.     }
  393. }
  394.  
  395. if (isset($data_dir_error)) {
  396.     echo " Some plugins might need access to data directory.<br />\n";
  397. else {
  398.     // todo_ornot: actually write something and read it back.
  399.     echo $IND "Data dir OK.<br />\n";
  400. }
  401.  
  402. if($data_dir == $attachment_dir{
  403.     echo $IND "Attachment dir is the same as data dir.<br />\n";
  404.     if (isset($data_dir_error)) {
  405.         do_err($data_dir_error);
  406.     }
  407. else {
  408.     if(!file_exists($attachment_dir)) {
  409.         do_err("Attachment dir ($attachment_dir) does not exist!");
  410.     }
  411.     if (!is_dir($attachment_dir)) {
  412.         do_err("Attachment dir ($attachment_dir) is not a directory!");
  413.     }
  414.     if (!sq_is_writable($attachment_dir)) {
  415.         do_err("I cannot write to attachment dir ($attachment_dir)!");
  416.     }
  417.     echo $IND "Attachment dir OK.<br />\n";
  418. }
  419.  
  420.  
  421. echo "Checking plugins...<br />\n";
  422.  
  423. /* check plugins and themes */
  424. //FIXME: check requirements given in plugin _info() function, such as required PHP extensions, Pear packages, other plugins, SM version, etc see development docs for list of returned info from that function
  425. //FIXME: update this list with most recent contents of the Obsolete category - I think it has changed recently
  426. $bad_plugins array(
  427.         'attachment_common',      // Integrated into SquirrelMail 1.2 core
  428.         'auto_prune_sent',        // Obsolete: See Proon Automatic Folder Pruning plugin
  429.         'compose_new_window',     // Integrated into SquirrelMail 1.4 core
  430.         'delete_move_next',       // Integrated into SquirrelMail 1.5 core
  431.         'disk_quota',             // Obsolete: See Check Quota plugin
  432.         'email_priority',         // Integrated into SquirrelMail 1.2 core
  433.         'emoticons',              // Obsolete: See HTML Mail plugin
  434.         'focus_change',           // Integrated into SquirrelMail 1.2 core
  435.         'folder_settings',        // Integrated into SquirrelMail 1.5.1 core
  436.         'global_sql_addressbook'// Integrated into SquirrelMail 1.4 core
  437.         'hancock',                // Not Working: See Random Signature Taglines plugin
  438.         'msg_flags',              // Integrated into SquirrelMail 1.5.1 core
  439.         'message_source',         // Added to SquirrelMail 1.4 Core Plugins (message_details)
  440.         'motd',                   // Integrated into SquirrelMail 1.2 core
  441.         'paginator',              // Integrated into SquirrelMail 1.2 core
  442.         'printer_friendly',       // Integrated into SquirrelMail 1.2 core
  443.         'procfilter',             // Obsolete: See Server Side Filter plugin
  444.         'redhat_php_cgi_fix',     // Integrated into SquirrelMail 1.1.1 core
  445.         'send_to_semicolon',      // Integrated into SquirrelMail 1.4.1 core
  446.         'spamassassin',           // Not working beyond SquirrelMail 1.2.7: See Spamassassin SpamFilter (Frontend) v2 plugin
  447.         'sqcalendar',             // Added to SquirrelMail 1.2 Core Plugins (calendar)
  448.         'sqclock',                // Integrated into SquirrelMail 1.2 core
  449.         'sql_squirrel_logger',    // Obsolete: See Squirrel Logger plugin
  450.         'tmda',                   // Obsolete: See TMDA Tools plugin
  451.         'vacation',               // Obsolete: See Vacation Local plugin
  452.         'view_as_html',           // Integrated into SquirrelMail 1.5.1 core
  453.         'xmailer'                 // Integrated into SquirrelMail 1.2 core
  454.         );
  455.  
  456. if (isset($plugins[0])) {
  457.     foreach($plugins as $plugin{
  458.         if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
  459.             do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot find it.'FALSE);
  460.         elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
  461.             do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot locate or read its setup.php file.'FALSE);
  462.         elseif (in_array($plugin$bad_plugins)) {
  463.             do_err('You have enabled the <i>'.$plugin.'</i> plugin, which causes problems with this version of SquirrelMail. Please check the ReleaseNotes or other documentation for more information.'false);
  464.         }
  465.     }
  466.  
  467.  
  468.     // load plugin functions
  469.     include_once(SM_PATH 'functions/plugin.php');
  470.  
  471.     // turn on output buffering in order to prevent output of new lines
  472.     ob_start();
  473.     foreach ($plugins as $name{
  474.         use_plugin($name);
  475.  
  476.         // get output and remove whitespace
  477.         $output trim(ob_get_contents());
  478.  
  479.         // if plugin outputs more than newlines and spacing, stop script execution.
  480.         if (!empty($output)) {
  481.             $plugin_load_error 'Some output was produced when plugin <i>' $name '</i> was loaded.  Usually this means there is an error in the plugin\'s setup or configuration file.  The output was: '.sm_encode_html_special_chars($output);
  482.             do_err($plugin_load_error);
  483.         }
  484.     }
  485.     ob_end_clean();
  486.  
  487.  
  488.     /**
  489.      * Check the contents of the static plugin hooks array file against
  490.      * the plugin setup file, which may have changed in an upgrade, etc.
  491.      * This helps remind admins to re-run the configuration utility when
  492.      * a plugin has been changed or upgraded.
  493.      */
  494.     $static_squirrelmail_plugin_hooks $squirrelmail_plugin_hooks;
  495.     $squirrelmail_plugin_hooks array();
  496.     foreach ($plugins as $name{
  497.         $function "squirrelmail_plugin_init_$name";
  498.         if (function_exists($function)) {
  499.             $function();
  500.  
  501.             // now iterate through each hook and make sure the
  502.             // plugin is registered on the correct ones in the
  503.             // static plugin configuration file
  504.             //
  505.             foreach ($squirrelmail_plugin_hooks as $hook_name => $hooked_plugins)
  506.                 foreach ($hooked_plugins as $hooked_plugin => $hooked_function)
  507.                     if ($hooked_plugin == $name
  508.                      && (empty($static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin])
  509.                       || $static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin!= $hooked_function))
  510.                         do_err('The plugin <i>' $name '</i> is supposed to be registered on the <i>' $hook_name '</i> hook, but it is not.  You need to re-run the configuration utility and re-save your configuration file.'FALSE);
  511.         }
  512.     }
  513.     $squirrelmail_plugin_hooks $static_squirrelmail_plugin_hooks;
  514.  
  515.  
  516.     /**
  517.      * Print plugin versions
  518.      */
  519.     echo $IND "Plugin versions...<br />\n";
  520.     foreach ($plugins as $name{
  521.         $plugin_version get_plugin_version($name);
  522.         $english_name get_plugin_requirement($name'english_name');
  523.         echo $IND $IND (empty($english_name$name ' ' $english_name ' (' $name ') '(empty($plugin_version'??' $plugin_version"<br />\n";
  524.  
  525.         // check if this plugin has any other plugin
  526.         // dependencies and if they are satisfied
  527.         //
  528.         $failed_dependencies check_plugin_dependencies($name);
  529.         if ($failed_dependencies === SQ_INCOMPATIBLE{
  530.             do_err($name ' is NOT COMPATIBLE with this version of SquirrelMail'FALSE);
  531.         }
  532.         else if (is_array($failed_dependencies)) {
  533.             $missing_plugins '';
  534.             $incompatible_plugins '';
  535.             foreach ($failed_dependencies as $depend_name => $depend_requirements{
  536.                 if ($depend_requirements['version'== SQ_INCOMPATIBLE)
  537.                     $incompatible_plugins .= ', ' $depend_name;
  538.                 else
  539.                     $missing_plugins .= ', ' $depend_name ' (version ' $depend_requirements['version'', ' ($depend_requirements['activate''must be activated' 'need not be activated'')';
  540.             }
  541.             $error_string (!empty($incompatible_plugins$name ' cannot be activated at the same time as the following plugins: ' trim($incompatible_plugins', ''')
  542.                           . (!empty($missing_plugins(!empty($incompatible_plugins'.  ' $name ' is also ' $name ' is ''missing some dependencies: ' trim($missing_plugins', ''');
  543.             do_err($error_stringFALSE);
  544.         }
  545.  
  546.     }
  547.  
  548.  
  549.     /**
  550.      * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
  551.      * message and return TRUE if there are any errors in its setup/configuration.
  552.      */
  553.     $plugin_err boolean_hook_function('configtest'$null1);
  554.     if($plugin_err{
  555.         do_err('Some plugin tests failed.');
  556.     else {
  557.         echo $IND "Plugins OK.<br />\n";
  558.     }
  559. else {
  560.     echo $IND "Plugins are not enabled in config.<br />\n";
  561. }
  562. foreach($theme as $thm{
  563.     if(!file_exists($thm['PATH'])) {
  564.         do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').'FALSE);
  565.     elseif(!is_readable($thm['PATH'])) {
  566.         do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').'FALSE);
  567.     }
  568. }
  569.  
  570. echo $IND "Themes OK.<br />\n";
  571.  
  572. if $squirrelmail_default_language != 'en_US' {
  573.     $loc_path SM_PATH .'locale/'.$squirrelmail_default_language.'/LC_MESSAGES/squirrelmail.mo';
  574.     iffile_exists$loc_path ) ) {
  575.         do_err('You have set <i>' $squirrelmail_default_language .
  576.                 '</i> as your default language, but I cannot find this translation (should be '.
  577.                 'in <tt>' $loc_path '</tt>). Please note that you have to download translations '.
  578.                 'separately from the main SquirrelMail package.'FALSE);
  579.     elseif is_readable$loc_path ) ) {
  580.         do_err('You have set <i>' $squirrelmail_default_language .
  581.                 '</i> as your default language, but I cannot read this translation (file '.
  582.                 'in <tt>' $loc_path '</tt> unreadable).'FALSE);
  583.     else {
  584.         echo $IND "Default language OK.<br />\n";
  585.     }
  586. else {
  587.     echo $IND "Default language OK.<br />\n";
  588. }
  589.  
  590. echo $IND "Base URL detected as: <tt>" sm_encode_html_special_chars($test_location.
  591.     "</tt> (location base " (empty($config_location_base'autodetected' 'set to <tt>' .
  592.     sm_encode_html_special_chars($config_location_base)."</tt>"")<br />\n";
  593.  
  594. /* check minimal requirements for other security options */
  595.  
  596. /* imaps or ssmtp */
  597. if($use_smtp_tls == || $use_imap_tls == 1{
  598.     if(!check_php_version(4,3,0)) {
  599.         do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
  600.     }
  601.     if(!extension_loaded('openssl')) {
  602.         do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
  603.     }
  604. }
  605. /* starttls extensions */
  606. if($use_smtp_tls === || $use_imap_tls === 2{
  607.     if (function_exists('stream_socket_enable_crypto')) {
  608.         do_err('If you want to use STARTTLS extension, you need stream_socket_enable_crypto() function from PHP 5.1.0 and newer.');
  609.     }
  610. }
  611. /* digest-md5 */
  612. if ($smtp_auth_mech=='digest-md5' || $imap_auth_mech =='digest-md5'{
  613.     if (!extension_loaded('xml')) {
  614.         do_err('You need the PHP XML extension to use Digest-MD5 authentication!');
  615.     }
  616. }
  617.  
  618. /* check outgoing mail */
  619.  
  620. echo "Checking outgoing mail service....<br />\n";
  621.  
  622. if($useSendmail{
  623.     // is_executable also checks for existance, but we want to be as precise as possible with the errors
  624.     if(!file_exists($sendmail_path)) {
  625.         do_err("Location of sendmail program incorrect ($sendmail_path)!");
  626.     }
  627.     if(!is_executable($sendmail_path)) {
  628.         do_err("I cannot execute the sendmail program ($sendmail_path)!");
  629.     }
  630.  
  631.     echo $IND "sendmail OK<br />\n";
  632. else {
  633.     // NB: Using "ssl://" ensures the highest possible TLS version
  634.     // will be negotiated with the server (whereas "tls://" only
  635.     // uses TLS version 1.0)
  636.     $stream fsockopen( ($use_smtp_tls==1?'ssl://':'').$smtpServerAddress$smtpPort,
  637.             $errorNumber$errorString);
  638.     if(!$stream{
  639.         do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
  640.                 "Server error: ($errorNumber".sm_encode_html_special_chars($errorString));
  641.     }
  642.  
  643.     // check for SMTP code; should be 2xx to allow us access
  644.     $smtpline fgets($stream1024);
  645.     if(((int) $smtpline{0}3{
  646.         do_err("Error connecting to SMTP server. Server error: ".
  647.                 sm_encode_html_special_chars($smtpline));
  648.     }
  649.  
  650.     /* smtp starttls checks */
  651.     if ($use_smtp_tls===2{
  652.         // if something breaks, script should close smtp connection on exit.
  653.  
  654.  
  655.         // format EHLO argument correctly if needed
  656.         //
  657.         if (preg_match('/^\d+\.\d+\.\d+\.\d+$/'$client_ip))
  658.             $helohost '[' $client_ip ']';
  659.         else // some day might add IPv6 here
  660.             $helohost $client_ip;
  661.  
  662.  
  663.         // say helo
  664.         fwrite($stream,"EHLO $helohost\r\n");
  665.  
  666.         $ehlo=array();
  667.         $ehlo_error false;
  668.         while ($line=fgets($stream1024)){
  669.             if (preg_match("/^250(-|\s)(\S*)\s+(\S.*)/",$line,$match)||
  670.                     preg_match("/^250(-|\s)(\S*)\s+/",$line,$match)) {
  671.                 if (!isset($match[3])) {
  672.                     // simple one word extension
  673.                     $ehlo[strtoupper($match[2])]='';
  674.                 else {
  675.                     // ehlo-keyword + ehlo-param
  676.                     $ehlo[strtoupper($match[2])]=trim($match[3]);
  677.                 }
  678.                 if ($match[1]==' '{
  679.                     $ret $line;
  680.                     break;
  681.                 }
  682.             else {
  683.                 //
  684.                 $ehlo_error true;
  685.                 $ehlo[]=$line;
  686.                 break;
  687.             }
  688.         }
  689.         if ($ehlo_error{
  690.             do_err('SMTP EHLO failed. You need ESMTP support for SMTP STARTTLS');
  691.         elseif (!array_key_exists('STARTTLS',$ehlo)) {
  692.             do_err('STARTTLS support is not declared by SMTP server.');
  693.         }
  694.  
  695.         fwrite($stream,"STARTTLS\r\n");
  696.         $starttls_response=fgets($stream1024);
  697.         if ($starttls_response[0]!=2{
  698.             $starttls_cmd_err 'SMTP STARTTLS failed. Server replied: '
  699.                 .sm_encode_html_special_chars($starttls_response);
  700.             do_err($starttls_cmd_err);
  701.         elseif(stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
  702.             do_err('Failed to enable encryption on SMTP STARTTLS connection.');
  703.         else {
  704.             echo $IND "SMTP STARTTLS extension looks OK.<br />\n";
  705.         }
  706.         // According to RFC we should second ehlo call here.
  707.     }
  708.  
  709.     fputs($stream'QUIT');
  710.     fclose($stream);
  711.     echo $IND 'SMTP server OK (<tt><small>'.
  712.             trim(sm_encode_html_special_chars($smtpline))."</small></tt>)<br />\n";
  713.  
  714.     /* POP before SMTP */
  715.     if($pop_before_smtp{
  716.         if (empty($pop_before_smtp_host)) $pop_before_smtp_host $smtpServerAddress;
  717.         $stream fsockopen($pop_before_smtp_host110$err_no$err_str);
  718.         if (!$stream{
  719.             do_err("Error connecting to POP Server ($pop_before_smtp_host:110) "
  720.                 . $err_no ' : ' sm_encode_html_special_chars($err_str));
  721.         }
  722.  
  723.         $tmp fgets($stream1024);
  724.         if (substr($tmp03!= '+OK'{
  725.             do_err("Error connecting to POP Server ($pop_before_smtp_host:110)"
  726.                 . ' '.sm_encode_html_special_chars($tmp));
  727.         }
  728.         fputs($stream'QUIT');
  729.         fclose($stream);
  730.         echo $IND "POP-before-SMTP OK.<br />\n";
  731.     }
  732. }
  733.  
  734. /**
  735.  * Check the IMAP server
  736.  */
  737. echo "Checking IMAP service....<br />\n";
  738.  
  739. /** Can we open a connection? */
  740. // NB: Using "ssl://" ensures the highest possible TLS version
  741. // will be negotiated with the server (whereas "tls://" only
  742. // uses TLS version 1.0)
  743. $stream fsockopen( ($use_imap_tls==1?'ssl://':'').$imapServerAddress$imapPort,
  744.         $errorNumber$errorString);
  745. if(!$stream{
  746.     do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
  747.             "Server error: ($errorNumber".
  748.             sm_encode_html_special_chars($errorString));
  749. }
  750.  
  751. /** Is the first response 'OK'? */
  752. $imapline fgets($stream1024);
  753. if(substr($imapline0,4!= '* OK'{
  754.     do_err('Error connecting to IMAP server. Server error: '.
  755.             sm_encode_html_special_chars($imapline));
  756. }
  757.  
  758. echo $IND 'IMAP server ready (<tt><small>'.
  759.     sm_encode_html_special_chars(trim($imapline))."</small></tt>)<br />\n";
  760.  
  761. /** Check capabilities */
  762. fputs($stream"A001 CAPABILITY\r\n");
  763. $capline '';
  764. while ($line=fgets($stream1024)){
  765.     if (preg_match("/A001.*/",$line)) {
  766.         break;
  767.     else {
  768.         $capline.=$line;
  769.     }
  770. }
  771.  
  772. /* don't display capabilities before STARTTLS */
  773. if ($use_imap_tls===&& stristr($capline'STARTTLS'=== false{
  774.     do_err('Your server doesn\'t support STARTTLS.');
  775. elseif($use_imap_tls===2{
  776.     /* try starting starttls */
  777.     fwrite($stream,"A002 STARTTLS\r\n");
  778.     $starttls_line=fgets($stream1024);
  779.     if (preg_match("/^A002 OK.*/i",$starttls_line)) {
  780.         $imap_starttls_err 'IMAP STARTTLS failed. Server replied: '
  781.             .sm_encode_html_special_chars($starttls_line);
  782.         do_err($imap_starttls_err);
  783.     elseif (stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
  784.         do_err('Failed to enable encryption on IMAP connection.');
  785.     else {
  786.         echo $IND "IMAP STARTTLS extension looks OK.<br />\n";
  787.     }
  788.  
  789.     // get new capability line
  790.     fwrite($stream,"A003 CAPABILITY\r\n");
  791.     $capline='';
  792.     while ($line=fgets($stream1024)){
  793.         if (preg_match("/A003.*/",$line)) {
  794.             break;
  795.         else {
  796.             $capline.=$line;
  797.         }
  798.     }
  799. }
  800.  
  801. echo $IND 'Capabilities: <tt>'.sm_encode_html_special_chars($capline)."</tt><br />\n";
  802.  
  803. if($imap_auth_mech == 'login' && stristr($capline'LOGINDISABLED'!== FALSE{
  804.     do_err('Your server doesn\'t allow plaintext logins. '.
  805.             'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '.
  806.             'in the SquirrelMail configuration.'FALSE);
  807. }
  808.  
  809. if (stristr($capline'XMAGICTRASH'!== false{
  810.     $magic_trash 'It looks like IMAP_MOVE_EXPUNGE_TO_TRASH option is turned on '
  811.         .'in your Courier IMAP configuration. Courier does not provide tools that '
  812.         .'allow to detect folder used for Trash or commands are not documented. '
  813.         .'SquirrelMail can\'t detect special trash folder. SquirrelMail manages '
  814.         .'all message deletion or move operations internally and '
  815.         .'IMAP_MOVE_EXPUNGE_TO_TRASH option can cause errors in message and '
  816.         .'folder management operations. Please turn off IMAP_MOVE_EXPUNGE_TO_TRASH '
  817.         .'option in Courier imapd configuration.';
  818.     do_err($magic_trash,false);
  819. }
  820.  
  821. /* add warning about IMAP delivery */
  822. if (stristr($capline'XCOURIEROUTBOX'!== false{
  823.     $courier_outbox 'OUTBOX setting is enabled in your Courier imapd '
  824.         .'configuration. SquirrelMail uses standard SMTP protocol or sendmail '
  825.         .'binary to send emails. Courier IMAP delivery method is not supported'
  826.         .' and can create duplicate email messages.';
  827.     do_err($courier_outbox,false);
  828. }
  829.  
  830. /** OK, close connection */
  831. fputs($stream"A004 LOGOUT\r\n");
  832. fclose($stream);
  833.  
  834. echo "Checking internationalization (i18n) settings...<br />\n";
  835. echo "$IND gettext - ";
  836. if (function_exists('gettext')) {
  837.     echo 'Gettext functions are available.'
  838.         .' On some systems you must have appropriate system locales compiled.'
  839.         ."<br />\n";
  840.  
  841.     /* optional setlocale() tests. Should work only on glibc systems. */
  842.     if (sqgetGlobalVar('testlocales',$testlocales,SQ_GET)) {
  843.         include_once(SM_PATH 'include/languages.php');
  844.         echo $IND $IND 'Testing translations:<br>';
  845.         foreach ($languages as $lang_code => $lang_data{
  846.             /* don't test aliases */
  847.             if (isset($lang_data['NAME'])) {
  848.                 /* locale can be $lang_code or $lang_data['LOCALE'] */
  849.                 if (isset($lang_data['LOCALE'])) {
  850.                     $setlocale $lang_data['LOCALE'];
  851.                 else {
  852.                     $setlocale $lang_code;
  853.                 }
  854.                 /* prepare information about tested locales */
  855.                 if (is_array($setlocale)) {
  856.                     $display_locale implode(', ',$setlocale);
  857.                     $locale_count count($setlocale);
  858.                 else {
  859.                     $display_locale $setlocale;
  860.                     $locale_count 1;
  861.                 }
  862.                 $tested_locales_msg 'Tested '.sm_encode_html_special_chars($display_locale).' '
  863.                     .($locale_count>'locales':'locale')'.';
  864.  
  865.                 echo $IND $IND .$IND $lang_data['NAME'].' (' .$lang_code') - ';
  866.                 $retlocale sq_setlocale(LC_ALL,$setlocale);
  867.                 if (is_bool($retlocale)) {
  868.                     echo '<font color="red">unsupported</font>. ';
  869.                     echo $tested_locales_msg;
  870.                 else {
  871.                     echo 'supported. '
  872.                         .$tested_locales_msg
  873.                         .' setlocale() returned "'.sm_encode_html_special_chars($retlocale).'"';
  874.                 }
  875.                 echo "<br />\n";
  876.             }
  877.         }
  878.         echo $IND $IND '<a href="configtest.php">Don\'t test translations</a>';
  879.     else {
  880.         echo $IND $IND '<a href="configtest.php?testlocales=1">Test translations</a>. '
  881.             .'This test is not accurate and might work only on some systems.'
  882.             ."\n";
  883.     }
  884.     echo "<br />\n";
  885.     /* end of translation tests */
  886. else {
  887.     echo 'Gettext functions are unavailable.'
  888.         .' SquirrelMail will use slower internal gettext functions.'
  889.         ."<br />\n";
  890. }
  891. echo "$IND mbstring - ";
  892. if (function_exists('mb_detect_encoding')) {
  893.     echo "Mbstring functions are available.<br />\n";
  894. else {
  895.     echo 'Mbstring functions are unavailable.'
  896.         ." Japanese translation won't work.<br />\n";
  897. }
  898. echo "$IND recode - ";
  899. if (function_exists('recode')) {
  900.     echo "Recode functions are available.<br />\n";
  901. elseif (isset($use_php_recode&& $use_php_recode{
  902.     echo "Recode functions are unavailable.<br />\n";
  903.     do_err('Your configuration requires recode support, but recode support is missing.');
  904. else {
  905.     echo "Recode functions are unavailable.<br />\n";
  906. }
  907. echo "$IND iconv - ";
  908. if (function_exists('iconv')) {
  909.     echo "Iconv functions are available.<br />\n";
  910. elseif (isset($use_php_iconv&& $use_php_iconv{
  911.     echo "Iconv functions are unavailable.<br />\n";
  912.     do_err('Your configuration requires iconv support, but iconv support is missing.');
  913. else {
  914.     echo "Iconv functions are unavailable.<br />\n";
  915. }
  916. // same test as in include/init.php + date_default_timezone_set check
  917. echo "$IND timezone - ";
  918. if ( (!ini_get('safe_mode')) || function_exists('date_default_timezone_set'||
  919.         !strcmp(ini_get('safe_mode_allowed_env_vars'),''||
  920.         preg_match('/^([\w_]+,)*TZ/'ini_get('safe_mode_allowed_env_vars')) ) {
  921.     echo "Webmail users can change their time zone settings. \n";
  922. else {
  923.     echo "Webmail users can't change their time zone settings. \n";
  924. }
  925. if (isset($_ENV['TZ'])) {
  926.     echo 'Default time zone is '.sm_encode_html_special_chars($_ENV['TZ']);
  927. else {
  928.     echo 'Current time zone is '.date('T');
  929. }
  930. echo ".<br />\n";
  931.  
  932. // Database tests
  933. echo "Checking database functions...<br />\n";
  934. if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn{
  935.     $dsns array();
  936.     if($prefs_dsn{
  937.         $dsns['preferences'$prefs_dsn;
  938.     }
  939.     if($addrbook_dsn{
  940.         $dsns['addressbook'$addrbook_dsn;
  941.     }
  942.     if($addrbook_global_dsn{
  943.         $dsns['global addressbook'$addrbook_global_dsn;
  944.     }
  945.  
  946.     global $disable_pdo$use_pdo;
  947.     if (empty($disable_pdo&& class_exists('PDO'))
  948.         $use_pdo TRUE;
  949.     else
  950.         $use_pdo FALSE;
  951.  
  952.     if ($use_pdo{
  953.  
  954.         // test connecting to each DSN
  955.         foreach($dsns as $type => $dsn{
  956.  
  957.             // parse and convert DSN to PDO style
  958.             // $matches will contain:
  959.             // 1: database type
  960.             // 2: username
  961.             // 3: password
  962.             // 4: hostname
  963.             // 5: database name
  964. //TODO: add support for unix_socket and charset
  965.             if (!preg_match('|^(.+)://(.+):(.+)@(.+)/(.+)$|i'$dsn$matches)) {
  966.                 return $this->set_error(_("Could not parse prefs DSN"));
  967.                 do_err('DSN parse error in ' .$type .' DSN.');
  968.             }
  969.             if (preg_match('|^(.+):(\d+)$|'$matches[4]$host_port_matches)) {
  970.                 $matches[4$host_port_matches[1];
  971.                 $matches[6$host_port_matches[2];
  972.             else
  973.                 $matches[6NULL;
  974.             $pdo_prefs_dsn $matches[1':host=' $matches[4(!empty($matches[6]';port=' $matches[6''';dbname=' $matches[5];
  975.             try {
  976.                 $dbh new PDO($pdo_prefs_dsn$matches[2]$matches[3]);
  977.             catch (Exception $e{
  978.                 do_err('Database error: 'sm_encode_html_special_chars($e->getMessage()) .
  979.                         ' in ' .$type .' DSN.');
  980.             }
  981.             echo "$IND$type database connect successful.<br />\n";
  982.         }
  983.  
  984.     else {
  985.         @include_once('DB.php');
  986.         if (class_exists('DB')) {
  987.             echo "$IND PHP Pear DB support is present, however it is deprecated and PHP PDO is recommended.<br />\n"
  988.                 .(!empty($disable_pdo"$IND You have set \$disable_pdo - if you experience errors below, try removing that.<br />\n'');
  989.             $db_functions=array(
  990.                     'dbase' => 'dbase_open',
  991.                     'fbsql' => 'fbsql_connect',
  992.                     'interbase' => 'ibase_connect',
  993.                     'informix' => 'ifx_connect',
  994.                     'msql' => 'msql_connect',
  995.                     'mssql' => 'mssql_connect',
  996.                     'mysql' => 'mysql_connect',
  997.                     'mysqli' => 'mysqli_connect',
  998.                     'oci8' => 'ocilogon',
  999.                     'odbc' => 'odbc_connect',
  1000.                     'pgsql' => 'pg_connect',
  1001.                     'sqlite' => 'sqlite_open',
  1002.                     'sybase' => 'sybase_connect'
  1003.                     );
  1004.  
  1005.             foreach($dsns as $type => $dsn{
  1006.                 $aDsn explode(':'$dsn);
  1007.                 $dbtype array_shift($aDsn);
  1008.  
  1009.                 if(isset($db_functions[$dbtype]&& function_exists($db_functions[$dbtype])) {
  1010.                     echo "$IND$dbtype database support present.<br />\n";
  1011.                 elseif(!(bool)ini_get('enable_dl'|| (bool)ini_get('safe_mode')) {
  1012.                     do_err($dbtype.' database support not present!');
  1013.                 else {
  1014.                     // Non-fatal error
  1015.                     do_err($dbtype.' database support not present or not configured!
  1016.                         Trying to dynamically load '.$dbtype.' extension.
  1017.                         Please note that it is advisable to not rely on dynamic loading of extensions.'FALSE);
  1018.                 }
  1019.  
  1020.  
  1021.                 // now, test this interface:
  1022.  
  1023.                 $dbh DB::connect($dsntrue);
  1024.                 if (DB::isError($dbh)) {
  1025.                     do_err('Database error: 'sm_encode_html_special_chars(DB::errorMessage($dbh)) .
  1026.                             ' in ' .$type .' DSN.');
  1027.                 }
  1028.                 $dbh->disconnect();
  1029.                 echo "$IND$type database connect successful.<br />\n";
  1030.             }
  1031.         else {
  1032.             $db_error='Required PHP PDO or PEAR DB support is not available.'
  1033.                 .(!empty($disable_pdo' You have set $disable_pdo - please try removing that.' '')
  1034.                 .' PDO should come preinstalled with PHP version 5.1 or higher.'
  1035.                 .' Otherwise, is PEAR installed and is the include path set correctly to find <tt>DB.php</tt>?'
  1036.                 .' The include path is now: "<tt>' ini_get('include_path''</tt>".';
  1037.             do_err($db_error);
  1038.         }
  1039.     }
  1040. else {
  1041.     echo $IND."not using database functionality.<br />\n";
  1042. }
  1043.  
  1044. // LDAP DB tests
  1045. echo "Checking LDAP functions...<br />\n";
  1046. ifempty($ldap_server) ) {
  1047.     echo $IND."not using LDAP functionality.<br />\n";
  1048. else {
  1049.     if !function_exists('ldap_connect') ) {
  1050.         do_err('Required LDAP support is not available.');
  1051.     else {
  1052.         echo "$IND LDAP support present.<br />\n";
  1053.         foreach $ldap_server as $param {
  1054.  
  1055.             $linkid @ldap_connect($param['host'](empty($param['port']389 $param['port']) );
  1056.  
  1057.             if $linkid {
  1058.                 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
  1059.  
  1060.                 if !empty($param['protocol']&&
  1061.                         !ldap_set_option($linkidLDAP_OPT_PROTOCOL_VERSION$param['protocol']) ) {
  1062.                     do_err('Unable to set LDAP protocol');
  1063.                 }
  1064.  
  1065.                 if empty($param['binddn']) ) {
  1066.                     $bind @ldap_bind($linkid);
  1067.                 else {
  1068.                     $bind @ldap_bind($linkid$param['binddn']$param['bindpw']);
  1069.                 }
  1070.  
  1071.                 if $bind {
  1072.                     echo "$IND LDAP Bind Successful <br />";
  1073.                 else {
  1074.                     do_err('Unable to Bind to LDAP Server');
  1075.                 }
  1076.  
  1077.                 @ldap_close($linkid);
  1078.             else {
  1079.                 do_err('Connection to LDAP failed');
  1080.             }
  1081.         }
  1082.     }
  1083. }
  1084.  
  1085. echo '<hr width="75%" align="center">';
  1086. echo '<h2 align="center">Summary</h2>';
  1087. $footer '<hr width="75%" align="center">';
  1088. if ($warnings{
  1089.     echo '<p>No fatal errors were found, but there was at least 1 warning. Please check the flagged issue(s) carefully, as correcting them may prevent erratic, undefined, or incorrect behavior (or flat out breakage).</p>';
  1090.     echo $footer;
  1091. else {
  1092.     print <<< EOF
  1093. <p>Congratulations, your SquirrelMail setup looks fine to me!</p>
  1094.  
  1095. <p><a href="login.php">Login now</a></p>
  1096.  
  1097. </body>
  1098. </html>
  1099. EOF;
  1100.     echo $footer;
  1101. }

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