diff --git a/config/config.sample.php b/config/config.sample.php
index dc1a62f46e3..5575340bc1b 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -1,12 +1,15 @@
- false,
+"dbtype" => "sqlite",
+"dbname" => "owncloud",
+"dbuser" => "",
+"dbpassword" => "",
+"dbhost" => "",
+"dbtableprefix" => "",
+"forcessl" => false,
+"enablebackup" => false,
+// "datadirectory" => ""
+);
?>
diff --git a/index.php b/index.php
index 62a515fa20f..2f56510bfbb 100644
--- a/index.php
+++ b/index.php
@@ -24,29 +24,31 @@
require_once( 'lib/base.php' );
require_once( 'appconfig.php' );
require_once( 'template.php' );
+var_dump( $_SESSION );
+//exit;
if( OC_USER::isLoggedIn()){
- if( $_GET["logout"] ){
- OC_USER::logout();
- OC_TEMPLATE::printGuestPage( "", "logout" );
- }
- else{
- header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
- exit();
- }
+ if( $_GET["logout"] ){
+ OC_USER::logout();
+ OC_TEMPLATE::printGuestPage( "", "logout" );
+ }
+ else{
+ header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
+ exit();
+ }
}
else{
- if( OC_USER::login( $_POST["user"], $_POST["password"] )){
- header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
- exit();
- }
- else{
- $error = false;
- // Say "bad login" in case the user wanted to login
- if( $_POST["user"] && $_POST["password"] ){
- $error = true;
- }
- OC_TEMPLATE::printGuestPage( "", "login", array( "error" => $error ));
- }
+ if( OC_USER::login( $_POST["user"], $_POST["password"] )){
+ header( "Location: ".OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" ));
+ exit();
+ }
+ else{
+ $error = false;
+ // Say "bad login" in case the user wanted to login
+ if( $_POST["user"] && $_POST["password"] ){
+ $error = true;
+ }
+ OC_TEMPLATE::printGuestPage( "", "login", array( "error" => $error ));
+ }
}
?>
diff --git a/lib/base.php b/lib/base.php
index 20ce6dcc4c4..6b3ca59e6be 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -55,24 +55,21 @@ if( !isset( $RUNTIME_NOAPPS )){
$RUNTIME_NOAPPS = false;
}
-// define default config values
-$CONFIG_DATADIRECTORY=$SERVERROOT.'/data';
-$CONFIG_BACKUPDIRECTORY=$SERVERROOT.'/backup';
-$CONFIG_HTTPFORCESSL=false;
-$CONFIG_ENABLEBACKUP=false;
-$CONFIG_DATEFORMAT='j M Y G:i';
-$CONFIG_FILESYSTEM=array();
-
-// include the generated configfile
-@include_once($SERVERROOT.'/config/config.php');
-
-$CONFIG_DATADIRECTORY_ROOT=$CONFIG_DATADIRECTORY;// store this in a seperate variable so we can change the data directory to jail users.
+// Doing the config stuff first
+require_once('config.php');
+
+// TODO: we should get rid of this one, too
+// WARNING: to make everything even more confusing, DATADIRECTORY is a var that
+// changes and DATATIRECTORY_ROOT stays the same, but is set by
+// "datadirectory". Any questions?
+$CONFIG_DATADIRECTORY = OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" );
+
// redirect to https site if configured
-if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
+if( OC_CONFIG::getValue( "forcessl", false )){
if(!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
- exit;
+ exit();
}
}
@@ -85,7 +82,6 @@ require_once('filesystem.php');
require_once('filestorage.php');
require_once('fileobserver.php');
require_once('log.php');
-require_once('config.php');
require_once('user.php');
require_once('group.php');
require_once('ocs.php');
@@ -95,11 +91,8 @@ require_once('plugin.php');
OC_PLUGIN::loadPlugins( "" );
-if(!isset($CONFIG_BACKEND)){
- $CONFIG_BACKEND='database';
-}
-OC_USER::setBackend( $CONFIG_BACKEND );
-OC_GROUP::setBackend( $CONFIG_BACKEND );
+OC_USER::setBackend( OC_CONFIG::getValue( "userbackend", "database" ));
+OC_GROUP::setBackend( OC_CONFIG::getValue( "groupbackend", "database" ));
// Set up file system unless forbidden
if( !$RUNTIME_NOSETUPFS ){
@@ -138,11 +131,10 @@ class OC_UTIL {
// Global Variables
global $SERVERROOT;
- global $CONFIG_DATADIRECTORY_ROOT;
global $CONFIG_DATADIRECTORY;
- global $CONFIG_BACKUPDIRECTORY;
- global $CONFIG_ENABLEBACKUP;
- global $CONFIG_FILESYSTEM;
+
+ $CONFIG_DATADIRECTORY_ROOT = OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" );
+ $CONFIG_BACKUPDIRECTORY = OC_CONFIG::getValue( "backupdirectory", "$SERVERROOT/backup" );
// Create root dir
if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){
@@ -157,7 +149,7 @@ class OC_UTIL {
if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem
//first set up the local "root" storage and the backupstorage if needed
$rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY));
- if($CONFIG_ENABLEBACKUP){
+ if( OC_CONFIG::getValue( "enablebackup", false )){
// This creates the Directorys recursively
if(!is_dir( "$CONFIG_BACKUPDIRECTORY/$user/$root" )){
mkdir( "$CONFIG_BACKUPDIRECTORY/$user/$root", 0755, true );
@@ -173,18 +165,19 @@ class OC_UTIL {
mkdir( $CONFIG_DATADIRECTORY, 0755, true );
}
- //set up the other storages according to the system settings
- foreach($CONFIG_FILESYSTEM as $storageConfig){
- if(OC_FILESYSTEM::hasStorageType($storageConfig['type'])){
- $arguments=$storageConfig;
- unset($arguments['type']);
- unset($arguments['mountpoint']);
- $storage=OC_FILESYSTEM::createStorage($storageConfig['type'],$arguments);
- if($storage){
- OC_FILESYSTEM::mount($storage,$storageConfig['mountpoint']);
- }
- }
- }
+// TODO: find a cool way for doing this
+// //set up the other storages according to the system settings
+// foreach($CONFIG_FILESYSTEM as $storageConfig){
+// if(OC_FILESYSTEM::hasStorageType($storageConfig['type'])){
+// $arguments=$storageConfig;
+// unset($arguments['type']);
+// unset($arguments['mountpoint']);
+// $storage=OC_FILESYSTEM::createStorage($storageConfig['type'],$arguments);
+// if($storage){
+// OC_FILESYSTEM::mount($storage,$storageConfig['mountpoint']);
+// }
+// }
+// }
//jail the user into his "home" directory
OC_FILESYSTEM::chroot("/$user/$root");
@@ -232,9 +225,10 @@ class OC_UTIL {
*/
public static function checkServer(){
global $SERVERROOT;
- global $CONFIG_DATADIRECTORY_ROOT;
- global $CONFIG_BACKUPDIRECTORY;
- global $CONFIG_ENABLEBACKUP;
+ global $CONFIG_DATADIRECTORY;
+
+ $CONFIG_DATADIRECTORY_ROOT = OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" );;
+ $CONFIG_BACKUPDIRECTORY = OC_CONFIG::getValue( "backupdirectory", "$SERVERROOT/backup" );
$CONFIG_INSTALLED = OC_CONFIG::getValue( "installed", false );
$error='';
if(!is_callable('sqlite_open') and !is_callable('mysql_connect')){
@@ -266,7 +260,7 @@ class OC_UTIL {
$error.='Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web
';
}
}
- if($CONFIG_ENABLEBACKUP){
+ if( OC_CONFIG::getValue( "enablebackup", false )){
$prems=substr(decoct(fileperms($CONFIG_BACKUPDIRECTORY)),-3);
if(substr($prems,-1)!='0'){
OC_HELPER::chmodr($CONFIG_BACKUPDIRECTORY,0770);
diff --git a/lib/config.php b/lib/config.php
index ceea05c139b..2660f43cad7 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -172,7 +172,7 @@ class OC_CONFIG{
}
else{
$value = str_replace( "'", "\\'", $value );
- $configContent .= "\"$key\" => '$value',\n";
+ $content .= "\"$key\" => '$value',\n";
}
}
$content .= ");\n?>\n";
diff --git a/lib/connect.php b/lib/connect.php
index 695ae482451..6fc8f2165cf 100644
--- a/lib/connect.php
+++ b/lib/connect.php
@@ -3,22 +3,22 @@
/**
* ownCloud
*
-* @author Frank Karlitschek
-* @copyright 2010 Frank Karlitschek karlitschek@kde.org
-*
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
+* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
-*
+*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
+*
+* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see .
-*
+*
*/
/**
@@ -27,7 +27,7 @@
*/
class OC_CONNECT{
static private $clouds=array();
-
+
static function connect($path,$user,$password){
$cloud=new OC_REMOTE_CLOUD($path,$user,$password);
if($cloud->connected){
@@ -48,7 +48,7 @@ class OC_REMOTE_CLOUD{
private $path;
private $connected=false;
private $cookiefile=false;
-
+
/**
* make an api call to the remote cloud
* @param string $action
@@ -72,8 +72,8 @@ class OC_REMOTE_CLOUD{
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($parameters));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
- curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile);
- curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile);
+ curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile);
+ curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result=curl_exec($ch);
$result=trim($result);
@@ -86,12 +86,12 @@ class OC_REMOTE_CLOUD{
return false;
}
}
-
+
public function __construct($path,$user,$password){
$this->path=$path;
$this->connected=$this->apiCall('login',array('username'=>$user,'password'=>$password));
}
-
+
/**
* check if we are stull logged in on the remote cloud
*
@@ -102,14 +102,14 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('checklogin');
}
-
+
public function __get($name){
switch($name){
case 'connected':
return $this->connected;
}
}
-
+
/**
* disconnect from the remote cloud
*
@@ -121,7 +121,7 @@ class OC_REMOTE_CLOUD{
}
$this->cookiefile=false;
}
-
+
/**
* create a new file or directory
* @param string $dir
@@ -134,7 +134,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('new',array('dir'=>$dir,'name'=>$name,'type'=>$type),true);
}
-
+
/**
* deletes a file or directory
* @param string $dir
@@ -146,7 +146,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('delete',array('dir'=>$dir,'file'=>$name),true);
}
-
+
/**
* moves a file or directory
* @param string $sorceDir
@@ -160,7 +160,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('move',array('sourcedir'=>$sourceDir,'source'=>$sourceFile,'targetdir'=>$targetDir,'target'=>$targetFile),true);
}
-
+
/**
* copies a file or directory
* @param string $sorceDir
@@ -174,7 +174,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('copy',array('sourcedir'=>$sourceDir,'source'=>$sourceFile,'targetdir'=>$targetDir,'target'=>$targetFile),true);
}
-
+
/**
* get a file tree
* @param string $dir
@@ -185,7 +185,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('gettree',array('dir'=>$dir),true);
}
-
+
/**
* get the files inside a directory of the remote cloud
* @param string $dir
@@ -196,7 +196,7 @@ class OC_REMOTE_CLOUD{
}
return $this->apiCall('getfiles',array('dir'=>$dir),true);
}
-
+
/**
* get a remove file and save it in a temporary file and return the path of the temporary file
* @param string $dir
@@ -215,28 +215,28 @@ class OC_REMOTE_CLOUD{
$fp=fopen($tmpfile,'w+');
$url=$this->path.="/files/api.php?action=get&dir=$dir&file=$file";
curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile);
- curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile);
+ curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile);
+ curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);
curl_close($ch);
return $tmpfile;
}
-
+
public function sendFile($sourceDir,$sourceFile,$targetDir,$targetFile){
global $WEBROOT;
$source=$sourceDir.'/'.$sourceFile;
$tmp=OC_FILESYSTEM::toTmpFile($source);
return $this->sendTmpFile($tmp,$targetDir,$targetFile);
}
-
+
public function sendTmpFile($tmp,$targetDir,$targetFile){
$token=sha1(uniqid().$tmp);
global $WEBROOT;
$file=sys_get_temp_dir().'/'.'remoteCloudFile'.$token;
rename($tmp,$file);
- if((isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL) or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
+ if( OC_CONFIG::getValue( "forcessl", false ) or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
$url = "https://". $_SERVER['SERVER_NAME'] . $WEBROOT;
}else{
$url = "http://". $_SERVER['SERVER_NAME'] . $WEBROOT;
diff --git a/lib/user.php b/lib/user.php
index 9841b8ef276..d70443b7e61 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -20,7 +20,7 @@
*
*/
-if( !$CONFIG_INSTALLED ){
+if( !OC_CONFIG::getValue( "installed", false )){
$_SESSION['user_id'] = '';
}