mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
fix rss sticky
This commit is contained in:
+15
-13
@@ -39,9 +39,10 @@ if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs", $brsectio
|
||||
}
|
||||
stdhead($lang_getrss['head_rss_feeds']);
|
||||
$query = [];
|
||||
$allowed_showrows=array('10','50','100','200');
|
||||
$stickyTypes = apply_filter('rss_sticky_types', ['first' => nexus_trans('torrent.pos_state_sticky'), 'second' => nexus_trans('torrent.pos_state_r_sticky')]);
|
||||
$query[] = "passkey=" . $CURUSER['passkey'];
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$allowed_showrows=array('10','50','100','200');
|
||||
$link = get_protocol_prefix(). $BASEURL ."/torrentrss.php";
|
||||
if (isset($_POST['showrows']) && in_array($_POST['showrows'], $allowed_showrows, 1))
|
||||
$query[] = "rows=".(int)$_POST['showrows'];
|
||||
@@ -156,10 +157,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$query[] = "search_mode=".$search_mode;
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['sort']) && in_array($_POST['sort'], ['newest', 'sticky'])) {
|
||||
$query[] = "sort=" . $_POST['sort'];
|
||||
} else {
|
||||
$query[] = "sort=sticky";
|
||||
if (!empty($_POST['sticky']) && is_array($_POST['sticky'])) {
|
||||
$query[] = "sticky=" . implode(',', $_POST['sticky']);
|
||||
}
|
||||
$inclbookmarked=intval($_POST['inclbookmarked'] ?? 0);
|
||||
if($inclbookmarked)
|
||||
@@ -323,11 +322,14 @@ if (get_setting('main.spsct') == 'yes') {
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_sort']?>
|
||||
<td class="rowhead"><?php echo $lang_getrss['row_sticky']?>
|
||||
</td>
|
||||
<td class="rowfollow" align="left">
|
||||
<label><input type="radio" name="sort" value="sticky" checked><?php echo $lang_getrss['sort_sticky']?></label>
|
||||
<label><input type="radio" name="sort" value="newest"><?php echo $lang_getrss['sort_newest']?></label>
|
||||
<?php
|
||||
foreach ($stickyTypes as $key => $value) {
|
||||
echo sprintf('<label><input type="checkbox" name="sticky[]" value="%s">%s</label>', $key, $value);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -338,11 +340,11 @@ if (get_setting('main.spsct') == 'yes') {
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td class="rowhead"><?php echo $lang_getrss['row_rows_per_page']?></td><td class="rowfollow" align="left"><select name="showrows">
|
||||
<option value="10">10</option>
|
||||
<option value="20">20</option>
|
||||
<option value="30">30</option>
|
||||
<option value="40">40</option>
|
||||
<option value="50">50</option>
|
||||
<?php
|
||||
foreach ($allowed_showrows as $showrow) {
|
||||
echo sprintf('<option value="%s">%s</option>', $showrow, $showrow);
|
||||
}
|
||||
?>
|
||||
</select></td></tr>
|
||||
<tr><td class="rowhead"><?php echo $lang_getrss['row_keyword']?></td>
|
||||
<td class="rowfollow" align="left">
|
||||
|
||||
+34
-17
@@ -6,7 +6,7 @@ if (!$passkey) {
|
||||
}
|
||||
$cacheKey = "nexus_rss:$passkey:" . md5(http_build_query($_GET));
|
||||
$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey);
|
||||
if ($cacheData) {
|
||||
if ($cacheData && nexus_env('APP_ENV') != 'local') {
|
||||
do_log("rss get from cache");
|
||||
header ("Content-type: text/xml");
|
||||
die($cacheData);
|
||||
@@ -75,15 +75,39 @@ if (isset($searchstr)){
|
||||
$wherea[] = implode($ANDOR, $like_expression_array);
|
||||
$where .= ($where ? " AND " : "") . implode(" AND ", $wherea);
|
||||
}
|
||||
$hasSticky = false;
|
||||
if (!empty($_GET['sticky'])) {
|
||||
$stickyArr = explode(',', $_GET['sticky']);
|
||||
$posStates = [];
|
||||
if (in_array('first', $stickyArr)) {
|
||||
$posStates[] = \App\Models\Torrent::POS_STATE_STICKY_FIRST;
|
||||
}
|
||||
if (in_array('second', $stickyArr)) {
|
||||
$posStates[] = \App\Models\Torrent::POS_STATE_STICKY_SECOND;
|
||||
}
|
||||
$idArr = [];
|
||||
if (!empty($posStates)) {
|
||||
$idArr = \App\Models\Torrent::query()->whereIn('pos_state', $posStates)->pluck('id')->toArray();
|
||||
}
|
||||
$idArr = apply_filter("rss_sticky_promotion_torrent_ids", $idArr, $stickyArr);
|
||||
if (!empty($idArr)) {
|
||||
$hasSticky = true;
|
||||
$where .= ($where ? " AND " : "") . "torrents.id in (" . implode(',', $idArr) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
$limit = "";
|
||||
$startindex = intval($_GET['startindex'] ?? 0);
|
||||
if ($startindex)
|
||||
$limit .= $startindex.", ";
|
||||
$showrows = intval($_GET['rows'] ?? 0);
|
||||
if($showrows < 1 || $showrows > 50)
|
||||
$showrows = 10;
|
||||
$limit .= $showrows;
|
||||
if (!$hasSticky) {
|
||||
$startindex = intval($_GET['startindex'] ?? 0);
|
||||
if ($startindex) {
|
||||
$limit .= $startindex.", ";
|
||||
}
|
||||
$showrows = intval($_GET['rows'] ?? 0);
|
||||
if($showrows < 1 || $showrows > 200) {
|
||||
$showrows = 10;
|
||||
}
|
||||
$limit .= $showrows;
|
||||
}
|
||||
|
||||
//approval status
|
||||
$approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible');
|
||||
@@ -118,17 +142,10 @@ get_where("teams", "team", "tea");
|
||||
get_where("audiocodecs", "audiocodec", "aud");
|
||||
if ($where)
|
||||
$where = "WHERE ".$where;
|
||||
if (!empty($_GET['sort']) && $_GET['sort'] == 'newest') {
|
||||
$sort = "id desc";
|
||||
} else {
|
||||
$sort = "pos_state desc, id desc";
|
||||
}
|
||||
$sort = "id desc";
|
||||
//$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY $sort LIMIT $limit";
|
||||
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, torrents.owner, categories.name AS category_name FROM torrents LEFT JOIN categories ON category = categories.id $where ORDER BY $sort LIMIT $limit";
|
||||
$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, torrents.owner, categories.name AS category_name FROM torrents LEFT JOIN categories ON category = categories.id $where ORDER BY $sort" . ($limit ? " LIMIT $limit" : "");
|
||||
$list = \Nexus\Database\NexusDB::select($query);
|
||||
if ($inclbookmarked == 0) {
|
||||
$list = apply_filter('torrent_list', $list, $startindex == 0 ? 0 : 1, null, $_GET['search'] ?? '');
|
||||
}
|
||||
|
||||
//dd($list);
|
||||
$torrentRep = new \App\Repositories\TorrentRepository();
|
||||
|
||||
Reference in New Issue
Block a user