diff options
author | Jakob Sack <mail@jakobsack.de> | 2011-03-01 23:20:16 +0100 |
---|---|---|
committer | Jakob Sack <mail@jakobsack.de> | 2011-03-01 23:20:16 +0100 |
commit | 132695ceb1d7ab0e4bfbb141e9e9639111dd25b5 (patch) | |
tree | f53fabcefd89a1e5bbeda9a2c2d2fff6683139d4 /files | |
parent | 1fd39a52fa750878e7d70fba63c099f252095762 (diff) | |
download | nextcloud-server-132695ceb1d7ab0e4bfbb141e9e9639111dd25b5.tar.gz nextcloud-server-132695ceb1d7ab0e4bfbb141e9e9639111dd25b5.zip |
Start of the refactoring. Commit is quite big because I forgot to use git right from the beginning. Sorry.
Diffstat (limited to 'files')
-rw-r--r-- | files/api.php | 101 | ||||
-rw-r--r-- | files/appinfo.php | 6 | ||||
-rw-r--r-- | files/get_files.php | 109 | ||||
-rw-r--r-- | files/index.php | 29 | ||||
-rw-r--r-- | files/open_file.php | 47 | ||||
-rw-r--r-- | files/pull.php | 11 | ||||
-rw-r--r-- | files/templates/_c/.gitkeep | 0 | ||||
-rw-r--r-- | files/templates/index.tmpl | 3 | ||||
-rw-r--r-- | files/upload.php | 37 |
9 files changed, 26 insertions, 317 deletions
diff --git a/files/api.php b/files/api.php deleted file mode 100644 index 08e1021af09..00000000000 --- a/files/api.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -/** -* ownCloud - ajax frontend -* -* @author Robin Appelman -* @copyright 2010 Robin Appelman icewind1991@gmail.com -* -* 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/>. -* -*/ -require_once('../inc/lib_base.php'); - -$arguments=$_POST; -if(!isset($_POST['action']) and isset($_GET['action'])){ - $arguments=$_GET; -} - -foreach($arguments as &$argument){ - $argument=stripslashes($argument); -} -global $CONFIG_DATADIRECTORY; -ob_clean(); -if($arguments['action']){ - switch($arguments['action']){ - case 'delete': - echo (OC_FILES::delete($arguments['dir'],$arguments['file']))?'true':'false'; - break; - case 'rename': - echo (OC_FILES::move($arguments['dir'],$arguments['file'],$arguments['dir'],$arguments['newname']))?'true':'false'; - break; - case 'new': - echo (OC_FILES::newfile($arguments['dir'],$arguments['name'],$arguments['type']))?'true':'false'; - break; - case 'move': - echo (OC_FILES::move($arguments['sourcedir'],$arguments['source'],$arguments['targetdir'],$arguments['target']))?'true':'false'; - break; - case 'copy': - echo (OC_FILES::copy($arguments['sourcedir'],$arguments['source'],$arguments['targetdir'],$arguments['target']))?'true':'false'; - break; - case 'get': - OC_FILES::get($arguments['dir'],$arguments['file']); - break; - case 'getfiles': - $max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize'))); - $files=OC_FILES::getDirectoryContent($arguments['dir']); - $files['__max_upload']=$max_upload; - echo json_encode($files); - break; - case 'gettree': - echo json_encode(OC_FILES::getTree($arguments['dir'])); - break; - case 'find': - echo json_encode(OC_FILESYSTEM::find($arguments['path'])); - break; - case 'login': - if(OC_USER::login($arguments['username'],$arguments['password'])){ - echo 'true'; - }else{ - echo 'false'; - } - break; - case 'checklogin': - if(OC_USER::isLoggedIn()){ - echo 'true'; - }else{ - echo 'false'; - } - break; - case 'pull': - return OC_FILES::pull($arguments['source'],$arguments['token'],$arguments['dir'],$arguments['file']); - } -} - -function return_bytes($val) { - $val = trim($val); - $last = strtolower($val[strlen($val)-1]); - switch($last) { - // The 'G' modifier is available since PHP 5.1.0 - case 'g': - $val *= 1024; - case 'm': - $val *= 1024; - case 'k': - $val *= 1024; - } - - return $val; -} -?> diff --git a/files/appinfo.php b/files/appinfo.php new file mode 100644 index 00000000000..44a533cf4a0 --- /dev/null +++ b/files/appinfo.php @@ -0,0 +1,6 @@ +<?php + +OC_UTIL::addApplication( array( "id" => "files", "name" => "Files" )); +OC_UTIL::addNavigationEntry( array( "app" => "files", "file" => "index.php", "name" => "Files" )); + +?> diff --git a/files/get_files.php b/files/get_files.php deleted file mode 100644 index 45d2b626e65..00000000000 --- a/files/get_files.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php - -/** -* ownCloud - ajax frontend -* -* @author Robin Appelman -* @copyright 2010 Robin Appelman icewind1991@gmail.com -* -* 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/>. -* -*/ -require_once('../inc/lib_base.php'); - -function return_bytes($val) { - $val = trim($val); - $last = strtolower($val[strlen($val)-1]); - switch($last) { - // The 'G' modifier is available since PHP 5.1.0 - case 'g': - $val *= 1024; - case 'm': - $val *= 1024; - case 'k': - $val *= 1024; - } - - return $val; -} - -// header('Content-type: text/plain'); -header('Content-type: application/xml'); - -$dir=isset($_GET['dir'])?$_GET['dir']:''; -$files=OC_FILES::getdirectorycontent($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 "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n"; -echo "<dir name='$dirname' max_upload='$max_upload'>\n"; -if(is_array($files)){ - foreach($files as $file){ - $attributes=''; - foreach($file as $name=>$data){ - $data=utf8_encode($data); - $data=utf8tohtml($data); - $data=str_replace("'",''',$data); - if (is_string($name)) $attributes.=" $name='$data'"; - } - $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\''; - echo "<file$attributes/>\n"; - } -} -echo "</dir>"; - -// converts a UTF8-string into HTML entities -// - $utf8: the UTF8-string to convert -// - $encodeTags: booloean. TRUE will convert "<" to "<" -// - return: returns the converted HTML-string -function utf8tohtml($utf8, $encodeTags=true) { - $result = ''; - for ($i = 0; $i < strlen($utf8); $i++) { - $char = $utf8[$i]; - $ascii = ord($char); - if ($ascii < 128) { - // one-byte character - $result .= ($encodeTags) ? htmlentities($char) : $char; - } else if ($ascii < 192) { - // non-utf8 character or not a start byte - } else if ($ascii < 224) { - // two-byte character - $result .= htmlentities(substr($utf8, $i, 2), ENT_QUOTES, 'UTF-8'); - $i++; - } else if ($ascii < 240) { - // three-byte character - $ascii1 = ord($utf8[$i+1]); - $ascii2 = ord($utf8[$i+2]); - $unicode = (15 & $ascii) * 4096 + - (63 & $ascii1) * 64 + - (63 & $ascii2); - $result .= "&#$unicode;"; - $i += 2; - } else if ($ascii < 248) { - // four-byte character - $ascii1 = ord($utf8[$i+1]); - $ascii2 = ord($utf8[$i+2]); - $ascii3 = ord($utf8[$i+3]); - $unicode = (15 & $ascii) * 262144 + - (63 & $ascii1) * 4096 + - (63 & $ascii2) * 64 + - (63 & $ascii3); - $result .= "&#$unicode;"; - $i += 3; - } - } - return $result; -} -?>
\ No newline at end of file diff --git a/files/index.php b/files/index.php index f2f7a48713a..538bd87971d 100644 --- a/files/index.php +++ b/files/index.php @@ -5,31 +5,36 @@ * * @author Robin Appelman * @copyright 2010 Robin Appelman icewind1991@gmail.com -* +* * 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 <http://www.gnu.org/licenses/>. -* +* */ -//require_once('../../config/config.php'); -require_once('../inc/lib_base.php'); +require_once('../lib/base.php'); +oc_require( 'template.php' ); +if( !OC_USER::isLoggedIn()){ + header( "Location: ".OC_UTIL::linkto( "index.php" )); + exit(); +} -OC_UTIL::addscript('/plugins/ajax/ajax.js'); +$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; -OC_UTIL::showheader(); +$files=OC_FILES::getdirectorycontent( $dir ); -echo "<div id='content'></div>"; +$tmpl = new OC_TEMPLATE( "files", "index", "user" ); +$tmpl->assign( "files", $files ); +$tmpl->printPage(); -OC_UTIL::showfooter(); ?> diff --git a/files/open_file.php b/files/open_file.php deleted file mode 100644 index ad91e3dad5c..00000000000 --- a/files/open_file.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** -* ownCloud - ajax frontend -* -* @author Robin Appelman -* @copyright 2010 Robin Appelman icewind1991@gmail.com -* -* 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/>. -* -*/ - -//not this file is for getting files themselves, get_files.php is for getting a list of files. - -require_once('../inc/lib_base.php'); - -if(isset($_GET['path'])){ - $filename=$_GET['path']; -}else{ - $file=$_GET['file']; - $dir=(isset($_GET['dir']))?$_GET['dir']:''; - $filename=$dir.'/'.$file; -} -if(strstr($filename,'..')){ - die(); -} -$filename=stripslashes($filename); -$ftype=OC_FILESYSTEM::getMimeType($filename); -ob_end_clean(); -header('Content-Type: '.$ftype); -header('Expires: 0'); -header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); -header('Pragma: public'); -header('Content-Length: ' . OC_FILESYSTEM::filesize($filename)); - -OC_FILESYSTEM::readfile($filename); -?>
\ No newline at end of file diff --git a/files/pull.php b/files/pull.php deleted file mode 100644 index 1cc82425845..00000000000 --- a/files/pull.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -$token=$_GET['token']; - -$file=sys_get_temp_dir().'/'.'remoteCloudFile'.$token; -if(file_exists($file) and is_readable($file) and is_writable($file)){ - readfile($file); - unlink($file); -}else{ - header("HTTP/1.0 404 Not Found"); -} -?>
\ No newline at end of file diff --git a/files/templates/_c/.gitkeep b/files/templates/_c/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/files/templates/_c/.gitkeep diff --git a/files/templates/index.tmpl b/files/templates/index.tmpl new file mode 100644 index 00000000000..7ea1df8644f --- /dev/null +++ b/files/templates/index.tmpl @@ -0,0 +1,3 @@ +<h1>Files</h1> + +# TBD (again)
\ No newline at end of file diff --git a/files/upload.php b/files/upload.php deleted file mode 100644 index 08c89e76024..00000000000 --- a/files/upload.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/** -* ownCloud - ajax frontend -* -* @author Robin Appelman -* @copyright 2010 Robin Appelman icewind1991@gmail.com -* -* 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/>. -* -*/ -require_once('../inc/lib_base.php'); - -$fileName=$_FILES['file']['name']; -$source=$_FILES['file']['tmp_name']; -$target=stripslashes($_GET['dir']).'/'.$fileName; -if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($_GET['dir'],'..')===false){ - if(OC_FILESYSTEM::fromTmpFile($source,$target)){ - echo 'true'; - }else{ - echo 'false'; - } -}else{ - echo 'false'; -} -?>
\ No newline at end of file |