From 6903475841d4687246d9206ae72ed192948f4db8 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 29 Oct 2012 22:03:18 +0100 Subject: [PATCH] Generate .htaccess when upgrading from old versions When upgrading from old ownCloud versions like 2.x the .htaccess is not generated - which exposes the data to the internet. This fix will generate a .htaccess when upgrading. (And no one exists) Fixes #127 --- lib/base.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/base.php b/lib/base.php index d7d5eef3256..18118a93b64 100644 --- a/lib/base.php +++ b/lib/base.php @@ -221,6 +221,12 @@ class OC{ $installedVersion=OC_Config::getValue('version', '0.0.0'); $currentVersion=implode('.', OC_Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { + // Check if the .htaccess is existing - this is needed for upgrades from really old ownCloud versions + if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { + if(!OC_Util::ishtaccessworking()) { + OC_Setup::createHtaccess(); + } + } OC_Log::write('core', 'starting upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG); $result=OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml'); if(!$result) { -- 2.39.5