mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-05 07:20:58 +08:00
fix rss sticky
This commit is contained in:
@@ -17,7 +17,7 @@ class CreateAgentAllowedFamilyTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('agent_allowed_family', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('family', 50)->default('');
|
||||
$table->string('start_name', 100)->default('');
|
||||
$table->string('peer_id_pattern', 200)->default('');
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateAudiocodecsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('audiocodecs', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->string('image')->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateCaticonsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('caticons', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 64)->default('');
|
||||
$table->string('folder')->default('');
|
||||
$table->string('cssfile')->default('');
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateCodecsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('codecs', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateDownloadspeedTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('downloadspeed', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 50)->default('');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateIspTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('isp', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 50)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateLinksTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('links', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->string('url')->default('');
|
||||
$table->string('title', 50)->default('');
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateMediaTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('media', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateProcessingsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('processings', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ class CreateSnatchedTable extends Migration
|
||||
$table->dateTime('startdat')->nullable();
|
||||
$table->dateTime('completedat')->nullable();
|
||||
$table->enum('finished', ['yes', 'no'])->default('no');
|
||||
$table->index(['torrentid', 'userid'], 'torrentid_userid');
|
||||
$table->unique(['torrentid', 'userid'], 'torrentid_userid');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateSourcesTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('sources', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateStandardsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('standards', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateStylesheetsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('stylesheets', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('uri')->default('');
|
||||
$table->string('name', 64)->default('');
|
||||
$table->text('addicode')->nullable();
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateTeamsTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('teams', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 30)->default('');
|
||||
$table->unsignedTinyInteger('sort_index')->default(0);
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ class CreateUploadspeedTable extends Migration
|
||||
return;
|
||||
}
|
||||
Schema::create('uploadspeed', function (Blueprint $table) {
|
||||
$table->tinyIncrements('id');
|
||||
$table->increments('id');
|
||||
$table->string('name', 50)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -934,23 +934,24 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
}
|
||||
|
||||
//delete duplicated snatched
|
||||
$snatchRes = sql_query('select userid, torrentid, group_concat(id) as ids from snatched group by userid, torrentid having(count(*)) > 1');
|
||||
while ($snatchRow = mysql_fetch_assoc($snatchRes)) {
|
||||
$torrentId = $snatchRow['torrentid'];
|
||||
$userId = $snatchRow['userid'];
|
||||
$idArr = explode(',', $snatchRes['ids']);
|
||||
sort($idArr, SORT_NUMERIC);
|
||||
$remainId = array_pop($idArr);
|
||||
$delIdStr = implode(',', $idArr);
|
||||
do_log("[DELETE_DUPLICATED_SNATCH], torrent: $torrentId, user: $userId");
|
||||
sql_query("delete from snatched where id in ($delIdStr)");
|
||||
sql_query("update claims set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
}
|
||||
$log = "delete duplicated snatched";
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
printProgress($log);
|
||||
}
|
||||
//is it necessary ? duplicate snatch update by torrent_id + userid, all records key fields are the same
|
||||
// $snatchRes = sql_query('select userid, torrentid, group_concat(id) as ids from snatched group by userid, torrentid having(count(*)) > 1');
|
||||
// while ($snatchRow = mysql_fetch_assoc($snatchRes)) {
|
||||
// $torrentId = $snatchRow['torrentid'];
|
||||
// $userId = $snatchRow['userid'];
|
||||
// $idArr = explode(',', $snatchRow['ids']);
|
||||
// sort($idArr, SORT_NUMERIC);
|
||||
// $remainId = array_pop($idArr);
|
||||
// $delIdStr = implode(',', $idArr);
|
||||
// do_log("[DELETE_DUPLICATED_SNATCH], torrent: $torrentId, user: $userId, snatchIdStr: $delIdStr");
|
||||
// sql_query("delete from snatched where id in ($delIdStr)");
|
||||
// sql_query("update claims set snatched_id = $remainId where torrent_id = $torrentId and uid = $userId");
|
||||
// }
|
||||
// $log = "delete duplicated snatched";
|
||||
// do_log($log);
|
||||
// if ($printProgress) {
|
||||
// printProgress($log);
|
||||
// }
|
||||
|
||||
//Priority Class 5: cleanup every 15 days
|
||||
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime5'");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-11');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-16');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -40,9 +40,7 @@ $lang_getrss = array
|
||||
'select_exact' => "准确",
|
||||
'text_mode' => "",
|
||||
'text_keyword_note' => "只订阅标题中包含此关键字的项目",
|
||||
'row_sort' => '排序',
|
||||
'sort_sticky' => '置顶优先(默认)',
|
||||
'sort_newest' => '最新优先',
|
||||
'row_sticky' => '置顶',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -40,7 +40,8 @@ $lang_getrss = array
|
||||
'select_or' => "或",
|
||||
'select_exact' => "准確",
|
||||
'text_mode' => "",
|
||||
'text_keyword_note' => "只訂閱標題中包含此關鍵字的項目"
|
||||
'text_keyword_note' => "只訂閱標題中包含此關鍵字的項目",
|
||||
'row_sticky' => '置頂',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -39,7 +39,8 @@ $lang_getrss = array
|
||||
'select_or' => "OR",
|
||||
'select_exact' => "Exact",
|
||||
'text_mode' => "matching mode ",
|
||||
'text_keyword_note' => "Ony subscribe to items with these keywords in titles."
|
||||
'text_keyword_note' => "Ony subscribe to items with these keywords in titles.",
|
||||
'row_sticky' => 'Sticky',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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