Create htaccess file by default into document if not already exists

This commit is contained in:
Laurent Destailleur 2009-10-05 23:04:05 +00:00
parent c681e267d8
commit 87de5396fb
2 changed files with 36 additions and 13 deletions

View File

@ -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<6C>, 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<63>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<EFBFBD><EFBFBD>
// 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<EFBFBD>sent mais ne peut etre modifi<66>
// 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 <EFBFBD> l'<27>tape suivante
// Si prerequis ok, on affiche le bouton pour passer a l'etape suivante
if ($checksok)
{
$ok=0;

View File

@ -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<EFBFBD>pertoire des documents g<>n<EFBFBD>r<EFBFBD>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<EFBFBD>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<EFBFBD>charg<72>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";