mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-30 00:47:22 +08:00
add torrent pos_state_until
This commit is contained in:
@@ -256,6 +256,21 @@ class Torrent extends NexusModel
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function listPickInfo($onlyKeyValue = false, $valueField = 'text'): array
|
||||||
|
{
|
||||||
|
$result = self::$pickTypes;
|
||||||
|
$keyValue = [];
|
||||||
|
foreach ($result as $status => &$info) {
|
||||||
|
$text = nexus_trans('torrent.pick_info.' . $status);
|
||||||
|
$info['text'] = $text;
|
||||||
|
$keyValue[$status] = $info[$valueField];
|
||||||
|
}
|
||||||
|
if ($onlyKeyValue) {
|
||||||
|
return $keyValue;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getHrAttribute(): string
|
public function getHrAttribute(): string
|
||||||
{
|
{
|
||||||
$hrMode = Setting::get('hr.mode');
|
$hrMode = Setting::get('hr.mode');
|
||||||
|
|||||||
@@ -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('torrents', function (Blueprint $table) {
|
||||||
|
$table->dateTime('pos_state_until')->nullable(true)->after('pos_state');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('torrents', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('pos_state_until');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -462,6 +462,28 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
|||||||
if ($printProgress) {
|
if ($printProgress) {
|
||||||
printProgress($log);
|
printProgress($log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//expire torrent sticky
|
||||||
|
$toBeExpirePosStates = [
|
||||||
|
\App\Models\Torrent::POS_STATE_STICKY_FIRST,
|
||||||
|
\App\Models\Torrent::POS_STATE_STICKY_SECOND,
|
||||||
|
];
|
||||||
|
$update = [
|
||||||
|
'pos_state' => \App\Models\Torrent::POS_STATE_STICKY_NONE,
|
||||||
|
'pos_state_until' => null,
|
||||||
|
];
|
||||||
|
\App\Models\Torrent::query()
|
||||||
|
->whereIn('pos_state', $toBeExpirePosStates)
|
||||||
|
->whereNotNull('pos_state_until')
|
||||||
|
->where('pos_state_until', '<', now())
|
||||||
|
->update($update);
|
||||||
|
$log = "expire torrent pos state";
|
||||||
|
do_log($log);
|
||||||
|
if ($printProgress) {
|
||||||
|
printProgress($log);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//automatically pick hot
|
//automatically pick hot
|
||||||
if ($hotdays_torrent)
|
if ($hotdays_torrent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5872,4 +5872,24 @@ function calculate_harem_addition($uid)
|
|||||||
return $addition;
|
return $addition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function datetimepicker_input($name, $value = '', $label = '')
|
||||||
|
{
|
||||||
|
\Nexus\Nexus::css('vendor/jquery-datetimepicker/jquery.datetimepicker.min.css', 'footer', true);
|
||||||
|
\Nexus\Nexus::js('vendor/jquery-datetimepicker/jquery.datetimepicker.full.min.js', 'footer', true);
|
||||||
|
$id = "datetime-picker-$name";
|
||||||
|
$input = sprintf('%s<input type="text" id="%s" name="%s" value="%s" autocomplete="off" >', $label, $id, $name, $value);
|
||||||
|
$lang = get_langfolder_cookie(true);
|
||||||
|
if ($lang == 'zh_CN') {
|
||||||
|
$lang = 'zh';
|
||||||
|
}
|
||||||
|
$lang = str_replace('_', '-', $lang);
|
||||||
|
$js = <<<JS
|
||||||
|
jQuery.datetimepicker.setLocale('{$lang}');
|
||||||
|
jQuery("#{$id}").datetimepicker({
|
||||||
|
format: 'Y-m-d H:i'
|
||||||
|
})
|
||||||
|
JS;
|
||||||
|
\Nexus\Nexus::js($js, 'footer', false);
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
+2
-1
@@ -182,7 +182,8 @@ else {
|
|||||||
foreach (\App\Models\Torrent::listPosStates() as $key => $value) {
|
foreach (\App\Models\Torrent::listPosStates() as $key => $value) {
|
||||||
$options[] = "<option" . (($row["pos_state"] == $key) ? " selected=\"selected\"" : "" ) . " value=\"" . $key . "\">".$value['text']."</option>";
|
$options[] = "<option" . (($row["pos_state"] == $key) ? " selected=\"selected\"" : "" ) . " value=\"" . $key . "\">".$value['text']."</option>";
|
||||||
}
|
}
|
||||||
$pickcontent .= "<b>".$lang_edit['row_torrent_position'].": </b>"."<select name=\"sel_posstate\" style=\"width: 100px;\">" . implode('', $options) . "</select> ";
|
$pickcontent .= "<b>".$lang_edit['row_torrent_position'].": </b>"."<select name=\"pos_state\" style=\"width: 100px;\">" . implode('', $options) . "</select> ";
|
||||||
|
$pickcontent .= datetimepicker_input('pos_state_until', $row['pos_state_until'], nexus_trans('label.deadline') . ": ");
|
||||||
}
|
}
|
||||||
if(user_can('torrentmanage') && ($CURUSER["picker"] == 'yes' || get_user_class() >= \App\Models\User::CLASS_SYSOP))
|
if(user_can('torrentmanage') && ($CURUSER["picker"] == 'yes' || get_user_class() >= \App\Models\User::CLASS_SYSOP))
|
||||||
{
|
{
|
||||||
|
|||||||
+17
-3
@@ -143,9 +143,21 @@ if(user_can('torrentonpromotion'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(user_can('torrentsticky') && isset($_POST['sel_posstate']) && isset(\App\Models\Torrent::$posStates[$_POST['sel_posstate']]))
|
if(user_can('torrentsticky'))
|
||||||
{
|
{
|
||||||
$updateset[] = "pos_state = '" . $_POST['sel_posstate'] . "'";
|
if (isset($_POST['pos_state']) && isset(\App\Models\Torrent::$posStates[$_POST['pos_state']])) {
|
||||||
|
$posStateUntil = null;
|
||||||
|
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
|
||||||
|
if (!empty($_POST['pos_state_until']) && $_POST['pos_state'] != \App\Models\Torrent::POS_STATE_STICKY_NONE) {
|
||||||
|
$posStateUntil = \Carbon\Carbon::parse($_POST['pos_state_until']);
|
||||||
|
if ($posStateUntil->gte(now())) {
|
||||||
|
$posState = $_POST['pos_state'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$updateset[] = sprintf("pos_state = %s", sqlesc($posState));
|
||||||
|
$updateset[] = sprintf("pos_state_until = %s", sqlesc($posStateUntil));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pick_info = "";
|
$pick_info = "";
|
||||||
@@ -202,7 +214,9 @@ $descriptionArr = format_description($descr);
|
|||||||
$cover = get_image_from_description($descriptionArr, true, false);
|
$cover = get_image_from_description($descriptionArr, true, false);
|
||||||
$updateset[] = "cover = " . sqlesc($cover);
|
$updateset[] = "cover = " . sqlesc($cover);
|
||||||
|
|
||||||
$affectedRows = sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
$sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id";
|
||||||
|
do_log("[UPDATE_TORRENT]: $sql");
|
||||||
|
$affectedRows = sql_query($sql) or sqlerr(__FILE__, __LINE__);
|
||||||
|
|
||||||
$dateTimeStringNow = date("Y-m-d H:i:s");
|
$dateTimeStringNow = date("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
|||||||
@@ -342,6 +342,31 @@ $insert = [
|
|||||||
if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']]) && user_can('torrent_hr')) {
|
if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']]) && user_can('torrent_hr')) {
|
||||||
$insert['hr'] = $_POST['hr'];
|
$insert['hr'] = $_POST['hr'];
|
||||||
}
|
}
|
||||||
|
if(user_can('torrentsticky')) {
|
||||||
|
if (isset($_POST['pos_state']) && isset(\App\Models\Torrent::$posStates[$_POST['pos_state']])) {
|
||||||
|
$posStateUntil = null;
|
||||||
|
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
|
||||||
|
if (!empty($_POST['pos_state_until']) && $_POST['pos_state'] != \App\Models\Torrent::POS_STATE_STICKY_NONE) {
|
||||||
|
$posStateUntil = \Carbon\Carbon::parse($_POST['pos_state_until']);
|
||||||
|
if ($posStateUntil->gte(now())) {
|
||||||
|
$posState = $_POST['pos_state'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$insert['pos_state'] = $posState;
|
||||||
|
$insert['pos_state_until'] = $posStateUntil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(user_can('torrentmanage') && ($CURUSER['picker'] == 'yes' || get_user_class() >= \App\Models\User::CLASS_SYSOP)) {
|
||||||
|
if (isset($_POST['picktype']) && isset(\App\Models\Torrent::$pickTypes[$_POST['picktype']])) {
|
||||||
|
$insert['picktype'] = $_POST['picktype'];
|
||||||
|
if ($insert['picktype'] == \App\Models\Torrent::PICK_NORMAL) {
|
||||||
|
$insert['picktime'] = null;
|
||||||
|
} else {
|
||||||
|
$insert['picktime'] = now()->toDateTimeString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
do_log("[INSERT_TORRENT]: " . nexus_json_encode($insert));
|
||||||
$id = \Nexus\Database\NexusDB::insert('torrents', $insert);
|
$id = \Nexus\Database\NexusDB::insert('torrents', $insert);
|
||||||
|
|
||||||
//$ret = sql_query("INSERT INTO torrents (filename, owner, visible, anonymous, name, size, numfiles, type, url, small_descr, descr, ori_descr, category, source, medium, codec, audiocodec, standard, processing, team, save_as, sp_state, added, last_action, nfo, info_hash, pt_gen, technical_info) VALUES (".sqlesc($fname).", ".sqlesc($CURUSER["id"]).", 'yes', ".sqlesc($anonymous).", ".sqlesc($torrent).", ".sqlesc($totallen).", ".count($filelist).", ".sqlesc($type).", ".sqlesc($url).", ".sqlesc($small_descr).", ".sqlesc($descr).", ".sqlesc($descr).", ".sqlesc($catid).", ".sqlesc($sourceid).", ".sqlesc($mediumid).", ".sqlesc($codecid).", ".sqlesc($audiocodecid).", ".sqlesc($standardid).", ".sqlesc($processingid).", ".sqlesc($teamid).", ".sqlesc($dname).", ".sqlesc($sp_state) .
|
//$ret = sql_query("INSERT INTO torrents (filename, owner, visible, anonymous, name, size, numfiles, type, url, small_descr, descr, ori_descr, category, source, medium, codec, audiocodec, standard, processing, team, save_as, sp_state, added, last_action, nfo, info_hash, pt_gen, technical_info) VALUES (".sqlesc($fname).", ".sqlesc($CURUSER["id"]).", 'yes', ".sqlesc($anonymous).", ".sqlesc($torrent).", ".sqlesc($totallen).", ".count($filelist).", ".sqlesc($type).", ".sqlesc($url).", ".sqlesc($small_descr).", ".sqlesc($descr).", ".sqlesc($descr).", ".sqlesc($catid).", ".sqlesc($sourceid).", ".sqlesc($mediumid).", ".sqlesc($codecid).", ".sqlesc($audiocodecid).", ".sqlesc($standardid).", ".sqlesc($processingid).", ".sqlesc($teamid).", ".sqlesc($dname).", ".sqlesc($sp_state) .
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
require_once("../include/bittorrent.php");
|
require_once("../include/bittorrent.php");
|
||||||
dbconn();
|
dbconn();
|
||||||
require_once(get_langfile_path());
|
require_once(get_langfile_path());
|
||||||
|
require_once(get_langfile_path('edit.php'));
|
||||||
loggedinorreturn();
|
loggedinorreturn();
|
||||||
parked();
|
parked();
|
||||||
$userInfo = \App\Models\User::query()->findOrFail($CURUSER['id']);
|
$userInfo = \App\Models\User::query()->findOrFail($CURUSER['id']);
|
||||||
@@ -180,6 +181,30 @@ JS;
|
|||||||
}
|
}
|
||||||
//===end
|
//===end
|
||||||
|
|
||||||
|
//pick
|
||||||
|
$pickcontent = '';
|
||||||
|
if(user_can('torrentsticky'))
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
foreach (\App\Models\Torrent::listPosStates() as $key => $value) {
|
||||||
|
$options[] = "<option" . (($row["pos_state"] == $key) ? " selected=\"selected\"" : "" ) . " value=\"" . $key . "\">".$value['text']."</option>";
|
||||||
|
}
|
||||||
|
$pickcontent .= "<b>".$lang_edit['row_torrent_position'].": </b>"."<select name=\"pos_state\" style=\"width: 100px;\">" . implode('', $options) . "</select> ";
|
||||||
|
$pickcontent .= datetimepicker_input('pos_state_until', '', nexus_trans('label.deadline') . ": ");
|
||||||
|
}
|
||||||
|
if(user_can('torrentmanage') && ($CURUSER["picker"] == 'yes' || get_user_class() >= \App\Models\User::CLASS_SYSOP))
|
||||||
|
{
|
||||||
|
if ($pickcontent) $pickcontent .= '<br />';
|
||||||
|
$pickcontent .= "<b>".$lang_edit['row_recommended_movie'].": </b>"."<select name=\"picktype\" style=\"width: 100px;\">";
|
||||||
|
foreach (\App\Models\Torrent::listPickInfo(true) as $_pick_type => $_pick_type_text) {
|
||||||
|
$pickcontent .= sprintf('<option value="%s">%s</option>', $_pick_type, $_pick_type_text);
|
||||||
|
}
|
||||||
|
$pickcontent .= '</select>';
|
||||||
|
}
|
||||||
|
if ($pickcontent) {
|
||||||
|
tr($lang_edit['row_pick'], $pickcontent, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if(user_can('beanonymous'))
|
if(user_can('beanonymous'))
|
||||||
{
|
{
|
||||||
tr($lang_upload['row_show_uploader'], "<input type=\"checkbox\" name=\"uplver\" value=\"yes\" />".$lang_upload['checkbox_hide_uploader_note'], 1);
|
tr($lang_upload['row_show_uploader'], "<input type=\"checkbox\" name=\"uplver\" value=\"yes\" />".$lang_upload['checkbox_hide_uploader_note'], 1);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user