diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 127bf921..3cfc2eba 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -39,7 +39,7 @@ use JeroenG\Explorer\Infrastructure\Scout\ElasticEngine; use League\Flysystem\StorageAttributes; use Nexus\Database\NexusDB; use Nexus\Imdb\Imdb; -use NexusPlugin\PostLike\PostLike; +use NexusPlugin\PostLike\PostLikeRepository; use NexusPlugin\StickyPromotion\Models\StickyPromotion; use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator; use Rhilip\Bencode\Bencode; @@ -77,8 +77,9 @@ class Test extends Command */ public function handle() { - $r = StickyPromotionParticipator::query()->first(); - dd($r->created_at); + $torrent = Torrent::query()->first(); + $torrent->name = Carbon::now()->toDateTimeString(); + $torrent->update(['seeders' => 100]); } diff --git a/app/Models/BonusLogs.php b/app/Models/BonusLogs.php index 44081767..bd6df7f1 100644 --- a/app/Models/BonusLogs.php +++ b/app/Models/BonusLogs.php @@ -16,12 +16,14 @@ class BonusLogs extends NexusModel const BUSINESS_TYPE_BUY_MEDAL = 2; const BUSINESS_TYPE_BUY_ATTENDANCE_CARD = 3; const BUSINESS_TYPE_STICKY_PROMOTION = 4; + const BUSINESS_TYPE_POST_REWARD = 5; public static array $businessTypes = [ self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'], self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'], self::BUSINESS_TYPE_BUY_ATTENDANCE_CARD => ['text' => 'Buy attendance card'], self::BUSINESS_TYPE_STICKY_PROMOTION => ['text' => 'Buy torrent sticky promotion'], + self::BUSINESS_TYPE_POST_REWARD => ['text' => 'Reward post'], ]; public static function getBonusForCancelHitAndRun() diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index f512e0e4..12a82b42 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -14,7 +14,8 @@ class Torrent extends NexusModel 'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec', 'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type', 'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime', - 'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', + 'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', 'last_action', + 'times_completed' ]; private static $globalPromotionState; @@ -157,10 +158,15 @@ class Torrent extends NexusModel } $spState = $this->sp_state; $global = self::getGlobalPromotionState(); - $log = sprintf('torrent: %s sp_state: %s, global sp state: %s', $this->id, $spState, $global); + $log = sprintf('torrent: %s original sp_state: %s, original global_sp_state: %s', $this->id, $spState, $global); + if ($this->__sticky_promotion) { + //Cover original sp_state + $spState = $this->__sticky_promotion['promotion_type']; + $log .= "[SP_STATE_CHANGE] to __sticky_promotion: $spState]"; + } if ($this->__ignore_global_sp_state) { - $log .= "[IGNORE_GLOBAL_SP_STATE]"; $global = self::PROMOTION_NORMAL; + $log .= "[IGNORE_GLOBAL_SP_STATE], reset to: $global"; } if ($global != self::PROMOTION_NORMAL) { $spState = $global; diff --git a/include/core.php b/include/core.php index 2fcc2670..2a89325c 100644 --- a/include/core.php +++ b/include/core.php @@ -17,11 +17,11 @@ require $rootpath . 'include/eloquent.php'; ini_set('date.timezone', nexus_config('nexus.timezone')); $Cache = new class_cache_redis(); //Load the caching class $Cache->setLanguageFolderArray(get_langfolder_list()); +require $rootpath . 'include/config.php'; $script = nexus()->getScript(); -if (!in_array($script, ['announce'])) { +if (!in_array($script, ['announce', 'scrape'])) { require $rootpath . get_langfile_path("functions.php"); } -require $rootpath . 'include/config.php'; if (!isRunningInConsole() && !in_array($script, ['announce', 'scrape', 'torrentrss', 'download'])) { checkGuestVisit(); } diff --git a/nexus/Plugin/Hook.php b/nexus/Plugin/Hook.php index 626e7804..bf469034 100644 --- a/nexus/Plugin/Hook.php +++ b/nexus/Plugin/Hook.php @@ -6,6 +6,8 @@ class Hook { private static array $callbacks = []; + private bool $isDoingAction = false; + public function addFilter($name, $function, $priority, $argc) { $id = $this->buildUniqueId($function); @@ -43,12 +45,18 @@ class Hook reset(self::$callbacks[$name]); do_log("name: $name, argc: " . (func_num_args() - 1)); do { - foreach ((array)current(self::$callbacks[$name]) as $callback) { + foreach ((array)current(self::$callbacks[$name]) as $id => $callback) { $args[1] = $value; +// do_log("name: $name, id: $id, before, params: " . json_encode(array_slice($args, 1, $callback['argc']))); $value = call_user_func_array($callback['function'], array_slice($args, 1, $callback['argc'])); + if ($this->isDoingAction) { + $value = $args[1]; + } +// do_log("name: $name, id: $id, after, value: " . var_export($value, true)); } } while (next(self::$callbacks[$name]) !== false); + $this->isDoingAction = false; return $value; } @@ -59,6 +67,7 @@ class Hook public function doAction($name, ...$args) { + $this->isDoingAction = true; $this->applyFilter(...func_get_args()); } diff --git a/nexus/Plugin/Plugin.php b/nexus/Plugin/Plugin.php index 211396c1..e77ebf11 100644 --- a/nexus/Plugin/Plugin.php +++ b/nexus/Plugin/Plugin.php @@ -36,6 +36,8 @@ class Plugin $className = str_replace('ServiceProvider', 'Repository', $provider); if (class_exists($className)) { call_user_func([new $className, 'boot']); + } else { + do_log("Plugin: $className not exists.", "error"); } } } diff --git a/public/forums.php b/public/forums.php index 9f9c1a3d..f560e1f2 100644 --- a/public/forums.php +++ b/public/forums.php @@ -703,18 +703,19 @@ if ($action == "viewtopic") print("\n"); - $body = "
".format_comment($arr["body"]); - + $body = "
"; + $bodyContent = format_comment($arr["body"]); if ($highlight){ - $body = highlight($highlight,$body); + $bodyContent = highlight($highlight,$body); } if (is_valid_id($arr['editedby'])) { $lastedittime = gettime($arr['editdate'],true,false); - $body .= "

".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."

\n"; + $bodyContent .= "

".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."

\n"; } - $body .= "
"; + $bodyContent = apply_filter('post_body', $bodyContent, $arr, $allPosts); + $body .= $bodyContent . "
"; if ($signature) $body .= "


____________________
" . format_comment($signature,false,false,false,true,500,true,false, 1,200) . "

";