Thread: [Openfirst-cvscommit] update selectinstalldir.php,1.2,1.3
Brought to you by:
xtimg
From: Tim G. <xt...@us...> - 2004-11-30 21:55:41
|
Update of /cvsroot/openfirst/update In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14361 Modified Files: selectinstalldir.php Log Message: Add writing of globals.php file (not yet uploaded). Fix typos. Index: selectinstalldir.php =================================================================== RCS file: /cvsroot/openfirst/update/selectinstalldir.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** selectinstalldir.php 30 Nov 2004 16:14:59 -0000 1.2 --- selectinstalldir.php 30 Nov 2004 21:55:32 -0000 1.3 *************** *** 1,4 **** --- 1,194 ---- <?php + if(isset($_REQUEST["createnewglobals"])) { + include_once("../config/globals.php"); + include_once($header); + + $system = mysql_fetch_object(mysql_query("SELECT * FROM ofirst_systems WHERE id='" . $_REQUEST["sysid"] . "' AND owner='$user->id';")); + + $ftpreachable = ftp_connect($system->ftpserver); + if($ftpreachable) { + $loginokay = @ftp_login($ftpreachable, $system->ftpusername, $system->ftppassword); + } + if(! $ftpreachable || ! $loginokay) { + echo "FTP server is unreachable or cannot login properly."; + include_once($footer); + die(); + } + + + // TODO + // Run tests to make sure that configuration works successfully. If it does not, abort. + // If it does, continue. + + + + + // Write the new globals.php file + + + + $tmpfname = tempnam("/tmp", "OFIRSTINSTALLER_"); + + $of = fopen($tmpfname, "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 the openFIRST + * Remote FTP installer. See: http://www.openfirst.org/ + * for more information. The globals.php file + * 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. Changes to this file + * which are made manually may be lost due to remote updates. + * + * If you encounter such problems, contact the openFIRST team. + */ + \$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 = \"\"; + + ofirst_select_db(\$sqldatabase, \$sqlconnection); + \$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); + + // TODO: Upload the new globals.php file here. + + + + // Done. + + // unlink($tmpfname); + + include_once($footer); + die(); + } + + if(! isset($ftpreachable)) { *************** *** 157,161 **** $syscfg->fbasepath = $system->fbasepath; } ! if(! isset($syscfg->dbasetype)) { $syscfg->basepath = $system->basepath; } --- 347,351 ---- $syscfg->fbasepath = $system->fbasepath; } ! if(! isset($syscfg->basepath)) { $syscfg->basepath = $system->basepath; } *************** *** 169,172 **** --- 359,365 ---- <h1>Base Configuration</h1> <p><form action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post"> + <input type='hidden' name='createnewglobals' value='createnewglobals'> + <input type='hidden' name='sysid' value='<?php echo $_REQUEST["sysid"]; ?>'> + Congratulations on your choice of openFIRST software. Please proceed through this setup wizard to get your new openFIRST portal software set up and working *************** *** 341,345 **** <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 $syscfg->fbasepath; ?>"></td> </tr> <tr> --- 534,538 ---- <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 $syscfg->fbasepath; ?>"></td> </tr> <tr> |