|
19 | 19 | * - Sorting and filtering |
20 | 20 | */ |
21 | 21 |
|
22 | | -// CWP Usage |
23 | | -$cwp = false; |
24 | | - |
25 | 22 | // Set timezone |
26 | 23 | date_default_timezone_set("Africa/Lagos"); |
27 | 24 |
|
28 | | -if ($cwp) { |
29 | | - $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); |
30 | | - $segments = explode("/", trim($path, "/")); |
31 | | - |
32 | | - $url_token = null; |
33 | | - $url_username = null; |
34 | | - |
35 | | - foreach ($segments as $index => $segment) { |
36 | | - if ($segment === "filemanager.php" && $index > 0) { |
37 | | - $url_username = $segments[$index - 1]; |
38 | | - if ($index > 1) { |
39 | | - $url_token = $segments[$index - 2]; |
40 | | - } |
41 | | - break; |
42 | | - } |
43 | | - } |
44 | | - |
45 | | - if (!$url_username || !$url_token) { |
46 | | - header("HTTP/1.1 403 Forbidden"); |
47 | | - echo "Access denied. Invalid URL format."; |
48 | | - exit(); |
49 | | - } |
50 | | - |
51 | | - $token_dir = "/home/$url_username/.tokens/"; |
52 | | - $token_file = $token_dir . $url_token; |
53 | | - |
54 | | - if (!file_exists($token_file)) { |
55 | | - header("HTTP/1.1 403 Forbidden"); |
56 | | - echo "Access denied. Invalid token."; |
57 | | - exit(); |
58 | | - } |
59 | | - |
60 | | - $token_data = json_decode(file_get_contents($token_file), true); |
61 | | - |
62 | | - if (time() > $token_data["expiry"]) { |
63 | | - unlink($token_file); |
64 | | - header("HTTP/1.1 403 Forbidden"); |
65 | | - echo "Access denied. Token expired."; |
66 | | - exit(); |
67 | | - } |
68 | | - |
69 | | - if ($token_data["username"] !== $url_username) { |
70 | | - header("HTTP/1.1 403 Forbidden"); |
71 | | - echo "Access denied. Username mismatch."; |
72 | | - exit(); |
73 | | - } |
74 | | - |
75 | | - $username = $token_data["username"]; |
76 | | - $root_path = "/home/$username"; |
77 | | -} else { |
78 | | - $username = "joe"; |
79 | | - $root_path = "/var/www/html/001_public"; |
80 | | -} |
| 25 | +$username = ""; // Username for directory listing |
| 26 | +$root_path = ""; // Path to the root directory |
81 | 27 |
|
82 | 28 | // Configuration |
83 | 29 | $config = [ |
|
0 commit comments