diff --git a/files/delete.php b/files/delete.php
index 1c660d97807..7d19a45a73a 100644
--- a/files/delete.php
+++ b/files/delete.php
@@ -25,10 +25,12 @@ require_once('../inc/lib_base.php');
$dir=$_GET['dir'];
$file=$_GET['file'];
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false){
- $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
- if(is_file($file)){
- unlink($file);
- }
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
+ if(is_file($file)){
+ unlink($file);
+ }elseif(is_dir($file)){
+ rmdir($file);
+ }
}
?>
\ No newline at end of file
diff --git a/files/get_files.php b/files/get_files.php
index 29f06d289d5..287b8cd453e 100644
--- a/files/get_files.php
+++ b/files/get_files.php
@@ -42,21 +42,23 @@ function return_bytes($val) {
header('Content-type: application/xml');
$dir=isset($_GET['dir'])?$_GET['dir']:'';
-$files=OC_FILES::getdirectorycontent($CONFIG_DATADIRECTORY.'/'.$dir);
-$dirname=$files[0]['directory'];
+$files=OC_FILES::getdirectorycontent(realpath($CONFIG_DATADIRECTORY.'/'.$dir));
+$dirname=(isset($files[0]))?$files[0]['directory']:'';
$dirname=substr($dirname,strrpos($dirname,'/'));
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
ob_clean();
echo "\n";
echo "
\n";
-foreach($files as $file){
- $attributes='';
- foreach($file as $name=>$data){
- $data=str_replace("'",''',$data);
- if (is_string($name)) $attributes.=" $name='$data'";
- }
- $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
- echo "\n";
+if(is_array($files)){
+ foreach($files as $file){
+ $attributes='';
+ foreach($file as $name=>$data){
+ $data=str_replace("'",''',$data);
+ if (is_string($name)) $attributes.=" $name='$data'";
+ }
+ $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
+ echo "\n";
+ }
}
-echo "";
+echo "\n";
?>
\ No newline at end of file
diff --git a/files/move.php b/files/move.php
new file mode 100644
index 00000000000..7103662c4a2
--- /dev/null
+++ b/files/move.php
@@ -0,0 +1,35 @@
+.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$sourceDir=$_GET['sourcedir'];
+$targetDir=$_GET['targetdir'];
+$source=$_GET['source'];
+$target=$_GET['target'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($sourceDir,'..')===false and strpos($source,'..')===false and strpos($targetDir,'..')===false and strpos($target,'..')===false){
+ $target=$CONFIG_DATADIRECTORY.'/'.$targetDir.'/'.$target.'/'.$source;
+ $source=$CONFIG_DATADIRECTORY.'/'.$sourceDir.'/'.$source;
+ rename($source,$target);
+}
+
+?>
\ No newline at end of file
diff --git a/files/new.php b/files/new.php
new file mode 100644
index 00000000000..c5d5608a567
--- /dev/null
+++ b/files/new.php
@@ -0,0 +1,38 @@
+.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$dir=$_GET['dir'];
+$name=$_GET['name'];
+$type=$_GET['type'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false and strpos($name,'..')===false){
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$name;
+ if($type=='dir'){
+ mkdir($file);
+ }elseif($type=='file'){
+ $fileHandle=fopen($file, 'w') or die("can't open file");
+ fclose($fileHandle);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/img/arrow_down.png b/img/arrow_down.png
index 0e0ab3c4c08..ecbca6ef606 100755
Binary files a/img/arrow_down.png and b/img/arrow_down.png differ
diff --git a/img/arrow_up.png b/img/arrow_up.png
new file mode 100644
index 00000000000..e2457c88838
Binary files /dev/null and b/img/arrow_up.png differ
diff --git a/img/icons/loading.gif b/img/icons/loading.gif
new file mode 100644
index 00000000000..40efb9be594
Binary files /dev/null and b/img/icons/loading.gif differ
diff --git a/inc/lib_base.php b/inc/lib_base.php
index 8c0c1ca606e..e4309261709 100755
--- a/inc/lib_base.php
+++ b/inc/lib_base.php
@@ -35,6 +35,9 @@ $SERVERROOT=substr(__FILE__,0,-17);
$DOCUMENTROOT=$_SERVER['DOCUMENT_ROOT'];
$count=strlen($DOCUMENTROOT);
$WEBROOT=substr($SERVERROOT,$count);
+if($WEBROOT{0}!=='/'){
+ $WEBROOT='/'.$WEBROOT;
+}
// set the right include path
set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$SERVERROOT.'/inc'.PATH_SEPARATOR.$SERVERROOT.'/config');
@@ -42,11 +45,12 @@ set_include_path(get_include_path().PATH_SEPARATOR.$SERVERROOT.PATH_SEPARATOR.$S
// define default config values
$CONFIG_ADMINLOGIN='';
$CONFIG_ADMINPASSWORD='';
-$CONFIG_DATADIRECTORY=$SERVERROOT.$WEBROOT.'/data';
+$CONFIG_DATADIRECTORY=$SERVERROOT.'/data';
$CONFIG_HTTPFORCESSL=false;
$CONFIG_DATEFORMAT='j M Y G:i';
$CONFIG_DBNAME='owncloud';
$CONFIG_DBTYPE='sqlite';
+
// include the generated configfile
@include_once('config.php');
@@ -63,7 +67,6 @@ if(isset($CONFIG_HTTPFORCESSL) and $CONFIG_HTTPFORCESSL){
require_once('lib_files.php');
require_once('lib_log.php');
require_once('lib_config.php');
-require_once('lib_ocs.php');
// load plugins
$CONFIG_LOADPLUGINS='music';
@@ -247,6 +250,7 @@ class OC_DB {
*/
static function query($cmd) {
global $DOCUMENTROOT;
+ global $SERVERROOT;
global $DBConnection;
global $CONFIG_DBNAME;
global $CONFIG_DBHOST;
@@ -255,9 +259,9 @@ class OC_DB {
global $CONFIG_DBTYPE;
if(!isset($DBConnection)) {
if($CONFIG_DBTYPE=='sqlite'){
- $DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
+ $DBConnection = @new SQLiteDatabase($SERVERROOT.'/'.$CONFIG_DBNAME);
}elseif($CONFIG_DBTYPE=='mysql'){
- $DBConnection =@new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
+ $DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
}
if (!$DBConnection) {
@ob_end_clean();
@@ -288,6 +292,7 @@ class OC_DB {
*/
static function multiquery($cmd) {
global $DOCUMENTROOT;
+ global $SERVERROOT;
global $DBConnection;
global $CONFIG_DBNAME;
global $CONFIG_DBTYPE;
@@ -296,7 +301,7 @@ class OC_DB {
global $CONFIG_DBPASSWORD;
if(!isset($DBConnection)) {
if($CONFIG_DBTYPE=='sqlite'){
- $DBConnection = @new SQLiteDatabase($DOCUMENTROOT.'/'.$CONFIG_DBNAME);
+ $DBConnection = new SQLiteDatabase($SERVERROOT.'/'.$CONFIG_DBNAME);
}elseif($CONFIG_DBTYPE=='mysql'){
$DBConnection = @new mysqli($CONFIG_DBHOST, $CONFIG_DBUSER, $CONFIG_DBPASSWORD,$CONFIG_DBNAME);
}
diff --git a/inc/lib_config.php b/inc/lib_config.php
index e3bce232f5e..a3270ab41b3 100755
--- a/inc/lib_config.php
+++ b/inc/lib_config.php
@@ -27,73 +27,102 @@ class OC_CONFIG{
global $CONFIG_DBUSER;
global $CONFIG_DBPASSWORD;
global $CONFIG_DBTYPE;
+ global $CONFIG_ADMINLOGIN;
+ global $CONFIG_ADMINPASSWORD;
if(isset($_POST['set_config'])){
//checkdata
- $error='';
- $FIRSTRUN=!isset($CONFIG_ADMINLOGIN);
- if(!$FIRSTRUN){
- if($_POST['currentpassword']!=$CONFIG_ADMINPASSWORD){
- $error.='wrong password';
- }
- }
-
- if(!isset($_POST['adminlogin']) or empty($_POST['adminlogin'])) $error.='admin login not set
';
- if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and $FIRSTRUN) $error.='admin password not set
';
- if(!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2']) and $FIRSTRUN) $error.='retype admin password not set
';
- if(!isset($_POST['datadirectory']) or empty($_POST['datadirectory'])) $error.='data directory not set
';
- if(!isset($_POST['dateformat']) or empty($_POST['dateformat'])) $error.='dateformat not set
';
- if(!isset($_POST['dbname']) or empty($_POST['dbname'])) $error.='databasename not set
';
- if($_POST['adminpassword']<>$_POST['adminpassword2'] ) $error.='admin passwords are not the same
';
-
- if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and !$FIRSTRUN){
- $_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
- }
- $dbtype=$_POST['dbtype'];
- if($dbtype=='mysql'){
- if(!isset($_POST['dbhost']) or empty($_POST['dbhost'])) $error.='database host not set
';
- if(!isset($_POST['dbuser']) or empty($_POST['dbuser'])) $error.='database user not set
';
- if($_POST['dbpassword']<>$_POST['dbpassword2'] ) $error.='database passwords are not the same
';
-
- }
- if(empty($error)) {
- //create/fill database
- $CONFIG_DBTYPE=$dbtype;
- $CONFIG_DBNAME=$_POST['dbname'];
- if($dbtype=='mysql'){
- $CONFIG_DBHOST=$_POST['dbhost'];
- $CONFIG_DBUSER=$_POST['dbuser'];
- $CONFIG_DBPASSWORD=$_POST['dbpassword'];
- }
- if(isset($_POST['createdatabase']) and $CONFIG_DBTYPE=='mysql'){
- self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
- }
- if(isset($_POST['filldb'])){
- self::filldatabase();
- }
-
- //storedata
- $config=' ';
-
- $filename=$SERVERROOT.'/config/config.php';
- file_put_contents($filename,$config);
- header("Location: ".$WEBROOT."/");
+ $error='';
+ $FIRSTRUN=empty($CONFIG_ADMINLOGIN);
+ if(!$FIRSTRUN){
+ if($_POST['currentpassword']!=$CONFIG_ADMINPASSWORD){
+ $error.='wrong password
';
+ }
+ }
+
+ if(!isset($_POST['adminlogin']) or empty($_POST['adminlogin'])) $error.='admin login not set
';
+ if((!isset($_POST['adminpassword']) or empty($_POST['adminpassword'])) and $FIRSTRUN) $error.='admin password not set
';
+ if((!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2'])) and $FIRSTRUN) $error.='retype admin password not set
';
+ if(!isset($_POST['datadirectory']) or empty($_POST['datadirectory'])) $error.='data directory not set
';
+ if(!isset($_POST['dateformat']) or empty($_POST['dateformat'])) $error.='dateformat not set
';
+ if(!isset($_POST['dbname']) or empty($_POST['dbname'])) $error.='databasename not set
';
+ if($_POST['adminpassword']<>$_POST['adminpassword2'] ) $error.='admin passwords are not the same
';
+ $dbtype=$_POST['dbtype'];
+ if($dbtype=='mysql'){
+ if(!isset($_POST['dbhost']) or empty($_POST['dbhost'])) $error.='database host not set
';
+ if(!isset($_POST['dbuser']) or empty($_POST['dbuser'])) $error.='database user not set
';
+ if($_POST['dbpassword']<>$_POST['dbpassword2'] ) $error.='database passwords are not the same
';
+
+ }
+ if(!$FIRSTRUN){
+ if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword'])){
+ $_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
+ }
+ if(!isset($_POST['dbpassword']) or empty($_POST['dbpassword'])){
+ $_POST['dbpassword']=$CONFIG_DBPASSWORD;
+ }
+ }
+ if(empty($error)) {
+ //create/fill database
+ $CONFIG_DBTYPE=$dbtype;
+ $CONFIG_DBNAME=$_POST['dbname'];
+ if($dbtype=='mysql'){
+ $CONFIG_DBHOST=$_POST['dbhost'];
+ $CONFIG_DBUSER=$_POST['dbuser'];
+ $CONFIG_DBPASSWORD=$_POST['dbpassword'];
+ }
+ try{
+ if(isset($_POST['createdatabase']) and $CONFIG_DBTYPE=='mysql'){
+ self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
+ }
+ }catch(Exception $e){
+ $error.='error while trying to create the database
';
+ }
+ if($CONFIG_DBTYPE=='sqlite'){
+ $f=@fopen($SERVERROOT.'/'.$CONFIG_DBNAME,'a+');
+ if(!$f){
+ $error.='path of sqlite database not writable by server
';
+ }
+ }
+ try{
+ if(isset($_POST['filldb'])){
+ self::filldatabase();
+ }
+ }catch(Exception $e){
+ $error.='error while trying to fill the database
';
+ }
+
+ //storedata
+ $config=' ';
- }
- return($error);
+ $filename=$SERVERROOT.'/config/config.php';
+ if(empty($error)){
+ header("Location: ".$WEBROOT."/");
+ try{
+ file_put_contents($filename,$config);
+ }catch(Exception $e){
+ $error.='error while trying to save the configuration file
';
+ return $error;
+ }
+ }else{
+ return $error;
+ }
+
+ }
+ return($error);
}
@@ -210,3 +239,5 @@ GRANT ALL PRIVILEGES ON `{$_POST['dbname']}` . * TO '{$_POST['dbuser']}';";
}
}
?>
+
+
diff --git a/inc/lib_files.php b/inc/lib_files.php
index 5ddf5a4e1f3..9c6cb25346a 100755
--- a/inc/lib_files.php
+++ b/inc/lib_files.php
@@ -89,6 +89,7 @@ class OC_FILES {
$content=array();
$dirs=array();
$file=array();
+ $files=array();
if (is_dir($directory)) {
if ($dh = opendir($directory)) {
while (($filename = readdir($dh)) !== false) {
diff --git a/inc/templates/configform.php b/inc/templates/configform.php
index 82a1efeee19..61217df2acf 100755
--- a/inc/templates/configform.php
+++ b/inc/templates/configform.php
@@ -1,5 +1,6 @@
-