4 //XXX function not used, remove?
6 public static function files($id) {
8 if (!is_dir(FILE_DIR.$_SESSION['user_id'])) {
9 mkdir(FILE_DIR.$_SESSION['user_id']);
11 copy($_FILES['data_file']['tmp_name'],FILE_DIR.$_SESSION['user_id'].'/'.$_FILES['data_file']['name']);
12 return $_SESSION['user_id'].'/'.$_FILES['data_file']['name'];
15 // Function that check if given filename is "secure" (for uploading)
16 // Dont use for reading files, directory traversal is not checked
18 public static function filename_secure($name){
19 $suffix = array_pop(explode('.', basename($name)));
21 // This is unfornately blacklist
22 // TODO extend for all possible server configuations
24 $preg_disallowed = '/([a-z]*)(php|htm|inc|js|vbs|cgi|asp|jsp|htaccess)([a-z]*)$/i';
25 if (preg_match($preg_disallowed, $suffix) > 0) {
34 * Returns disk usage in bytes of directory $d. Limit depth level with $depth.
35 * Updates, documentation and examples: http://daniel.lorch.cc/projects/disk_usage/
40 function disk_usage($d, $depth = NULL) {
44 if(isset($depth) && $depth < 0)
47 if($d[strlen($d)-1] != '\\' || $d[strlen($d)-1] != '/')
54 while($e = readdir($dh))
55 if($e != '.' && $e != '..')
56 $usage += disk_usage($d.$e, isset($depth) ? $depth - 1 : NULL);