[Openfirst-cvscommit] base/config first.php,1.43,1.44
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2004-12-29 22:00:48
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8194/config Modified Files: first.php Log Message: -Templates implemented -Setting detection occurs before any HTML is printed Index: first.php =================================================================== RCS file: /cvsroot/openfirst/base/config/first.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** first.php 28 Dec 2004 19:55:06 -0000 1.43 --- first.php 29 Dec 2004 22:00:38 -0000 1.44 *************** *** 53,198 **** ofirst_select_db($sqldatabase); // They have submitted the form, write a new globals.php file and test // options. if(is_writable("./globals.php")) { ! $of = fopen("./globals.php", "w"); ! if(isset($_POST["cookielogins"])&&$_POST["cookielogins"]=="yes"){ ! $cookielogins=""; ! }else{ ! $cookielogins='$pass_save_disabled=true;'; ! } ! if(isset($_POST["allowreg"])&&$_POST["allowreg"]=="yes"){ ! $allowreg='$regenabled=true;'; ! }else{ ! $allowreg='$regenabled=false;'; ! } ! if(! isset($_POST["peardb"])) { $_POST["peardb"] = false; } ! fputs($of, "<?php ! /* ! * openFIRST base configuration file ! * This file has been automatically generated by first.php. ! * it contains the basic configuration options required to ! * operate the OpenFIRST web portal software. Note, that ! * most configuration options are now stored in the MySQL ! * database, in the ofirst_config table. ! */ ! \$dbasetype = \"" . $_POST["dbasetype"] . "\"; ! \$peardb = " . $_POST["peardb"] . "; ! \$ostype = '" . $_POST["ostype"] . "'; ! if (\$ostype == \"windows\") { ! ini_set(\"include_path\", ini_get(\"include_path\") . \";../config/;.\"); ! include_once('dbase.php'); ! } else { ! ini_set(\"include_path\", ini_get(\"include_path\") . \":../config/:.\"); ! include_once('dbase.php'); ! } ! ! \$encryption = '" . $_POST["encryption"] . "'; ! ! \$title = '" . $_POST["title"] . "'; ! \$version = '" . $_POST["version"] . "'; ! \$sqlserver = '" . $_POST["sqlserver"] . "'; ! \$sqluser = '" . $_POST["sqluser"] . "'; ! \$sqlpassword = '" . $_POST["sqlpassword"] . "'; ! \$sqldatabase = '" . $_POST["sqldatabase"] . "'; ! if(function_exists(\"ofirst_dbconnect\") == false) { ! die(\"Your version of PHP has not been compiled with MySQL support, therefore the openFIRST web portal system cannot run on this system. Please contact your system administrator to request MySQL support for your version of PHP.\"); ! } ! ! \$sqlconnection = ofirst_dbconnect(\"\$sqlserver\",\"\$sqluser\",\"\$sqlpassword\"); ! ! if(\$peardb) { ! \$sqlconnection = ofirst_select_db(\$sqldatabase); ! } else { ! ofirst_select_db(\$sqldatabase); ! } ! ! $cookielogins ! $allowreg ! \$home = '" . $_POST["home"] . "'; ! \$header = '" . $_POST["header"] . "'; ! \$footer = '" . $_POST["footer"] . "'; ! \$mailnotify = '" . $_POST["mailnotify"] . "'; ! \$mailfrom = '" . $_POST["mailfrom"] . "'; ! \$basepath = '" . $_POST["basepath"] . "'; ! \$fbasepath = '" . $_POST["fbasepath"] . "'; ! ! // Determine what module the user is viewing ! ! \$currentmodule = str_replace(\$basepath, \"\", \$_SERVER[\"SCRIPT_NAME\"]); ! \$currentmodule = substr(\$currentmodule, 1, strpos(\$currentmodule, \"/\", 2) - 1); ! ! ! session_start(); ! include('auth.php'); ! if(function_exists(\"glob\")) { ! // Include the functions using glob(); ! if(is_readable(getcwd() . \"/../config/functions/\")) { ! foreach (glob(getcwd() . \"/../config/functions/*.php\") as \$filename) { ! include(\$filename); ! } ! } elseif (is_readable(getcwd() . \"/../../config/functions/\")) { ! foreach (glob(getcwd() . \"/../../config/functions/*.php\") as \$filename) { ! include(\$filename); ! } ! } ! } else { ! // Include the functions without using glob(); ! } ! ! \$headers = \"\"; ! ! \$incl = ofirst_dbquery(\"SELECT * FROM ofirst_config\"); ! ! // If there is no error then run the module add feature ! if(ofirst_dberrno() == 0) { ! // Begin to loop through modules from the databaes ! while(\$module = ofirst_dbfetch_object(\$incl)) { ! // Check if the value is try, if it is then run an include ! if( (bool) \$module->active == true) { ! // Check if there are includes that need to be included ! if(! \$module->includes == \"\"){ ! // If the list is not empty then explode the value and put it into inclist ! \$inclist = explode(\",\",\$module->includes); ! // This is to remove an error that you have if you don't check if there are more then 2 ! if(count(\$inclist) >= 2){ ! ! // Loop through the inclist and add them according to their paths ! foreach(\$inclist As \$inc){ ! include(\"\$fbasepath/\$module->modulename/\$inc\"); ! } ! } else { ! // If there is only 1 include available then use this line to include it instead ! include(\"\$fbasepath/\$module->modulename/\$module->includes\"); ! } ! } ! ! // If the module has requested to be shown on the menu then add it ! if( (bool) \$module->showonmenu == true) { ! // If it is the current module then color the item ! if (\$currentmodule == \$module->modulename){ ! \$headers .= \" » <font color='red'><u><a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a></u></font> |\"; ! ! // Declare important variables so that headers can pick them up and preview them ! ! \$adminnav = str_replace(\"\\\$basepath\", \$basepath, \$module->adminnavigation) . \" <a href='http://bugzilla.openfirst.org'>Report Bug</a>\"; ! \$subnav = str_replace(\"\\\$basepath\", \$basepath, \$module->modulenavigation); ! ! } else { ! \$headers .= \" » <a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a> |\"; ! } ! } ! } ! } ! } ! ! session_write_close(); ! ?>"); ! fclose($of); ! include("../config/globals.php"); ! include("$header"); ! echo("<h1>openFIRST Software Configured</h1> <p>If this page does not display errors elsewhere, then your openFIRST has now been successfully configured. If there are errors, check your configuration options and try again. You may now --- 53,117 ---- ofirst_select_db($sqldatabase); + function GetVarValue($var) { + ob_Start(); + var_export($var); + $Value = ob_Get_Contents(); + ob_End_Clean(); + return $Value; + } + // They have submitted the form, write a new globals.php file and test // options. if(is_writable("./globals.php")) { ! $file = file_get_contents('./globals.tpl'); ! $cookielogins = ((isset($_POST["cookielogins"]) && $_POST["cookielogins"]=="yes") ? true : false); ! $allowreg = ((isset($_POST["allowreg"]) && $_POST["allowreg"]=="yes") ? true : false); if(! isset($_POST["peardb"])) { $_POST["peardb"] = false; } ! $find = array('%DBTYPE%', ! '%PEAR%', ! '%OS%', ! '%ENCRYPT%', ! '%TITLE%', ! '%VER%', ! '%DBSERVER%', ! '%DBUSER%', ! '%DBPASS%', ! '%DBNAME%' ! '%COOKIE%', ! '%REG%', ! '%HOME%', ! '%HEADER%', ! '%FOOTER%', ! '%MASTERMAIL%', ! '%BOTMAIL%', ! '%BASEPATH%', ! '%FBASEPATH%'); ! ! $replace = array(GetVarValue($_POST['dbasetype']), ! GetVarValue($_POST['peardb']), ! GetVarValue($_POST['ostype']), ! GetVarValue($_POST['encryption']), ! GetVarValue($_POST['title']), ! GetVarValue($_POST['version']), ! GetVarValue($_POST['sqlserver']), ! GetVarValue($_POST['sqluser']), ! GetVarValue($_POST['sqlpassword']), ! GetVarValue($_POST['sqldatabase']), ! GetVarValue($cookielogins), ! GetVarValue($allowreg), ! GetVarValue($_POST['home']), ! GetVarValue($_POST['header']), ! GetVarValue($_POST['footer']), ! GetVarValue($_POST['mailnotify']), ! GetVarValue($_POST['mailfrom']), ! GetVarValue($_POST['basepath']), ! GetVarValue($_POST['fbasepath'])); ! ! str_replace($find, $replace, $file); ! file_put_contents('./globals.php', $file); ! include("../config/globals.php"); ! include("$header"); ! echo("<h1>openFIRST Software Configured</h1> <p>If this page does not display errors elsewhere, then your openFIRST has now been successfully configured. If there are errors, check your configuration options and try again. You may now *************** *** 201,213 **** <b>openfirst</b>, if not, then either the password for that account has been changed, or the MySQL settings are incorrect.</p>"); ! showlogin(); ! die(include("$footer")); ! } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); } else { ! include("../config/headers.php"); ! } ! echo("<h1>System Configuration Error</h1> <p>Cannot write to configuration file. Please check permissions on <b>globals.php</b> and ensure that the web user has the ability to write to this file.</p> --- 120,132 ---- <b>openfirst</b>, if not, then either the password for that account has been changed, or the MySQL settings are incorrect.</p>"); ! showlogin(); ! die(include("$footer")); } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); ! } else { ! include("../config/headers.php"); ! } ! echo("<h1>System Configuration Error</h1> <p>Cannot write to configuration file. Please check permissions on <b>globals.php</b> and ensure that the web user has the ability to write to this file.</p> *************** *** 219,234 **** <br />chmod 666 globals.php </code></p>"); ! } ! } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); ! } else { ! include("../config/headers.php"); ! } ! // User is visiting the configuration page, present them with a form ! // of options to fill out. ! ?> <h1>Base Configuration</h1> ! <p><form action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post"> Congratulations on your choice of openFIRST software. Please proceed through this setup wizard to get your new openFIRST portal software set up and working --- 138,188 ---- <br />chmod 666 globals.php </code></p>"); ! } ! } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); ! } else { ! include("../config/headers.php"); ! } ! ! // Detect default options ! $basepath = substr($_SERVER["SCRIPT_NAME"], 0, -17)); ! $server = $_SERVER["SERVER_NAME"]; ! $basepath = str_replace("\\", '/', getcwd()); ! chdir('..'); ! $fbasepath = str_replace("\\", '/', getcwd()); ! $windows = (isset($_ENV['OS']) && strpos(' ' . $_ENV['OS'], 'Windows')) ? true : false; ! $fd = explode(($windows ? ';' : ':'), ini_get('include_path')); ! ! $peardb = false; ! foreach($fd as $d) { ! if(file_exists("$d/DB.php")) { ! $peardb = true; ! } ! } ! ! $sqlhost = 'localhost'; ! if(ini_get('mysql.default_host') != '') { ! $sqlhost = ini_get('mysql.default_host'); ! } ! ! $sqluser = 'sqluser'; ! if(ini_get('mysql.default_user') != '') { ! $sqluser = ini_get('mysql.default_user'); ! } ! ! $sqlpass = ''; ! if(ini_get('mysql.default_password') != '') { ! $sqlpass = ini_get('mysql.default_password'); ! } ! ! $mailto = $_SERVER['SERVER_ADMIN']; ! $mailfrom = "openfirst@$server"; ! ! // User is visiting the configuration page, present them with a form ! // of options to fill out. ! ?> <h1>Base Configuration</h1> ! <p><form action="<?php echo htmlentities($_SERVER["PHP_SELF"]); ?>" method="post"> Congratulations on your choice of openFIRST software. Please proceed through this setup wizard to get your new openFIRST portal software set up and working *************** *** 250,260 **** <td><select name="ostype"> <?php ! if (isset($_ENV["OS"]) && strpos(" " . $_ENV["OS"], "Windows")) { ! echo("<option value='unix'>UNIX</option> ! <option value='windows' selected='selected'>Windows</option>"); ! } else { ! echo("<option value='unix' selected='selected'>UNIX</option> ! <option value='windows'>Windows</option>"); ! } ?> </select> <font size="2">(UNIX includes variants, such as Linux, Mac OS --- 204,214 ---- <td><select name="ostype"> <?php ! if ($windows) { ! echo("<option value='unix'>UNIX</option> ! <option value='windows' selected='selected'>Windows</option>"); ! } else { ! echo("<option value='unix' selected='selected'>UNIX</option> ! <option value='windows'>Windows</option>"); ! } ?> </select> <font size="2">(UNIX includes variants, such as Linux, Mac OS *************** *** 264,278 **** <td>Database Type <?php ! $fd = explode(";", ini_get('include_path')); ! $peardb = false; ! foreach($fd as $d) { ! if(file_exists($d . "/DB.php")) { ! echo ("<br>The PEAR Database Abstraction layer exists and will be used."); ! $peardb = true; ! } ! } ?> </td> ! <td><?php if(! $peardb) { ?> <input type='hidden' name='peardb' value='false'> <select name="dbasetype"> --- 218,229 ---- <td>Database Type <?php ! if ($peardb) { ! echo ("<br />The PEAR Database Abstraction layer exists and will be used."); ! } ?> </td> ! <td><?php ! if(! $peardb) { ! ?> <input type='hidden' name='peardb' value='false'> <select name="dbasetype"> *************** *** 282,286 **** </select> ! <?php } else { ?> <input type='hidden' name='peardb' value='true'> <select name="dbasetype"> --- 233,239 ---- </select> ! <?php ! } else { ! ?> <input type='hidden' name='peardb' value='true'> <select name="dbasetype"> *************** *** 299,303 **** <option value="sybase">Sybase (through PEAR DB)</option> </select> ! <?php } ?> <tr> <td>Title of Website</td> --- 252,258 ---- <option value="sybase">Sybase (through PEAR DB)</option> </select> ! <?php ! } ! ?> <tr> <td>Title of Website</td> *************** *** 309,335 **** </tr> <tr> ! <td>Database Server Address</td> ! <td><input type="text" name="sqlserver" value="<?php ! if(ini_get("mysql.default_host") != "") { ! echo(ini_get("mysql.default_host")); ! } else { ! echo("localhost"); ! }?>" /></td> </tr> <tr> <td>Database User Name</td> ! <td><input type="text" name="sqluser" value="<?php ! if(ini_get("mysql.default_user") != "") { ! echo(ini_get("mysql.default_user")); ! } else { ! echo("sqluser"); ! }?>" /></td> </tr> <tr> <td>Database User Password</td> ! <td><input type="password" name="sqlpassword" value="<?php ! if(ini_get("mysql.default_password") != "") { ! echo(ini_get("mysql.default_password")); ! }?>" /></td> </tr> <tr> --- 264,277 ---- </tr> <tr> ! <td>Database Server Address</td> ! <td><input type="text" name="sqlserver" value="<?php echo htmlentities($sqlhost); ?>" /></td> </tr> <tr> <td>Database User Name</td> ! <td><input type="text" name="sqluser" value="<?php echo htmlentities($sqluser); ?>" /></td> </tr> <tr> <td>Database User Password</td> ! <td><input type="password" name="sqlpassword" value="<?php echo htmlentities($sqlpass); ?>" /></td> </tr> <tr> *************** *** 346,361 **** to your main page) <em>Note:</em> Do not place a slash after the link ie. http://www.yoursite.com</font></td> ! <td> <input type="text" name="home" value="<?php echo("http://" . $_SERVER["SERVER_NAME"] . substr($_SERVER["SCRIPT_NAME"], 0, -17)); ?>" ></td> </tr> <tr> <td>Header file<br> <font size="1">(this should be a full system path) ie. c:\inetpub\wwwroot\openfirst\config\header.php or /home/site/public_html/openfirst/config/headers.php</font></td> ! <td><input type="text" name="header" value="<?php echo(str_replace("\\", "/", getcwd())); ?>/headers.php" /></td> </tr> <tr> <td>Footer file<br> <font size="1">(this should be a full system path) ie. c:\inetpub\wwwroot\openfirst\config\footers.php or /home/site/public_html/openfirst/config/footers.php</font></td> ! <td><input type="text" name="footer" value="<?php ! echo(str_replace("\\", "/", getcwd())); ?>/footers.php" /></td> </tr> <tr> --- 288,302 ---- to your main page) <em>Note:</em> Do not place a slash after the link ie. http://www.yoursite.com</font></td> ! <td> <input type="text" name="home" value="<?php echo htmlentities("http://$server$basepath"); ?>" ></td> </tr> <tr> <td>Header file<br> <font size="1">(this should be a full system path) ie. c:\inetpub\wwwroot\openfirst\config\header.php or /home/site/public_html/openfirst/config/headers.php</font></td> ! <td><input type="text" name="header" value="<?php echo htmlentities($basepath); ?>/headers.php" /></td> </tr> <tr> <td>Footer file<br> <font size="1">(this should be a full system path) ie. c:\inetpub\wwwroot\openfirst\config\footers.php or /home/site/public_html/openfirst/config/footers.php</font></td> ! <td><input type="text" name="footer" value="<?php echo htmlentities($basepath); ?>/footers.php" /></td> </tr> <tr> *************** *** 363,372 **** http://openfirst.sourceforge.net<strong>/openfirst</strong>) this should always have a beginning slash but no ending slash.</font></td> ! <td><input type="text" name="basepath" value="<?php echo(substr($_SERVER["SCRIPT_NAME"], 0, -17)); ?>"></td> </tr> <tr> <td>The file system path to the basepath<br> <font size="1">(example: <strong>/home/openfirst/htdocs/openfirst</strong> or c:\inetpub\wwwroot\openfirst) this should not have a ending slash.</font></td> ! <td><input type="text" name="fbasepath" value="<?php chdir(".."); echo str_replace("\\", "/", getcwd()); ?>"></td> </tr> <tr> --- 304,313 ---- http://openfirst.sourceforge.net<strong>/openfirst</strong>) this should always have a beginning slash but no ending slash.</font></td> ! <td><input type="text" name="basepath" value="<?php echo htmlentities($basepath); ?>"></td> </tr> <tr> <td>The file system path to the basepath<br> <font size="1">(example: <strong>/home/openfirst/htdocs/openfirst</strong> or c:\inetpub\wwwroot\openfirst) this should not have a ending slash.</font></td> ! <td><input type="text" name="fbasepath" value="<?php echo htmlentities($fbasepath); ?>"></td> </tr> <tr> *************** *** 406,415 **** <td>Mail Notification<br> <font size="1">(the e-mail address used to notify you when significant events occur)</font></td> ! <td><input type="text" name="mailnotify" value="tea...@ex..."></td> </tr> <tr> <td>Mail From<br> <font size="1">(the e-mail address that mail from the openFIRST site should appear to be from)</font></td> ! <td><input type="text" name="mailfrom" value="no...@ex..."></td> </tr> <tr> --- 347,356 ---- <td>Mail Notification<br> <font size="1">(the e-mail address used to notify you when significant events occur)</font></td> ! <td><input type="text" name="mailnotify" value="<?php echo htmlentities($mailto); ?>"></td> </tr> <tr> <td>Mail From<br> <font size="1">(the e-mail address that mail from the openFIRST site should appear to be from)</font></td> ! <td><input type="text" name="mailfrom" value="<?php echo htmlentities($mailfrom); ?>"></td> </tr> <tr> |