зеркало из https://github.com/nextcloud/server.git
DRY for creating htaccess to protect data-directory
This commit is contained in:
Родитель
246d7ea2ea
Коммит
6d09752940
|
@ -225,9 +225,7 @@ class OC{
|
||||||
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
|
||||||
if(!OC_Util::ishtaccessworking()) {
|
if(!OC_Util::ishtaccessworking()) {
|
||||||
if(!file_exists(OC::$SERVERROOT.'/data/.htaccess')) {
|
if(!file_exists(OC::$SERVERROOT.'/data/.htaccess')) {
|
||||||
$content = "deny from all\n";
|
OC_Setup::protectDataDirectory();
|
||||||
$content.= "IndexIgnore *";
|
|
||||||
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,6 +559,10 @@ class OC_Setup {
|
||||||
$content.= "Options -Indexes\n";
|
$content.= "Options -Indexes\n";
|
||||||
@file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
@file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
||||||
|
|
||||||
|
self::protectDataDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function protectDataDirectory() {
|
||||||
$content = "deny from all\n";
|
$content = "deny from all\n";
|
||||||
$content.= "IndexIgnore *";
|
$content.= "IndexIgnore *";
|
||||||
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
|
file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче