Gazelle/sections/tools/managers/ocelot.php

51 lines
1.2 KiB
PHP
Raw Normal View History

<?
2013-12-01 08:00:44 +00:00
$Key = $_REQUEST['key'];
$Type = $_REQUEST['type'];
2013-02-22 08:00:24 +00:00
2013-12-01 08:00:44 +00:00
if (($Key != TRACKER_SECRET) || ($_SERVER['REMOTE_ADDR'] != TRACKER_HOST && $_SERVER['REMOTE_HOST'] != TRACKER_HOST)) {
error(403);
}
2013-02-22 08:00:24 +00:00
2013-12-01 08:00:44 +00:00
switch ($Type) {
case 'expiretoken':
if (isset($_GET['tokens'])) {
$Tokens = explode(',', $_GET['tokens']);
if (empty($Tokens)) {
error(0);
}
$Cond = $UserIDs = array();
foreach ($Tokens as $Key => $Token) {
list($UserID, $TorrentID) = explode(':', $Token);
if (!is_number($UserID) || !is_number($TorrentID)) {
continue;
2013-02-01 08:00:18 +00:00
}
2013-12-01 08:00:44 +00:00
$Cond[] = "(UserID = $UserID AND TorrentID = $TorrentID)";
$UserIDs[] = $UserID;
}
if (!empty($Cond)) {
$Query = "
UPDATE users_freeleeches
SET Expired = TRUE
WHERE ".implode(" OR ", $Cond);
$DB->query($Query);
foreach ($UserIDs as $UserID) {
$Cache->delete_value("users_tokens_$UserID");
2013-02-01 08:00:18 +00:00
}
}
2013-12-01 08:00:44 +00:00
} else {
$TorrentID = $_REQUEST['torrentid'];
$UserID = $_REQUEST['userid'];
if (!is_number($TorrentID) || !is_number($UserID)) {
error(403);
}
$DB->query("
UPDATE users_freeleeches
SET Expired = TRUE
WHERE UserID = $UserID
AND TorrentID = $TorrentID");
$Cache->delete_value("users_tokens_$UserID");
}
break;
}
?>