mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
Refactor IP History
This commit is contained in:
@@ -657,6 +657,7 @@ if(count($USERUPDATESET) && $userid)
|
||||
$lockKey = sprintf("record_batch_lock:%s:%s", $userid, $torrentid);
|
||||
if ($redis->set($lockKey, TIMENOW, ['nx', 'ex' => $autoclean_interval_one])) {
|
||||
\App\Repositories\CleanupRepository::recordBatch($redis, $userid, $torrentid);
|
||||
\App\Repositories\IpLogRepository::saveToCache($userid, null, [$ip]);
|
||||
}
|
||||
if (\App\Repositories\RequireSeedTorrentRepository::shouldRecordUser($redis, $userid, $torrentid)) {
|
||||
if (!isset($snatchInfo)) {
|
||||
|
||||
@@ -62,10 +62,11 @@ if (!empty($_REQUEST['downhash'])) {
|
||||
}
|
||||
}
|
||||
//User may choose to download torrent from RSS. So log ip changes when downloading torrents.
|
||||
if ($iplog1 == "yes") {
|
||||
if (($oldip != $CURUSER["ip"]) && $CURUSER["ip"])
|
||||
sql_query("INSERT INTO iplog (ip, userid, access) VALUES (" . sqlesc($CURUSER['ip']) . ", " . $CURUSER['id'] . ", '" . $CURUSER['last_access'] . "')");
|
||||
}
|
||||
//if ($iplog1 == "yes") {
|
||||
// if (($oldip != $CURUSER["ip"]) && $CURUSER["ip"])
|
||||
// sql_query("INSERT INTO iplog (ip, userid, access) VALUES (" . sqlesc($CURUSER['ip']) . ", " . $CURUSER['id'] . ", '" . $CURUSER['last_access'] . "')");
|
||||
//}
|
||||
\App\Repositories\IpLogRepository::saveToCache($CURUSER['id']);
|
||||
//User may choose to download torrent from RSS. So update his last_access and ip when downloading torrents.
|
||||
sql_query("UPDATE users SET last_access = ".sqlesc(date("Y-m-d H:i:s")).", ip = ".sqlesc($CURUSER['ip'])." WHERE id = ".sqlesc($CURUSER['id']));
|
||||
|
||||
|
||||
@@ -6,6 +6,33 @@ dbconn_announce();
|
||||
|
||||
// BLOCK ACCESS WITH WEB BROWSERS AND CHEATS!
|
||||
block_browser();
|
||||
$passkey = $_GET['passkey'] ?? '';
|
||||
if (empty($passkey)) {
|
||||
err('require passkey');
|
||||
}
|
||||
$redis = $Cache->getRedis();
|
||||
$passkeyInvalidKey = "passkey_invalid";
|
||||
// check passkey
|
||||
if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){
|
||||
$res = sql_query("SELECT id, username, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror, passkey, donor, donoruntil, seedbonus, tracker_url_id FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");
|
||||
$az = mysql_fetch_array($res);
|
||||
do_log("[check passkey], currentUser: " . nexus_json_encode($az));
|
||||
$Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 3600);
|
||||
}
|
||||
if (!$az) {
|
||||
$redis->set("$passkeyInvalidKey:$passkey", TIMENOW, ['ex' => 24*3600]);
|
||||
err("Invalid passkey! Re-download the .torrent from $BASEURL");
|
||||
}
|
||||
if ($az["enabled"] == "no")
|
||||
err("Your account is disabled!", 300);
|
||||
elseif ($az["parked"] == "yes")
|
||||
err("Your account is parked! (Read the FAQ)", 300);
|
||||
elseif ($az["downloadpos"] == "no")
|
||||
err("Your downloading privileges have been disabled! (Read the rules)", 300);
|
||||
|
||||
$userid = intval($az['id'] ?? 0);
|
||||
unset($GLOBALS['CURUSER']);
|
||||
$CURUSER = $GLOBALS["CURUSER"] = $az;
|
||||
|
||||
preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_array);
|
||||
$fields = "info_hash, times_completed, seeders, leechers";
|
||||
|
||||
@@ -310,7 +310,7 @@ elseif ($action == 'tweaksettings') // tweak settings
|
||||
print ($notice);
|
||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_tweak' />");
|
||||
yesorno($lang_settings['row_save_user_location'], 'where', $TWEAK["where"], $lang_settings['text_save_user_location_note']);
|
||||
yesorno($lang_settings['row_log_user_ips'], 'iplog1', $TWEAK["iplog1"], $lang_settings['text_store_user_ips_note']);
|
||||
// yesorno($lang_settings['row_log_user_ips'], 'iplog1', $TWEAK["iplog1"], $lang_settings['text_store_user_ips_note']);
|
||||
tr($lang_settings['row_kps_enabled'],"<input type='radio' id='bonusenable' name='bonus'" . ($TWEAK["bonus"] == "enable" ? " checked='checked'" : "") . " value='enable' /> <label for='bonusenable'>".$lang_settings['text_enabled']."</label> <input type='radio' id='bonusdisablesave' name='bonus'" . ($TWEAK["bonus"] == "disablesave" ? " checked='checked'" : "") . " value='disablesave' /> <label for='bonusdisablesave'>".$lang_settings['text_disabled_but_save']."</label> <input type='radio' id='bonusdisable' name='bonus'" . ($TWEAK["bonus"] == "disable" ? " checked='checked'" : "") . " value='disable' /> <label for='bonusdisable'>".$lang_settings['text_disabled_no_save']."</label> <br />".$lang_settings['text_kps_note'], 1);
|
||||
yesorno($lang_settings['row_enable_location'], 'enablelocation', $TWEAK["enablelocation"], $lang_settings['text_enable_location_note']);
|
||||
yesorno($lang_settings['row_enable_tooltip'], 'enabletooltip', $TWEAK["enabletooltip"], $lang_settings['text_enable_tooltip_note']);
|
||||
|
||||
Reference in New Issue
Block a user