-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastdlprocess.php
More file actions
66 lines (57 loc) · 2.07 KB
/
Copy pathfastdlprocess.php
File metadata and controls
66 lines (57 loc) · 2.07 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
$return = true;
require __DIR__ . '/configuration.php';
require __DIR__ . '/include.php';
requireSameOrigin('index.php');
require __DIR__ . '/includes/fastdl.php';
$clientId = (int) ($_SESSION['clientid'] ?? 0);
if (!$clientId) {
header('Location: login.php');
exit;
}
$task = sanitizeInput($_POST['task'] ?? ($_GET['task'] ?? ''));
$serverid = (int) ($_POST['serverid'] ?? ($_GET['serverid'] ?? 0));
$srv = dbRow(
"SELECT `serverid`, `name`, `boxid`, `fastdl` FROM `server`
WHERE `serverid` = '" . $serverid . "' AND `clientid` = '" . $clientId . "' LIMIT 1",
true
);
if (!is_array($srv) || empty($srv)) {
header('Location: server.php');
exit;
}
$who = trim(($_SESSION['clientfirstname'] ?? '') . ' ' . ($_SESSION['clientlastname'] ?? ''));
$ip = $_SERVER['REMOTE_ADDR'] ?? '';
function fastdl_log(int $clientId, int $serverid, int $boxid, string $message, string $who, string $ip): void
{
dbExec(
"INSERT INTO `log` SET " .
"`clientid` = '" . $clientId . "', " .
"`serverid` = '" . $serverid . "', " .
"`boxid` = '" . $boxid . "', " .
"`message` = '" . dbEscape($message) . "', " .
"`name` = '" . dbEscape($who) . "', " .
"`ip` = '" . dbEscape($ip) . "'"
);
}
if ($task === 'enable') {
$token = fastdlToken();
dbExec("UPDATE `server` SET `fastdl` = '" . dbEscape($token) . "' WHERE `serverid` = '" . $serverid . "'");
fastdl_log(
$clientId, $serverid, (int) $srv['boxid'],
'FastDL enabled: <a href="serversummary.php?id=' . $serverid . '">#' . $serverid . '</a> (Client)',
$who, $ip
);
$_SESSION['msg1'] = 'FastDL enabled';
$_SESSION['msg2'] = 'Set the sv_downloadurl shown on this page in your server config.';
} elseif ($task === 'disable') {
dbExec("UPDATE `server` SET `fastdl` = '' WHERE `serverid` = '" . $serverid . "'");
fastdl_log(
$clientId, $serverid, (int) $srv['boxid'],
'FastDL disabled: <a href="serversummary.php?id=' . $serverid . '">#' . $serverid . '</a> (Client)',
$who, $ip
);
$_SESSION['msg1'] = 'FastDL disabled';
$_SESSION['msg2'] = 'The download URL will stop working.';
}
header('Location: serversummary.php?id=' . $serverid);