summaryrefslogtreecommitdiff
path: root/www/class.files.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/class.files.php')
-rw-r--r--www/class.files.php216
1 files changed, 216 insertions, 0 deletions
diff --git a/www/class.files.php b/www/class.files.php
new file mode 100644
index 0000000..7ce7d64
--- /dev/null
+++ b/www/class.files.php
@@ -0,0 +1,216 @@
+<?php
+
+class file {
+
+ public $file;
+ public $DirList;
+ public $FileList;
+
+ function __construct($val = null){
+ if($val == null){
+ $this->file = collect_content($GLOBALS["db"], $_GET["name"], $_GET["folder"]);
+ } else {
+ $this->file = $val;
+ }
+
+ $f = $this->file;
+
+ $DirRes = false;
+ $FileRes = false;
+ $DirCnt = 0;
+ $FileCnt = 0;
+
+ for($i=0; $i<count($f); $i++){
+ if($f[$i][4] == "DIRECTORY"){
+ $DirRes[$DirCnt] = $f[$i];
+ $DirCnt++;
+ } else {
+ $FileRes[$FileCnt] = $f[$i];
+ $FileCnt++;
+ }
+ }
+
+ $this->DirList = $DirRes;
+ $this->FileList = $FileRes;
+ }
+ 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){
+ if(!$val){
+ return false;
+ }
+ $this->file=$val;
+ }
+ function getDim(){
+ return count($this->file);
+ }
+ function getId($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][0];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][0];
+ }
+ return $res;
+ }
+ }
+ function getParent($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][1];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][1];
+ }
+ return $res;
+ }
+ }
+ function getOwnerId(){
+ $id = user_id($GLOBALS["db"], $_GET["name"]);
+ return $id;
+ }
+ function getOwnerName(){
+ return $_GET["name"];
+ }
+ function getName($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][3];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][3];
+ }
+ return $res;
+ }
+ }
+ function getType($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][4];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][4];
+ }
+ return $res;
+ }
+ }
+ function getMime($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][5];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][5];
+ }
+ return $res;
+ }
+ }
+ function getSize($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][6];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][6];
+ }
+ return $res;
+ }
+ }
+ function getHash($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][7];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][7];
+ }
+ return $res;
+ }
+ }
+ function getDownLink($val = null){
+ $ar = $this->file;
+ if($val != null){
+ if(!preg_match("/^[0-9]+$/", $val)){
+ return false;
+ }
+ return $ar[$val][8];
+ } else {
+ $res;
+ for($i=0; $i<count($ar); $i++){
+ $res[$i] = $ar[$i][8];
+ }
+ return $res;
+ }
+ }
+ function getAll(){
+ return $this->file;
+ }
+ function getDirList(){
+ return $this->DirList;
+ }
+ function getFileList(){
+ return $this->FileList;
+ }
+ function getDirNum(){
+ if(!$this->DirList){
+ return false;
+ } else {
+ return count($this->DirList);
+ }
+ }
+ function getFileNum(){
+ if(!$this->FileList){
+ return false;
+ } else {
+ return count($this->FileList);
+ }
+ }
+}