mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
bonus redemption limit click frequency
This commit is contained in:
@@ -38,6 +38,7 @@ use Illuminate\Support\Facades\Hash;
|
|||||||
use Illuminate\Support\Facades\Redis;
|
use Illuminate\Support\Facades\Redis;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Imdb\Cache;
|
||||||
use League\Flysystem\StorageAttributes;
|
use League\Flysystem\StorageAttributes;
|
||||||
use Nexus\Database\NexusDB;
|
use Nexus\Database\NexusDB;
|
||||||
use Nexus\Imdb\Imdb;
|
use Nexus\Imdb\Imdb;
|
||||||
@@ -86,7 +87,7 @@ class Test extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$r = \Illuminate\Support\Facades\Cache::lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.24');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.24');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-08');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-09-11');
|
||||||
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");
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ $lang_mybonus = array
|
|||||||
'reward_type_basic' => '基本奖励',
|
'reward_type_basic' => '基本奖励',
|
||||||
'reward_type_harem_addition' => '后宫加成',
|
'reward_type_harem_addition' => '后宫加成',
|
||||||
'bonus_base' => '基础魔力',
|
'bonus_base' => '基础魔力',
|
||||||
|
'lock_text' => '系统限制 %s 秒内只能点击交换按钮一次!',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ $lang_mybonus = array
|
|||||||
'reward_type_basic' => '基本獎勵',
|
'reward_type_basic' => '基本獎勵',
|
||||||
'reward_type_harem_addition' => '後宮加成',
|
'reward_type_harem_addition' => '後宮加成',
|
||||||
'bonus_base' => '基礎魔力',
|
'bonus_base' => '基礎魔力',
|
||||||
|
'lock_text' => '系統限製 %s 秒內只能點擊交換按鈕一次!',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i<
|
|||||||
'reward_type_basic' => 'Basic reward',
|
'reward_type_basic' => 'Basic reward',
|
||||||
'reward_type_harem_addition' => 'Harem addition',
|
'reward_type_harem_addition' => 'Harem addition',
|
||||||
'bonus_base' => 'Base bonus',
|
'bonus_base' => 'Base bonus',
|
||||||
|
'lock_text' => 'The system limits you to one click on the exchange button within %s seconds!',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
50
nexus/Database/NexusLock.php
Normal file
50
nexus/Database/NexusLock.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Nexus\Database;
|
||||||
|
|
||||||
|
use Illuminate\Cache\LuaScripts;
|
||||||
|
use Illuminate\Cache\RedisLock;
|
||||||
|
|
||||||
|
class NexusLock extends RedisLock
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Redis
|
||||||
|
*/
|
||||||
|
protected $redis;
|
||||||
|
/**
|
||||||
|
* NexusLock constructor.
|
||||||
|
* @param string $name
|
||||||
|
* @param int $seconds
|
||||||
|
* @param null $owner
|
||||||
|
*/
|
||||||
|
public function __construct($name, $seconds, $owner = null)
|
||||||
|
{
|
||||||
|
parent::__construct(NexusDB::redis(), $name, $seconds, $owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to acquire the lock.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function acquire()
|
||||||
|
{
|
||||||
|
if ($this->seconds > 0) {
|
||||||
|
return $this->redis->set($this->name, $this->owner, ['nx', 'ex' => $this->seconds]) == true;
|
||||||
|
} else {
|
||||||
|
return $this->redis->setnx($this->name, $this->owner) == true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release the lock.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function release()
|
||||||
|
{
|
||||||
|
return (bool) $this->redis->eval(LuaScripts::releaseLock(), [$this->name, $this->owner], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -429,8 +429,15 @@ JS;
|
|||||||
function hex_esc($matches) {
|
function hex_esc($matches) {
|
||||||
return sprintf("%02x", ord($matches[0]));
|
return sprintf("%02x", ord($matches[0]));
|
||||||
}
|
}
|
||||||
if ($enablenfo_main=='yes')
|
$infoTds = [];
|
||||||
tr($lang_details['row_torrent_info'], "<table><tr>" . (!empty($files_info) ? "<td class=\"no_border_wide\">" . $files_info . "</td>" : "") . "<td class=\"no_border_wide\"><b>".$lang_details['row_info_hash'].":</b> ".preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"]))."</td>". (user_can('torrentstructure') ? "<td class=\"no_border_wide\"><b>" . $lang_details['text_torrent_structure'] . "</b><a href=\"torrent_info.php?id=".$id."\">".$lang_details['text_torrent_info_note']."</a></td>" : "") . "</tr></table><span id='filelist'></span>",1);
|
if (!empty($files_info)) {
|
||||||
|
$infoTds[] = "<td class=\"no_border_wide\">" . $files_info . "</td>";
|
||||||
|
}
|
||||||
|
$infoTds[] = "<td class=\"no_border_wide\"><b>".$lang_details['row_info_hash'].":</b> ".preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"]))."</td>";
|
||||||
|
if (user_can('torrentstructure')) {
|
||||||
|
$infoTds[] = "<td class=\"no_border_wide\"><b>" . $lang_details['text_torrent_structure'] . "</b><a href=\"torrent_info.php?id=".$id."\">".$lang_details['text_torrent_info_note']."</a></td>";
|
||||||
|
}
|
||||||
|
tr($lang_details['row_torrent_info'], "<table><tr>" . implode("", $infoTds) . "</tr></table><span id='filelist'></span>",1);
|
||||||
tr($lang_details['row_hot_meter'], "<table><tr><td class=\"no_border_wide\"><b>" . $lang_details['text_views']."</b>". $row["views"] . "</td><td class=\"no_border_wide\"><b>" . $lang_details['text_hits']. "</b>" . $row["hits"] . "</td><td class=\"no_border_wide\"><b>" .$lang_details['text_snatched'] . "</b><a href=\"viewsnatches.php?id=".$id."\"><b>" . $row["times_completed"]. $lang_details['text_view_snatches'] . "</td><td class=\"no_border_wide\"><b>" . $lang_details['row_last_seeder']. "</b>" . gettime($row["last_action"]) . "</td></tr></table>",1);
|
tr($lang_details['row_hot_meter'], "<table><tr><td class=\"no_border_wide\"><b>" . $lang_details['text_views']."</b>". $row["views"] . "</td><td class=\"no_border_wide\"><b>" . $lang_details['text_hits']. "</b>" . $row["hits"] . "</td><td class=\"no_border_wide\"><b>" .$lang_details['text_snatched'] . "</b><a href=\"viewsnatches.php?id=".$id."\"><b>" . $row["times_completed"]. $lang_details['text_view_snatches'] . "</td><td class=\"no_border_wide\"><b>" . $lang_details['row_last_seeder']. "</b>" . gettime($row["last_action"]) . "</td></tr></table>",1);
|
||||||
$bwres = sql_query("SELECT uploadspeed.name AS upname, downloadspeed.name AS downname, isp.name AS ispname FROM users LEFT JOIN uploadspeed ON users.upload = uploadspeed.id LEFT JOIN downloadspeed ON users.download = downloadspeed.id LEFT JOIN isp ON users.isp = isp.id WHERE users.id=".$row['owner']);
|
$bwres = sql_query("SELECT uploadspeed.name AS upname, downloadspeed.name AS downname, isp.name AS ispname FROM users LEFT JOIN uploadspeed ON users.upload = uploadspeed.id LEFT JOIN downloadspeed ON users.download = downloadspeed.id LEFT JOIN isp ON users.isp = isp.id WHERE users.id=".$row['owner']);
|
||||||
$bwrow = mysql_fetch_array($bwres);
|
$bwrow = mysql_fetch_array($bwres);
|
||||||
|
|||||||
@@ -235,7 +235,8 @@ function bonusarray($option = 0){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$allBonus = bonusarray();
|
$allBonus = bonusarray();
|
||||||
|
$lockSeconds = 10;
|
||||||
|
$lockText = sprintf($lang_mybonus['lock_text'], $lockSeconds);
|
||||||
if ($bonus_tweak == "disable" || $bonus_tweak == "disablesave")
|
if ($bonus_tweak == "disable" || $bonus_tweak == "disablesave")
|
||||||
stderr($lang_mybonus['std_sorry'],$lang_mybonus['std_karma_system_disabled'].($bonus_tweak == "disablesave" ? "<b>".$lang_mybonus['std_points_active']."</b>" : ""),false);
|
stderr($lang_mybonus['std_sorry'],$lang_mybonus['std_karma_system_disabled'].($bonus_tweak == "disablesave" ? "<b>".$lang_mybonus['std_points_active']."</b>" : ""),false);
|
||||||
|
|
||||||
@@ -265,6 +266,8 @@ if (isset($do)) {
|
|||||||
$msg = $lang_mybonus['text_success_buy_medal'];
|
$msg = $lang_mybonus['text_success_buy_medal'];
|
||||||
elseif ($do == "attendance_card")
|
elseif ($do == "attendance_card")
|
||||||
$msg = $lang_mybonus['text_success_buy_attendance_card'];
|
$msg = $lang_mybonus['text_success_buy_attendance_card'];
|
||||||
|
elseif ($do == 'duplicated')
|
||||||
|
$msg = $lockText;
|
||||||
else
|
else
|
||||||
$msg = '';
|
$msg = '';
|
||||||
}
|
}
|
||||||
@@ -275,10 +278,10 @@ if (!$action) {
|
|||||||
print("<table align=\"center\" width=\"97%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n");
|
print("<table align=\"center\" width=\"97%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n");
|
||||||
print("<tr><td class=\"colhead\" colspan=\"4\" align=\"center\"><font class=\"big\">".$SITENAME.$lang_mybonus['text_karma_system']."</font></td></tr>\n");
|
print("<tr><td class=\"colhead\" colspan=\"4\" align=\"center\"><font class=\"big\">".$SITENAME.$lang_mybonus['text_karma_system']."</font></td></tr>\n");
|
||||||
if ($msg)
|
if ($msg)
|
||||||
print("<tr><td align=\"center\" colspan=\"4\"><font class=\"striking\">". $msg ."</font></td></tr>");
|
print("<tr><td align=\"center\" colspan=\"4\"><font class=\"striking\"><b>". $msg ."</b></font></td></tr>");
|
||||||
?>
|
?>
|
||||||
<tr><td class="text" align="center" colspan="4"><?php echo $lang_mybonus['text_exchange_your_karma']?><?php echo $bonus?><?php echo $lang_mybonus['text_for_goodies'] ?>
|
<tr><td class="text" align="center" colspan="4"><?php echo $lang_mybonus['text_exchange_your_karma']?><?php echo $bonus?><?php echo $lang_mybonus['text_for_goodies'] ?>
|
||||||
<br /><b><?php echo $lang_mybonus['text_no_buttons_note'] ?></b></td></tr>
|
<br /><b><?php echo $lang_mybonus['text_no_buttons_note'] ?></b><br /><small style="color: orangered">(<?php echo $lockText ?>)</small></td></tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
print("<tr><td class=\"colhead\" align=\"center\">".$lang_mybonus['col_option']."</td>".
|
print("<tr><td class=\"colhead\" align=\"center\">".$lang_mybonus['col_option']."</td>".
|
||||||
@@ -452,6 +455,7 @@ if ($factor > 0) {
|
|||||||
number_format($addition * $factor, 3)
|
number_format($addition * $factor, 3)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$summaryTable .= '</tbody></table>';
|
$summaryTable .= '</tbody></table>';
|
||||||
|
|
||||||
print '<div style="display: flex;justify-content: center;margin-top: 20px;">'.$summaryTable.'</div>';
|
print '<div style="display: flex;justify-content: center;margin-top: 20px;">'.$summaryTable.'</div>';
|
||||||
@@ -512,6 +516,12 @@ if ($action == "exchange") {
|
|||||||
|
|
||||||
if($CURUSER['seedbonus'] >= $points) {
|
if($CURUSER['seedbonus'] >= $points) {
|
||||||
$bonusRep = new \App\Repositories\BonusRepository();
|
$bonusRep = new \App\Repositories\BonusRepository();
|
||||||
|
$lockName = "user:$userid:exchange:bonus";
|
||||||
|
$lock = new \Nexus\Database\NexusLock($lockName, $lockSeconds);
|
||||||
|
if (!$lock->get()) {
|
||||||
|
do_log("[LOCKED], $lockName, $lockText");
|
||||||
|
nexus_redirect('mybonus.php?do=duplicated');
|
||||||
|
}
|
||||||
//=== trade for upload
|
//=== trade for upload
|
||||||
if($art == "traffic") {
|
if($art == "traffic") {
|
||||||
if ($CURUSER['uploaded'] > $dlamountlimit_bonus * 1073741824)//uploaded amount reach limit
|
if ($CURUSER['uploaded'] > $dlamountlimit_bonus * 1073741824)//uploaded amount reach limit
|
||||||
@@ -550,7 +560,7 @@ if ($action == "exchange") {
|
|||||||
// $bonuscomment = date("Y-m-d") . " - " .$points. " Points for invites.\n " .htmlspecialchars($bonuscomment);
|
// $bonuscomment = date("Y-m-d") . " - " .$points. " Points for invites.\n " .htmlspecialchars($bonuscomment);
|
||||||
// sql_query("UPDATE users SET invites = ".sqlesc($inv).", seedbonus = seedbonus - $points, bonuscomment=".sqlesc($bonuscomment)." WHERE id = ".sqlesc($userid)) or sqlerr(__FILE__, __LINE__);
|
// sql_query("UPDATE users SET invites = ".sqlesc($inv).", seedbonus = seedbonus - $points, bonuscomment=".sqlesc($bonuscomment)." WHERE id = ".sqlesc($userid)) or sqlerr(__FILE__, __LINE__);
|
||||||
$bonusRep->consumeUserBonus($CURUSER['id'], $points, \App\Models\BonusLogs::BUSINESS_TYPE_EXCHANGE_INVITE, $points. " Points for invites.", ['invites' => $inv, ]);
|
$bonusRep->consumeUserBonus($CURUSER['id'], $points, \App\Models\BonusLogs::BUSINESS_TYPE_EXCHANGE_INVITE, $points. " Points for invites.", ['invites' => $inv, ]);
|
||||||
nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=invite");
|
nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=invite");
|
||||||
}
|
}
|
||||||
//=== trade for special title
|
//=== trade for special title
|
||||||
/**** the $words array are words that you DO NOT want the user to have... use to filter "bad words" & user class...
|
/**** the $words array are words that you DO NOT want the user to have... use to filter "bad words" & user class...
|
||||||
|
|||||||
Reference in New Issue
Block a user