Merge branch 'master' of git://gitorious.org/owncloud/owncloud

This commit is contained in:
Robin Appelman 2010-11-28 22:54:59 +00:00
commit 962e548495
11 changed files with 69 additions and 135 deletions

4
files/upload.php Normal file → Executable file
View File

@ -22,11 +22,9 @@
*/ */
require_once('../inc/lib_base.php'); require_once('../inc/lib_base.php');
// sleep(5); //immitate slow internet.
$fileName=$_FILES['file']['name']; $fileName=$_FILES['file']['name'];
$source=$_FILES['file']['tmp_name']; $source=$_FILES['file']['tmp_name'];
$target=$_GET['dir'].'/'.$fileName; $target=stripslashes($_GET['dir']).'/'.$fileName;
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($_GET['dir'],'..')===false){ if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($_GET['dir'],'..')===false){
if(OC_FILESYSTEM::fromTmpFile($source,$target)){ if(OC_FILESYSTEM::fromTmpFile($source,$target)){
echo 'true'; echo 'true';

View File

@ -926,7 +926,7 @@ class MDB2_Result_sqlite extends MDB2_Result_Common
if ($object_class == 'stdClass') { if ($object_class == 'stdClass') {
$row = (object) $row; $row = (object) $row;
} else { } else {
$row = &new $object_class($row); $row = new $object_class($row);
} }
} }
++$this->rownum; ++$this->rownum;

View File

@ -112,11 +112,14 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
* *
*/ */
public static function logoutLisener() { public static function logoutLisener() {
global $WEBROOT;
if ( isset($_GET['logoutbutton']) AND isset($_SESSION['username']) ) { if ( isset($_GET['logoutbutton']) AND isset($_SESSION['username']) ) {
OC_LOG::event($_SESSION['username'], 2, ''); OC_LOG::event($_SESSION['username'], 2, '');
$_SESSION['user_id'] = false; $_SESSION['user_id'] = false;
$_SESSION['username'] = ''; $_SESSION['username'] = '';
$_SESSION['username_clean'] = ''; $_SESSION['username_clean'] = '';
header("location: $WEBROOT");
} }
} }

View File

@ -31,7 +31,6 @@ date_default_timezone_set('Europe/Berlin');
ini_set('arg_separator.output','&'); ini_set('arg_separator.output','&');
ini_set('session.cookie_httponly','1;'); ini_set('session.cookie_httponly','1;');
session_start(); session_start();
// calculate the documentroot // calculate the documentroot
$SERVERROOT=substr(__FILE__,0,-17); $SERVERROOT=substr(__FILE__,0,-17);
$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
@ -119,6 +118,7 @@ class OC_UTIL {
if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble
return false; return false;
} }
global $SERVERROOT;
global $CONFIG_DATADIRECTORY_ROOT; global $CONFIG_DATADIRECTORY_ROOT;
global $CONFIG_DATADIRECTORY; global $CONFIG_DATADIRECTORY;
global $CONFIG_BACKUPDIRECTORY; global $CONFIG_BACKUPDIRECTORY;
@ -172,7 +172,7 @@ class OC_UTIL {
* @return array * @return array
*/ */
public static function getVersion(){ public static function getVersion(){
return array(1,0,60); return array(1,1,0);
} }
/** /**

View File

@ -3,20 +3,20 @@
/** /**
* ownCloud * ownCloud
* *
* @author Frank Karlitschek * @author Frank Karlitschek
* @copyright 2010 Frank Karlitschek karlitschek@kde.org * @copyright 2010 Frank Karlitschek karlitschek@kde.org
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * 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. * version 3 of the License, or any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -44,7 +44,7 @@ class OC_FILESTORAGE{
} }
} }
} }
public function __construct($parameters){} public function __construct($parameters){}
public function mkdir($path){} public function mkdir($path){}
public function rmdir($path){} public function rmdir($path){}
@ -202,11 +202,11 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
} }
return $return; return $return;
} }
public function getMimeType($fspath){ public function getMimeType($fspath){
if (@is_dir($this->datadir.$fspath)) { if (@is_dir($this->datadir.$fspath)) {
// directories are easy // directories are easy
return "httpd/unix-directory"; return "httpd/unix-directory";
}elseif (function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)){ }elseif (function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)){
$mimeType =strtolower(finfo_file($finfo,$this->datadir.$fspath)); $mimeType =strtolower(finfo_file($finfo,$this->datadir.$fspath));
$mimeType=substr($mimeType,0,strpos($mimeType,';')); $mimeType=substr($mimeType,0,strpos($mimeType,';'));
@ -216,15 +216,15 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
// use mime magic extension if available // use mime magic extension if available
$mime_type = mime_content_type($this->datadir.$fspath); $mime_type = mime_content_type($this->datadir.$fspath);
} else if (self::canExecute("file")) { } else if (self::canExecute("file")) {
// it looks like we have a 'file' command, // it looks like we have a 'file' command,
// lets see it it does have mime support // lets see it it does have mime support
$fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r"); $fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
$reply = fgets($fp); $reply = fgets($fp);
pclose($fp); pclose($fp);
//trim the character set from the end of the response //trim the character set from the end of the response
$mime_type=substr($reply,0,strrpos($reply,' ')); $mime_type=substr($reply,0,strrpos($reply,' '));
} }
if (empty($mime_type)) { if (empty($mime_type)) {
// Fallback solution: try to guess the type by the file extension // Fallback solution: try to guess the type by the file extension
// TODO: add more ... // TODO: add more ...
@ -290,53 +290,66 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
break; break;
} }
} }
return $mime_type; return $mime_type;
} }
/** /**
* detect if a given program is found in the search PATH * detect if a given program is found in the search PATH
* *
* helper function used by _mimetype() to detect if the * helper function used by _mimetype() to detect if the
* external 'file' utility is available * external 'file' utility is available
* *
* @param string program name * @param string program name
* @param string optional search path, defaults to $PATH * @param string optional search path, defaults to $PATH
* @return bool true if executable program found in path * @return bool true if executable program found in path
*/ */
private function canExecute($name, $path = false) private function canExecute($name, $path = false)
{ {
// path defaults to PATH from environment if not set // path defaults to PATH from environment if not set
if ($path === false) { if ($path === false) {
$path = getenv("PATH"); $path = getenv("PATH");
} }
// check method depends on operating system // check method depends on operating system
if (!strncmp(PHP_OS, "WIN", 3)) { if (!strncmp(PHP_OS, "WIN", 3)) {
// on Windows an appropriate COM or EXE file needs to exist // on Windows an appropriate COM or EXE file needs to exist
$exts = array(".exe", ".com"); $exts = array(".exe", ".com");
$check_fn = "file_exists"; $check_fn = "file_exists";
} else { } else {
// anywhere else we look for an executable file of that name // anywhere else we look for an executable file of that name
$exts = array(""); $exts = array("");
$check_fn = "is_executable"; $check_fn = "is_executable";
} }
// now check the directories in the path for the program
foreach (explode(PATH_SEPARATOR, $path) as $dir) {
// skip invalid path entries
if (!file_exists($dir)) continue;
if (!is_dir($dir)) continue;
// and now look for the file // Default check will be done with $path directories :
foreach ($exts as $ext) { $dirs = explode(PATH_SEPARATOR, $path);
if ($check_fn("$dir/$name".$ext)) return true;
} // WARNING : We have to check if open_basedir is enabled :
} $obd = ini_get('open_basedir');
if($obd != "none")
$obd_values = explode(PATH_SEPARATOR, $obd);
if(count($obd_values) > 0)
{
// open_basedir is in effect !
// We need to check if the program is in one of these dirs :
$dirs = $obd_values;
}
foreach($dirs as $dir)
{
foreach($exts as $ext)
{
if($check_fn("$dir/$name".$ext))
return true;
}
}
return false; return false;
} }
public function toTmpFile($path){ public function toTmpFile($path){
$tmpFolder=sys_get_temp_dir(); $tmpFolder=sys_get_temp_dir();
$filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.'))); $filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.')));
@ -347,7 +360,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
return false; return false;
} }
} }
public function fromTmpFile($tmpFile,$path){ public function fromTmpFile($tmpFile,$path){
if(rename($tmpFile,$this->datadir.$path)){ if(rename($tmpFile,$this->datadir.$path)){
$this->notifyObservers($path,OC_FILEACTION_CREATE); $this->notifyObservers($path,OC_FILEACTION_CREATE);
@ -356,21 +369,21 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
return false; return false;
} }
} }
public function delTree($dir) { public function delTree($dir) {
$dirRelative=$dir; $dirRelative=$dir;
$dir=$this->datadir.$dir; $dir=$this->datadir.$dir;
if (!file_exists($dir)) return true; if (!file_exists($dir)) return true;
if (!is_dir($dir) || is_link($dir)) return unlink($dir); if (!is_dir($dir) || is_link($dir)) return unlink($dir);
foreach (scandir($dir) as $item) { foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') continue; if ($item == '.' || $item == '..') continue;
if(is_file($dir.'/'.$item)){ if(is_file($dir.'/'.$item)){
if(unlink($dir.'/'.$item)){ if(unlink($dir.'/'.$item)){
$this->notifyObservers($dir.'/'.$item,OC_FILEACTION_DELETE); $this->notifyObservers($dir.'/'.$item,OC_FILEACTION_DELETE);
} }
}elseif(is_dir($dir.'/'.$item)){ }elseif(is_dir($dir.'/'.$item)){
if (!$this->delTree($dirRelative. "/" . $item)){ if (!$this->delTree($dirRelative. "/" . $item)){
return false; return false;
}; };
} }
} }
@ -379,7 +392,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
} }
return $return; return $return;
} }
public function find($path){ public function find($path){
$return=System::find($this->datadir.$path); $return=System::find($this->datadir.$path);
foreach($return as &$file){ foreach($return as &$file){
@ -387,7 +400,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
} }
return $return; return $return;
} }
public function getTree($dir) { public function getTree($dir) {
if(substr($dir,-1,1)=='/'){ if(substr($dir,-1,1)=='/'){
$dir=substr($dir,0,-1); $dir=substr($dir,0,-1);
@ -396,9 +409,9 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
$tree[]=$dir; $tree[]=$dir;
$dirRelative=$dir; $dirRelative=$dir;
$dir=$this->datadir.$dir; $dir=$this->datadir.$dir;
if (!file_exists($dir)) return true; if (!file_exists($dir)) return true;
foreach (scandir($dir) as $item) { foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') continue; if ($item == '.' || $item == '..') continue;
if(is_file($dir.'/'.$item)){ if(is_file($dir.'/'.$item)){
$tree[]=$dirRelative.'/'.$item; $tree[]=$dirRelative.'/'.$item;
}elseif(is_dir($dir.'/'.$item)){ }elseif(is_dir($dir.'/'.$item)){

View File

@ -88,7 +88,7 @@ echo('<form method="post" action="'.$action.'">')
echo "<tr><td colspan='3' class='error'>$CONFIG_ERROR</td></tr>"; echo "<tr><td colspan='3' class='error'>$CONFIG_ERROR</td></tr>";
} }
if($FIRSTRUN){?> if($FIRSTRUN){?>
<tr><th colspan="2">Administartor User</th></tr> <tr><th colspan="2">Administrator User</th></tr>
<tr title="Name used to log in."><td>user name:</td><td><input type="text" name="adminlogin" size="30" class="formstyle" value=""></input></td></tr> <tr title="Name used to log in."><td>user name:</td><td><input type="text" name="adminlogin" size="30" class="formstyle" value=""></input></td></tr>
<tr title="Make a secure password, use at least 9 characters. Use letters and numbers."><td>password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle"></input></td></tr> <tr title="Make a secure password, use at least 9 characters. Use letters and numbers."><td>password:</td><td><input type="password" name="adminpassword" size="30" class="formstyle"></input></td></tr>
<tr title="Retype password to avoid typing errors."><td>retype password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle"></input></td></tr> <tr title="Retype password to avoid typing errors."><td>retype password:</td><td><input type="password" name="adminpassword2" size="30" class="formstyle"></input></td></tr>

View File

@ -310,7 +310,7 @@ OC_FILES.browser.show_callback=function(content){
OC_FILES.browser.files.show(null,content); OC_FILES.browser.files.show(null,content);
} }
if(OC_FILES.uploadForm){ if(OC_FILES.uploadForm){
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir); OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+encodeURIComponent(dir));
} }
} }
@ -423,7 +423,7 @@ OC_FILES.browser.showuploader=function(dir,parent,max_upload){
var iframeId=OC_FILES.uploadIFrames.length var iframeId=OC_FILES.uploadIFrames.length
OC_FILES.uploadForm=document.createElement('form'); OC_FILES.uploadForm=document.createElement('form');
OC_FILES.uploadForm.setAttribute('target','uploadIFrame'+iframeId); OC_FILES.uploadForm.setAttribute('target','uploadIFrame'+iframeId);
OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+dir); OC_FILES.uploadForm.setAttribute('action','files/upload.php?dir='+encodeURIComponent(dir));
OC_FILES.uploadForm.method='post'; OC_FILES.uploadForm.method='post';
OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data'); OC_FILES.uploadForm.setAttribute('enctype','multipart/form-data');
OC_FILES.uploadIFrames[iframeId]=document.createElement('iframe'); OC_FILES.uploadIFrames[iframeId]=document.createElement('iframe');

View File

@ -1,37 +0,0 @@
<?php
/**
* ownCloud
*
* @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
* 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 Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once('../../inc/lib_base.php');
OC_UTIL::showheader();
echo('<div class="center">');
echo('nothing here yet :-)');
echo('</div>');
OC_UTIL::showfooter();
?>

View File

@ -1,29 +0,0 @@
<?php
/**
* ownCloud
*
* @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
* 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 Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OC_UTIL::addnavigationentry('Music','/plugins/music');
?>

View File

@ -1,14 +0,0 @@
<?xml version="1.0"?>
<plugin version='1.0'>
<info>
<id>music</id>
<name>Music player for ownCloud</name>
<version>0.1</version>
<licence>AGPL</licence>
<author>2010 Frank Karlitschek karlitschek@kde.org</author>
<require>1.1</require>
</info>
<runtime>
<include>lib_music.php</include>
</runtime>
</plugin>

View File

@ -33,8 +33,8 @@ $FIRSTRUN=false;
OC_CONFIG::addForm('User Settings','/inc/templates/configform.php'); OC_CONFIG::addForm('User Settings','/inc/templates/configform.php');
if(OC_USER::ingroup($_SESSION['username'],'admin')){ if(OC_USER::ingroup($_SESSION['username'],'admin')){
OC_CONFIG::addForm('System Settings','/inc/templates/adminform.php'); OC_CONFIG::addForm('System Settings','/inc/templates/adminform.php');
OC_CONFIG::addForm('User Managment','/inc/templates/userform.php'); OC_CONFIG::addForm('User Management','/inc/templates/userform.php');
OC_CONFIG::addForm('Plugin Managment','/inc/templates/pluginform.php'); OC_CONFIG::addForm('Plugin Management','/inc/templates/pluginform.php');
} }
echo('<div class="center">'); echo('<div class="center">');