mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
misc up
This commit is contained in:
@@ -24,7 +24,7 @@ class TorrentUpdated
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Model $model, Model $modelOld)
|
||||
public function __construct(Model $model, ?Model $modelOld = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->modelOld = $modelOld;
|
||||
|
||||
@@ -363,10 +363,9 @@ class TorrentResource extends Resource
|
||||
return $result;
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(fn (callable $set) => $set('section_id', null))
|
||||
->required()
|
||||
,
|
||||
Forms\Components\Select::make('category')
|
||||
Forms\Components\Select::make('category_id')
|
||||
->label(__('searchbox.category_label'))
|
||||
->options(function (callable $get) {
|
||||
$sectionId = $get('section_id');
|
||||
@@ -375,19 +374,17 @@ class TorrentResource extends Resource
|
||||
}
|
||||
return Category::query()->where('mode', $sectionId)->pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->required()
|
||||
,
|
||||
|
||||
])
|
||||
->action(function (Collection $records, array $data) {
|
||||
// $torrentRep = new TorrentRepository();
|
||||
// try {
|
||||
// $data['torrent_id'] = $record->id;
|
||||
// $torrentRep->approval(Auth::user(), $data);
|
||||
// } catch (\Exception $exception) {
|
||||
// do_log($exception->getMessage(), 'error');
|
||||
// }
|
||||
$torrentRep = new TorrentRepository();
|
||||
try {
|
||||
$torrentRep->changeCategory($records, $data['section_id'], $data['category_id']);
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage(), 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ class SeedBoxRepository extends BaseRepository
|
||||
$asnObj = $reader->asn($ip);
|
||||
return $asnObj->autonomousSystemNumber ?? 0;
|
||||
} catch (\Exception $e) {
|
||||
do_log("ip: $ip, error: " . $e->getMessage(), 'error');
|
||||
do_log("ip: $ip, error: " . $e->getMessage());
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Repositories;
|
||||
|
||||
use App\Auth\Permission;
|
||||
use App\Enums\ModelEventEnum;
|
||||
use App\Events\TorrentUpdated;
|
||||
use App\Exceptions\InsufficientPermissionException;
|
||||
use App\Exceptions\NexusException;
|
||||
use App\Http\Resources\TorrentResource;
|
||||
@@ -18,6 +19,7 @@ use App\Models\Peer;
|
||||
use App\Models\Processing;
|
||||
use App\Models\SearchBox;
|
||||
use App\Models\Setting;
|
||||
use App\Models\SiteLog;
|
||||
use App\Models\Snatch;
|
||||
use App\Models\Source;
|
||||
use App\Models\StaffMessage;
|
||||
@@ -36,6 +38,7 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -1095,4 +1098,33 @@ HTML;
|
||||
}
|
||||
}
|
||||
|
||||
public function changeCategory(Collection $torrents, int $sectionId, int $categoryId): void
|
||||
{
|
||||
assert_has_permission(Permission::canManageTorrent());
|
||||
$searchBox = SearchBox::query()->findOrFail($sectionId);
|
||||
$category = $searchBox->categories()->findOrFail($categoryId);
|
||||
$torrentIdArr = $torrents->pluck('id')->toArray();
|
||||
if (empty($torrentIdArr)) {
|
||||
do_log("torrents is empty", 'warn');
|
||||
return;
|
||||
}
|
||||
$operatorId = get_user_id();
|
||||
$siteLogArr = [];
|
||||
foreach ($torrents as $torrent) {
|
||||
$siteLogArr[] = [
|
||||
'added' => now(),
|
||||
'txt' => sprintf("torrent: %s category was set to: %s(%s)", $torrent->id, $category->name, $category->id),
|
||||
'uid' => $operatorId,
|
||||
];
|
||||
}
|
||||
NexusDB::transaction(function () use ($torrentIdArr, $categoryId, $siteLogArr) {
|
||||
SiteLog::query()->insert($siteLogArr);
|
||||
Torrent::query()->whereIn('id', $torrentIdArr)->update(['category' => $categoryId]);
|
||||
});
|
||||
foreach ($torrents as $torrent) {
|
||||
fire_event(ModelEventEnum::TORRENT_UPDATED, $torrent);
|
||||
}
|
||||
do_log("success change torrent category to $categoryId, torrent count:" . $torrents->count());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ return [
|
||||
'defaults' => [
|
||||
'supervisor-1' => [
|
||||
'connection' => 'redis',
|
||||
'queue' => ['default', 'nexus_queue'],
|
||||
'queue' => ['nexus_queue'],
|
||||
'balance' => 'auto',
|
||||
'autoScalingStrategy' => 'time',
|
||||
'maxProcesses' => 1,
|
||||
|
||||
@@ -2331,7 +2331,7 @@ function get_css_row() {
|
||||
}
|
||||
$Cache->cache_value('stylesheet_content', $rows, 95400);
|
||||
}
|
||||
return $rows[$cssid];
|
||||
return $rows[$cssid] ?? $rows[$defcss];
|
||||
}
|
||||
function get_css_uri($file = "")
|
||||
{
|
||||
@@ -6300,13 +6300,11 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
$baseBonusFactor = $donortimes_bonus;
|
||||
}
|
||||
$baseBonus = $bonusResult['seed_bonus'] * $baseBonusFactor;
|
||||
$totalBonus = number_format(
|
||||
$baseBonus
|
||||
$totalBonus = $baseBonus
|
||||
+ $haremAddition * $haremFactor
|
||||
+ $bonusResult['official_bonus'] * $officialAdditionalFactor
|
||||
+ $bonusResult['medal_bonus'] * $bonusResult['medal_additional_factor']
|
||||
, 3
|
||||
);
|
||||
;
|
||||
|
||||
$rowSpan = 1;
|
||||
$hasHaremAddition = $hasOfficialAddition = $hasMedalAddition = false;
|
||||
|
||||
@@ -1280,6 +1280,13 @@ function user_can($permission, $fail = false, $uid = 0): bool
|
||||
throw new \App\Exceptions\InsufficientPermissionException();
|
||||
}
|
||||
|
||||
function assert_has_permission(bool $permissionCheckResult): void
|
||||
{
|
||||
if (!$permissionCheckResult) {
|
||||
throw new \App\Exceptions\InsufficientPermissionException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function is_donor(array $userInfo): bool
|
||||
|
||||
@@ -13,7 +13,7 @@ if (isset($_GET['del']))
|
||||
}
|
||||
}
|
||||
$where=$_GET["type"] ?? '';
|
||||
$refresh = ($CURUSER['sbrefresh'] ? $CURUSER['sbrefresh'] : 120)
|
||||
$refresh = ($CURUSER['sbrefresh'] ?? 120)
|
||||
?>
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
|
||||
@@ -10,10 +10,18 @@ if (($CURUSER['id'] != $id && !user_can('viewinvite')) || !is_valid_id($id))
|
||||
$email = unesc(htmlspecialchars(trim($_POST["email"])));
|
||||
if(!empty($_POST['conusr'])) {
|
||||
// sql_query("UPDATE users SET status = 'confirmed', editsecret = '' WHERE id IN (" . implode(", ", $_POST['conusr']) . ") AND status='pending'");
|
||||
\App\Models\User::query()->whereIn('id', $_POST['conusr'])
|
||||
$userList = \App\Models\User::query()->whereIn('id', $_POST['conusr'])
|
||||
->where('status', 'pending')
|
||||
->update(['status' => 'confirmed', 'editsecret' => ''])
|
||||
->get(\App\Models\User::$commonFields)
|
||||
;
|
||||
if ($userList->isNotEmpty()) {
|
||||
$uidArr = [];
|
||||
foreach ($userList as $user) {
|
||||
$uidArr[] = $user->id;
|
||||
fire_event(\App\Enums\ModelEventEnum::USER_UPDATED, $user);
|
||||
}
|
||||
\App\Models\User::query()->whereIn('id', $uidArr)->update(['status' => 'confirmed', 'editsecret' => '']);
|
||||
}
|
||||
} else {
|
||||
stderr($lang_takeconfirm['std_sorry'],$lang_takeconfirm['std_no_buddy_to_confirm'].
|
||||
"<a class=altlink href=invite.php?id={$CURUSER['id']}>".$lang_takeconfirm['std_here_to_go_back'],false);
|
||||
|
||||
@@ -4,7 +4,8 @@ $passkey = $_GET['passkey'] ?? $CURUSER['passkey'] ?? '';
|
||||
if (!$passkey) {
|
||||
die("require passkey");
|
||||
}
|
||||
$cacheKey = "nexus_rss:$passkey:" . md5(http_build_query($_GET));
|
||||
unset($_GET['passkey']);
|
||||
$cacheKey = "nexus_rss:" . md5(http_build_query($_GET));
|
||||
$cacheData = \Nexus\Database\NexusDB::cache_get($cacheKey);
|
||||
if ($cacheData && nexus_env('APP_ENV') != 'local') {
|
||||
do_log("rss get from cache");
|
||||
|
||||
Reference in New Issue
Block a user