mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
seed bonus add log etc
This commit is contained in:
@@ -237,6 +237,11 @@ function disable_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey)
|
||||
$userModifyLogs = [];
|
||||
foreach ($results as $user) {
|
||||
$uid = $user->id;
|
||||
$enableCacheResult = \Nexus\Database\NexusDB::cache_get(\App\Models\User::getUserEnableLatelyCacheKey($uid));
|
||||
if ($enableCacheResult) {
|
||||
do_log(sprintf("user: %s just enable at: %s, skip", $uid, $enableCacheResult));
|
||||
continue;
|
||||
}
|
||||
$uidArr[] = $uid;
|
||||
$reason = nexus_trans($reasonKey, [], $user->locale);
|
||||
$userBanLogData[] = [
|
||||
@@ -251,6 +256,9 @@ function disable_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey)
|
||||
'updated_at' => date("Y-m-d H:i:s"),
|
||||
];
|
||||
}
|
||||
if (empty($uidArr)) {
|
||||
return [];
|
||||
}
|
||||
$sql = sprintf(
|
||||
"update users set enabled = '%s' where id in (%s)",
|
||||
\App\Models\User::ENABLED_NO, implode(', ', $uidArr)
|
||||
@@ -275,9 +283,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
global $Cache;
|
||||
global $rootpath;
|
||||
$requestId = nexus()->getRequestId();
|
||||
|
||||
// require_once($rootpath . '/lang/_target/lang_cleanup.php');
|
||||
|
||||
set_time_limit(0);
|
||||
ignore_user_abort(1);
|
||||
$now = time();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.7');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-07-21');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-09-08');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -2810,7 +2810,7 @@ if ($msgalert)
|
||||
$Cache->cache_value($cacheKey, $toApprovalCounts, 60);
|
||||
}
|
||||
if ($toApprovalCounts) {
|
||||
msgalert('torrents.php?approval_status=0', sprintf($lang_functions['text_torrent_to_approval'], is_or_are($toApprovalCounts), $toApprovalCounts, add_s($toApprovalCounts)), 'darkred');
|
||||
msgalert('torrents.php?approval_status=0&incldead=0', sprintf($lang_functions['text_torrent_to_approval'], is_or_are($toApprovalCounts), $toApprovalCounts, add_s($toApprovalCounts)), 'darkred');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3007,17 +3007,7 @@ function get_protocol_prefix()
|
||||
if (isHttps()) {
|
||||
return "https://";
|
||||
}
|
||||
if ($securelogin == "yes") {
|
||||
return "https://";
|
||||
} elseif ($securelogin == "no") {
|
||||
return "http://";
|
||||
} else {
|
||||
if (!isset($_COOKIE["c_secure_ssl"])) {
|
||||
return "http://";
|
||||
} else {
|
||||
return base64_decode($_COOKIE["c_secure_ssl"]) == "yeah" ? "https://" : "http://";
|
||||
}
|
||||
}
|
||||
return 'http://';
|
||||
}
|
||||
|
||||
function get_langid_from_langcookie($lang = '')
|
||||
@@ -5818,7 +5808,7 @@ function can_access_torrent($torrent, $uid)
|
||||
|
||||
function get_ip_location_from_geoip($ip): bool|array
|
||||
{
|
||||
$locationInfo = \Nexus\Database\NexusDB::remember("locations_{$ip}", 3600, function () use ($ip) {
|
||||
$locationInfo = \Nexus\Database\NexusDB::remember("locations_{$ip}", 864000, function () use ($ip) {
|
||||
$lang = get_langfolder_cookie();
|
||||
$langMap = [
|
||||
'chs' => 'zh-CN',
|
||||
@@ -5861,7 +5851,7 @@ function get_ip_location_from_geoip($ip): bool|array
|
||||
$info['continent'] = $continentName;
|
||||
$info['continent_en'] = $record->continent->names['en'] ?? '';
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||
do_log($exception->getMessage());
|
||||
}
|
||||
return $info;
|
||||
});
|
||||
@@ -5898,7 +5888,7 @@ function msgalert($url, $text, $bgcolor = "red")
|
||||
function build_medal_image(\Illuminate\Support\Collection $medals, $maxHeight = 200, $withActions = false): string
|
||||
{
|
||||
$medalImages = [];
|
||||
$wrapBefore = '<form><div style="display: flex;justify-content: center;margin-top: 10px;">';
|
||||
$wrapBefore = '<form><div style="display: flex;flex-wrap: wrap;justify-content: center;margin-top: 10px;">';
|
||||
$wrapAfter = '</div></form>';
|
||||
foreach ($medals as $medal) {
|
||||
$html = sprintf('<div style="display: flex;flex-direction: column;justify-content: space-between;margin-right: 10px"><div><img src="%s" title="%s" class="preview" style="max-height: %spx;max-width: %spx"/></div>', $medal->image_large, $medal->name, $maxHeight, $maxHeight);
|
||||
@@ -6003,6 +5993,7 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
|
||||
$nzero_bonus = $settingBonus['nzero'];
|
||||
$bzero_bonus = $settingBonus['bzero'];
|
||||
$l_bonus = $settingBonus['l'];
|
||||
$minSize = $settingBonus['min_size'] ?? 0;
|
||||
|
||||
$sqrtof2 = sqrt(2);
|
||||
$logofpointone = log(0.1);
|
||||
@@ -6022,9 +6013,9 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
|
||||
$torrentIdArr = [-1];
|
||||
}
|
||||
$idStr = implode(',', \Illuminate\Support\Arr::wrap($torrentIdArr));
|
||||
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, 'NO_PEER_ID' as peerID, '' as last_action from torrents WHERE id in ($idStr)";
|
||||
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, 'NO_PEER_ID' as peerID, '' as last_action from torrents WHERE id in ($idStr) and size >= $minSize";
|
||||
} else {
|
||||
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID, peers.last_action from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' group by peers.torrent, peers.peer_id";
|
||||
$sql = "select torrents.id, torrents.added, torrents.size, torrents.seeders, peers.id as peerID, peers.last_action from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid = $uid AND peers.seeder ='yes' and torrents.size > $minSize group by peers.torrent, peers.peer_id";
|
||||
}
|
||||
$tagGrouped = [];
|
||||
$torrentResult = \Nexus\Database\NexusDB::select($sql);
|
||||
|
||||
@@ -763,7 +763,13 @@ function get_user_row($id)
|
||||
if (isset($userRows[$id])) return $userRows[$id];
|
||||
$cacheKey = 'user_'.$id.'_content';
|
||||
$row = \Nexus\Database\NexusDB::remember($cacheKey, 3600, function () use ($id, $neededColumns) {
|
||||
$user = \App\Models\User::query()->with(['wearing_medals'])->find($id, $neededColumns);
|
||||
$user = \App\Models\User::query()->with([
|
||||
'wearing_medals' => function ($query) {
|
||||
$query->orderBy('user_medals.priority', 'desc')
|
||||
->orderBy('user_medals.id', 'desc')
|
||||
->limit(get_setting('system.maximum_number_of_medals_can_be_worn', 3));
|
||||
}
|
||||
])->find($id, $neededColumns);
|
||||
if (!$user) {
|
||||
return null;
|
||||
}
|
||||
@@ -1392,7 +1398,7 @@ function fire_event(string $name, \Illuminate\Database\Eloquent\Model $model, ?\
|
||||
}
|
||||
}
|
||||
call_user_func_array([$eventClass, "dispatch"], $params);
|
||||
publish_model_event($name, $model->id);
|
||||
publish_model_event($name, $model->id, $model->toJson());
|
||||
do_log("success fire_event in laravel, name: $name, id: $model->id, oldId: " . ($oldModel ? $oldModel->id : ""));
|
||||
}
|
||||
}
|
||||
@@ -1400,11 +1406,11 @@ function fire_event(string $name, \Illuminate\Database\Eloquent\Model $model, ?\
|
||||
/**
|
||||
* 仅仅是往 redis 发布事件, php 端无监听者仅在其他平台有需要的触发这个即可, 较轻量
|
||||
*/
|
||||
function publish_model_event(string $event, int $id): void
|
||||
function publish_model_event(string $event, int $id, string $json = ""): void
|
||||
{
|
||||
$channel = nexus_env("CHANNEL_NAME_MODEL_EVENT");
|
||||
if (!empty($channel)) {
|
||||
\Nexus\Database\NexusDB::redis()->publish($channel, json_encode(["event" => $event, "id" => $id]));
|
||||
\Nexus\Database\NexusDB::redis()->publish($channel, json_encode(["event" => $event, "id" => $id, "json" => $json]));
|
||||
} else {
|
||||
do_log("event: $event, id: $id, channel: $channel, channel is empty!", "error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user