mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-29 08:27:23 +08:00
paid torrent
This commit is contained in:
+7
-1
@@ -126,7 +126,7 @@ elseif ($az['showclienterror'] == 'yes'){
|
||||
}
|
||||
|
||||
// check torrent based on info_hash
|
||||
$checkTorrentSql = "SELECT torrents.id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, added, banned, hr, approval_status, categories.mode FROM torrents left join categories on torrents.category = categories.id WHERE " . hash_where("info_hash", $info_hash);
|
||||
$checkTorrentSql = "SELECT torrents.id, size, owner, sp_state, seeders, leechers, UNIX_TIMESTAMP(added) AS ts, added, banned, hr, approval_status, price, categories.mode FROM torrents left join categories on torrents.category = categories.id WHERE " . hash_where("info_hash", $info_hash);
|
||||
if (!$torrent = $Cache->get_value('torrent_hash_'.$info_hash.'_content')){
|
||||
$res = sql_query($checkTorrentSql);
|
||||
$torrent = mysql_fetch_array($res);
|
||||
@@ -152,6 +152,12 @@ if ($torrent['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW &&
|
||||
err("torrent review not approved");
|
||||
}
|
||||
}
|
||||
if (isset($torrent['price']) && $torrent['price'] > 0 && $torrent['owner'] != $userid) {
|
||||
$hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $userid)->where('torrent_id', $torrent['id'])->exists();
|
||||
if (!$hasBuy) {
|
||||
err("You have not buy the torrent yet");
|
||||
}
|
||||
}
|
||||
|
||||
// select peers info from peers table for this torrent
|
||||
$torrentid = $torrent["id"];
|
||||
|
||||
+14
-3
@@ -11,7 +11,7 @@ if (!isset($id) || !$id)
|
||||
die();
|
||||
|
||||
$taxonomyFields = "sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name";
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, torrents.approval_status,
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, torrents.approval_status, torrents.price,
|
||||
categories.name AS cat_name, categories.mode as search_box_id, $taxonomyFields
|
||||
FROM torrents LEFT JOIN categories ON torrents.category = categories.id
|
||||
LEFT JOIN sources ON torrents.source = sources.id
|
||||
@@ -74,7 +74,8 @@ if (!$row) {
|
||||
$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
|
||||
$hrImg = get_hr_img($row, $row['search_box_id']);
|
||||
$approvalStatusIcon = $torrentRep->renderApprovalStatus($row["approval_status"]);
|
||||
$s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? " ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon;
|
||||
$paidIcon = $torrentRep->getPaidIcon($row, 20);
|
||||
$s=htmlspecialchars($row["name"]).$banned_torrent.$paidIcon.($sp_torrent ? " ".$sp_torrent : "").($sp_torrent_sub) . $hrImg . $approvalStatusIcon;
|
||||
print("<h1 align=\"center\" id=\"top\">".$s."</h1>\n");
|
||||
|
||||
//Banned reason
|
||||
@@ -162,7 +163,17 @@ if (!$row) {
|
||||
tr($lang_details['row_basic_info'], $size_info.$type_info.$taxonomyRendered, 1);
|
||||
$actions = [];
|
||||
if ($CURUSER["downloadpos"] != "no") {
|
||||
$actions[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" /> <b><font class=\"small\">".$lang_details['text_download_torrent']."</font></b></a>";
|
||||
$hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $CURUSER['id'])->where('torrent_id', $id)->exists();
|
||||
if ($row['price'] > 0) {
|
||||
if ($hasBuy) {
|
||||
$downloadBtn = $lang_details['text_download_bought_torrent'];
|
||||
} else {
|
||||
$downloadBtn = sprintf($lang_details['text_download_paid_torrent'], number_format($row['price']));
|
||||
}
|
||||
} else {
|
||||
$downloadBtn = $lang_details['text_download_torrent'];
|
||||
}
|
||||
$actions[] = "<a title=\"".$lang_details['title_download_torrent']."\" href=\"download.php?id=".$id."\"><img class=\"dt_download\" src=\"pic/trans.gif\" alt=\"download\" /> <b><font class=\"small\">".$downloadBtn."</font></b></a>";
|
||||
}
|
||||
if ($owned == 1) {
|
||||
$actions[] = "<$editlink><img class=\"dt_edit\" src=\"pic/trans.gif\" alt=\"edit\" /> <b><font class=\"small\">".(user_can('torrentmanage') ? $lang_details['text_edit_and_delete_torrent'] : $lang_details['text_edit_torrent']). "</font></b></a>";
|
||||
|
||||
+13
-1
@@ -88,7 +88,7 @@ $trackerSchemaAndHost = get_tracker_schema_and_host();
|
||||
$ssl_torrent = $trackerSchemaAndHost['ssl_torrent'];
|
||||
$base_announce_url = $trackerSchemaAndHost['base_announce_url'];
|
||||
|
||||
$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, torrents.approval_status, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
$res = sql_query("SELECT torrents.name, torrents.filename, torrents.save_as, torrents.size, torrents.owner, torrents.banned, torrents.approval_status, torrents.price, categories.mode as search_box_id FROM torrents left join categories on torrents.category = categories.id WHERE torrents.id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
$row = mysql_fetch_assoc($res);
|
||||
if (!$row) {
|
||||
do_log("[TORRENT_NOT_EXISTS_IN_DATABASE] $id", 'error');
|
||||
@@ -107,6 +107,7 @@ if (filesize($fn) == 0) {
|
||||
do_log("[TORRENT_NOT_VALID_SIZE_ZERO] $fn",'error');
|
||||
httperr();
|
||||
}
|
||||
|
||||
$approvalNotAllowed = $row['approval_status'] != \App\Models\Torrent::APPROVAL_STATUS_ALLOW && get_setting('torrent.approval_status_none_visible') == 'no';
|
||||
$allowOwnerDownload = $row['owner'] == $CURUSER['id'];
|
||||
$canSeedBanned = user_can('seebanned');
|
||||
@@ -116,6 +117,17 @@ if ((($row['banned'] == 'yes' || ($approvalNotAllowed && !$allowOwnerDownload))
|
||||
denyDownload();
|
||||
}
|
||||
|
||||
if ($row['price'] > 0 && $CURUSER['id'] != $row['owner']) {
|
||||
$hasBuy = \App\Models\TorrentBuyLog::query()->where('uid', $CURUSER['id'])->where('torrent_id', $id)->exists();
|
||||
if (!$hasBuy) {
|
||||
if ($CURUSER['seedbonus'] < $row['price']) {
|
||||
stderr('Error', nexus_trans('bonus.not_enough', ['require_bonus' => number_format($row['price']), 'now_bonus' => number_format($CURUSER['seedbonus'])]));
|
||||
}
|
||||
$bonusRep = new \App\Repositories\BonusRepository();
|
||||
$bonusRep->consumeToBuyTorrent($CURUSER['id'], $id, 'Web');
|
||||
}
|
||||
}
|
||||
|
||||
sql_query("UPDATE torrents SET hits = hits + 1 WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
//require_once "include/benc.php";
|
||||
|
||||
+7
-1
@@ -73,7 +73,13 @@ else {
|
||||
tr($lang_edit['row_nfo_file'], "<font class=\"medium\"><input type=\"radio\" name=\"nfoaction\" value=\"keep\" checked=\"checked\" />".$lang_edit['radio_keep_current'].
|
||||
"<input type=\"radio\" name=\"nfoaction\" value=\"remove\" />".$lang_edit['radio_remove'].
|
||||
"<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);
|
||||
print("<tr><td class=\"rowhead\">".$lang_edit['row_description']."<font color=\"red\">*</font></td><td class=\"rowfollow\">");
|
||||
|
||||
//price
|
||||
if (user_can('torrent-set-price')) {
|
||||
tr(nexus_trans('label.torrent.price'), '<input type="number" min="0" name="price" value="'.$row['price'].'" /> ' . 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\">");
|
||||
textbbcode("edittorrent","descr",($row["descr"]), false, 130, true);
|
||||
print("</td></tr>");
|
||||
|
||||
|
||||
@@ -163,6 +163,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
}
|
||||
if (!empty($_POST['sticky']) && is_array($_POST['sticky'])) {
|
||||
$query[] = "sticky=" . implode(',', $_POST['sticky']);
|
||||
}
|
||||
if (isset($_POST['paid'])) {
|
||||
$query[] = "paid=" . $_POST['paid'];
|
||||
}
|
||||
$inclbookmarked=intval($_POST['inclbookmarked'] ?? 0);
|
||||
if($inclbookmarked)
|
||||
@@ -337,6 +340,15 @@ if (get_setting('main.spsct') == 'yes') {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_paid']?>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_item_title_type']?>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
|
||||
+5
-2
@@ -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',
|
||||
'nfo_view_style_default', 'tax_factor',
|
||||
);
|
||||
$validConfig = apply_filter('setting_valid_config', $validConfig);
|
||||
GetVar($validConfig);
|
||||
@@ -225,7 +225,7 @@ elseif ($action == 'savesettings_authority') // save user authority
|
||||
'torrentstructure','sendinvite','viewhistory','topten','log','confilog','userprofile', 'torrenthistory','prfmanage', 'cruprfmanage',
|
||||
'uploadsub','delownsub','submanage','updateextinfo', 'viewanonymous','beanonymous','addoffer','offermanage', 'upload','uploadspecial',
|
||||
'view_special_torrent','movetorrent','chrmanage','viewinvite', 'buyinvite','seebanned','againstoffer','userbar', 'torrent-approval',
|
||||
'torrent-delete', 'user-delete', 'user-change-class', 'torrent-set-special-tag', 'torrent-approval-allow-automatic'
|
||||
'torrent-delete', 'user-delete', 'user-change-class', 'torrent-set-special-tag', 'torrent-approval-allow-automatic', 'torrent-set-price'
|
||||
);
|
||||
GetVar($validConfig);
|
||||
$AUTHORITY = [];
|
||||
@@ -459,6 +459,7 @@ elseif ($action == 'authoritysettings') //Authority settings
|
||||
tr(nexus_trans('permission.torrent-set-special-tag.text'), $lang_settings['text_minimum_class'].classlist('torrent-set-special-tag',$maxclass,$AUTHORITY['torrent-set-special-tag'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_ADMINISTRATOR,false,true,true).nexus_trans('permission.torrent-set-special-tag.desc'),1);
|
||||
tr(nexus_trans('permission.torrent-approval.text'), $lang_settings['text_minimum_class'].classlist('torrent-approval',$maxclass,$AUTHORITY['torrent-approval'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_ADMINISTRATOR,false,true,true).nexus_trans('permission.torrent-approval.desc'),1);
|
||||
tr(nexus_trans('permission.torrent-approval-allow-automatic.text'), $lang_settings['text_minimum_class'].classlist('torrent-approval-allow-automatic',$maxclass,$AUTHORITY['torrent-approval-allow-automatic'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_UPLOADER,false,true,true).nexus_trans('permission.torrent-approval-allow-automatic.desc'),1);
|
||||
tr(nexus_trans('permission.torrent-set-price.text'), $lang_settings['text_minimum_class'].classlist('torrent-set-price',$maxclass,$AUTHORITY['torrent-set-price'] ?? '',0,true).$lang_settings['text_default'].get_user_class_name(UC_UPLOADER,false,true,true).nexus_trans('permission.torrent-set-price.desc'),1);
|
||||
|
||||
tr($lang_settings['row_ask_for_reseed'], $lang_settings['text_minimum_class'].classlist('askreseed',$maxclass,$AUTHORITY['askreseed'],0,true).$lang_settings['text_default'].get_user_class_name(UC_POWER_USER,false,true,true).$lang_settings['text_ask_for_reseed_note'],1);
|
||||
tr($lang_settings['row_view_nfo'], $lang_settings['text_minimum_class'].classlist('viewnfo',$maxclass,$AUTHORITY['viewnfo'],0,true).$lang_settings['text_default'].get_user_class_name(UC_POWER_USER,false,true,true).$lang_settings['text_view_nfo_note'],1);
|
||||
@@ -740,6 +741,8 @@ 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_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);
|
||||
tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."<input type='text' style=\"width: 50px\" name=largesize value='".(isset($TORRENT["largesize"]) ? $TORRENT["largesize"] : 20 )."'>".$lang_settings['text_gb_promoted_to']."<select name=largepro>".promotion_selection((isset($TORRENT['largepro']) ? $TORRENT['largepro'] : 2), 1)."</select>".$lang_settings['text_by_system_upon_uploading']."<br />".$lang_settings['text_large_torrent_promotion_note'], 1);
|
||||
|
||||
@@ -215,6 +215,13 @@ $updateset[] = "cover = " . sqlesc($cover);
|
||||
if (isset($_POST['hr'][$newcatmode]) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr'][$newcatmode]]) && user_can('torrent_hr')) {
|
||||
$updateset[] = "hr = " . sqlesc($_POST['hr'][$newcatmode]);
|
||||
}
|
||||
/**
|
||||
* price
|
||||
* @since 1.8.0
|
||||
*/
|
||||
if (user_can('torrent-set-price')) {
|
||||
$updateset[] = "price = " . sqlesc($_POST['price'] ?? 0);
|
||||
}
|
||||
|
||||
$sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id";
|
||||
do_log("[UPDATE_TORRENT]: $sql");
|
||||
|
||||
@@ -373,6 +373,9 @@ 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')) {
|
||||
$insert['price'] = $_POST['price'] ?? 0;
|
||||
}
|
||||
do_log("[INSERT_TORRENT]: " . nexus_json_encode($insert));
|
||||
$id = \Nexus\Database\NexusDB::insert('torrents', $insert);
|
||||
|
||||
|
||||
@@ -97,6 +97,17 @@ $onlyBrowseSection = get_setting('main.spsct') != 'yes' || !user_can('view_speci
|
||||
if ($onlyBrowseSection) {
|
||||
$where .= ($where ? " AND " : "") . "categories.mode = $browseMode";
|
||||
}
|
||||
//check price
|
||||
if (isset($_GET['paid']) && in_array($_GET['paid'], ['0', '1', '2'], true)) {
|
||||
$paidFilter = $_GET['paid'];
|
||||
} else {
|
||||
$paidFilter = '0';
|
||||
}
|
||||
if ($paidFilter === '0') {
|
||||
$where .= ($where ? " AND " : "") . "torrents.price = 0";
|
||||
} elseif ($paidFilter === '1') {
|
||||
$where .= ($where ? " AND " : "") . "torrents.price > 0";
|
||||
}
|
||||
|
||||
function get_where($tablename = "sources", $itemname = "source", $getname = "sou")
|
||||
{
|
||||
|
||||
@@ -73,6 +73,11 @@ stdhead($lang_upload['head_upload']);
|
||||
if ($enablenfo_main=='yes') {
|
||||
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" /> ' . 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\">");
|
||||
textbbcode("upload","descr", "", false, 130, true);
|
||||
print("</td></tr>\n");
|
||||
|
||||
Reference in New Issue
Block a user