00001 <?php
00002 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
00003 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
00004 \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\n";
00005
00006 print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en_US\">\n";
00007 print "<head>\n";
00008 print "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n";
00009 print "<title>Basic PHP tests</title>\n";
00010 print "<style type=\"text/css\">\n";
00011 print "<!--\n";
00012 print ".different { background-color: #ffadad; color: black; }\n";
00013 print ".unset { background-color: #ffdada; color: black; }\n";
00014 print "-->\n";
00015 print "</style>\n";
00016 print "</head>\n\n";
00017 print "<body>\n";
00018
00019
00020 print "<h1>Basic PHP pre-tests for Savane installation</h1>\n";
00021 print "<p>This page should help you to check whether your installation is properly configured. Once your installation is running, you should remove this file or restrict its access, since it could give details about your setup to anybody.</p>";
00022
00023 #==============================================================================
00024 print "<h2>Base PHP configuration:</h2>\n";
00025
00026 $phptags = array (
00027 'register_globals' => 1,
00028 'register_long_arrays' => 1,
00029 'file_uploads' => 1,
00030 'magic_quotes_gpc' => 1,
00031 'post_max_size' => '2M',
00032 'upload_max_filesize' => '2M',
00033 'arg_separator.output' => '&',
00034 );
00035
00036 print "<table border=\"1\" summary=\"PHP configuration\">\n";
00037 print "<tr><th>PHP Tag name</th><th>Local value</th><th>Suggested/Required value</th></tr>\n";
00038 unset($unset);
00039 ksort($phptags);
00040 foreach ( $phptags as $tag => $goodval ) {
00041 if (htmlentities(ini_get($tag)) == htmlentities($goodval))
00042 {
00043 # OK
00044 printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",$tag,htmlentities(ini_get($tag)),htmlentities($goodval));
00045 }
00046 else if (htmlentities(ini_get($tag)))
00047 {
00048 # Different
00049 printf ("<tr><td>%s</td><td class=\"different\">%s</td><td>%s</td></tr>\n",$tag,htmlentities(ini_get($tag)),htmlentities($goodval));
00050 }
00051 else
00052 {
00053 # Non existing ini value: may be unset or Off
00054 printf ("<tr><td>%s</td><td class=\"unset\">Off or Unset *</td><td>%s</td></tr>\n",$tag,htmlentities($goodval));
00055 $unset = 1;
00056 }
00057 }
00058 print "</table>\n";
00059 if ($unset)
00060 {
00061 print "<blockquote>* This tag was set to Off or not found at all. Look for this tag in php.ini. If you find it, update it accordingly. Otherwise, if you cannot find such tag in your php.ini file, it is probably irrelevant to your PHP installation and then should ignore this entry.</blockquote>";
00062 }
00063
00064 #==============================================================================
00065 print "<h2>PHP functions:</h2>\n";
00066
00067 $phpfunctions = array (
00068 'mysql_connect' => 'You should install/configure php-mysql ! [REQUIRED]',
00069 'gettext' => 'You should install/configure php with gettext support ! [RECOMMANDED]',
00070 );
00071
00072 foreach ( $phpfunctions as $func => $comment ) {
00073
00074 if (function_exists($func)) {
00075 print "function <strong>".$func."()</strong> exist.<br />\n";
00076 } else {
00077 print "function <strong>".$func."()</strong> does not exist. $comment <br />\n";
00078 }
00079 }
00080
00081 #==============================================================================
00082 print "<h2>Apache environment vars:</h2>\n";
00083
00084 $configfile = '/etc/savannah/';
00085
00086 if ( getenv('SAVANE_CONF') ) {
00087 $configfile = getenv('SAVANE_CONF');
00088 print "SAVANE_CONF configured to ".$configfile."<br />\n";
00089 } elseif ( getenv('SV_LOCAL_INC_PREFIX') ) {
00090 $configfile = getenv('SV_LOCAL_INC_PREFIX');
00091 print "SV_LOCAL_INC_PREFIX configured to ".$configfile."<br />\n";
00092 } else {
00093 print "SAVANE_CONF nor SV_LOCAL_INC_PREFIX are set! (Default to ".$configfile.") <br />\n";
00094 }
00095
00096 $configfile .= '/savannah.conf.php';
00097
00098 if (is_readable($configfile)) {
00099 print "File <strong>$configfile</strong> exists and is readable.";
00100 } else {
00101 print "File <strong>$configfile</strong> does not exist or is not readable!";
00102 }
00103
00104 #==============================================================================
00105 print "<h2>Savane configuration:</h2>\n";
00106
00107 if (!is_readable($configfile))
00108 {
00109 print "Since $configfile does not exist or is not readable, this part cannot be checked.";
00110 }
00111 else
00112 {
00113 include $configfile;
00114 $variables = array (
00115 # Name / required
00116 'sys_default_domain' => 1,
00117 'sys_https_host' => 0,
00118 'sys_dbhost' => 1,
00119 'sys_dbname' => 1,
00120 'sys_dbuser' => 1,
00121 'sys_dbpasswd' => 1,
00122 'sys_www_topdir' => 1,
00123 'sys_url_topdir' => 1,
00124 'sys_incdir' => 1,
00125 'sys_name' => 1,
00126 'sys_unix_group_name' => 1,
00127 'sys_themedefault' => 1,
00128 'sys_mail_domain' => 1,
00129 'sys_mail_admin' => 1,
00130 'sys_mail_replyto' => 1,
00131 );
00132
00133 print "<table border=\"1\">\n";
00134 print "<tr><th>Conf variable</th><th>Current value</th><th>Is required?</th></tr>\n";
00135 unset($unset);
00136 foreach ( $variables as $tag => $required ) {
00137 if (!$required || htmlentities($GLOBALS[$tag]))
00138 {
00139 # Is set
00140 $value = $GLOBALS[$tag];
00141 if ($tag == "sys_dbpasswd")
00142 { $value = "**************"; }
00143
00144 printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",$tag,htmlentities($value),$required);
00145 }
00146 else
00147 {
00148 # Is not set, and should be set
00149 printf ("<tr><td>%s</td><td class=\"unset\">%s</td><td>%s</td></tr>\n",$tag," ",$required);
00150 }
00151 }
00152
00153 print "</table>\n";
00154 }
00155
00156
00157 #=============================================================================
00158 print "<h2>Securing PHP configuration:</h2>\n";
00159
00160 print "The following is not required to run Savane but could enhance security of your production server. Some of these makes harder to debug an installation and, as such, should be avoided on a test installation, or if your installation is not working.";
00161
00162 $phptags = array (
00163 'display_errors' => 'Off',
00164 'allow_url_fopen' => 'Off',
00165 'disable_functions' => 'exec, passthru, popen, shell_exec, system',
00166 );
00167
00168 print "<table border=\"1\">\n";
00169 print "<tr><th>PHP Tag name</th><th>Local value</th><th>Suggested/Required value</th></tr>\n";
00170 unset($unset);
00171 ksort($phptags);
00172 foreach ( $phptags as $tag => $goodval ) {
00173 if (htmlentities(ini_get($tag)) == htmlentities($goodval))
00174 {
00175 # OK
00176 printf ("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",$tag,htmlentities(ini_get($tag)),htmlentities($goodval));
00177 }
00178 else if (htmlentities(ini_get($tag)))
00179 {
00180 # Different
00181 printf ("<tr><td>%s</td><td class=\"different\">%s</td><td>%s</td></tr>\n",$tag,htmlentities(ini_get($tag)),htmlentities($goodval));
00182 }
00183 else
00184 {
00185 # Non existing ini value: may be unset or Off
00186 printf ("<tr><td>%s</td><td class=\"unset\">Off or Unset *</td><td>%s</td></tr>\n",$tag,htmlentities($goodval));
00187 $unset = 1;
00188 }
00189 }
00190 print "</table>\n";
00191 if ($unset)
00192 {
00193 print "<blockquote>* This tag was set to Off or not found at all. Look for this tag in php.ini. If you find it, update it accordingly. Otherwise, if you cannot find such tag in your php.ini file, it is probably irrelevant to your PHP installation and then should ignore this entry.</blockquote>";
00194 }
00195
00196
00197 #==============================================================================
00198
00199 print "<h2>That's it!</h2>";
00200 print "</body>\n<html>\n";
00201
00202 ?>