fix cleanup + attendance bonus

This commit is contained in:
xiaomlove
2022-03-09 12:08:14 +08:00
parent b8c288d07b
commit 7b8b7ed510
7 changed files with 24 additions and 16 deletions
+1
View File
@@ -12,6 +12,7 @@ Complete PT website building solution. Based on NexusPHP + Laravel Framework + E
- H&R - H&R
- Attendance - Attendance
- Medal - Medal
- Custom tags
- Forum - Forum
- Multi-language - Multi-language
- Automatic backup - Automatic backup
+1
View File
@@ -11,6 +11,7 @@
- H&R - H&R
- 签到 - 签到
- 勋章 - 勋章
- 自定义标签
- 论坛 - 论坛
- 多语言 - 多语言
- 自动备份 - 自动备份
@@ -3,6 +3,7 @@ namespace App\Repositories;
use App\Models\Attendance; use App\Models\Attendance;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
class AttendanceRepository extends BaseRepository class AttendanceRepository extends BaseRepository
@@ -55,6 +56,7 @@ class AttendanceRepository extends BaseRepository
} }
do_log("[DO_UPDATE]: " . nexus_json_encode($update)); do_log("[DO_UPDATE]: " . nexus_json_encode($update));
$attendance->update($update); $attendance->update($update);
User::query()->where('id', $uid)->increment('seedbonus', $update['points']);
} }
} }
$attendance->added_time = $now->toTimeString(); $attendance->added_time = $now->toTimeString();
+12 -8
View File
@@ -308,8 +308,9 @@ function docleanup($forceAll = 0, $printProgress = false) {
$row = mysql_fetch_array($res); $row = mysql_fetch_array($res);
if (!$row) { if (!$row) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime2',".sqlesc($now).")") or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime2',".sqlesc($now).")") or sqlerr(__FILE__, __LINE__);
do_log("no value for arg: 'lastcleantime2', return"); $log = "no value for arg: 'lastcleantime2', return";
return; do_log($log);
return $log;
} }
$ts = $row[0]; $ts = $row[0];
if ($ts + $autoclean_interval_two > $now && !$forceAll) { if ($ts + $autoclean_interval_two > $now && !$forceAll) {
@@ -333,8 +334,9 @@ function docleanup($forceAll = 0, $printProgress = false) {
$row = mysql_fetch_array($res); $row = mysql_fetch_array($res);
if (!$row) { if (!$row) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime3',$now)") or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime3',$now)") or sqlerr(__FILE__, __LINE__);
do_log("no value for arg: 'lastcleantime3', return"); $log = "no value for arg: 'lastcleantime3', return";
return; do_log($log);
return $log;
} }
$ts = $row[0]; $ts = $row[0];
if ($ts + $autoclean_interval_three > $now && !$forceAll) { if ($ts + $autoclean_interval_three > $now && !$forceAll) {
@@ -492,8 +494,9 @@ function docleanup($forceAll = 0, $printProgress = false) {
$row = mysql_fetch_array($res); $row = mysql_fetch_array($res);
if (!$row) { if (!$row) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime4',$now)") or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime4',$now)") or sqlerr(__FILE__, __LINE__);
do_log("no value for arg: 'lastcleantime4', return"); $log = "no value for arg: 'lastcleantime4', return";
return; do_log($log);
return $log;
} }
$ts = $row[0]; $ts = $row[0];
if ($ts + $autoclean_interval_four > $now && !$forceAll) { if ($ts + $autoclean_interval_four > $now && !$forceAll) {
@@ -818,8 +821,9 @@ function docleanup($forceAll = 0, $printProgress = false) {
$row = mysql_fetch_array($res); $row = mysql_fetch_array($res);
if (!$row) { if (!$row) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime5',$now)") or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime5',$now)") or sqlerr(__FILE__, __LINE__);
do_log("no value for arg: 'lastcleantime5', return"); $log = "no value for arg: 'lastcleantime5', return";
return; do_log($log);
return $log;
} }
$ts = $row[0]; $ts = $row[0];
if ($ts + $autoclean_interval_five > $now && !$forceAll) { if ($ts + $autoclean_interval_five > $now && !$forceAll) {
+5 -5
View File
@@ -6,6 +6,7 @@
*/ */
require "bittorrent.php"; require "bittorrent.php";
require 'cleanup.php';
$fd = fopen(sprintf('%s/nexus_cleanup_cli.lock', sys_get_temp_dir()), 'w+'); $fd = fopen(sprintf('%s/nexus_cleanup_cli.lock', sys_get_temp_dir()), 'w+');
if (!flock($fd, LOCK_EX|LOCK_NB)) { if (!flock($fd, LOCK_EX|LOCK_NB)) {
@@ -21,19 +22,18 @@ $force = 0;
if (isset($_SERVER['argv'][1])) { if (isset($_SERVER['argv'][1])) {
$force = $_SERVER['argv'][1] ? 1 : 0; $force = $_SERVER['argv'][1] ? 1 : 0;
} }
$logPrefix = "[CLEANUP_CLI]";
try { try {
if ($force) { if ($force) {
require_once(ROOT_PATH . 'include/cleanup.php');
$result = docleanup(1, true); $result = docleanup(1, true);
} else { } else {
$result = autoclean(); $result = autoclean(true);
} }
$log = "[CLEANUP_CLI DONE!] $result"; $log = "$logPrefix, DONE: $result";
do_log($log); do_log($log);
printProgress($log); printProgress($log);
} catch (\Exception $exception) { } catch (\Exception $exception) {
$log = "ERROR: " . $exception->getMessage(); $log = "$logPrefix, ERROR: " . $exception->getMessage();
do_log($log); do_log($log);
printProgress($log); printProgress($log);
throw new \RuntimeException($exception->getMessage()); throw new \RuntimeException($exception->getMessage());
+2 -2
View File
@@ -1902,7 +1902,7 @@ function userlogin() {
return $loginResult = true; return $loginResult = true;
} }
function autoclean() { function autoclean($printProgress = false) {
global $autoclean_interval_one, $rootpath; global $autoclean_interval_one, $rootpath;
$now = TIMENOW; $now = TIMENOW;
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
@@ -1923,7 +1923,7 @@ function autoclean() {
return false; return false;
} }
require_once($rootpath . 'include/cleanup.php'); require_once($rootpath . 'include/cleanup.php');
return docleanup(); return docleanup(0, $printProgress);
} }
function unesc($x) { function unesc($x) {
+1 -1
View File
@@ -168,7 +168,7 @@ if (!$row) {
} }
} }
} }
print("<td class=\"embedded\"><form method=\"get\" action=\"http://shooter.cn/sub/\" target=\"_blank\"><input type=\"text\" name=\"searchword\" id=\"keyword\" style=\"width: 250px\" value=\"".$moviename."\" /><input type=\"submit\" value=\"".$lang_details['submit_search_at_shooter']."\" /></form></td><td class=\"embedded\"><form method=\"get\" action=\"http://www.opensubtitles.org/en/search2/\" target=\"_blank\"><input type=\"hidden\" id=\"moviename\" name=\"MovieName\" /><input type=\"hidden\" name=\"action\" value=\"search\" /><input type=\"hidden\" name=\"SubLanguageID\" value=\"all\" /><input onclick=\"document.getElementById('moviename').value=document.getElementById('keyword').value;\" type=\"submit\" value=\"".$lang_details['submit_search_at_opensubtitles']."\" /></form></td>\n"); print("<td class=\"embedded\"><form method=\"get\" action=\"https://assrt.net/sub/\" target=\"_blank\"><input type=\"text\" name=\"searchword\" id=\"keyword\" style=\"width: 250px\" value=\"".$moviename."\" /><input type=\"submit\" value=\"".$lang_details['submit_search_at_shooter']."\" /></form></td><td class=\"embedded\"><form method=\"get\" action=\"https://www.opensubtitles.org/en/search2/\" target=\"_blank\"><input type=\"hidden\" id=\"moviename\" name=\"MovieName\" /><input type=\"hidden\" name=\"action\" value=\"search\" /><input type=\"hidden\" name=\"SubLanguageID\" value=\"all\" /><input onclick=\"document.getElementById('moviename').value=document.getElementById('keyword').value;\" type=\"submit\" value=\"".$lang_details['submit_search_at_opensubtitles']."\" /></form></td>\n");
print("</tr></table>"); print("</tr></table>");
print("</td></tr>\n"); print("</td></tr>\n");
// ---------------- end subtitle block -------------------// // ---------------- end subtitle block -------------------//