paid torent max_price&enabled configurable

This commit is contained in:
xiaomlove
2023-04-29 12:57:46 +08:00
parent 241485be0f
commit 73871a51ba
14 changed files with 59 additions and 13 deletions
+7 -2
View File
@@ -75,8 +75,13 @@ else {
"<input id=\"nfoupdate\" type=\"radio\" name=\"nfoaction\" value=\"update\" />".$lang_edit['radio_update']."</font><br /><input type=\"file\" name=\"nfo\" onchange=\"document.getElementById('nfoupdate').checked=true\" />", 1);
//price
if (user_can('torrent-set-price')) {
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" value="'.$row['price'].'" />&nbsp;&nbsp;' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
if (user_can('torrent-set-price') && get_setting("torrent.paid_torrent_enabled") == "yes") {
$maxPrice = get_setting("torrent.max_price");
$pricePlaceholder = "";
if ($maxPrice > 0) {
$pricePlaceholder = nexus_trans("label.torrent.max_price_help", ["max_price" => $maxPrice]);
}
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" value="'.$row['price'].'" placeholder="'.$pricePlaceholder.'" />&nbsp;&nbsp;' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
}
print("<tr><td class=\"rowhead\">".$lang_edit['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
+3
View File
@@ -340,6 +340,7 @@ if (get_setting('main.spsct') == 'yes') {
</td>
</tr>
<tr>
<?php if(get_setting("torrent.paid_torrent_enabled") == "yes"){?>
<tr>
<td class="rowhead"><?php echo $lang_getrss['row_paid']?>
</td>
@@ -347,8 +348,10 @@ if (get_setting('main.spsct') == 'yes') {
<label><input type="radio" name="paid" value="0" checked><?php echo $lang_getrss['paid_no']?></label>
<label><input type="radio" name="paid" value="1"><?php echo $lang_getrss['paid_yes']?></label>
<label><input type="radio" name="paid" value="2"><?php echo $lang_getrss['paid_all']?></label>
<div><?php echo $lang_getrss['row_paid_help'] ?></div>
</td>
</tr>
<?php }?>
<td class="rowhead"><?php echo $lang_getrss['row_item_title_type']?>
</td>
<td class="rowfollow" align="left">
+4 -2
View File
@@ -158,7 +158,7 @@ elseif($action == 'savesettings_torrent') // save account
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
'download_support_passkey', 'claim_enabled', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus',
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded', 'approval_status_icon_enabled', 'approval_status_none_visible',
'nfo_view_style_default', 'tax_factor',
'nfo_view_style_default', 'tax_factor', 'max_price', 'paid_torrent_enabled'
);
$validConfig = apply_filter('setting_valid_config', $validConfig);
GetVar($validConfig);
@@ -741,7 +741,9 @@ elseif ($action == 'torrentsettings')
}
tr($lang_settings['row_' . $name], $nfoViewStyleRadio, 1);
tr($lang_settings['row_tax_factor'],"<input type='text' name=tax_factor style=\"width: 100px\" value={$TORRENT['tax_factor']}> ".$lang_settings['text_tax_factor_note'], 1);
yesorno($lang_settings['row_paid_torrent_enabled'], 'paid_torrent_enabled', $TORRENT["paid_torrent_enabled"], $lang_settings['text_paid_torrent_enabled_note']);
tr($lang_settings['row_tax_factor'],"<input type='number' name=tax_factor style=\"width: 100px\" value={$TORRENT['tax_factor']}> ".$lang_settings['text_tax_factor_note'], 1);
tr($lang_settings['row_max_price'],"<input type='number' name=max_price style=\"width: 100px\" value={$TORRENT['max_price']}> ".$lang_settings['text_max_price_note'], 1);
yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']);
tr($lang_settings['row_random_promotion'], $lang_settings['text_random_promotion_note_one']."<ul><li><input type='text' style=\"width: 50px\" name=randomhalfleech value='".(isset($TORRENT["randomhalfleech"]) ? $TORRENT["randomhalfleech"] : 5 )."'>".$lang_settings['text_halfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomfree value='".(isset($TORRENT["randomfree"]) ? $TORRENT["randomfree"] : 2 )."'>".$lang_settings['text_free_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoup value='".(isset($TORRENT["randomtwoup"]) ? $TORRENT["randomtwoup"] : 2 )."'>".$lang_settings['text_twoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoupfree value='".(isset($TORRENT["randomtwoupfree"]) ? $TORRENT["randomtwoupfree"] : 1 )."'>".$lang_settings['text_freetwoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwouphalfdown value='".(isset($TORRENT["randomtwouphalfdown"]) ? $TORRENT["randomtwouphalfdown"] : 0 )."'>".$lang_settings['text_twouphalfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomthirtypercentdown value='".(isset($TORRENT["randomthirtypercentdown"]) ? $TORRENT["randomthirtypercentdown"] : 0 )."'>".$lang_settings['text_thirtypercentleech_chance_becoming']."</li></ul>".$lang_settings['text_random_promotion_note_two'], 1);
+7 -1
View File
@@ -13,6 +13,12 @@ if (!mkglobal("id:name:descr:type")){
global $lang_takeedit;
bark($lang_takeedit['std_missing_form_data']);
}
//check max price
$maxPrice = get_setting("torrent.max_price");
$paidTorrentEnabled = get_setting("torrent.paid_torrent_enabled") == "yes";
if ($maxPrice > 0 && $_POST['price'] > $maxPrice && $paidTorrentEnabled) {
bark('price too much');
}
$id = intval($id ?? 0);
if (!$id)
@@ -219,7 +225,7 @@ if (isset($_POST['hr'][$newcatmode]) && isset(\App\Models\Torrent::$hrStatus[$_P
* price
* @since 1.8.0
*/
if (user_can('torrent-set-price')) {
if (user_can('torrent-set-price') && $paidTorrentEnabled) {
$updateset[] = "price = " . sqlesc($_POST['price'] ?? 0);
}
+8 -1
View File
@@ -98,6 +98,13 @@ bark("eek");
if (!filesize($tmpname))
bark($lang_takeupload['std_empty_file']);
//check max price
$maxPrice = get_setting("torrent.max_price");
$paidTorrentEnabled = get_setting("torrent.paid_torrent_enabled") == "yes";
if ($maxPrice > 0 && $_POST['price'] > $maxPrice && $paidTorrentEnabled) {
bark('price too much');
}
try {
$dict = \Rhilip\Bencode\Bencode::load($tmpname);
} catch (\Rhilip\Bencode\ParseErrorException $e) {
@@ -373,7 +380,7 @@ if(user_can('torrentmanage') && ($CURUSER['picker'] == 'yes' || get_user_class()
if (user_can('torrent-approval-allow-automatic')) {
$insert['approval_status'] = \App\Models\Torrent::APPROVAL_STATUS_ALLOW;
}
if (user_can('torrent-set-price')) {
if (user_can('torrent-set-price') && $paidTorrentEnabled) {
$insert['price'] = $_POST['price'] ?? 0;
}
do_log("[INSERT_TORRENT]: " . nexus_json_encode($insert));
+7 -2
View File
@@ -74,8 +74,13 @@ stdhead($lang_upload['head_upload']);
tr($lang_upload['row_nfo_file'], "<input type=\"file\" class=\"file\" name=\"nfo\" /><br /><font class=\"medium\">".$lang_upload['text_only_viewed_by'].get_user_class_name($viewnfo_class,false,true,true).$lang_upload['text_or_above']."</font>", 1);
}
//price
if (user_can('torrent-set-price')) {
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" />&nbsp;&nbsp;' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
if (user_can('torrent-set-price') && get_setting("torrent.paid_torrent_enabled") == "yes") {
$maxPrice = get_setting("torrent.max_price");
$pricePlaceholder = "";
if ($maxPrice > 0) {
$pricePlaceholder = nexus_trans("label.torrent.max_price_help", ["max_price" => $maxPrice]);
}
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" placeholder="'.$pricePlaceholder.'" />&nbsp;&nbsp;' . nexus_trans('label.torrent.price_help', ['tax_factor' => (floatval(get_setting('torrent.tax_factor', 0)) * 100) . '%']), 1);
}
print("<tr><td class=\"rowhead\" style='padding: 3px' valign=\"top\">".$lang_upload['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");