From 87de5396fb816e3695d00cd7446c329dfa167f2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Mon, 5 Oct 2009 23:04:05 +0000 Subject: [PATCH] Create htaccess file by default into document if not already exists --- htdocs/install/check.php | 27 +++++++++++++++++---------- htdocs/install/etape1.php | 22 +++++++++++++++++++--- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 74fe8a1fe83..6fba9643389 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -151,22 +151,29 @@ if ($memmaxorig != '') } -// Si fichier present et lisible et renseigne +// If config file presente and filled clearstatcache(); if (is_readable($conffile) && filesize($conffile) > 8) { - dolibarr_install_syslog("check: conf file '$conffile' already exists"); + dolibarr_install_syslog("check: conf file '$conffile' already defined"); $confexists=1; include_once($conffile); - // Deja install�, on peut upgrader - // \todo Test if database ok - $allowupgrade=1; + $databaseok=1; // TODO Check if database is ok + if ($databaseok) + { + // Already installed for all parts (config and database). We can propose upgrade. + $allowupgrade=1; + } + else + { + $allowupgrade=0; + } } else { - // Si non on le cr�e - dolibarr_install_syslog("check: we try to creat conf file '$conffile'"); + // If not, we create it + dolibarr_install_syslog("check: we try to create conf file '$conffile'"); $confexists=0; # First we try by copying example @@ -196,7 +203,7 @@ else -// Si fichier absent et n'a pu etre cr�� +// Si fichier absent et n'a pu etre cree if (! file_exists($conffile)) { //print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated",$conffile); @@ -210,7 +217,7 @@ if (! file_exists($conffile)) } else { - // Si fichier pr�sent mais ne peut etre modifi� + // Si fichier present mais ne peut etre modifie if (!is_writable($conffile)) { if ($confexists) @@ -246,7 +253,7 @@ else } print "<br />\n"; - // Si prerequis ok, on affiche le bouton pour passer � l'�tape suivante + // Si prerequis ok, on affiche le bouton pour passer a l'etape suivante if ($checksok) { $ok=0; diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index b6bc5f61e8f..2c2d051ccf8 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -64,7 +64,7 @@ if (substr($_POST["main_url"], strlen($_POST["main_url"]) -1) == "/") $_POST["main_url"] = substr($_POST["main_url"], 0, strlen($_POST["main_url"])-1); } -// R�pertoire des documents g�n�r�s (factures, etc...) +// Directory for generated documents (invoices, orders, ecm, etc...) $main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:''; if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; } @@ -120,7 +120,7 @@ if ($_POST["action"] == "set") // Create subdirectory main_data_dir if (! $error) { - // R�pertoire des documents + // Create directory for documents if (! is_dir($main_data_dir)) { create_exdir($main_data_dir); @@ -138,7 +138,23 @@ if ($_POST["action"] == "set") } else { - // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre t�l�charg�s en passant outre l'authentification + // Create .htaccess file in document directory + $pathhtaccess=$main_data_dir.'/.htaccess'; + if (! file_exists($pathhtaccess)) + { + dolibarr_install_syslog("etape1: .htaccess file does not exists, we create it in '".$main_data_dir."'"); + $handlehtaccess=@fopen($pathhtaccess,'w'); + if ($handlehtaccess) + { + fwrite($handlehtaccess,'Order allow,deny'."\n"); + fwrite($handlehtaccess,'Deny from all'."\n"); + + fclose($handlehtaccess); + dolibarr_install_syslog("etape1: .htaccess file created"); + } + } + + // Les documents sont en dehors de htdocs car ne doivent pas pouvoir etre telecharges en passant outre l'authentification $dir[0] = "$main_data_dir/facture"; $dir[1] = "$main_data_dir/users"; $dir[2] = "$main_data_dir/propale"; -- GitLab