fixing HTACCESS div bug + control on capacity to write/read htaccess and htpasswd

This commit is contained in:
Benjamin Sonntag 2011-06-04 12:42:01 +00:00
parent 6c4674275b
commit d7a2d40591
3 changed files with 22 additions and 4 deletions

View File

@ -71,18 +71,28 @@ class m_hta {
return false; return false;
} }
if (!file_exists($absolute)) { if (!file_exists($absolute)) {
mkdir($absolute,00777); @mkdir($absolute,00777);
} }
if (!file_exists("$absolute/.htaccess")) { if (!file_exists("$absolute/.htaccess")) {
touch("$absolute/.htaccess"); if (!@touch("$absolute/.htaccess")) {
$file = fopen("$absolute/.htaccess","r+"); $err->raise("hta",12);
return false;
}
$file = @fopen("$absolute/.htaccess","r+");
if (!$file) {
$err->raise("hta",12);
return false;
}
fseek($file,0); fseek($file,0);
$param="AuthUserFile $absolute/.htpasswd\nAuthName \"Zone Protégée\"\nAuthType Basic\nrequire valid-user\n"; $param="AuthUserFile $absolute/.htpasswd\nAuthName \"Zone Protégée\"\nAuthType Basic\nrequire valid-user\n";
fwrite($file, $param); fwrite($file, $param);
fclose($file); fclose($file);
} }
if (!file_exists("$absolute/.htpasswd")) { if (!file_exists("$absolute/.htpasswd")) {
touch("$absolute/.htpasswd"); if (!touch("$absolute/.htpasswd")) {
$err->raise("hta",12);
return false;
}
return true; return true;
} }
return true; return true;

View File

@ -376,6 +376,10 @@ msgstr "The user '%s' already exist for this folder"
msgid "err_hta_11" msgid "err_hta_11"
msgstr "Please enter a valid username" msgstr "Please enter a valid username"
#. Cannot write inside the requested folder. Please check your permissions
msgid "err_hta_12"
msgstr "Cannot write inside the requested folder. Please check your permissions."
#. Email Accounts #. Email Accounts
msgid "quota_mail" msgid "quota_mail"
msgstr "Email Accounts" msgstr "Email Accounts"

View File

@ -378,6 +378,10 @@ msgstr "L'utilisateur '%s' existe d
msgid "err_hta_11" msgid "err_hta_11"
msgstr "Veuillez saisir un nom d'utilisateur valide" msgstr "Veuillez saisir un nom d'utilisateur valide"
#. Cannot write inside the requested folder. Please check your permissions
msgid "err_hta_12"
msgstr "Impossible d'écrire dans le dossier concerné. Vérifiez vos permissions."
#. Email Accounts #. Email Accounts
msgid "quota_mail" msgid "quota_mail"
msgstr "Comptes emails" msgstr "Comptes emails"