-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathadmin_scripts.php
More file actions
52 lines (43 loc) · 1.41 KB
/
admin_scripts.php
File metadata and controls
52 lines (43 loc) · 1.41 KB
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
/**
* DeepSID
*
* Show the scripts page in the 'Admin' tab.
*
* For administrators only.
*
* @used-by main.js
*/
require_once("class.account.php"); // Includes setup
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest')
die("Direct access not permitted.");
if (!$account->IsAdmin())
die("This is for administrators only.");
$html = $section = '';
$baseURL = $_SERVER['HTTP_HOST'] == LOCALHOST ? "http://chordian/deepsid/php/" : "https://deepsid.chordian.net/php/";
try {
$db = $account->GetDB();
// Get all the admin scripts rows
$select = $db->query('SELECT * FROM admin_scripts ORDER BY section, name');
$scripts = $select->fetchAll(PDO::FETCH_OBJ);
$html = '<h3>Scripts</h3>';
// Build the rows for each setting
foreach ($scripts as $s) {
if ($s->section !== $section) {
$section = $s->section;
$html .= '<h4>' . $section . '</h4>';
}
$html .= '
<div class="script">
<div class="name">' . $s->name . '</div>
<span>' . $s->description . '</span>
<button class="run-script" data-script="'.$baseURL.'run_shell.php?script=' . $s->script . '" title="' . $baseURL.$s->script . '">RUN</button>
</div>
';
}
} catch(PDOException $e) {
$account->LogActivityError(basename(__FILE__), $e->getMessage());
die(json_encode(array('status' => 'error', 'message' => DB_ERROR)));
}
die(json_encode(array('status' => 'ok', 'html' => $html)));
?>