mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-27 22:47:23 +08:00
custom donation content
This commit is contained in:
+55
-9
@@ -9,6 +9,13 @@ class Setting extends NexusModel
|
|||||||
{
|
{
|
||||||
protected $fillable = ['name', 'value'];
|
protected $fillable = ['name', 'value'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get setting autoload = yes with cache
|
||||||
|
*
|
||||||
|
* @param null $name
|
||||||
|
* @param null $default
|
||||||
|
* @return array|\ArrayAccess|false|int|mixed|string|null
|
||||||
|
*/
|
||||||
public static function get($name = null, $default = null)
|
public static function get($name = null, $default = null)
|
||||||
{
|
{
|
||||||
$settings = NexusDB::remember("nexus_settings_in_laravel", 600, function () {
|
$settings = NexusDB::remember("nexus_settings_in_laravel", 600, function () {
|
||||||
@@ -20,18 +27,19 @@ class Setting extends NexusModel
|
|||||||
return Arr::get($settings, $name, $default);
|
return Arr::get($settings, $name, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFromDb($name = null, $default = null)
|
/**
|
||||||
|
* get setting autoload = yes without cache
|
||||||
|
*
|
||||||
|
* @param null $name
|
||||||
|
* @param null $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getFromDb($name = null, $default = null): mixed
|
||||||
{
|
{
|
||||||
$rows = self::query()->get(['name', 'value']);
|
$rows = self::query()->where('autoload', 'yes')->get(['name', 'value']);
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$value = $row->value;
|
$value = self::normalizeValue($row);
|
||||||
if (!is_null($value)) {
|
|
||||||
$arr = json_decode($value, true);
|
|
||||||
if (is_array($arr)) {
|
|
||||||
$value = $arr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Arr::set($result, $row->name, $value);
|
Arr::set($result, $row->name, $value);
|
||||||
}
|
}
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
@@ -40,4 +48,42 @@ class Setting extends NexusModel
|
|||||||
return Arr::get($result, $name, $default);
|
return Arr::get($result, $name, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get from db by name, generally used for `autoload` = 'no'
|
||||||
|
*
|
||||||
|
* @param $name
|
||||||
|
* @param null $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getByName($name, $default = null): mixed
|
||||||
|
{
|
||||||
|
$result = self::query()->where('name', $name)->first();
|
||||||
|
if ($result) {
|
||||||
|
return self::normalizeValue($result);
|
||||||
|
}
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getByWhereRaw($whereRaw): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$list = self::query()->whereRaw($whereRaw)->get();
|
||||||
|
foreach ($list as $value) {
|
||||||
|
Arr::set($result, $value->name, self::normalizeValue($value));
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function normalizeValue(Setting $setting)
|
||||||
|
{
|
||||||
|
$value = $setting->value;
|
||||||
|
if (!is_null($value)) {
|
||||||
|
$arr = json_decode($value, true);
|
||||||
|
if (is_array($arr)) {
|
||||||
|
$value = $arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class ClaimRepository extends BaseRepository
|
|||||||
public function store($uid, $torrentId)
|
public function store($uid, $torrentId)
|
||||||
{
|
{
|
||||||
$isEnabled = Claim::getConfigIsEnabled();
|
$isEnabled = Claim::getConfigIsEnabled();
|
||||||
if ($isEnabled) {
|
if (!$isEnabled) {
|
||||||
throw new \RuntimeException(nexus_trans("torrent.claim_disabled"));
|
throw new \RuntimeException(nexus_trans("torrent.claim_disabled"));
|
||||||
}
|
}
|
||||||
$exists = Claim::query()->where('uid', $uid)->where('torrent_id', $torrentId)->exists();
|
$exists = Claim::query()->where('uid', $uid)->where('torrent_id', $torrentId)->exists();
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->enum('autoload', ['yes', 'no'])->default('yes');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('autoload');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4938,17 +4938,17 @@ function torrentTags($tags = 0, $type = 'checkbox')
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSetting($prefix, $nameAndValue)
|
function saveSetting($prefix, $nameAndValue, $autoload = 'yes')
|
||||||
{
|
{
|
||||||
$prefix = strtolower($prefix);
|
$prefix = strtolower($prefix);
|
||||||
$datetimeNow = date('Y-m-d H:i:s');
|
$datetimeNow = date('Y-m-d H:i:s');
|
||||||
$sql = "insert into settings (name, value, created_at, updated_at) values ";
|
$sql = "insert into settings (name, value, created_at, updated_at, autoload) values ";
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($nameAndValue as $name => $value) {
|
foreach ($nameAndValue as $name => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = json_encode($value);
|
$value = json_encode($value);
|
||||||
}
|
}
|
||||||
$data[] = sprintf("(%s, %s, %s, %s)", sqlesc("$prefix.$name"), sqlesc($value), sqlesc($datetimeNow), sqlesc($datetimeNow));
|
$data[] = sprintf("(%s, %s, %s, %s, '%s')", sqlesc("$prefix.$name"), sqlesc($value), sqlesc($datetimeNow), sqlesc($datetimeNow), $autoload);
|
||||||
}
|
}
|
||||||
$sql .= implode(",", $data) . " on duplicate key update value = values(value)";
|
$sql .= implode(",", $data) . " on duplicate key update value = values(value)";
|
||||||
sql_query($sql) or sqlerr(__FILE__, __LINE__);
|
sql_query($sql) or sqlerr(__FILE__, __LINE__);
|
||||||
|
|||||||
@@ -753,6 +753,11 @@ $lang_settings = array
|
|||||||
'claim_give_up_deduct_user_bonus' => '用户主动放弃认领扣除用户 %s 魔力。',
|
'claim_give_up_deduct_user_bonus' => '用户主动放弃认领扣除用户 %s 魔力。',
|
||||||
'claim_reach_standard' => '达标标准:每月做种时间大于等于 %s 小时, 或上传量大于等于其体积 %s 倍。',
|
'claim_reach_standard' => '达标标准:每月做种时间大于等于 %s 小时, 或上传量大于等于其体积 %s 倍。',
|
||||||
'claim_bonus_multiplier' => '计算达标种子魔力奖励是正常魔力值的 %s 倍。',
|
'claim_bonus_multiplier' => '计算达标种子魔力奖励是正常魔力值的 %s 倍。',
|
||||||
|
'row_misc_settings' => '其他设定',
|
||||||
|
'submit_misc_settings' => '其他设定',
|
||||||
|
'text_misc_settings_note' => '配置其他杂项。',
|
||||||
|
'row_misc_donation_custom' => '捐赠自定义内容',
|
||||||
|
'text_donation_custom_note' => '捐赠页自定义的内容,展示于支付宝、PayPal上面。支持 <b><a href="tags.php" target="_blank">bbcode 标签</a></b>',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -752,6 +752,11 @@ $lang_settings = array
|
|||||||
'claim_give_up_deduct_user_bonus' => '用戶主動放棄認領扣除用戶 %s 魔力。',
|
'claim_give_up_deduct_user_bonus' => '用戶主動放棄認領扣除用戶 %s 魔力。',
|
||||||
'claim_reach_standard' => '達標標準:每月做種時間大於等於 %s 小時, 或上傳量大於等於其體積 %s 倍。',
|
'claim_reach_standard' => '達標標準:每月做種時間大於等於 %s 小時, 或上傳量大於等於其體積 %s 倍。',
|
||||||
'claim_bonus_multiplier' => '計算達標種子魔力獎勵是正常魔力值的 %s 倍。',
|
'claim_bonus_multiplier' => '計算達標種子魔力獎勵是正常魔力值的 %s 倍。',
|
||||||
|
'row_misc_settings' => '其他設定',
|
||||||
|
'submit_misc_settings' => '其他設定',
|
||||||
|
'text_misc_settings_note' => '配置其他雜項。',
|
||||||
|
'row_misc_donation_custom' => '捐贈自定義內容',
|
||||||
|
'text_donation_custom_note' => '捐贈頁自定義的內容,展示於支付寶、PayPal上面。支持 <b><a href="tags.php" target="_blank">bbcode 標簽</a></b>',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -752,6 +752,11 @@ $lang_settings = array
|
|||||||
'claim_give_up_deduct_user_bonus' => 'User actively gives up claiming deduct user %s bonus.',
|
'claim_give_up_deduct_user_bonus' => 'User actively gives up claiming deduct user %s bonus.',
|
||||||
'claim_reach_standard' => 'Standard: Monthly seeding time greater than or equal to %s of hours, or uploaded greater than or equal to %s times its size.',
|
'claim_reach_standard' => 'Standard: Monthly seeding time greater than or equal to %s of hours, or uploaded greater than or equal to %s times its size.',
|
||||||
'claim_bonus_multiplier' => 'Calculate %s times the normal bonus value of the attained seed bonus.',
|
'claim_bonus_multiplier' => 'Calculate %s times the normal bonus value of the attained seed bonus.',
|
||||||
|
'row_misc_settings' => 'Misc settings',
|
||||||
|
'submit_misc_settings' => 'Misc settings',
|
||||||
|
'text_misc_settings_note' => 'Misc settings',
|
||||||
|
'row_misc_donation_custom' => 'Donation custom',
|
||||||
|
'text_donation_custom_note' => 'Donation page custom content, displayed above Alipay, PayPal. Support <b><a href="tags.php" target="_blank">bbcode tag</a></b>',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
+11
-5
@@ -10,8 +10,9 @@ $do = $_GET['do'] ?? '';
|
|||||||
if ($do == 'thanks') {
|
if ($do == 'thanks') {
|
||||||
stderr($lang_donate['std_success'], $lang_donate['std_donation_success_note_one']."<a href=\"sendmessage.php?receiver=".$ACCOUNTANTID."\"><b>".$lang_donate['std_here']."</b></a>".$lang_donate['std_donation_success_note_two'], false);
|
stderr($lang_donate['std_success'], $lang_donate['std_donation_success_note_one']."<a href=\"sendmessage.php?receiver=".$ACCOUNTANTID."\"><b>".$lang_donate['std_here']."</b></a>".$lang_donate['std_donation_success_note_two'], false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$custom = trim(\App\Models\Setting::getByName('misc.donation_custom'));
|
||||||
$paypal = safe_email($PAYPALACCOUNT);
|
$paypal = safe_email($PAYPALACCOUNT);
|
||||||
if ($paypal && check_email($paypal))
|
if ($paypal && check_email($paypal))
|
||||||
$showpaypal = true;
|
$showpaypal = true;
|
||||||
@@ -27,14 +28,19 @@ else
|
|||||||
$tdattr = "width=\"50%\"";
|
$tdattr = "width=\"50%\"";
|
||||||
elseif ($showpaypal || $showalipay)
|
elseif ($showpaypal || $showalipay)
|
||||||
$tdattr = "colspan=\"2\" width=\"100%\"";
|
$tdattr = "colspan=\"2\" width=\"100%\"";
|
||||||
else
|
|
||||||
stderr($lang_donate['std_error'], $lang_donate['std_no_donation_account_available'], false);
|
if (!$showpaypal && !$showalipay && !$custom) {
|
||||||
|
stderr($lang_donate['std_error'], $lang_donate['std_no_donation_account_available'], false);
|
||||||
|
}
|
||||||
|
|
||||||
stdhead($lang_donate['head_donation']);
|
stdhead($lang_donate['head_donation']);
|
||||||
begin_main_frame();
|
begin_main_frame();
|
||||||
print("<h2>".$lang_donate['text_donate']."</h2>");
|
print("<h2>".$lang_donate['text_donate']."</h2>");
|
||||||
print("<table width=100%><tr>");
|
print("<table width=100%>");
|
||||||
print("<td colspan=2 class=text align=left>".$lang_donate['text_donation_note']."</td></tr>");
|
print("<tr><td colspan=2 class=text align=left>".$lang_donate['text_donation_note']."</td></tr>");
|
||||||
|
if ($custom) {
|
||||||
|
echo sprintf('<tr><td class="text" align="left">%s</td></tr>', format_comment($custom));
|
||||||
|
}
|
||||||
print("<tr>");
|
print("<tr>");
|
||||||
if ($showpaypal){
|
if ($showpaypal){
|
||||||
?>
|
?>
|
||||||
|
|||||||
+27
-1
@@ -23,7 +23,7 @@ function yesorno($title, $name, $value, $note="")
|
|||||||
}
|
}
|
||||||
|
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : 'showmenu';
|
$action = isset($_POST['action']) ? $_POST['action'] : 'showmenu';
|
||||||
$allowed_actions = array('basicsettings','mainsettings','smtpsettings','securitysettings','authoritysettings','tweaksettings', 'botsettings','codesettings','bonussettings','accountsettings','torrentsettings', 'attachmentsettings', 'advertisementsettings', 'savesettings_basic', 'savesettings_main','savesettings_smtp','savesettings_security','savesettings_authority','savesettings_tweak','savesettings_bot','savesettings_code','savesettings_bonus', 'savesettings_account','savesettings_torrent', 'savesettings_attachment', 'savesettings_advertisement', 'showmenu');
|
$allowed_actions = array('basicsettings','mainsettings','smtpsettings','securitysettings','authoritysettings','tweaksettings', 'botsettings','codesettings','bonussettings','accountsettings','torrentsettings', 'attachmentsettings', 'advertisementsettings', 'savesettings_basic', 'savesettings_main','savesettings_smtp','savesettings_security','savesettings_authority','savesettings_tweak','savesettings_bot','savesettings_code','savesettings_bonus', 'savesettings_account','savesettings_torrent', 'savesettings_attachment', 'savesettings_advertisement', 'showmenu', 'miscsettings', 'savesettings_misc');
|
||||||
if (!in_array($action, $allowed_actions))
|
if (!in_array($action, $allowed_actions))
|
||||||
$action = 'showmenu';
|
$action = 'showmenu';
|
||||||
$notice = "<h1 align=\"center\"><a class=\"faqlink\" href=\"settings.php\">".$lang_settings['text_website_settings']."</a></h1><table cellspacing=\"0\" cellpadding=\"10\" width=\"97%\"><tr><td colspan=\"2\" style='padding: 10px; background: black' align=\"center\">
|
$notice = "<h1 align=\"center\"><a class=\"faqlink\" href=\"settings.php\">".$lang_settings['text_website_settings']."</a></h1><table cellspacing=\"0\" cellpadding=\"10\" width=\"97%\"><tr><td colspan=\"2\" style='padding: 10px; background: black' align=\"center\">
|
||||||
@@ -267,6 +267,20 @@ elseif ($action == 'savesettings_advertisement') // save advertisement
|
|||||||
write_log("Tracker ADVERTISEMENT settings updated by {$CURUSER['username']}. $actiontime",'mod');
|
write_log("Tracker ADVERTISEMENT settings updated by {$CURUSER['username']}. $actiontime",'mod');
|
||||||
go_back();
|
go_back();
|
||||||
}
|
}
|
||||||
|
elseif ($action == 'savesettings_misc')
|
||||||
|
{
|
||||||
|
stdhead($lang_settings['row_misc_settings']);
|
||||||
|
$validConfig = array('donation_custom', );
|
||||||
|
GetVar($validConfig);
|
||||||
|
$data = [];
|
||||||
|
foreach($validConfig as $config) {
|
||||||
|
$data[$config] = $$config ?? null;
|
||||||
|
}
|
||||||
|
saveSetting('misc', $data, 'no');
|
||||||
|
$actiontime = date("F j, Y, g:i a");
|
||||||
|
write_log("Misc settings updated by {$CURUSER['username']}. $actiontime",'mod');
|
||||||
|
go_back();
|
||||||
|
}
|
||||||
elseif ($action == 'tweaksettings') // tweak settings
|
elseif ($action == 'tweaksettings') // tweak settings
|
||||||
{
|
{
|
||||||
$TWEAK = get_setting_from_db('tweak');
|
$TWEAK = get_setting_from_db('tweak');
|
||||||
@@ -817,6 +831,17 @@ JS;
|
|||||||
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
|
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
|
||||||
print ("</form>");
|
print ("</form>");
|
||||||
}
|
}
|
||||||
|
elseif ($action == 'miscsettings')
|
||||||
|
{
|
||||||
|
$result = \App\Models\Setting::getByWhereRaw("name like 'misc.%'");
|
||||||
|
$misc = $result['misc'] ?? [];
|
||||||
|
stdhead($lang_settings['head_torrent_settings']);
|
||||||
|
print ($notice);
|
||||||
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_misc'>");
|
||||||
|
tr($lang_settings['row_misc_donation_custom'],"<textarea cols=\"100\" rows=\"10\" name='donation_custom'>".($misc['donation_custom'] ?? '')."</textarea><br/>".$lang_settings['text_donation_custom_note'], 1);
|
||||||
|
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
|
||||||
|
print ("</form>");
|
||||||
|
}
|
||||||
elseif ($action == 'showmenu') // settings main page
|
elseif ($action == 'showmenu') // settings main page
|
||||||
{
|
{
|
||||||
stdhead($lang_settings['head_website_settings']);
|
stdhead($lang_settings['head_website_settings']);
|
||||||
@@ -832,6 +857,7 @@ elseif ($action == 'showmenu') // settings main page
|
|||||||
tr($lang_settings['row_torrents_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='torrentsettings'><input type='submit' value=\"".$lang_settings['submit_torrents_settings']."\"> ".$lang_settings['text_torrents_settings_note']."</form>", 1);
|
tr($lang_settings['row_torrents_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='torrentsettings'><input type='submit' value=\"".$lang_settings['submit_torrents_settings']."\"> ".$lang_settings['text_torrents_settings_note']."</form>", 1);
|
||||||
tr($lang_settings['row_attachment_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='attachmentsettings'><input type='submit' value=\"".$lang_settings['submit_attachment_settings']."\"> ".$lang_settings['text_attachment_settings_note']."</form>", 1);
|
tr($lang_settings['row_attachment_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='attachmentsettings'><input type='submit' value=\"".$lang_settings['submit_attachment_settings']."\"> ".$lang_settings['text_attachment_settings_note']."</form>", 1);
|
||||||
tr($lang_settings['row_advertisement_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='advertisementsettings'><input type='submit' value=\"".$lang_settings['submit_advertisement_settings']."\"> ".$lang_settings['text_advertisement_settings_note']."</form>", 1);
|
tr($lang_settings['row_advertisement_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='advertisementsettings'><input type='submit' value=\"".$lang_settings['submit_advertisement_settings']."\"> ".$lang_settings['text_advertisement_settings_note']."</form>", 1);
|
||||||
|
tr($lang_settings['row_misc_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='miscsettings'><input type='submit' value=\"".$lang_settings['submit_misc_settings']."\"> ".$lang_settings['text_misc_settings_note']."</form>", 1);
|
||||||
// tr($lang_settings['row_code_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='codesettings'><input type='submit' value=\"".$lang_settings['submit_code_settings']."\"> ".$lang_settings['text_code_settings_note']."</form>", 1);
|
// tr($lang_settings['row_code_settings'], "<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='codesettings'><input type='submit' value=\"".$lang_settings['submit_code_settings']."\"> ".$lang_settings['text_code_settings_note']."</form>", 1);
|
||||||
}
|
}
|
||||||
print("</table>");
|
print("</table>");
|
||||||
|
|||||||
Reference in New Issue
Block a user