From 7b3427b4278817df9443ae0de057e50b544d919f Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 20 Apr 2014 16:05:53 +0200 Subject: Error handling in class_file and more methods. --- www/functions/class_files.php | 133 +++++++++++++++++++++++++++++++++++++----- www/functions/func_select.php | 2 +- 2 files changed, 118 insertions(+), 17 deletions(-) (limited to 'www/functions') diff --git a/www/functions/class_files.php b/www/functions/class_files.php index 0cf066c..10182a9 100644 --- a/www/functions/class_files.php +++ b/www/functions/class_files.php @@ -33,41 +33,142 @@ class file { } } function initFile($val){ + if(!$val){ + return false; + } $this->file=$val; } function getDim(){ return count($this->file); } - function getParent($val){ + function getId($val = null){ $ar = $this->file; - return $ar[$val][1]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][0]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][2]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][1]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][3]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][3]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][4]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][4]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][5]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][5]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][6]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][6]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][7]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][7]; + } else { + $res; + for($i=0; $ifile; - return $ar[$val][8]; + if($val != null){ + if(!preg_match("/^[0-9]+$/", $val)){ + return false; + } + return $ar[$val][8]; + } else { + $res; + for($i=0; $ifile; } } diff --git a/www/functions/func_select.php b/www/functions/func_select.php index 9f10cd6..a6f776d 100755 --- a/www/functions/func_select.php +++ b/www/functions/func_select.php @@ -1,7 +1,7 @@