From d7a2d4059119f722630d921d32d4c5846ef6a293 Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Sat, 4 Jun 2011 12:42:01 +0000 Subject: [PATCH] fixing HTACCESS div bug + control on capacity to write/read htaccess and htpasswd --- bureau/class/m_hta.php | 18 ++++++++++++++---- bureau/locales/en_US/LC_MESSAGES/manual.po | 4 ++++ bureau/locales/fr_FR/LC_MESSAGES/manual.po | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bureau/class/m_hta.php b/bureau/class/m_hta.php index 7b4e4624..8f44f434 100644 --- a/bureau/class/m_hta.php +++ b/bureau/class/m_hta.php @@ -71,18 +71,28 @@ class m_hta { return false; } if (!file_exists($absolute)) { - mkdir($absolute,00777); + @mkdir($absolute,00777); } if (!file_exists("$absolute/.htaccess")) { - touch("$absolute/.htaccess"); - $file = fopen("$absolute/.htaccess","r+"); + if (!@touch("$absolute/.htaccess")) { + $err->raise("hta",12); + return false; + } + $file = @fopen("$absolute/.htaccess","r+"); + if (!$file) { + $err->raise("hta",12); + return false; + } fseek($file,0); $param="AuthUserFile $absolute/.htpasswd\nAuthName \"Zone Protégée\"\nAuthType Basic\nrequire valid-user\n"; fwrite($file, $param); fclose($file); } if (!file_exists("$absolute/.htpasswd")) { - touch("$absolute/.htpasswd"); + if (!touch("$absolute/.htpasswd")) { + $err->raise("hta",12); + return false; + } return true; } return true; diff --git a/bureau/locales/en_US/LC_MESSAGES/manual.po b/bureau/locales/en_US/LC_MESSAGES/manual.po index 78615eaf..64419f98 100644 --- a/bureau/locales/en_US/LC_MESSAGES/manual.po +++ b/bureau/locales/en_US/LC_MESSAGES/manual.po @@ -376,6 +376,10 @@ msgstr "The user '%s' already exist for this folder" msgid "err_hta_11" 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 msgid "quota_mail" msgstr "Email Accounts" diff --git a/bureau/locales/fr_FR/LC_MESSAGES/manual.po b/bureau/locales/fr_FR/LC_MESSAGES/manual.po index b1fbc151..25b0f970 100644 --- a/bureau/locales/fr_FR/LC_MESSAGES/manual.po +++ b/bureau/locales/fr_FR/LC_MESSAGES/manual.po @@ -378,6 +378,10 @@ msgstr "L'utilisateur '%s' existe d msgid "err_hta_11" 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 msgid "quota_mail" msgstr "Comptes emails"