Skip to content
Snippets Groups Projects
Commit 87de5396 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Create htaccess file by default into document if not already exists

parent c681e267
Branches
Tags
No related merge requests found
...@@ -151,22 +151,29 @@ if ($memmaxorig != '') ...@@ -151,22 +151,29 @@ if ($memmaxorig != '')
} }
// Si fichier present et lisible et renseigne // If config file presente and filled
clearstatcache(); clearstatcache();
if (is_readable($conffile) && filesize($conffile) > 8) 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; $confexists=1;
include_once($conffile); include_once($conffile);
// Deja install�, on peut upgrader $databaseok=1; // TODO Check if database is ok
// \todo Test if database ok if ($databaseok)
{
// Already installed for all parts (config and database). We can propose upgrade.
$allowupgrade=1; $allowupgrade=1;
} }
else else
{ {
// Si non on le cr�e $allowupgrade=0;
dolibarr_install_syslog("check: we try to creat conf file '$conffile'"); }
}
else
{
// If not, we create it
dolibarr_install_syslog("check: we try to create conf file '$conffile'");
$confexists=0; $confexists=0;
# First we try by copying example # First we try by copying example
...@@ -196,7 +203,7 @@ else ...@@ -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)) if (! file_exists($conffile))
{ {
//print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated",$conffile); //print '<img src="../theme/eldy/img/error.png" alt="Error"> '.$langs->trans("ConfFileDoesNotExistsAndCouldNotBeCreated",$conffile);
...@@ -210,7 +217,7 @@ if (! file_exists($conffile)) ...@@ -210,7 +217,7 @@ if (! file_exists($conffile))
} }
else else
{ {
// Si fichier prsent mais ne peut etre modifi // Si fichier present mais ne peut etre modifie
if (!is_writable($conffile)) if (!is_writable($conffile))
{ {
if ($confexists) if ($confexists)
...@@ -246,7 +253,7 @@ else ...@@ -246,7 +253,7 @@ else
} }
print "<br />\n"; 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) if ($checksok)
{ {
$ok=0; $ok=0;
......
...@@ -64,7 +64,7 @@ if (substr($_POST["main_url"], strlen($_POST["main_url"]) -1) == "/") ...@@ -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); $_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"]:''; $main_data_dir=isset($_POST["main_data_dir"])?$_POST["main_data_dir"]:'';
if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; } if (! $main_data_dir) { $main_data_dir="$main_dir/documents"; }
...@@ -120,7 +120,7 @@ if ($_POST["action"] == "set") ...@@ -120,7 +120,7 @@ if ($_POST["action"] == "set")
// Create subdirectory main_data_dir // Create subdirectory main_data_dir
if (! $error) if (! $error)
{ {
// R�pertoire des documents // Create directory for documents
if (! is_dir($main_data_dir)) if (! is_dir($main_data_dir))
{ {
create_exdir($main_data_dir); create_exdir($main_data_dir);
...@@ -138,7 +138,23 @@ if ($_POST["action"] == "set") ...@@ -138,7 +138,23 @@ if ($_POST["action"] == "set")
} }
else 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[0] = "$main_data_dir/facture";
$dir[1] = "$main_data_dir/users"; $dir[1] = "$main_data_dir/users";
$dir[2] = "$main_data_dir/propale"; $dir[2] = "$main_data_dir/propale";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment