From f4f8b96e979d45c397ada36a2dad0399517ebe0d Mon Sep 17 00:00:00 2001 From: nikrou Date: Mon, 22 Mar 2010 20:30:56 +0000 Subject: Feature 1525 : propose to download config database file when permissions for writing it to local/config directory are missing. git-svn-id: http://piwigo.org/svn/trunk@5266 68402e56-0260-453c-a942-63ccdbb3a9ee --- install.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index 080b262e1..f51d7d593 100644 --- a/install.php +++ b/install.php @@ -119,6 +119,20 @@ else include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); @include(PHPWG_ROOT_PATH. 'local/config/config.inc.php'); +// download database config file if exists +if (!empty($_GET['dl']) && file_exists($conf['local_data_dir'].'/pwg_'.$_GET['dl'])) +{ + $filename = $conf['local_data_dir'].'/pwg_'.$_GET['dl']; + header('Cache-Control: no-cache, must-revalidate'); + header('Pragma: no-cache'); + header('Content-Disposition: attachment; filename="database.inc.php"'); + header('Content-Transfer-Encoding: binary'); + header('Content-Length: '.filesize($filename)); + echo file_get_contents($filename); + unlink($filename); + exit(); +} + // Obtain various vars $dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost'; $dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : ''; @@ -320,12 +334,22 @@ define(\'DB_COLLATE\', \'\'); // writing the configuration file if ( !($fp = @fopen( $config_file, 'w' ))) { - $html_content = htmlentities( $file_content, ENT_QUOTES ); - $html_content = nl2br( $html_content ); - $error_copy = l10n('Copy the text in pink between hyphens and paste it into the file "local/config/database.inc.php"(Warning : database.inc.php must only contain what is in pink, no line return or space character)'); - $error_copy .= '
--------------------------------------------------------------------
'; - $error_copy .= '' . $html_content . ''; - $error_copy .= '
--------------------------------------------------------------------
'; + $tmp_filename = md5(uniqid(time())); + $fh = @fopen( $conf['local_data_dir'] . '/pwg_' . $tmp_filename, 'w' ); + @fputs($fh, $file_content, strlen($file_content)); + @fclose($fh); + + $error_copy = l10n('Creation of config file local/config/database.inc.php failed.'); + $error_copy .= sprintf('
%s %s', + $tmp_filename, + l10n('You can download the config file'), + l10n('and upload it to local/config directory of your installation.') + ); + + $error_copy .= '

'; + $error_copy .= l10n('An alternate solution is to copy the text in the box above and paste it into the file "local/config/database.inc.php" (Warning : database.inc.php must only contain what is in the textarea, no line return or space character)'); + $error_copy .= '

'; + $error_copy .= ''; } @fputs($fp, $file_content, strlen($file_content)); @fclose($fp); -- cgit v1.2.3