mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
plugin sticky promotion do not change torrent original field
This commit is contained in:
@@ -39,7 +39,7 @@ use JeroenG\Explorer\Infrastructure\Scout\ElasticEngine;
|
|||||||
use League\Flysystem\StorageAttributes;
|
use League\Flysystem\StorageAttributes;
|
||||||
use Nexus\Database\NexusDB;
|
use Nexus\Database\NexusDB;
|
||||||
use Nexus\Imdb\Imdb;
|
use Nexus\Imdb\Imdb;
|
||||||
use NexusPlugin\PostLike\PostLike;
|
use NexusPlugin\PostLike\PostLikeRepository;
|
||||||
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
|
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
|
||||||
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
|
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
|
||||||
use Rhilip\Bencode\Bencode;
|
use Rhilip\Bencode\Bencode;
|
||||||
@@ -77,8 +77,9 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$r = StickyPromotionParticipator::query()->first();
|
$torrent = Torrent::query()->first();
|
||||||
dd($r->created_at);
|
$torrent->name = Carbon::now()->toDateTimeString();
|
||||||
|
$torrent->update(['seeders' => 100]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ class BonusLogs extends NexusModel
|
|||||||
const BUSINESS_TYPE_BUY_MEDAL = 2;
|
const BUSINESS_TYPE_BUY_MEDAL = 2;
|
||||||
const BUSINESS_TYPE_BUY_ATTENDANCE_CARD = 3;
|
const BUSINESS_TYPE_BUY_ATTENDANCE_CARD = 3;
|
||||||
const BUSINESS_TYPE_STICKY_PROMOTION = 4;
|
const BUSINESS_TYPE_STICKY_PROMOTION = 4;
|
||||||
|
const BUSINESS_TYPE_POST_REWARD = 5;
|
||||||
|
|
||||||
public static array $businessTypes = [
|
public static array $businessTypes = [
|
||||||
self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'],
|
self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'],
|
||||||
self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'],
|
self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'],
|
||||||
self::BUSINESS_TYPE_BUY_ATTENDANCE_CARD => ['text' => 'Buy attendance card'],
|
self::BUSINESS_TYPE_BUY_ATTENDANCE_CARD => ['text' => 'Buy attendance card'],
|
||||||
self::BUSINESS_TYPE_STICKY_PROMOTION => ['text' => 'Buy torrent sticky promotion'],
|
self::BUSINESS_TYPE_STICKY_PROMOTION => ['text' => 'Buy torrent sticky promotion'],
|
||||||
|
self::BUSINESS_TYPE_POST_REWARD => ['text' => 'Reward post'],
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getBonusForCancelHitAndRun()
|
public static function getBonusForCancelHitAndRun()
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ class Torrent extends NexusModel
|
|||||||
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
|
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
|
||||||
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
|
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
|
||||||
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
|
'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;
|
private static $globalPromotionState;
|
||||||
@@ -157,10 +158,15 @@ class Torrent extends NexusModel
|
|||||||
}
|
}
|
||||||
$spState = $this->sp_state;
|
$spState = $this->sp_state;
|
||||||
$global = self::getGlobalPromotionState();
|
$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) {
|
if ($this->__ignore_global_sp_state) {
|
||||||
$log .= "[IGNORE_GLOBAL_SP_STATE]";
|
|
||||||
$global = self::PROMOTION_NORMAL;
|
$global = self::PROMOTION_NORMAL;
|
||||||
|
$log .= "[IGNORE_GLOBAL_SP_STATE], reset to: $global";
|
||||||
}
|
}
|
||||||
if ($global != self::PROMOTION_NORMAL) {
|
if ($global != self::PROMOTION_NORMAL) {
|
||||||
$spState = $global;
|
$spState = $global;
|
||||||
|
|||||||
+2
-2
@@ -17,11 +17,11 @@ require $rootpath . 'include/eloquent.php';
|
|||||||
ini_set('date.timezone', nexus_config('nexus.timezone'));
|
ini_set('date.timezone', nexus_config('nexus.timezone'));
|
||||||
$Cache = new class_cache_redis(); //Load the caching class
|
$Cache = new class_cache_redis(); //Load the caching class
|
||||||
$Cache->setLanguageFolderArray(get_langfolder_list());
|
$Cache->setLanguageFolderArray(get_langfolder_list());
|
||||||
|
require $rootpath . 'include/config.php';
|
||||||
$script = nexus()->getScript();
|
$script = nexus()->getScript();
|
||||||
if (!in_array($script, ['announce'])) {
|
if (!in_array($script, ['announce', 'scrape'])) {
|
||||||
require $rootpath . get_langfile_path("functions.php");
|
require $rootpath . get_langfile_path("functions.php");
|
||||||
}
|
}
|
||||||
require $rootpath . 'include/config.php';
|
|
||||||
if (!isRunningInConsole() && !in_array($script, ['announce', 'scrape', 'torrentrss', 'download'])) {
|
if (!isRunningInConsole() && !in_array($script, ['announce', 'scrape', 'torrentrss', 'download'])) {
|
||||||
checkGuestVisit();
|
checkGuestVisit();
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -6,6 +6,8 @@ class Hook
|
|||||||
{
|
{
|
||||||
private static array $callbacks = [];
|
private static array $callbacks = [];
|
||||||
|
|
||||||
|
private bool $isDoingAction = false;
|
||||||
|
|
||||||
public function addFilter($name, $function, $priority, $argc)
|
public function addFilter($name, $function, $priority, $argc)
|
||||||
{
|
{
|
||||||
$id = $this->buildUniqueId($function);
|
$id = $this->buildUniqueId($function);
|
||||||
@@ -43,12 +45,18 @@ class Hook
|
|||||||
reset(self::$callbacks[$name]);
|
reset(self::$callbacks[$name]);
|
||||||
do_log("name: $name, argc: " . (func_num_args() - 1));
|
do_log("name: $name, argc: " . (func_num_args() - 1));
|
||||||
do {
|
do {
|
||||||
foreach ((array)current(self::$callbacks[$name]) as $callback) {
|
foreach ((array)current(self::$callbacks[$name]) as $id => $callback) {
|
||||||
$args[1] = $value;
|
$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']));
|
$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);
|
while (next(self::$callbacks[$name]) !== false);
|
||||||
|
$this->isDoingAction = false;
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +67,7 @@ class Hook
|
|||||||
|
|
||||||
public function doAction($name, ...$args)
|
public function doAction($name, ...$args)
|
||||||
{
|
{
|
||||||
|
$this->isDoingAction = true;
|
||||||
$this->applyFilter(...func_get_args());
|
$this->applyFilter(...func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class Plugin
|
|||||||
$className = str_replace('ServiceProvider', 'Repository', $provider);
|
$className = str_replace('ServiceProvider', 'Repository', $provider);
|
||||||
if (class_exists($className)) {
|
if (class_exists($className)) {
|
||||||
call_user_func([new $className, 'boot']);
|
call_user_func([new $className, 'boot']);
|
||||||
|
} else {
|
||||||
|
do_log("Plugin: $className not exists.", "error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -703,18 +703,19 @@ if ($action == "viewtopic")
|
|||||||
|
|
||||||
print("<table class=\"main\" width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
|
print("<table class=\"main\" width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
|
||||||
|
|
||||||
$body = "<div id=\"pid".$postid."body\">".format_comment($arr["body"]);
|
$body = "<div id=\"pid".$postid."body\">";
|
||||||
|
$bodyContent = format_comment($arr["body"]);
|
||||||
if ($highlight){
|
if ($highlight){
|
||||||
$body = highlight($highlight,$body);
|
$bodyContent = highlight($highlight,$body);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_valid_id($arr['editedby']))
|
if (is_valid_id($arr['editedby']))
|
||||||
{
|
{
|
||||||
$lastedittime = gettime($arr['editdate'],true,false);
|
$lastedittime = gettime($arr['editdate'],true,false);
|
||||||
$body .= "<br /><p><font class=\"small\">".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."</font></p>\n";
|
$bodyContent .= "<br /><p><font class=\"small\">".$lang_forums['text_last_edited_by'].get_username($arr['editedby']).$lang_forums['text_last_edit_at'].$lastedittime."</font></p>\n";
|
||||||
}
|
}
|
||||||
$body .= "</div>";
|
$bodyContent = apply_filter('post_body', $bodyContent, $arr, $allPosts);
|
||||||
|
$body .= $bodyContent . "</div>";
|
||||||
if ($signature)
|
if ($signature)
|
||||||
$body .= "<p style='vertical-align:bottom'><br />____________________<br />" . format_comment($signature,false,false,false,true,500,true,false, 1,200) . "</p>";
|
$body .= "<p style='vertical-align:bottom'><br />____________________<br />" . format_comment($signature,false,false,false,true,500,true,false, 1,200) . "</p>";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user