mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
user add last_announce_at/seeding_torrent_count/seeding_torrent_size
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Repositories\ExamRepository;
|
|||||||
use App\Repositories\SeedBoxRepository;
|
use App\Repositories\SeedBoxRepository;
|
||||||
use App\Repositories\UploadRepository;
|
use App\Repositories\UploadRepository;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Nexus\PTGen\PTGen;
|
use Nexus\PTGen\PTGen;
|
||||||
use NexusPlugin\Menu\Filament\MenuItemResource\Pages\ManageMenuItems;
|
use NexusPlugin\Menu\Filament\MenuItemResource\Pages\ManageMenuItems;
|
||||||
use NexusPlugin\Menu\MenuRepository;
|
use NexusPlugin\Menu\MenuRepository;
|
||||||
@@ -59,7 +60,15 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$failedJob = DB::table('failed_jobs')->find(555);
|
||||||
|
|
||||||
|
$payload = json_decode($failedJob->payload, true);
|
||||||
|
dd($payload);
|
||||||
|
|
||||||
|
$base64 = $payload['data']['command'];
|
||||||
|
$job = unserialize($base64);
|
||||||
|
|
||||||
|
dd($job);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class AuthCodeResource extends Resource
|
|||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('id'),
|
Tables\Columns\TextColumn::make('id'),
|
||||||
Tables\Columns\TextColumn::make('user.username')
|
Tables\Columns\TextColumn::make('user_id')
|
||||||
->label(__('label.username'))
|
->label(__('label.username'))
|
||||||
->formatStateUsing(fn ($record) => username_for_admin($record->user_id)),
|
->formatStateUsing(fn ($record) => username_for_admin($record->user_id)),
|
||||||
Tables\Columns\TextColumn::make('client.name')
|
Tables\Columns\TextColumn::make('client.name')
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ class CalculateUserSeedBonus implements ShouldQueue
|
|||||||
do_log("$logPrefix, [GET_UID_REAL], count: " . count($results) . ", logFile: $logFile");
|
do_log("$logPrefix, [GET_UID_REAL], count: " . count($results) . ", logFile: $logFile");
|
||||||
$fd = fopen($logFile, 'a');
|
$fd = fopen($logFile, 'a');
|
||||||
$seedPointsUpdates = $seedPointsPerHourUpdates = $seedBonusUpdates = [];
|
$seedPointsUpdates = $seedPointsPerHourUpdates = $seedBonusUpdates = [];
|
||||||
|
$seedingTorrentCountUpdates = $seedingTorrentSizeUpdates = [];
|
||||||
$logStr = "";
|
$logStr = "";
|
||||||
foreach ($results as $userInfo)
|
foreach ($results as $userInfo)
|
||||||
{
|
{
|
||||||
@@ -129,6 +130,8 @@ class CalculateUserSeedBonus implements ShouldQueue
|
|||||||
// NexusDB::statement($sql);
|
// NexusDB::statement($sql);
|
||||||
$seedPointsUpdates[] = sprintf("when %d then ifnull(seed_points, 0) + %f", $uid, $seed_points);
|
$seedPointsUpdates[] = sprintf("when %d then ifnull(seed_points, 0) + %f", $uid, $seed_points);
|
||||||
$seedPointsPerHourUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['seed_points']);
|
$seedPointsPerHourUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['seed_points']);
|
||||||
|
$seedingTorrentCountUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['count']);
|
||||||
|
$seedingTorrentSizeUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['size']);
|
||||||
$seedBonusUpdates[] = sprintf("when %d then seedbonus + %f", $uid, $all_bonus);
|
$seedBonusUpdates[] = sprintf("when %d then seedbonus + %f", $uid, $all_bonus);
|
||||||
if ($fd) {
|
if ($fd) {
|
||||||
$log = sprintf(
|
$log = sprintf(
|
||||||
@@ -145,8 +148,8 @@ class CalculateUserSeedBonus implements ShouldQueue
|
|||||||
}
|
}
|
||||||
$nowStr = now()->toDateTimeString();
|
$nowStr = now()->toDateTimeString();
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
"update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seedbonus = case id %s end, seed_points_updated_at = '%s' where id in (%s)",
|
"update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seedbonus = case id %s end, seeding_torrent_count = case id %s end, seeding_torrent_size = case id %s end, seed_points_updated_at = '%s' where id in (%s)",
|
||||||
implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusUpdates), $nowStr, $idStr
|
implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusUpdates), implode(" ", $seedingTorrentCountUpdates), implode(" ", $seedingTorrentSizeUpdates), $nowStr, $idStr
|
||||||
);
|
);
|
||||||
$result = NexusDB::statement($sql);
|
$result = NexusDB::statement($sql);
|
||||||
if ($delIdRedisKey) {
|
if ($delIdRedisKey) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class CheckCleanup implements ShouldQueue
|
class CheckCleanup
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
class UpgradeRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
const DATETIME_INVALID_VALUE_FIELDS = [
|
||||||
|
'comments' => ['editdate'],
|
||||||
|
'invites' => ['time_invited'],
|
||||||
|
'offers' => ['allowedtime'],
|
||||||
|
'peers' => ['last_action', 'prev_action'],
|
||||||
|
'posts' => ['editdate'],
|
||||||
|
'snatched' => ['last_action', 'completedat'],
|
||||||
|
'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'],
|
||||||
|
'users' => [
|
||||||
|
'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg',
|
||||||
|
'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until',
|
||||||
|
'leechwarnuntil', 'lastwarned',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -13,20 +13,7 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$tableFields = [
|
$tableFields = \App\Repositories\UpgradeRepository::DATETIME_INVALID_VALUE_FIELDS;
|
||||||
'comments' => ['editdate'],
|
|
||||||
'invites' => ['time_invited'],
|
|
||||||
'offers' => ['allowedtime'],
|
|
||||||
'peers' => ['last_action', 'prev_action'],
|
|
||||||
'posts' => ['editdate'],
|
|
||||||
'snatched' => ['last_action', 'completedat'],
|
|
||||||
'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'],
|
|
||||||
'users' => [
|
|
||||||
'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg',
|
|
||||||
'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until',
|
|
||||||
'leechwarnuntil', 'lastwarned',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($tableFields as $table => $fields) {
|
foreach ($tableFields as $table => $fields) {
|
||||||
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
|
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->integer("seeding_torrent_count")->default(0);
|
||||||
|
$table->bigInteger("seeding_torrent_size")->default(0);
|
||||||
|
$table->dateTime("last_announce_at")->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn("seeding_torrent_count", "seeding_torrent_size", "last_announce_at");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$tableFields = \App\Repositories\UpgradeRepository::DATETIME_INVALID_VALUE_FIELDS;
|
||||||
|
|
||||||
|
foreach ($tableFields as $table => $fields) {
|
||||||
|
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if (isset($columnInfo[$field]) && $columnInfo[$field]['DATA_TYPE'] == 'datetime') {
|
||||||
|
\Illuminate\Support\Facades\DB::statement("update $table set $field = null where $field = '0000-00-00 00:00:00'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo("snatched");
|
||||||
|
if (isset($columnInfo["finish_ip"])) {
|
||||||
|
\Illuminate\Support\Facades\DB::statement("alter table snatched drop column finish_ip");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.4');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.5');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-06-01');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-06-09');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
@@ -596,6 +596,7 @@ if (count($updateset) || $hasChangeSeederLeecher) // Update only when there is c
|
|||||||
if($client_familyid != 0 && $client_familyid != $az['clientselect']) {
|
if($client_familyid != 0 && $client_familyid != $az['clientselect']) {
|
||||||
$USERUPDATESET[] = "clientselect = ".sqlesc($client_familyid);
|
$USERUPDATESET[] = "clientselect = ".sqlesc($client_familyid);
|
||||||
}
|
}
|
||||||
|
$USERUPDATESET[] = "last_announce_at = $dt";
|
||||||
/**
|
/**
|
||||||
* VIP do not calculate downloaded
|
* VIP do not calculate downloaded
|
||||||
* @since 1.7.13
|
* @since 1.7.13
|
||||||
|
|||||||
+8
-9
@@ -163,8 +163,8 @@ JS;
|
|||||||
print("<tr><td colspan=7 align=center>".$lang_invite['text_no_invites']."</tr>");
|
print("<tr><td colspan=7 align=center>".$lang_invite['text_no_invites']."</tr>");
|
||||||
} else {
|
} else {
|
||||||
list($pagertop, $pagerbottom, $limit) = pager($pageSize, $number, "?id=$id&menu=$menuSelected&");
|
list($pagertop, $pagerbottom, $limit) = pager($pageSize, $number, "?id=$id&menu=$menuSelected&");
|
||||||
$haremAdditionFactor = get_setting('bonus.harem_addition');
|
$haremAdditionFactor = (float)get_setting('bonus.harem_addition');
|
||||||
$ret = sql_query("SELECT id, username, email, uploaded, downloaded, status, warned, enabled, donor, email FROM users WHERE $whereStr $limit") or sqlerr();
|
$ret = sql_query("SELECT id, username, email, uploaded, downloaded, status, warned, enabled, donor, email,seeding_torrent_count, seeding_torrent_size, last_announce_at FROM users WHERE $whereStr $limit") or sqlerr();
|
||||||
$num = mysql_num_rows($ret);
|
$num = mysql_num_rows($ret);
|
||||||
|
|
||||||
print("<tr>
|
print("<tr>
|
||||||
@@ -208,7 +208,6 @@ JS;
|
|||||||
$status = "<a href=userdetails.php?id={$arr['id']}><font color=#1f7309>".$lang_invite['text_confirmed']."</font></a>";
|
$status = "<a href=userdetails.php?id={$arr['id']}><font color=#1f7309>".$lang_invite['text_confirmed']."</font></a>";
|
||||||
else
|
else
|
||||||
$status = "<a href=checkuser.php?id={$arr['id']}><font color=#ca0226>".$lang_invite['text_pending']."</font></a>";
|
$status = "<a href=checkuser.php?id={$arr['id']}><font color=#ca0226>".$lang_invite['text_pending']."</font></a>";
|
||||||
$seedBonusResult = calculate_seed_bonus($arr['id']);
|
|
||||||
print("<tr class=rowfollow>
|
print("<tr class=rowfollow>
|
||||||
<td class=rowfollow>".get_username($arr['id'])."</td>
|
<td class=rowfollow>".get_username($arr['id'])."</td>
|
||||||
<td>{$arr['email']}</td>
|
<td>{$arr['email']}</td>
|
||||||
@@ -216,15 +215,15 @@ JS;
|
|||||||
<td class=rowfollow>" . mksize($arr['uploaded']) . "</td>
|
<td class=rowfollow>" . mksize($arr['uploaded']) . "</td>
|
||||||
<td class=rowfollow>" . mksize($arr['downloaded']) . "</td>
|
<td class=rowfollow>" . mksize($arr['downloaded']) . "</td>
|
||||||
<td class=rowfollow>$ratio</td>
|
<td class=rowfollow>$ratio</td>
|
||||||
<td class=rowfollow>{$seedBonusResult['count']}</td>
|
<td class=rowfollow>".number_format($arr['seeding_torrent_count'])."</td>
|
||||||
<td class=rowfollow>".mksize($seedBonusResult['size'])."</td>
|
<td class=rowfollow>".mksize($arr['seeding_torrent_size'])."</td>
|
||||||
<td class=rowfollow>".number_format($seedBonusResult['seed_points'], 3)."</td>
|
<td class=rowfollow>".number_format($arr['seed_points_per_hour'], 3)."</td>
|
||||||
");
|
");
|
||||||
|
|
||||||
if ($haremAdditionFactor > 0) {
|
if ($haremAdditionFactor > 0) {
|
||||||
print ("<td class=rowfollow>".number_format($seedBonusResult['seed_points'] * $haremAdditionFactor, 3)."</td>");
|
print ("<td class=rowfollow>".number_format(floatval($arr['seed_points_per_hour']) * $haremAdditionFactor, 3)."</td>");
|
||||||
}
|
}
|
||||||
print("<td class=rowfollow>{$seedBonusResult['last_action']}</td>");
|
print("<td class=rowfollow>{$arr['last_announce_at']}</td>");
|
||||||
print("<td class=rowfollow>$status</td>");
|
print("<td class=rowfollow>$status</td>");
|
||||||
if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP){
|
if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP){
|
||||||
print("<td>");
|
print("<td>");
|
||||||
@@ -240,7 +239,7 @@ JS;
|
|||||||
if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP)
|
if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP)
|
||||||
{
|
{
|
||||||
$pendingcount = number_format(get_row_count("users", "WHERE status='pending' AND invited_by={$CURUSER['id']}"));
|
$pendingcount = number_format(get_row_count("users", "WHERE status='pending' AND invited_by={$CURUSER['id']}"));
|
||||||
$colSpan = 7;
|
$colSpan = 12;
|
||||||
if (isset($haremAdditionFactor) && $haremAdditionFactor > 0) {
|
if (isset($haremAdditionFactor) && $haremAdditionFactor > 0) {
|
||||||
$colSpan += 1;
|
$colSpan += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ if ($type == 'invite')
|
|||||||
$dt = date("Y-m-d H:i:s");
|
$dt = date("Y-m-d H:i:s");
|
||||||
$locale = get_user_locale($inviter);
|
$locale = get_user_locale($inviter);
|
||||||
$subject = nexus_trans("user.msg_invited_user_has_registered", [], $locale);
|
$subject = nexus_trans("user.msg_invited_user_has_registered", [], $locale);
|
||||||
$msg = nexus_trans("user.msg_user_you_invited", [],$locale).$usern.nexus_trans("user.msg_has_registered", [], $locale);
|
$msg = nexus_trans("user.msg_user_you_invited", [],$locale).$wantusername.nexus_trans("user.msg_has_registered", [], $locale);
|
||||||
//sql_query("UPDATE users SET uploaded = uploaded + 10737418240 WHERE id = $inviter"); //add 10GB to invitor's uploading credit
|
//sql_query("UPDATE users SET uploaded = uploaded + 10737418240 WHERE id = $inviter"); //add 10GB to invitor's uploading credit
|
||||||
\App\Models\Message::add([
|
\App\Models\Message::add([
|
||||||
'sender' => 0,
|
'sender' => 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user