diff --git a/app/Repositories/ClaimRepository.php b/app/Repositories/ClaimRepository.php index e4dbdd9e..b9488706 100644 --- a/app/Repositories/ClaimRepository.php +++ b/app/Repositories/ClaimRepository.php @@ -168,10 +168,15 @@ class ClaimRepository extends BaseRepository do_log("uid: $uid, filter: user_has_role_work_seeding => true, skip"); return false; } - $user = User::query()->with('language')->findOrFail($uid); - $list = Claim::query()->where('uid', $uid)->with(['snatch', 'torrent' => fn ($query) => $query->select(Torrent::$commentFields)])->get(); $now = Carbon::now(); $startOfThisMonth = $now->clone()->startOfMonth(); + $user = User::query()->with('language')->findOrFail($uid); + $list = Claim::query() + ->where('uid', $uid) + ->where("created_at", "<", $startOfThisMonth) + ->with(['snatch', 'torrent' => fn ($query) => $query->select(Torrent::$commentFields)]) + ->get() + ; $seedTimeRequiredHours = Claim::getConfigStandardSeedTimeHours(); $uploadedRequiredTimes = Claim::getConfigStandardUploadedTimes(); $bonusMultiplier = Claim::getConfigBonusMultiplier(); diff --git a/include/functions.php b/include/functions.php index 0ad6b847..63f0bdc0 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5371,7 +5371,7 @@ function checkGuestVisit() } -function render($view, $data, $return = false) +function render($view, $data = [], $return = false) { extract($data); if (!file_exists($view)) { diff --git a/nexus/Plugin/BasePlugin.php b/nexus/Plugin/BasePlugin.php index afda0ca4..c3643fb9 100644 --- a/nexus/Plugin/BasePlugin.php +++ b/nexus/Plugin/BasePlugin.php @@ -37,4 +37,11 @@ abstract class BasePlugin extends BaseRepository )); } } + + public function getNexusView($name): string + { + $reflection = new \ReflectionClass(get_called_class()); + $pluginRoot = dirname($reflection->getFileName(), 2); + return $pluginRoot . "/resources/views/" . trim($name, "/"); + } } diff --git a/nexus/Plugin/Plugin.php b/nexus/Plugin/Plugin.php index f1193af4..a7d50097 100644 --- a/nexus/Plugin/Plugin.php +++ b/nexus/Plugin/Plugin.php @@ -5,6 +5,8 @@ class Plugin { private static mixed $providers = null; + private static array $plugins = []; + public function __construct() { $this->loadProviders(); @@ -16,6 +18,11 @@ class Plugin return !empty(self::$providers[$name]['providers']); } + public static function getById($id) :BasePlugin|null + { + return self::$plugins[$id] ?? null; + } + public function getMainClass($name) { if (isset(self::$providers[$name]['providers'][0])) { @@ -39,7 +46,12 @@ class Plugin if (defined($constantName) && version_compare(VERSION_NUMBER, constant($constantName), '<')) { continue; } - call_user_func([new $className, 'boot']); + $plugin = new $className; + call_user_func([$plugin, 'boot']); + $pluginIdName = "$className::ID"; + if (defined($pluginIdName)) { + self::$plugins[constant($pluginIdName)] = $plugin; + } } } } @@ -58,4 +70,6 @@ class Plugin } + + } diff --git a/public/page.php b/public/page.php new file mode 100644 index 00000000..2dc26bad --- /dev/null +++ b/public/page.php @@ -0,0 +1,29 @@ +getNexusView($view); + } else { + $viewFile = ROOT_PATH . "resources/views/$view"; + } + + if (!str_ends_with($viewFile, ".php")) { + $viewFile .= ".php"; + } + if (file_exists($viewFile)) { + require $viewFile; + } else { + $msg = "viewFile: $viewFile not exists, _REQUEST: " . json_encode($_REQUEST); + do_log($msg, "error"); + throw new \RuntimeException($msg); + } +} else { + $msg = "require view parameter, _REQUEST: " . json_encode($_REQUEST); + do_log($msg, "error"); + throw new \RuntimeException($msg); +}