seed bonus add log etc

This commit is contained in:
xiaomlove
2025-09-08 03:05:55 +07:00
parent ae08039323
commit 60b5aba518
53 changed files with 720 additions and 131 deletions
+26 -26
View File
@@ -401,6 +401,8 @@ if (
}
}
$leechTimeNoSeeder = "";
// current peer_id, or you could say session with tracker not found in table peers
if (!isset($self))
{
@@ -473,13 +475,18 @@ else // continue an existing session
}
do_log("upthis: $upthis, downthis: $downthis, announcetime: $announcetime, is_cheater: $is_cheater");
$snatchInfo = get_snatch_info($torrentid, $userid);
if (!isset($snatchInfo)) {
$snatchInfo = get_snatch_info($torrentid, $userid);
}
if (!$is_cheater && ($trueupthis > 0 || $truedownthis > 0))
{
$dataTraffic = getDataTraffic($torrent, $_GET, $az, $self, $snatchInfo, apply_filter('torrent_promotion', $torrent));
$USERUPDATESET[] = "uploaded = uploaded + " . $dataTraffic['uploaded_increment_for_user'];
$USERUPDATESET[] = "downloaded = downloaded + " . $dataTraffic['downloaded_increment_for_user'];
}
if ($torrent['seeders'] <= 0 && $seeder == 'no' && $self['announcetime'] > 0) {
$leechTimeNoSeeder = ", leech_time_no_seeder = leech_time_no_seeder + {$self['announcetime']}";
}
}
$dt = sqlesc(date("Y-m-d H:i:s"));
@@ -495,7 +502,7 @@ if (isset($self) && $event == "stopped")
{
$updateset[] = ($self["seeder"] == "yes" ? "seeders = seeders - 1" : "leechers = leechers - 1");
$hasChangeSeederLeecher = true;
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." WHERE id = {$snatchInfo['id']}") or err("SL Err 1");
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime $leechTimeNoSeeder, last_action = ".$dt." WHERE id = {$snatchInfo['id']}") or err("SL Err 1");
}
}
elseif(isset($self))
@@ -518,7 +525,7 @@ elseif(isset($self))
$hasChangeSeederLeecher = true;
}
if (!empty($snatchInfo)) {
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." $finished_snatched WHERE id = {$snatchInfo['id']}") or err("SL Err 2");
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." $finished_snatched $leechTimeNoSeeder WHERE id = {$snatchInfo['id']}") or err("SL Err 2");
do_action('snatched_saved', $torrent, $snatchInfo);
}
}
@@ -571,14 +578,16 @@ if (($left > 0 || $event == "completed") && $az['class'] < \App\Models\HitAndRun
$hrLog .= ", hrExists: $hrExists";
if (!$hrExists) {
//last check include rate
$includeRate = \App\Models\HitAndRun::getConfig('include_rate', $torrent['mode']);
if ($includeRate === "" || $includeRate === null) {
//not set yet
$includeRate = 1;
}
$includeRate = (float)\App\Models\HitAndRun::getConfig('include_rate', $torrent['mode']);
// if ($includeRate === "" || $includeRate === null) {
// //not set yet
// $includeRate = 1;
// }
$hrLog .= ", includeRate: $includeRate";
//get newest snatch info
$snatchInfo = get_snatch_info($torrentid, $userid);
if (!isset($snatchInfo)) {
$snatchInfo = get_snatch_info($torrentid, $userid);
}
$requiredDownloaded = $torrent['size'] * $includeRate;
if ($snatchInfo['downloaded'] >= $requiredDownloaded) {
$nowStr = date('Y-m-d H:i:s');
@@ -598,28 +607,13 @@ if (($left > 0 || $event == "completed") && $az['class'] < \App\Models\HitAndRun
do_log("$hrLog, total downloaded: {$snatchInfo['downloaded']} < required: $requiredDownloaded", "debug");
}
} else {
$hrLog .= ", already exists";
if (isset($self) && $torrent['seeders'] <= 0) {
$hrLeechTimeMin = \App\Models\HitAndRun::getConfig('leech_time_minimum', $torrent['mode']);
if ($hrLeechTimeMin > 0) {
$hrLog .= ", enable hrLeechTimeMin: $hrLeechTimeMin";
$hrInfo = json_decode($hrExists, true);
if ($hrInfo['status'] == \App\Models\HitAndRun::STATUS_INSPECTING) {
sql_query("update hit_and_runs set leech_time_no_seeder = leech_time_no_seeder + {$self['announcetime']} where id = {$hrInfo['id']} limit 1");
} else {
do_log("$hrLog, hr status != STATUS_INSPECTING", "debug");
}
} else {
do_log("$hrLog, not enable hrLeechTimeMin", "debug");
}
} else {
do_log("$hrLog, no self or seeders({$torrent['seeders']}) > 0", "debug");
}
do_log("$hrLog, already exists", 'debug');
}
} else {
do_log("$hrLog, not match", "debug");
}
}
// revert to only increment/decrement
//if (isset($event) && !empty($event)) {
// $updateset[] = 'seeders = ' . get_row_count("peers", "where torrent = $torrentid and to_go = 0");
@@ -660,6 +654,12 @@ $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);
}
if (\App\Repositories\RequireSeedTorrentRepository::shouldRecordUser($redis, $userid, $torrentid)) {
if (!isset($snatchInfo)) {
$snatchInfo = get_snatch_info($torrentid, $userid);
}
\App\Repositories\RequireSeedTorrentRepository::recordUser($redis, $userid, $torrentid, $snatchInfo);
}
do_action('announced', $torrent, $az, $_REQUEST);
benc_resp($rep_dict);
?>
+1 -12
View File
@@ -39,7 +39,7 @@ if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs", $brsectio
}
stdhead($lang_getrss['head_rss_feeds']);
$query = [];
$allowed_showrows=array('10','50','100','200');
$allowed_showrows=array('10','50');
$stickyTypes = [
0 => nexus_trans('torrent.pos_state_normal'),
1 => nexus_trans('torrent.pos_state_sticky'),
@@ -365,17 +365,6 @@ if (get_setting('main.spsct') == 'yes') {
}
?>
</select></td></tr>
<tr><td class="rowhead"><?php echo $lang_getrss['row_keyword']?></td>
<td class="rowfollow" align="left">
<input type="text" name="search" style="width: 200px;" /> <?php echo $lang_getrss['text_with']?>
<select name="search_mode" style="width: 60px;">
<option value="0"><?php echo $lang_getrss['select_and'] ?></option>
<option value="2"><?php echo $lang_getrss['select_exact'] ?></option>
</select>
<?php echo $lang_getrss['text_mode']?>
<div><?php echo $lang_getrss['text_keyword_note'] ?></div>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="<?php echo $lang_getrss['submit_generatte_rss_link']?>" />
+3 -1
View File
@@ -111,7 +111,9 @@ if ($action == "edituser")
if ($arr['email'] != $email){
$updateset[] = "email = " . sqlesc($email);
// $modcomment = date("Y-m-d") . " - Email changed from $arr[email] to $email by {$CURUSER['username']}.\n". $modcomment;
$userModifyLogs[] = "Email changed from $arr[email] to $email by {$CURUSER['username']}.";
$modifyLog = "Email changed from $arr[email] to $email by {$CURUSER['username']}.";
do_log($modifyLog, "alert");
$userModifyLogs[] = $modifyLog;
$locale = get_user_locale($userid);
$subject = sqlesc(nexus_trans("user.msg_email_change", [], $locale));
$msg = sqlesc(nexus_trans("user.msg_your_email_changed_from", [], $locale).$arr['email'].nexus_trans("user.msg_to_new", [], $locale) . $email .nexus_trans("user.msg_by", [], $locale).$CURUSER['username']);
+5 -1
View File
@@ -51,6 +51,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST")
$title = $SITENAME.$lang_recover['mail_title'];
$mailOne = sprintf($lang_recover['mail_one'], $siteName);
$mailFour = sprintf($lang_recover['mail_four'], $siteName);
\Nexus\Database\NexusDB::cache_put("recover:$hash", now()->toDateTimeString());
$body = <<<EOD
{$mailOne}($email){$lang_recover['mail_two']}$ip{$lang_recover['mail_three']}
@@ -69,7 +70,10 @@ elseif($_SERVER["REQUEST_METHOD"] == "GET" && $take_recover && isset($_GET["id"]
$md5 = $_GET["secret"];
if (!$id)
httperr();
if (!\Nexus\Database\NexusDB::cache_get("recover:$md5")) {
do_log("secret: $md5 is expired", "error");
httperr();
}
$res = sql_query("SELECT username, email, passhash, editsecret FROM users WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_array($res) or httperr();
+2 -1
View File
@@ -99,7 +99,7 @@ elseif ($action == 'savesettings_bonus') // save bonus
'tengbupload', 'ratiolimit','dlamountlimit','oneinvite','customtitle','vipstatus','bonusgift', 'basictax', 'taxpercentage',
'prolinkpoint', 'prolinktime', 'attendance_initial', 'attendance_step', 'attendance_max', 'cancel_hr', 'attendance_card',
'harem_addition', 'hundredgbupload', 'tengbdownload', 'hundredgbdownload', 'official_addition', 'official_tag', 'zero_bonus_tag', 'zero_bonus_factor',
'one_tmp_invite', 'rainbow_id', 'change_username_card',
'one_tmp_invite', 'rainbow_id', 'change_username_card', 'min_size'
);
GetVar($validConfig);
$BONUS = [];
@@ -576,6 +576,7 @@ elseif ($action == 'bonussettings'){
print ($notice);
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_bonus'>");
print("<tr><td colspan=2 align=center><b>".$lang_settings['text_bonus_by_seeding']."</b></td></tr>");
tr($lang_settings['row_min_size'], $lang_settings['text_bonus_mini_size']."<input type='text' style=\"width: 100px\" name=min_size value='".(isset($BONUS["min_size"]) ? $BONUS["min_size"] : 0 )."'>".$lang_settings['text_bonus_mini_size_help'],1);
tr($lang_settings['row_donor_gets_double'], $lang_settings['text_donor_gets']."<input type='text' style=\"width: 50px\" name=donortimes value='".(isset($BONUS["donortimes"]) ? $BONUS["donortimes"] : 2 )."'>".$lang_settings['text_times_as_many'],1);
tr($lang_settings['row_basic_seeding_bonus'], $lang_settings['text_user_would_get']."<input type='text' style=\"width: 50px\" name=perseeding value='".(isset($BONUS["perseeding"]) ? $BONUS["perseeding"] : 1 )."'>".$lang_settings['text_bonus_points']."<input type='text' style=\"width: 50px\" name=maxseeding value='".(isset($BONUS["maxseeding"]) ? $BONUS["maxseeding"] : 7 )."'>".$lang_settings['text_torrents_default'], 1);
+3 -2
View File
@@ -15,9 +15,10 @@ $id = intval($_GET['id'] ?? 0);
int_check($id,true);
if (get_user_class() >= UC_MODERATOR || $CURUSER['id'] == "$id")
{
{
$deadtime = deadtime();
sql_query("DELETE FROM peers WHERE last_action < FROM_UNIXTIME($deadtime) AND userid=" . sqlesc($id));
$lastAction = date("Y-m-d H:i:s", $deadtime);
sql_query("DELETE FROM peers WHERE last_action < '$lastAction' AND userid=" . sqlesc($id));
$effected = mysql_affected_rows();
stderr($lang_takeflush['std_success'], "$effected ".$lang_takeflush['std_ghost_torrents_cleaned']);
+4 -2
View File
@@ -93,8 +93,10 @@ $torrent = unesc($_POST["name"]);
if ($f['size'] > $max_torrent_size)
bark($lang_takeupload['std_torrent_file_too_big'].number_format($max_torrent_size).$lang_takeupload['std_remake_torrent_note']);
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname))
bark("eek");
if (!is_uploaded_file($tmpname)) {
do_log("eek, FILE: " . nexus_json_encode($f), 'error');
bark("eek");
}
if (!filesize($tmpname))
bark($lang_takeupload['std_empty_file']);
+4 -3
View File
@@ -37,7 +37,8 @@ if ($passkey){
}
}
}
$searchstr = mysql_real_escape_string(trim($_GET["search"] ?? ''));
//$searchstr = mysql_real_escape_string(trim($_GET["search"] ?? ''));
$searchstr = null;//don't support search, use client self filter instead
if (empty($searchstr))
unset($searchstr);
if (isset($searchstr)){
@@ -81,8 +82,8 @@ if ($startindex) {
$limit .= $startindex.", ";
}
$showrows = intval($_GET['rows'] ?? 0);
if($showrows < 1 || $showrows > 200) {
$showrows = 10;
if($showrows < 1 || $showrows > 50) {
$showrows = 50;
}
$limit .= $showrows;
+1 -1
View File
@@ -738,7 +738,7 @@ if (isset($searchstr))
{
$searchstr_element = trim($searchstr_element); // furthur trim to ensure that multi space seperated words still work
$searchstr_exploded_count++;
if ($searchstr_exploded_count > 10) // maximum 10 keywords
if ($searchstr_exploded_count > 3) // maximum 3 keywords
break;
$like_expression_array[] = " LIKE '%" . $searchstr_element. "%'";
}