From 0a28d7fe6ddebdc74a343574a38f3bb646a7ddd5 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 20 Apr 2014 06:27:27 +0200 Subject: Added new methods --- www/functions/class_files.php | 30 +++++++++++++++++++++++++++--- www/index.php | 17 +++++++++-------- 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"]); -- cgit v1.2.3