}
}
-class OC_MediaSearchProvider extends OC_SearchProvider{
+class OC_MediaSearchProvider extends OC_Search_Provider{
function search($query){
require_once('lib_collection.php');
$artists=OC_MEDIA_COLLECTION::getArtists($query);
$songs=OC_MEDIA_COLLECTION::getSongs(0,0,$query);
$results=array();
foreach($artists as $artist){
- $results[]=new OC_SearchResult($artist['artist_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist['artist_name']) ),'Music');
+ $results[]=new OC_Search_Result($artist['artist_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist['artist_name']) ),'Music');
}
foreach($albums as $album){
$artist=urlencode(OC_MEDIA_COLLECTION::getArtistName($album['album_artist']));
- $results[]=new OC_SearchResult($album['album_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.urlencode($album['album_name']) ),'Music');
+ $results[]=new OC_Search_Result($album['album_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.urlencode($album['album_name']) ),'Music');
}
foreach($songs as $song){
$minutes=floor($song['song_length']/60);
$secconds=$song['song_length']%60;
$artist=urlencode(OC_MEDIA_COLLECTION::getArtistName($song['song_artist']));
$album=urlencode(OC_MEDIA_COLLECTION::getalbumName($song['song_album']));
- $results[]=new OC_SearchResult($song['song_name'],"$minutes:$secconds",OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.$album.'&song='.urlencode($song['song_name']) ),'Music');
+ $results[]=new OC_Search_Result($song['song_name'],"$minutes:$secconds",OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.$album.'&song='.urlencode($song['song_name']) ),'Music');
}
return $results;
}
}
}
}
-?>
\ No newline at end of file
if(!$error and !$RUNTIME_NOAPPS ){
OC_APP::loadApps();
}
+
+// FROM Connect.php
+function OC_CONNECT_TEST($path,$user,$password){
+ echo 'connecting...';
+ $remote=OC_CONNECT::connect($path,$user,$password);
+ if($remote->connected){
+ echo 'done<br/>';
+ if($remote->isLoggedIn()){
+ echo 'logged in, session working<br/>';
+ echo 'trying to get remote files...';
+ $files=$remote->getFiles('');
+ if($files){
+ echo count($files).' files found:<br/>';
+ foreach($files as $file){
+ echo "{$file['type']} {$file['name']}: {$file['size']} bytes<br/>";
+ }
+ echo 'getting file "'.$file['name'].'"...';
+ $size=$file['size'];
+ $file=$remote->getFile('',$file['name']);
+ if(file_exists($file)){
+ $newSize=filesize($file);
+ if($size!=$newSize){
+ echo "fail<br/>Error: $newSize bytes received, $size expected.";
+ echo '<br/><br/>Recieved file:<br/>';
+ readfile($file);
+ unlink($file);
+ return;
+ }
+ OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
+ echo 'done<br/>';
+ echo 'sending file "burning_avatar.png"...';
+ $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
+ if($res){
+ echo 'done<br/>';
+ }else{
+ echo 'fail<br/>';
+ }
+ }else{
+ echo 'fail<br/>';
+ }
+ }else{
+ echo 'fail<br/>';
+ }
+ }else{
+ echo 'no longer logged in, session fail<br/>';
+ }
+ }else{
+ echo 'fail<br/>';
+ }
+ $remote->disconnect();
+ die();
+}
+
+// From files.php
+function zipAddDir($dir,$zip,$internalDir=''){
+ $dirname=basename($dir);
+ $zip->addEmptyDir($internalDir.$dirname);
+ $internalDir.=$dirname.='/';
+ $files=OC_FILES::getdirectorycontent($dir);
+ foreach($files as $file){
+ $filename=$file['name'];
+ $file=$dir.'/'.$filename;
+ if(OC_FILESYSTEM::is_file($file)){
+ $tmpFile=OC_FILESYSTEM::toTmpFile($file);
+ OC_FILES::$tmpFiles[]=$tmpFile;
+ $zip->addFile($tmpFile,$internalDir.$filename);
+ }elseif(OC_FILESYSTEM::is_dir($file)){
+ zipAddDir($file,$zip,$internalDir);
+ }
+ }
+}
+
+if(!function_exists('sys_get_temp_dir')) {
+ function sys_get_temp_dir() {
+ if( $temp=getenv('TMP') ) return $temp;
+ if( $temp=getenv('TEMP') ) return $temp;
+ if( $temp=getenv('TMPDIR') ) return $temp;
+ $temp=tempnam(__FILE__,'');
+ if (file_exists($temp)) {
+ unlink($temp);
+ return dirname($temp);
+ }
+ return null;
+ }
+}
+
+require_once('fakedirstream.php');
+
+// FROM search.php
+new OC_Search_Provider_File();
}
}
}
-
-function OC_CONNECT_TEST($path,$user,$password){
- echo 'connecting...';
- $remote=OC_CONNECT::connect($path,$user,$password);
- if($remote->connected){
- echo 'done<br/>';
- if($remote->isLoggedIn()){
- echo 'logged in, session working<br/>';
- echo 'trying to get remote files...';
- $files=$remote->getFiles('');
- if($files){
- echo count($files).' files found:<br/>';
- foreach($files as $file){
- echo "{$file['type']} {$file['name']}: {$file['size']} bytes<br/>";
- }
- echo 'getting file "'.$file['name'].'"...';
- $size=$file['size'];
- $file=$remote->getFile('',$file['name']);
- if(file_exists($file)){
- $newSize=filesize($file);
- if($size!=$newSize){
- echo "fail<br/>Error: $newSize bytes received, $size expected.";
- echo '<br/><br/>Recieved file:<br/>';
- readfile($file);
- unlink($file);
- return;
- }
- OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
- echo 'done<br/>';
- echo 'sending file "burning_avatar.png"...';
- $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
- if($res){
- echo 'done<br/>';
- }else{
- echo 'fail<br/>';
- }
- }else{
- echo 'fail<br/>';
- }
- }else{
- echo 'fail<br/>';
- }
- }else{
- echo 'no longer logged in, session fail<br/>';
- }
- }else{
- echo 'fail<br/>';
- }
- $remote->disconnect();
- die();
-}
-
-
-?>
}
}
}
-?>
\ No newline at end of file
--- /dev/null
+<?php
+global $FAKEDIRS;
+$FAKEDIRS=array();
+
+class fakeDirStream{
+ private $name;
+ private $data;
+ private $index;
+
+ public function dir_opendir($path,$options){
+ global $FAKEDIRS;
+ $url=parse_url($path);
+ $this->name=substr($path,strlen('fakedir://'));
+ $this->index=0;
+ if(isset($FAKEDIRS[$this->name])){
+ $this->data=$FAKEDIRS[$this->name];
+ }else{
+ $this->data=array();
+ }
+ return true;
+ }
+
+ public function dir_readdir(){
+ if($this->index>=count($this->data)){
+ return false;
+ }
+ $filename=$this->data[$this->index];
+ $this->index++;
+ return $filename;
+ }
+
+ public function dir_closedir() {
+ $this->data=false;
+ $this->name='';
+ return true;
+ }
+
+ public function dir_rewinddir() {
+ $this->index=0;
+ return true;
+ }
+}
+
+stream_wrapper_register("fakedir", "fakeDirStream");
+
@file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
}
}
-
-function zipAddDir($dir,$zip,$internalDir=''){
- $dirname=basename($dir);
- $zip->addEmptyDir($internalDir.$dirname);
- $internalDir.=$dirname.='/';
- $files=OC_FILES::getdirectorycontent($dir);
- foreach($files as $file){
- $filename=$file['name'];
- $file=$dir.'/'.$filename;
- if(OC_FILESYSTEM::is_file($file)){
- $tmpFile=OC_FILESYSTEM::toTmpFile($file);
- OC_FILES::$tmpFiles[]=$tmpFile;
- $zip->addFile($tmpFile,$internalDir.$filename);
- }elseif(OC_FILESYSTEM::is_dir($file)){
- zipAddDir($file,$zip,$internalDir);
- }
- }
-}
-
-if(!function_exists('sys_get_temp_dir')) {
- function sys_get_temp_dir() {
- if( $temp=getenv('TMP') ) return $temp;
- if( $temp=getenv('TEMP') ) return $temp;
- if( $temp=getenv('TMPDIR') ) return $temp;
- $temp=tempnam(__FILE__,'');
- if (file_exists($temp)) {
- unlink($temp);
- return dirname($temp);
- }
- return null;
- }
-}
-
-global $FAKEDIRS;
-$FAKEDIRS=array();
-
-class fakeDirStream{
- private $name;
- private $data;
- private $index;
-
- public function dir_opendir($path,$options){
- global $FAKEDIRS;
- $url=parse_url($path);
- $this->name=substr($path,strlen('fakedir://'));
- $this->index=0;
- if(isset($FAKEDIRS[$this->name])){
- $this->data=$FAKEDIRS[$this->name];
- }else{
- $this->data=array();
- }
- return true;
- }
-
- public function dir_readdir(){
- if($this->index>=count($this->data)){
- return false;
- }
- $filename=$this->data[$this->index];
- $this->index++;
- return $filename;
- }
-
- public function dir_closedir() {
- $this->data=false;
- $this->name='';
- return true;
- }
-
- public function dir_rewinddir() {
- $this->index=0;
- return true;
- }
-}
-stream_wrapper_register("fakedir", "fakeDirStream");
-?>
--- /dev/null
+<?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 Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
+ private $url;
+ private $username;
+ private $password;
+ private $remote=false;
+ private $statCache;
+ private $statCacheDir=false;
+ private $changed=array();
+
+ private function cacheDir($dir){
+ if($this->statCacheDir!=$dir or $this->statCacheDir===false){
+ $this->statCache=$this->remote->getFiles($dir);
+ $keys=array_keys($this->statCache);
+ $this->statCacheDir=$dir;
+ }
+ }
+
+ public function __construct($arguments){
+ $this->url=$arguments['url'];
+ $this->username=$arguments['username'];
+ $this->password=$arguments['password'];
+ }
+ private function connect(){
+ if($this->remote===false){
+ $this->remote=OC_CONNECT::connect($this->url,$this->username,$this->password);
+ }
+ }
+ public function mkdir($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $return=$this->remote->newFile($parent,$name,'dir');
+ if($return){
+ $this->notifyObservers($path,OC_FILEACTION_CREATE);
+ }
+ return $return;
+ }
+ public function rmdir($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $return=$this->remote->delete($parent,$name);
+ if($return){
+ $this->notifyObservers($path,OC_FILEACTION_DELETE);
+ }
+ return $return;
+ }
+ public function opendir($path){
+ $this->connect();
+ $this->cacheDir($path);
+ $dirs=array_keys($this->statCache);
+ $id=uniqid();
+ global $FAKEDIRS;
+ $FAKEDIRS[$id]=$dirs;
+ if($return=opendir("fakedir://$id")){
+ $this->notifyObservers($path,OC_FILEACTION_READ);
+ }
+ return $return;
+ }
+ public function is_dir($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($path);
+ if($path=='' or $path=='/'){
+ return true;
+ }
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return ($this->statCache[$name]['type'=='dir']);
+ }
+ public function is_file($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return ($this->statCache[$name]['type'!='dir']);
+ }
+ public function stat($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return $false;
+ }
+ return $this->statCache[$name];
+ }
+ public function filetype($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['type'];
+ }
+ public function filesize($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return $false;
+ }
+ return $this->statCache[$name]['size'];
+ }
+ public function is_readable($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['readable'];
+ }
+ public function is_writeable($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['writeable'];
+ }
+ public function file_exists($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ return isset($this->statCache[$name]);
+ }
+ public function readfile($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $file=$this->remote->getFile($parent,$name);
+ readfile($file);
+ unlink($file);
+ }
+ public function filectime($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['ctime'];
+ }
+ public function filemtime($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['mtime'];
+ }
+ public function fileatime($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['atime'];
+ }
+ public function file_get_contents($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $file=$this->remote->getFile($parent,$name);
+ file_get_contents($file);
+ unlink($file);
+ }
+ public function file_put_contents($path,$data){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $file=$this->remote->getFile($parent,$name);
+ $file=tempnam(sys_get_temp_dir(),'oc_');
+ file_put_contents($file,$data);
+ if($return=$this->remote->sendTmpFile($file,$parent,$name)){
+ $this->notifyObservers($path,OC_FILEACTION_WRITE);
+ }
+ }
+ public function unlink($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ if($return=$this->remote->delete($paren,$name)){
+ $this->notifyObservers($path,OC_FILEACTION_DELETE);
+ }
+ return $return;
+ }
+ public function rename($path1,$path2){
+ $this->connect();
+ $parent1=dirname($path1);
+ $name1=substr($path1,strlen($parent1)+1);
+ $parent2=dirname($path2);
+ $name2=substr($path2,strlen($parent2)+1);
+ if($return=$this->remote->move($parent1,$name1,$parent2,$name2)){
+ $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
+ }
+ return $return;
+ }
+ public function copy($path1,$path2){
+ $this->connect();
+ $parent1=dirname($path1);
+ $name1=substr($path1,strlen($parent1)+1);
+ $parent2=dirname($path2);
+ $name2=substr($path2,strlen($parent2)+1);
+ if($return=$this->copy->rename($parent1,$name1,$parent2,$name2)){
+ $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
+ }
+ return $return;
+ }
+ public function fopen($path,$mode){
+ $this->connect();
+ $changed=false;
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ $file=$this->remote->getFile($parent,$name);
+ if($return=fopen($file,$mode)){
+ switch($mode){
+ case 'r':
+ $this->notifyObservers($path,OC_FILEACTION_READ);
+ break;
+ case 'r+':
+ case 'w+':
+ case 'x+':
+ case 'a+':
+ $this->notifyObservers($path,OC_FILEACTION_READ | OC_FILEACTION_WRITE);
+ $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
+ break;
+ case 'w':
+ case 'x':
+ case 'a':
+ $this->notifyObservers($path,OC_FILEACTION_WRITE);
+ $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
+ break;
+ }
+ }
+ return $return;
+ }
+
+ public function getMimeType($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ if(substr($name,0,1)=='/'){
+ $name=substr($name,1);
+ }
+ $this->cacheDir($parent);
+ if(!isset($this->statCache[$name])){
+ return false;
+ }
+ return $this->statCache[$name]['mime'];
+ }
+
+ public function toTmpFile($path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ if(substr($name,0,1)=='/'){
+ $name=substr($name,1);
+ }
+ $filename=$this->remote->getFile($parent,$name);
+ if($filename){
+ $this->notifyObservers($path,OC_FILEACTION_READ);
+ return $filename;
+ }else{
+ return false;
+ }
+ }
+
+ public function fromTmpFile($tmpFile,$path){
+ $this->connect();
+ $parent=dirname($path);
+ $name=substr($path,strlen($parent)+1);
+ if($this->remote->sendTmpFile($tmpFile,$parent,$name)){
+ $this->notifyObservers($path,OC_FILEACTION_CREATE);
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ public function delTree($dir) {
+ $this->connect();
+ $parent=dirname($dir);
+ $name=substr($dir,strlen($parent)+1);
+ $return=$this->remote->delete($parent,$name);
+ if($return=rmdir($dir)){
+ $this->notifyObservers($dir,OC_FILEACTION_DELETE);
+ }
+ return $return;
+ }
+
+ public function find($path){
+ return $this->getTree($path);
+ }
+
+ public function getTree($dir) {
+ $this->connect();
+ if($return=$this->remote->getTree($dir)){
+ $this->notifyObservers($dir,OC_FILEACTION_READ);
+ }
+ return $return;
+ }
+
+ public function __destruct(){
+ foreach($this->changed as $changed){
+ $this->remote->sendTmpFile($changed['tmp'],$changed['dir'],$changed['file']);
+ }
+ }
+}
return $filteredLogs;
}
}
-
-
-
-?>
'webm'=>'video/webm',
'wmv'=>'video/x-ms-asf'
);
-?>
\ No newline at end of file
return OC_PREFERENCES::deleteKey($user,$app,$key);
}
}
-
-?>
return $this->apiCall('pull',array('dir'=>$targetDir,'file'=>$targetFile,'token'=>$token,'source'=>$url),true);
}
}
-
+
\ No newline at end of file
+++ /dev/null
-<?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 Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-
-class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
- private $url;
- private $username;
- private $password;
- private $remote=false;
- private $statCache;
- private $statCacheDir=false;
- private $changed=array();
-
- private function cacheDir($dir){
- if($this->statCacheDir!=$dir or $this->statCacheDir===false){
- $this->statCache=$this->remote->getFiles($dir);
- $keys=array_keys($this->statCache);
- $this->statCacheDir=$dir;
- }
- }
-
- public function __construct($arguments){
- $this->url=$arguments['url'];
- $this->username=$arguments['username'];
- $this->password=$arguments['password'];
- }
- private function connect(){
- if($this->remote===false){
- $this->remote=OC_CONNECT::connect($this->url,$this->username,$this->password);
- }
- }
- public function mkdir($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $return=$this->remote->newFile($parent,$name,'dir');
- if($return){
- $this->notifyObservers($path,OC_FILEACTION_CREATE);
- }
- return $return;
- }
- public function rmdir($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $return=$this->remote->delete($parent,$name);
- if($return){
- $this->notifyObservers($path,OC_FILEACTION_DELETE);
- }
- return $return;
- }
- public function opendir($path){
- $this->connect();
- $this->cacheDir($path);
- $dirs=array_keys($this->statCache);
- $id=uniqid();
- global $FAKEDIRS;
- $FAKEDIRS[$id]=$dirs;
- if($return=opendir("fakedir://$id")){
- $this->notifyObservers($path,OC_FILEACTION_READ);
- }
- return $return;
- }
- public function is_dir($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($path);
- if($path=='' or $path=='/'){
- return true;
- }
- if(!isset($this->statCache[$name])){
- return false;
- }
- return ($this->statCache[$name]['type'=='dir']);
- }
- public function is_file($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return ($this->statCache[$name]['type'!='dir']);
- }
- public function stat($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return $false;
- }
- return $this->statCache[$name];
- }
- public function filetype($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['type'];
- }
- public function filesize($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return $false;
- }
- return $this->statCache[$name]['size'];
- }
- public function is_readable($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['readable'];
- }
- public function is_writeable($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['writeable'];
- }
- public function file_exists($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- return isset($this->statCache[$name]);
- }
- public function readfile($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $file=$this->remote->getFile($parent,$name);
- readfile($file);
- unlink($file);
- }
- public function filectime($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['ctime'];
- }
- public function filemtime($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['mtime'];
- }
- public function fileatime($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['atime'];
- }
- public function file_get_contents($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $file=$this->remote->getFile($parent,$name);
- file_get_contents($file);
- unlink($file);
- }
- public function file_put_contents($path,$data){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $file=$this->remote->getFile($parent,$name);
- $file=tempnam(sys_get_temp_dir(),'oc_');
- file_put_contents($file,$data);
- if($return=$this->remote->sendTmpFile($file,$parent,$name)){
- $this->notifyObservers($path,OC_FILEACTION_WRITE);
- }
- }
- public function unlink($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- if($return=$this->remote->delete($paren,$name)){
- $this->notifyObservers($path,OC_FILEACTION_DELETE);
- }
- return $return;
- }
- public function rename($path1,$path2){
- $this->connect();
- $parent1=dirname($path1);
- $name1=substr($path1,strlen($parent1)+1);
- $parent2=dirname($path2);
- $name2=substr($path2,strlen($parent2)+1);
- if($return=$this->remote->move($parent1,$name1,$parent2,$name2)){
- $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
- }
- return $return;
- }
- public function copy($path1,$path2){
- $this->connect();
- $parent1=dirname($path1);
- $name1=substr($path1,strlen($parent1)+1);
- $parent2=dirname($path2);
- $name2=substr($path2,strlen($parent2)+1);
- if($return=$this->copy->rename($parent1,$name1,$parent2,$name2)){
- $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
- }
- return $return;
- }
- public function fopen($path,$mode){
- $this->connect();
- $changed=false;
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- $file=$this->remote->getFile($parent,$name);
- if($return=fopen($file,$mode)){
- switch($mode){
- case 'r':
- $this->notifyObservers($path,OC_FILEACTION_READ);
- break;
- case 'r+':
- case 'w+':
- case 'x+':
- case 'a+':
- $this->notifyObservers($path,OC_FILEACTION_READ | OC_FILEACTION_WRITE);
- $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
- break;
- case 'w':
- case 'x':
- case 'a':
- $this->notifyObservers($path,OC_FILEACTION_WRITE);
- $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
- break;
- }
- }
- return $return;
- }
-
- public function getMimeType($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- if(substr($name,0,1)=='/'){
- $name=substr($name,1);
- }
- $this->cacheDir($parent);
- if(!isset($this->statCache[$name])){
- return false;
- }
- return $this->statCache[$name]['mime'];
- }
-
- public function toTmpFile($path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- if(substr($name,0,1)=='/'){
- $name=substr($name,1);
- }
- $filename=$this->remote->getFile($parent,$name);
- if($filename){
- $this->notifyObservers($path,OC_FILEACTION_READ);
- return $filename;
- }else{
- return false;
- }
- }
-
- public function fromTmpFile($tmpFile,$path){
- $this->connect();
- $parent=dirname($path);
- $name=substr($path,strlen($parent)+1);
- if($this->remote->sendTmpFile($tmpFile,$parent,$name)){
- $this->notifyObservers($path,OC_FILEACTION_CREATE);
- return true;
- }else{
- return false;
- }
- }
-
- public function delTree($dir) {
- $this->connect();
- $parent=dirname($dir);
- $name=substr($dir,strlen($parent)+1);
- $return=$this->remote->delete($parent,$name);
- if($return=rmdir($dir)){
- $this->notifyObservers($dir,OC_FILEACTION_DELETE);
- }
- return $return;
- }
-
- public function find($path){
- return $this->getTree($path);
- }
-
- public function getTree($dir) {
- $this->connect();
- if($return=$this->remote->getTree($dir)){
- $this->notifyObservers($dir,OC_FILEACTION_READ);
- }
- return $return;
- }
-
- public function __destruct(){
- foreach($this->changed as $changed){
- $this->remote->sendTmpFile($changed['tmp'],$changed['dir'],$changed['file']);
- }
- }
-}
-
-?>
/**
* register a new search provider to be used
- * @param OC_SearchProvider $provider
+ * @param OC_Search_Provider $provider
*/
public static function registerProvider($provider){
self::$providers[]=$provider;
/**
* search all provider for $query
* @param string query
- * @return array An array of OC_SearchResult's
+ * @return array An array of OC_Search_Result's
*/
public static function search($query){
$results=array();
return $results;
}
}
-
-/**
- * provides search functionalty
- */
-abstract class OC_SearchProvider{
- public function __construct(){
- OC_SEARCH::registerProvider($this);
- }
-
- /**
- * search for $query
- * @param string $query
- * @return array An array of OC_SearchResult's
- */
- abstract function search($query);
-}
-
-/**
- * a result of a search
- */
-class OC_SearchResult{
- private $name;
- private $text;
- private $link;
- private $type;
-
- /**
- * create a new search result
- * @param string $name short name for the result
- * @param string $text some more information about the result
- * @param string $link link for the result
- * @param string $type the type of result as human readable string ('File', 'Music', etc)
- */
- public function __construct($name,$text,$link,$type){
- $this->name=$name;
- $this->text=$text;
- $this->link=$link;
- $this->type=$type;
- }
-
- public function __get($name){
- switch($name){
- case 'name':
- return $this->name;
- case 'text':
- return $this->text;
- case 'link':
- return $this->link;
- case 'type':
- return $this->type;
- }
- }
-}
-
-class OC_FileSearchProvider extends OC_SearchProvider{
- function search($query){
- $files=OC_FILESYSTEM::search($query);
- $results=array();
- foreach($files as $file){
- if(OC_FILESYSTEM::is_dir($file)){
- $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'index.php?dir='.$file ),'Files');
- }else{
- $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'download.php?file='.$file ),'Files');
- }
- }
- return $results;
- }
-}
-
-new OC_FileSearchProvider();
-?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * provides search functionalty
+ */
+abstract class OC_Search_Provider{
+ public function __construct(){
+ OC_SEARCH::registerProvider($this);
+ }
+
+ /**
+ * search for $query
+ * @param string $query
+ * @return array An array of OC_Search_Result's
+ */
+ abstract function search($query);
+}
--- /dev/null
+<?php
+
+class OC_Search_Provider_File extends OC_Search_Provider{
+ function search($query){
+ $files=OC_FILESYSTEM::search($query);
+ $results=array();
+ foreach($files as $file){
+ if(OC_FILESYSTEM::is_dir($file)){
+ $results[]=new OC_Search_Result(basename($file),$file,OC_HELPER::linkTo( 'files', 'index.php?dir='.$file ),'Files');
+ }else{
+ $results[]=new OC_Search_Result(basename($file),$file,OC_HELPER::linkTo( 'files', 'download.php?file='.$file ),'Files');
+ }
+ }
+ return $results;
+ }
+}
--- /dev/null
+<?php
+/**
+ * a result of a search
+ */
+class OC_Search_Result{
+ private $name;
+ private $text;
+ private $link;
+ private $type;
+
+ /**
+ * create a new search result
+ * @param string $name short name for the result
+ * @param string $text some more information about the result
+ * @param string $link link for the result
+ * @param string $type the type of result as human readable string ('File', 'Music', etc)
+ */
+ public function __construct($name,$text,$link,$type){
+ $this->name=$name;
+ $this->text=$text;
+ $this->link=$link;
+ $this->type=$type;
+ }
+
+ public function __get($name){
+ switch($name){
+ case 'name':
+ return $this->name;
+ case 'text':
+ return $this->text;
+ case 'link':
+ return $this->link;
+ case 'type':
+ return $this->type;
+ }
+ }
+}
<?php
-include_once( 'installer.php' );
-
$hasSQLite = (is_callable('sqlite_open') or class_exists('SQLite3'));
$hasMySQL = is_callable('mysql_connect');
$datadir = OC_CONFIG::getValue('datadir', $SERVERROOT.'/data');
return $content->printPage();
}
}
-
-?>