diff options
| author | Horus3 | 2014-04-21 18:35:43 +0200 |
|---|---|---|
| committer | Horus3 | 2014-04-21 18:35:43 +0200 |
| commit | def084a19a19e1d5c77600c0c0967e5a8fed5b93 (patch) | |
| tree | 6b8eb4b3af0decc1d0a48dc9304789f2794fd98a /www/class.files.php | |
| parent | 2a1a332c4e7625a40008d5c4565fca1bbf062d91 (diff) | |
| download | files.iamfabulous.de-def084a19a19e1d5c77600c0c0967e5a8fed5b93.tar.gz | |
Now you can get a full list of FILES or DIRECTORY from class files. Also changed database layout to log every up- and download.
Diffstat (limited to 'www/class.files.php')
| -rw-r--r-- | www/class.files.php | 216 |
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); + } + } +} |
