]> source.dussan.org Git - nextcloud-server.git/commitdiff
create .htaccess files during installation for apache users
authorRobin Appelman <icewind1991@gmail.com>
Mon, 18 Apr 2011 12:05:21 +0000 (14:05 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Mon, 18 Apr 2011 12:12:53 +0000 (14:12 +0200)
index.php
lib/installer.php

index c582cbdaace328058aeec4f9b990aa361046f31c..6815aa43dcce4c326c4c0abc53f22040228bdbec 100644 (file)
--- a/index.php
+++ b/index.php
@@ -21,6 +21,8 @@
 *
 */
 
+$RUNTIME_NOAPPS=true;//no apps, yet
+
 require_once( 'lib/base.php' );
 require_once( 'appconfig.php' );
 require_once( 'template.php' );
@@ -48,6 +50,7 @@ if(count($errors)>0){
                exit();
        }
 }elseif(isset($_POST["user"])){
+       OC_APP::loadApps();
        if( OC_USER::login( $_POST["user"], $_POST["password"] )){
                header( "Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
                exit();
@@ -55,6 +58,7 @@ if(count($errors)>0){
                OC_TEMPLATE::printGuestPage( "", "login", array( "error" => true));
        }
 }else{
+       OC_APP::loadApps();
        OC_TEMPLATE::printGuestPage( "", "login", array( "error" => false ));
 }
 
index 965642e84764103170cd87a0369ca8ca8105124e..1222a22e71c206da3852d21a59ed3a8c61163de8 100644 (file)
@@ -97,6 +97,9 @@ class OC_INSTALLER{
                                OC_GROUP::createGroup('admin');
                                OC_GROUP::addToGroup($username,'admin');
                                
+                               //create htaccess files for apache hosts
+                               self::createHtaccess();//TODO detect if apache is used
+                               
                                //and we are done
                                OC_CONFIG::setValue('installed',true);
                        }
@@ -125,6 +128,19 @@ class OC_INSTALLER{
                $query="CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
                $result = mysql_query($query,$connection);
        }
+       
+       /**
+        * create .htaccess files for apache hosts
+        */
+       private static function createHtaccess(){
+               global $SERVERROOT;
+               global $WEBROOT;
+               $content="ErrorDocument 404 /$WEBROOT/templates/404.php\n";
+               file_put_contents($SERVERROOT.'/.htaccess',$content);
+               
+               $content="deny from all";
+               file_put_contents(OC_CONFIG::getValue('datadirectory',$SERVERROOT.'/data').'/.htaccess',$content);
+       }
 }
 
 ?>
\ No newline at end of file