summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-04-20 06:27:27 +0200
committerroot2014-04-20 06:27:27 +0200
commit0a28d7fe6ddebdc74a343574a38f3bb646a7ddd5 (patch)
treef8c801bd06d28f90894fa1ff3970ec7bb55cd045
parentfbd2513b6094d8b902e1ac687e6d9d4889a48701 (diff)
downloadfiles.iamfabulous.de-0a28d7fe6ddebdc74a343574a38f3bb646a7ddd5.tar.gz
Added new methods
-rw-r--r--www/functions/class_files.php30
-rwxr-xr-xwww/index.php17
2 files changed, 36 insertions, 11 deletions
diff --git a/www/functions/class_files.php b/www/functions/class_files.php
index 716d4c2..0cf066c 100644
--- a/www/functions/class_files.php
+++ b/www/functions/class_files.php
@@ -4,9 +4,33 @@ class file {
public $file;
- function __construct(){
- $f = collect_content($GLOBALS["db"], $_GET["name"], $_GET["folder"]);
- $this->file=$f;
+ function __construct($val = null){
+ if($val == null){
+ $this->file = collect_content($GLOBALS["db"], $_GET["name"], $_GET["folder"]);
+ } else {
+ $this->file = $val;
+ }
+ }
+ function NotFound(){
+ if($this->file == FILE_NOT_FOUND){
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function isEmpty(){
+ if($this->file == EMPTY_FOLDER){
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function isFile(){
+ if(check_if_file($GLOBALS["db"], $_GET["name"], $_GET["folder"])){
+ return true;
+ } else {
+ return false;
+ }
}
function initFile($val){
$this->file=$val;
diff --git a/www/index.php b/www/index.php
index 3110776..333d02e 100755
--- a/www/index.php
+++ b/www/index.php
@@ -142,21 +142,22 @@ if(empty($_GET)){
} else {
/* shows the user content, downloads files, main function */
+
+ $f = new file();
if(rewrite($db)){
- if(!check_if_file($db, $_GET["name"], $_GET["folder"])){
- $content = collect_content($db, $_GET["name"], $_GET["folder"]);
- if($content == FILE_NOT_FOUND){
+ if($f->isFile()){
+ start_file_download($_GET["name"], $_GET["folder"]);
+ } else {
+ if($f->notFound()){
$content = get_path_to_wrong_folder($db, $_GET["name"], $_GET["folder"]);
print_wrong_folder($content);
- } elseif ($content == EMPTY_FOLDER){
- print_browser($content);
+ } elseif ($f->isEmpty()){
+ print_browser($f);
//TODO: echo "print: folder_is_empty"; exit;
} else {
- print_browser($content);
+ print_browser($f);
}
- } else {
- start_file_download($_GET["name"], $_GET["folder"]);
}
} else {
get_404($_GET["name"], $_GET["name"]);