diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-28 08:50:42 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-28 08:50:42 +0200 |
commit | 5fd776debffb9aca4871d4365445d9a88720f478 (patch) | |
tree | fa341a902376891d570e51ce7a3fc2d1e4b12268 | |
parent | 642f57c1d534c4f5b9280495b2f3a77b0b88ac7b (diff) | |
parent | 7086c386fdd1cfcec0ddc0db19615bd4586bade3 (diff) | |
download | nextcloud-server-5fd776debffb9aca4871d4365445d9a88720f478.tar.gz nextcloud-server-5fd776debffb9aca4871d4365445d9a88720f478.zip |
Merge pull request #7473 from owncloud/append-error-document
Remove .htaccess creation code
-rw-r--r--[-rwxr-xr-x] | .htaccess | 2 | ||||
-rw-r--r-- | lib/private/setup.php | 54 | ||||
-rw-r--r-- | lib/private/updater.php | 6 |
3 files changed, 14 insertions, 48 deletions
diff --git a/.htaccess b/.htaccess index 4ba5095e144..e1ded52dcd9 100755..100644 --- a/.htaccess +++ b/.htaccess @@ -6,8 +6,6 @@ RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION </IfModule> </IfModule> </IfModule> -ErrorDocument 403 /core/templates/403.php -ErrorDocument 404 /core/templates/404.php <IfModule mod_php5.c> php_value upload_max_filesize 513M php_value post_max_size 513M diff --git a/lib/private/setup.php b/lib/private/setup.php index b1061b3a25b..4889f603332 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -110,9 +110,10 @@ class OC_Setup { // out that this is indeed an ownCloud data directory file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.ocdata', ''); - //create htaccess files for apache hosts + // Update htaccess files for apache hosts if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { - self::createHtaccess(); + self::updateHtaccess(); + self::protectDataDirectory(); } //and we are done @@ -123,52 +124,13 @@ class OC_Setup { } /** - * create .htaccess files for apache hosts + * Append the correct ErrorDocument path for Apache hosts */ - private static function createHtaccess() { - $content = "<IfModule mod_fcgid.c>\n"; - $content.= "<IfModule mod_setenvif.c>\n"; - $content.= "<IfModule mod_headers.c>\n"; - $content.= "SetEnvIfNoCase ^Authorization$ \"(.+)\" XAUTHORIZATION=$1\n"; - $content.= "RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION\n"; - $content.= "</IfModule>\n"; - $content.= "</IfModule>\n"; - $content.= "</IfModule>\n"; + public static function updateHtaccess() { + $content = "\n"; $content.= "ErrorDocument 403 ".OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page - $content.= "ErrorDocument 404 ".OC::$WEBROOT."/core/templates/404.php\n";//custom 404 error page - $content.= "<IfModule mod_php5.c>\n"; - $content.= "php_value upload_max_filesize 512M\n";//upload limit - $content.= "php_value post_max_size 512M\n"; - $content.= "php_value memory_limit 512M\n"; - $content.= "php_value mbstring.func_overload 0\n"; - $content.= "<IfModule env_module>\n"; - $content.= " SetEnv htaccessWorking true\n"; - $content.= "</IfModule>\n"; - $content.= "</IfModule>\n"; - $content.= "<IfModule mod_rewrite.c>\n"; - $content.= "RewriteEngine on\n"; - $content.= "RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]\n"; - $content.= "RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]\n"; - $content.= "RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]\n"; - $content.= "RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]\n"; - $content.= "RewriteRule ^apps/([^/]*)/(.*\.(php))$ index.php?app=$1&getfile=$2 [QSA,L]\n"; - $content.= "RewriteRule ^remote/(.*) remote.php [QSA,L]\n"; - $content.= "</IfModule>\n"; - $content.= "<IfModule mod_mime.c>\n"; - $content.= "AddType image/svg+xml svg svgz\n"; - $content.= "AddEncoding gzip svgz\n"; - $content.= "</IfModule>\n"; - $content.= "<IfModule dir_module>\n"; - $content.= "DirectoryIndex index.php index.html\n"; - $content.= "</IfModule>\n"; - $content.= "AddDefaultCharset utf-8\n"; - $content.= "Options -Indexes\n"; - $content.= "<IfModule pagespeed_module>\n"; - $content.= "ModPagespeed Off\n"; - $content.= "</IfModule>\n"; - @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it - - self::protectDataDirectory(); + $content.= "ErrorDocument 404 ".OC::$WEBROOT."/core/templates/404.php";//custom 404 error page + @file_put_contents(OC::$SERVERROOT.'/.htaccess', $content, FILE_APPEND); //suppress errors in case we don't have permissions for it } public static function protectDataDirectory() { diff --git a/lib/private/updater.php b/lib/private/updater.php index 9f57aa0b6a0..a59e3820deb 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -91,6 +91,7 @@ class Updater extends BasicEmitter { /** * runs the update actions in maintenance mode, does not upgrade the source files + * except the main .htaccess file */ public function upgrade() { \OC_DB::enableCaching(false); @@ -102,6 +103,11 @@ class Updater extends BasicEmitter { } $this->emit('\OC\Updater', 'maintenanceStart'); + // Update htaccess files for apache hosts + if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { + \OC_Setup::updateHtaccess(); + } + // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) |