summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSam Tuke <mail@samtuke.com>2012-10-29 16:28:46 -0700
committerSam Tuke <mail@samtuke.com>2012-10-29 16:28:46 -0700
commit3fdf239b478273155a68ec4ede8d4e4dd54b504d (patch)
treeb305155605d5e566a412b31d8c35ef27b337d3bb /lib
parent56cf7660bd0bc73431f038f1cc705c83cc7ef342 (diff)
parentf6b6780072134998919a66ed4c99922c40d2a937 (diff)
downloadnextcloud-server-3fdf239b478273155a68ec4ede8d4e4dd54b504d.tar.gz
nextcloud-server-3fdf239b478273155a68ec4ede8d4e4dd54b504d.zip
Merge pull request #147 from owncloud/htaccess-upgrade-check
Generate .htaccess when upgrading from old versions
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php
index d7d5eef3256..5c3d3fb80ce 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -221,6 +221,16 @@ 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()) {
+ if(!file_exists(OC::$SERVERROOT.'/data/.htaccess')) {
+ $content = "deny from all\n";
+ $content.= "IndexIgnore *";
+ file_put_contents(OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data').'/.htaccess', $content);
+ }
+ }
+ }
OC_Log::write('core', 'starting upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG);
$result=OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
if(!$result) {