Commit | Line | Data |
---|---|---|
e586807d H |
1 | <?php |
2 | /* This program is free software. It comes without any warranty, to | |
3 | * the extent permitted by applicable law. You can redistribute it | |
4 | * and/or modify it under the terms of the Do What The Fuck You Want | |
5 | * To Public License, Version 2, as published by Sam Hocevar. See | |
6 | * http://sam.zoy.org/wtfpl/COPYING for more details. */ | |
7 | ||
8 | class filez { | |
9 | ||
10 | function filez($id) { | |
11 | global $db,$error; | |
12 | if (!is_dir(FILE_DIR.$_SESSION['user_id'])) { | |
13 | mkdir(FILE_DIR.$_SESSION['user_id']); | |
14 | } | |
15 | copy($_FILES['data_file']['tmp_name'],FILE_DIR.$_SESSION['user_id'].'/'.$_FILES['data_file']['name']); | |
16 | return $_SESSION['user_id'].'/'.$_FILES['data_file']['name']; | |
17 | } | |
18 | ||
19 | } | |
20 | ||
21 | /* | |
22 | * Returns disk usage in bytes of directory $d. Limit depth level with $depth. | |
23 | * Updates, documentation and examples: http://daniel.lorch.cc/projects/disk_usage/ | |
24 | * | |
25 | * Revision: 1.00 | |
26 | */ | |
27 | ||
28 | function disk_usage($d, $depth = NULL) { | |
29 | if(is_file($d)) | |
30 | return filesize($d); | |
31 | ||
32 | if(isset($depth) && $depth < 0) | |
33 | return 0; | |
34 | ||
35 | if($d[strlen($d)-1] != '\\' || $d[strlen($d)-1] != '/') | |
36 | $d .= '/'; | |
37 | ||
38 | $dh=@opendir($d); | |
39 | if(!$dh) | |
40 | return 0; | |
41 | ||
42 | while($e = readdir($dh)) | |
43 | if($e != '.' && $e != '..') | |
44 | $usage += disk_usage($d.$e, isset($depth) ? $depth - 1 : NULL); | |
45 | ||
46 | closedir($dh); | |
47 | ||
48 | return $usage; | |
49 | } | |
50 | ||
51 | ||
52 | ?> |