forked from DirectoryLister/DirectoryLister
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
52 lines (37 loc) · 1.25 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// Include the DirectoryLister class
require_once('resources/DirectoryLister.php');
// Initialize the DirectoryLister object
$lister = new DirectoryLister();
// Restrict access to current directory
ini_set('open_basedir', getcwd());
// Return file hash
if (isset($_GET['hash'])) {
// Get file hash array and JSON encode it
$hashes = $lister->getFileHash($_GET['hash']);
$data = json_encode($hashes);
// Return the data
die($data);
}
if (isset($_GET['zip'])) {
$dirArray = $lister->zipDirectory($_GET['zip']);
} else {
// Initialize the directory array
if (isset($_GET['dir'])) {
$dirArray = $lister->listDirectory($_GET['dir']);
} else {
$dirArray = $lister->listDirectory('.');
}
// Define theme path
if (!defined('THEMEPATH')) {
define('THEMEPATH', $lister->getThemePath());
}
// Set path to theme index
$themeIndex = $lister->getThemePath(true) . '/index.php';
// Initialize the theme
if (file_exists($themeIndex)) {
include($themeIndex);
} else {
die('ERROR: Failed to initialize theme');
}
}