From edd3a5db7eb0f721c6e24c4afd4b752d105b80b3 Mon Sep 17 00:00:00 2001 From: defacer Date: Thu, 19 Aug 2004 08:34:21 +0000 Subject: [PATCH] When config.php cannot be written to disk, click the button to download it and save it yourself. --- install.php | 96 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/install.php b/install.php index 72116d0311..1f00bdd14e 100644 --- a/install.php +++ b/install.php @@ -103,6 +103,23 @@ if (isset($_GET['help'])) { } +//==========================================================================// + +/// Any special action we need to take? + +if(isset($_POST['specialaction'])) { + switch($_POST['specialaction']) { + case 'downloadconfig': + $str = generate_config_php(); + header('Content-Type: text/plain'); + header('Content-Disposition: attachment; filename="config.php"'); + header('Content-Length: '.strlen($str)); + header('Connection: Close'); + echo $str; + die(); + break; + } +} //==========================================================================// @@ -258,38 +275,8 @@ if ($nextstage == 4 or $INSTALL['stage'] == 4) { /// Try to open config file for writing. if ($nextstage == 5) { - - $str = 'dbtype = \''.$INSTALL['dbtype']."';\n"; - $str .= '$CFG->dbhost = \''.$INSTALL['dbhost']."';\n"; - if ($INSTALL['dbtype'] == 'mysql') { - $str .= '$CFG->dbname = \''.$INSTALL['dbname']."';\n"; - $str .= '$CFG->dbuser = \''.$INSTALL['dbuser']."';\n"; - $str .= '$CFG->dbpass = \''.$INSTALL['dbpass']."';\n"; - } - $str .= '$CFG->dbpersist = false;'."\n"; - $str .= '$CFG->prefix = \''.$INSTALL['prefix']."';\n"; - $str .= "\n"; - - $str .= '$CFG->wwwroot = \''.$INSTALL['wwwroot']."';\n"; - $str .= '$CFG->dirroot = \''.$INSTALL['dirroot']."';\n"; - $str .= '$CFG->dataroot = \''.$INSTALL['dataroot']."';\n"; - $str .= "\n"; - - $str .= '$CFG->directorypermissions = 0777;'."\n"; - $str .= "\n"; - - $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\n"; - $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\n"; - $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\n"; - $str .= '?>'; - if (( $configsuccess = ($fh = @fopen($configfile, 'w')) ) !== false) { + $str = generate_config_php(); fwrite($fh, $str); fclose($fh); } @@ -354,10 +341,10 @@ if ($nextstage == 5) { echo "

".get_string('configfilewritten', 'install')."

\n"; } else { echo "

".get_string('configfilenotwritten', 'install')."

"; - echo "
\n"; - echo "
\n"; - print_object(htmlentities($str)); - echo "
\n"; + echo '

'; + echo ''; + echo ''; + echo '

'; echo "
\n"; } $options = array(); @@ -626,6 +613,45 @@ function check_memory_limit() { return ((int)str_replace('M', '', get_memory_limit()) >= 16); } +//==========================================================================// + +function generate_config_php() { + global $INSTALL; + + $str = 'dbtype = \''.$INSTALL['dbtype']."';\n"; + $str .= '$CFG->dbhost = \''.$INSTALL['dbhost']."';\n"; + if ($INSTALL['dbtype'] == 'mysql') { + $str .= '$CFG->dbname = \''.$INSTALL['dbname']."';\n"; + $str .= '$CFG->dbuser = \''.$INSTALL['dbuser']."';\n"; + $str .= '$CFG->dbpass = \''.$INSTALL['dbpass']."';\n"; + } + $str .= '$CFG->dbpersist = false;'."\n"; + $str .= '$CFG->prefix = \''.$INSTALL['prefix']."';\n"; + $str .= "\n"; + + $str .= '$CFG->wwwroot = \''.$INSTALL['wwwroot']."';\n"; + $str .= '$CFG->dirroot = \''.$INSTALL['dirroot']."';\n"; + $str .= '$CFG->dataroot = \''.$INSTALL['dataroot']."';\n"; + $str .= "\n"; + + $str .= '$CFG->directorypermissions = 0777;'."\n"; + $str .= "\n"; + + $str .= 'require_once("$CFG->dirroot/lib/setup.php");'."\n"; + $str .= '// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,'."\n"; + $str .= '// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.'."\n"; + $str .= '?>'; + + return $str; +} + + //==========================================================================// function css_styles() { -- 2.39.5