| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:53:39 2008 ] | [ PHProjekt 5.0.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 ini_set('error_reporting', E_ALL); 4 5 // env_test.php - PHProjekt Version 5.0 6 // copyright © 2000-2005 Albrecht Guenther ag@phprojekt.com 7 // www.phprojekt.com 8 // Author: Albrecht Guenther, $Author: fgraf $ 9 // $Id: env_test.php,v 1.12.2.1 2005/09/16 09:22:55 fgraf Exp $ 10 11 /* 12 Welcome to the test routine of PHProjekt! 13 But already now I can tell you that it won't work - 14 because you see this text here! :-) 15 This means that your php parser is not working - 16 otherwise this text would be recognized as a comment and 17 not shown onthe screen :-| 18 The requirements for a setup of PHProjekt 19 are a webserver with a php parser and a sql database. 20 A typical combination would be a LAMP or WAMP system. 21 Installation tutorials can be found e.g. here: 22 http://www.dynamic-webpages.de/07.installation.php 23 'til later! 24 */ 25 26 // this script will produce it's own error messages, in this case we 27 // don't need any additional warnings from the parser :-) 28 error_reporting(0); 29 30 // run env_test.php only if this is the first installation! 31 if (file_exists('./config.inc.php')) die('You are not allowed to do this!'); 32 33 34 // the variables for this script will partly be treansferred via sessions 35 // include the gpc_vars library to get all post and get variables, regardsless the value of register_globals 36 include_once ("./lib/gpcs_vars.inc.php"); 37 38 39 // to restart the script all session data have to be deleted 40 if ($free == 1 or $_GET["free"] == 1) { 41 session_destroy(); 42 $_REQUEST['parser_test'] = 0; 43 $_REQUEST['env_test'] = 0; 44 $_REQUEST['session_test'] = 0; 45 $_REQUEST['db_test'] = 0; 46 $_REQUEST['mail_test'] = 0; 47 $_REQUEST['file_test'] = 0; 48 } 49 50 $red1 = "<div style='color:red;'>"; 51 $red2 = '</div>'; 52 53 echo "<html><head><title>PHProjekt SYSTEM test</title></head><body bgcolor=#E2E2E2><br>"; 54 echo "<h2>PHProjekt environment test</h2>"; 55 echo "Thank you for taking the time to check whether your<br>environment meets to the needs of a PHProjekt installation<br><br>"; 56 57 // PHP Version - exclude PHP3 58 echo "<br>**********************"; 59 echo "<h4>PHP Parser test</h4>"; 60 if (!$_REQUEST['parser_test']) { 61 echo "<form><input type='hidden' name='parser_test' value='1'>\n"; 62 echo "<input type='hidden' name='".session_name()."' value='".session_id()."'>\n"; 63 echo "First we have a look on the used PHP version<br><br>\n"; 64 echo "<input type='submit' value='Parser test'></form>"; 65 } 66 else if ($_REQUEST['parser_test'] == 1) { 67 // PHP Version - exclude PHP3 68 if (substr(phpversion(),0,1) == "3") { 69 ("<b>sorry, PHP 4 required!</b><br><br> Please download the current version at <a href='http://www.php.net'>www.php.net</a>. (exit)\n"); 70 $_REQUEST['parser_test'] = "failed"; 71 } 72 else if (substr(phpversion(),0,3) == "4.0") { 73 echo "The used PHP version is 4.0 - we strongly recommend you to update to a newer version.<br><br>"; 74 $_REQUEST['parser_test'] = "update recommended"; 75 } 76 else { 77 echo "The version of the used PHP parser is valid!"; 78 $parser_test = "o.k."; 79 } 80 $_SESSION['parser_test'] =& $parser_test; 81 } 82 else echo "<i>PHP version test done, result: ".$_REQUEST['parser_test']."</i>"; 83 // end parser test 84 85 86 87 // begin environment test 88 echo "<br>**********************"; 89 echo "<h4>PHP environment test</h4>"; 90 // offer env test 91 if (!$_REQUEST['env_test']) { 92 echo "<form><input type='hidden' name='env_test' value='1'>\n"; 93 echo "<input type='hidden' name='".session_name()."' value='".session_id()."'>\n"; 94 echo "Now we check whether how the configuration of PHP is set.<br><br>\n"; 95 echo "<input type='submit' value='env test'></form>"; 96 } 97 // env_test submitted, start test 98 else if ($_REQUEST['env_test'] == 1) { 99 echo '<ul>'; 100 // magic quotes runtime test 101 if (ini_get("magic_quotes_runtime")) { 102 echo "<li>".$red1."Please change the value of 'magic_quotes_runtime' in the php.ini to 'off'\n".$red2; 103 // add this string to the env-test variable 104 $_REQUEST['env_test'] = "<li>change magic_quotes_runtime to 'off' in the php.ini"; 105 } 106 else echo "<li>variable 'magic_quotes_runtime' is set to off - o.k.!"; 107 108 // use_trans_sid test 109 if (in_array(strtolower(ini_get("session.use_trans_sid")), array('on', '1'))) { 110 echo "<li>".$red1."The variable session.use_trans_sid is set to 1 -<br> 111 this will cause problems if users run PHProjekt without cookies!<br> 112 We recommend to set session.use_trans_sid to 0\n".$red2; 113 // add this string to the env-test variable 114 $_REQUEST['env_test'] = "<li>Recommendation: set session.use_trans_sid to 0"; 115 } 116 else echo "<li>variable 'session.use_trans_sid' is set to off - o.k.!"; 117 118 // open_basedir test 119 if (ini_get("open_basedir")) { 120 echo "<li>".$red1."Please delete the value of 'open_basedir' in the php.ini\n".$red2; 121 $_REQUEST['env_test'] .= "<li>delete the value of 'open_basedir' in the php.ini\n"; 122 } 123 // open basedir correct? 124 else echo "<li>variable 'open_basedir' is empty - o.k.!"; 125 126 // safe mode test 127 if ((ini_get("safe_mode") == "on") or (ini_get("safe_mode") == 1)) { 128 echo "<li>".$red1."your php runs in the safe mode configuration.<br> 129 In this case the PHProjekt directory and all subdirectories have to be owned by the webserver.".$red2; 130 $_REQUEST['env_test'] .= "safe mode is on! -> the webserver must own all subdirectories of PHProjekt"; 131 } 132 else echo "<li>variable 'safe_mode' is 'off' - o.k.!"; 133 134 echo '</ul>'; 135 136 // if none of the above test has written an error message into the variable -> "o.k."! :-) 137 if ($_REQUEST['env_test'] == 1) $_REQUEST['env_test'] = "o.k."; 138 // write variable into session 139 $_SESSION['env_test'] =& $env_test; 140 } 141 // env_test done, show result 142 else echo "<i>PHP environment test done, result: ".$_REQUEST['env_test']."</i>"; 143 144 145 146 // session test 147 echo "<br>**********************"; 148 echo "<h4>Session Test</h4>"; 149 150 if (!$_REQUEST['session_test']) { 151 echo "<form><input type=hidden name=session_test value=1>\n"; 152 echo "<input type=hidden name='".session_name()."' value='".session_id()."'>\n"; 153 echo "PHProjekt uses sessions to store information <br>Now we check whether the server has a working session management.<br><br>\n"; 154 echo "<input type=submit value='session test'></form>"; 155 $session_ok = 1; 156 $_SESSION['session_ok'] =& $session_ok; 157 } 158 else if ($_REQUEST['session_test'] == 1) { 159 // check whether session are enabled at all!! 160 if (!extension_loaded('session')) { 161 echo "<br><h2>Panic - the php parser has been compiled without session support! </h2><br>"; 162 $_REQUEST['session_test'] = "failed"; 163 } 164 165 if ($session_ok == 1) { 166 echo "<i>Session management works!</i>"; 167 $_REQUEST['session_test'] = "o.k."; 168 } 169 else { 170 echo "oops - can't find my session!"; 171 $_REQUEST['session_test'] = "failed"; 172 } 173 $_SESSION['session_test'] =& $session_test; 174 } 175 else echo "<i>Session management test done, result: ".$_REQUEST['session_test']."</i>"; 176 177 178 179 // sql test 180 echo "<br>**********************"; 181 echo "<h4>Database Access</h4>"; 182 183 if (!$_REQUEST['db_test']) { 184 echo "Please enter your db access parameters, the script will try to connect to the database:\n"; 185 echo "<form>\n"; 186 echo "<input type='hidden' name='".session_name()."' value='".session_id()."'>\n"; 187 echo "<input type='hidden' name='db_test' value='1'>\n"; 188 // select database 189 echo "<table><tr><td>db_type:</td><td> <select name=db_type>\n"; 190 echo "<option value='mysql'>mysql\n"; 191 echo "<option value='oracle'>oracle\n"; 192 echo "<option value='informix'>informix\n"; 193 echo "<option value='postgresql'>postgres\n"; 194 echo "<option value='interbase'>interbase\n"; 195 echo "<option value='ms_sql'>MS SQL\n"; 196 echo "</select></td></tr>\n"; 197 echo "<tr><td>Host:</td><td><input type='text' name='db_host'></td></tr>\n"; 198 echo "<tr><td>Username:</td><td><input type='text' name='db_user'></td></tr>\n"; 199 echo "<tr><td>Password:</td><td><input type='Password' name='db_pass'></td></tr>\n"; 200 echo "<tr><td>Database name:</td><td><input type='text' name='db_name'></td></tr>\n"; 201 echo "<tr><td> </td><td><input type='submit' value='db test'></td></tr>\n"; 202 echo "</table></form>\n"; 203 } 204 else if($_REQUEST['db_test'] == 1) { 205 206 // well ;-) 207 $db_host = $_REQUEST['db_host']; 208 $db_user = $_REQUEST['db_user']; 209 $db_pass = $_REQUEST['db_pass']; 210 $db_host2 = $_REQUEST['db_host2']; 211 $db_name = $_REQUEST['db_name']; 212 $db_type = $_REQUEST['db_type']; 213 214 // *** db test *** 215 216 // test mysql access 217 if ($db_type == "mysql") { 218 $link = mysql_connect($db_host,$db_user,$db_pass) or $_REQUEST['db_test'] = "failed"; 219 } 220 221 // test interbase access 222 else if ($db_type == "interbase") { 223 $db_host2 = "$db_host:$db_name"; 224 $link = ibase_connect($db_host2, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed"; 225 } 226 // test ms_sql 227 else if ($db_type == "ms_sql") { 228 $link = mssql_connect($db_host, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed"; 229 } 230 // test oracle 231 else if ($db_type == "oracle") { 232 $link = OCILogon($db_user, $db_pass, $db_name) or $_REQUEST['db_test'] = "failed"; 233 $datestmt = OCIParse($link, "alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH:MI:SS'"); 234 OCIExecute($datestmt); 235 } 236 // test informix 237 else if ($db_type == "informix") { 238 if ($db_host == "") $db = $db_name; 239 else $db = $db_name."@".$db_host; 240 $link = ifx_connect($db, $db_user, $db_pass) or $_REQUEST['db_test'] = "failed"; 241 } 242 // test postgres 243 else if ( $db_type == "postgresql" ) { 244 echo "<br>Trying to connect to $db_name"; 245 $link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=$db_name user=$db_user"); 246 echo "<br>$link"; 247 if (!$link) { 248 echo "<br>Trying to connect to template1"; 249 $link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=template1 user=$db_user") or $_REQUEST['db_test'] = "failed"; 250 echo "<br>Trying to create database $db_name"; 251 $result = pg_exec($link, "CREATE DATABASE $db_name") or $_REQUEST['db_test'] = "failed"; 252 echo "<br>Database create, closing connection to template1"; 253 $link = pg_close($link) or die("Can't close database connection"); 254 echo "<br>Opening new connection to db $db_name"; 255 $link = pg_connect((($db_host == "") ? "" : "host = $db_host ").(($db_pass == "") ? "" : "password=$db_pass ")."dbname=$db_name user=$db_user") or $_REQUEST['db_test'] = "failed"; 256 } 257 } 258 // *** end test db access *** 259 260 // output error message 261 if ($db_error == 1 or !$link or (isset($conn) and !$conn)) { 262 echo "oops - no connection to the dataase!<br>Reasons could be:<ul> 263 <li>Wrong access parameter, <li>The database is not running, <li>The database hasn't been setup correctly, 264 <li>The PHP parser has not been installed with this db support 265 </ul>Please fix it and try it again ...<br><br>"; 266 $_REQUEST['db_test'] = "failed"; 267 } 268 else { 269 echo "Seems that connecting the database has been successful :-)"; 270 $_REQUEST['db_test'] = "o.k."; 271 } 272 $_SESSION['db_test'] =& $db_test; 273 } 274 else echo "<i>Database access test done, result: ".$_REQUEST['db_test']."</i>"; 275 // end db test 276 277 278 279 // ********** 280 // mail check 281 echo "<br>**********************"; 282 echo "<h4>Mail Test</h4>\n"; 283 284 if (!$_REQUEST['email']) { 285 echo "Here you can test whether you are able to send and receive mails with PHProjekt.<br> 286 Enter your email adress here, the script will send you an email:<br>\n"; 287 echo "<form><input type='text' name='email'>\n"; 288 echo "<input type='hidden' name='".session_name()."' value='".session_id()."'>\n"; 289 echo "<input type='submit' value='send mail'></form>\n"; 290 } 291 else if ($_REQUEST['email'] <> 2) { 292 mail(urldecode($_REQUEST['email']),"PHProjekt Mail Test","Congratulations!\n Now you know that you can 293 use PHProjekt to send mails\n","From:$user_email\nReply-To:$user_email\nSender:$user_email\nReturn-Path:$user_email"); 294 echo "Please check your mailbox whether you got a mail from PHProjekt. If not, you should examine the mail settings in your php.ini"; 295 296 // imap extensions test 297 if (function_exists('imap_open')) { 298 echo "<br>Checking your mail configuration ... the IMAP library is active, therefore you can use the full mail client"; 299 $email_receive_test = "o.k."; 300 } 301 else { 302 echo "<br>oh, the imap library from PHP is missing, at the moment you cannot install the full email client :-( 303 <br> please tell your sysadmin or provider to install the imap library of php (not to be mixed with the imap server)."; 304 $email_receive_test = "failed"; 305 } 306 $_SESSION['email_receive_test'] =& $email_receive_test; 307 } 308 else echo "<i>Email test done, result: receive email $email_receive_test</i>"; 309 310 311 312 // ********* 313 // file test 314 echo "<br>**********************"; 315 echo "<h4>File writing Test</h4>"; 316 317 if (!$_REQUEST['file_test']) { 318 echo "<form>\n"; 319 echo "<input type='hidden' name='".session_name()."' value='".session_id()."'>\n"; 320 echo "Now the script proofs whether it is able to write <br>a test file in the PHProjekt root diretory.<br><br>\n"; 321 echo "<input type='hidden' name='file_test' value='1'>\n"; 322 echo "<input type='submit' value='file_test'></form><br>\n"; 323 } 324 else if ($_REQUEST['file_test'] == 1) { 325 $fp = fopen("test_phprojekt.txt", 'w'); 326 327 if (!$fp or $fp == "FALSE") { 328 echo "I couldn't write this file!<br>Please give the webserver read and write permission for this directory!\n"; 329 $_REQUEST['file_test'] = "failed"; 330 } 331 else { 332 $fw = fwrite($fp,"This file was created for testing reasons. You can delete it."); 333 echo "test file successfully written! Now it will be deleted again ...<br>\n"; 334 $_REQUEST['file_test'] = "o.k."; 335 fclose($fp); 336 $delete = unlink("test_phprojekt.txt"); 337 if (!$delete) { 338 echo ".. but it failed to erase this file!"; 339 $_REQUEST['file_test'] = "failed"; 340 } 341 } 342 343 // additional test - check whether file_uploads is set to "on" 344 if (ini_get("file_uploads") <> "1") { 345 echo "Please change the value of 'file_uploads' in the php.ini to 'on', otherwise you can't use the file or mail module!"; 346 if ($_REQUEST['file_test'] == "o.k.") $_REQUEST['file_test'] .= " but please change 'file_uploads' in the php.ini to 'on'."; 347 } 348 $_SESSION['file_test'] =& $file_test; 349 } 350 else echo "<i>file management test done, result: ".$_REQUEST['file_test']."</i>"; 351 352 353 echo "<br>**********************"; 354 echo "<br><br>If you want to run this test another time, please follow <a href='env_test.php?free=1'>this link here</a>\n"; 355 echo "<br><br><br>"; 356 357 // read and write permissions for root, attach, chat and upload directory 358 // blank screen problem! -> include of en.inc.php possible? 359 360 // next proof: file_uploads in the php.ini must be set to on .. 361 362 ?> 363 364 </body> 365 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |