mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-07-25 04:57:36 +08:00
Compare commits
13 Commits
f18fa80eac
...
290ad0f375
| Author | SHA1 | Date | |
|---|---|---|---|
| 290ad0f375 | |||
| 8602831d3a | |||
| c5b55dbda1 | |||
| 7f0f8cca16 | |||
| 00ec3d5e8d | |||
| eb248110fc | |||
| 33fd265a20 | |||
| 6180ae18df | |||
| d255499e83 | |||
| 88f2318699 | |||
| f97d564ada | |||
| 70bc00b707 | |||
| ac83b68929 |
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TorrentCustomFields\Pages;
|
||||
|
||||
use App\Filament\Resources\TorrentCustomFields\TorrentCustomFieldResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTorrentCustomFields extends ListRecords
|
||||
{
|
||||
protected static string $resource = TorrentCustomFieldResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TorrentCustomFields\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Nexus\Field\Field;
|
||||
|
||||
class TorrentCustomFieldForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(__('label.field.name'))
|
||||
->helperText(__('label.field.name_help'))
|
||||
->alphaDash()
|
||||
->required(),
|
||||
TextInput::make('label')
|
||||
->label(__('label.field.field_label'))
|
||||
->required(),
|
||||
Select::make('type')
|
||||
->options((new Field())->getTypeRadioOptions())
|
||||
->label(__('label.field.type'))
|
||||
->required(),
|
||||
Checkbox::make('required')
|
||||
->label(__('label.field.required')),
|
||||
Textarea::make('help')
|
||||
->label(__('label.field.help'))
|
||||
->rows(3),
|
||||
Textarea::make('options')
|
||||
->label(__('label.field.options'))
|
||||
->rows(3)
|
||||
->hiddenJs("\$get('type') !== 'radio' && \$get('type') !== 'checkbox' && \$get('type') !== 'select'")
|
||||
->helperText(__('label.field.options_help')),
|
||||
Checkbox::make('is_single_row')
|
||||
->label(__('label.field.is_single_row')),
|
||||
TextInput::make('priority')
|
||||
->label(__('label.priority'))
|
||||
->numeric(),
|
||||
Textarea::make('display')
|
||||
->label(__('label.field.display'))
|
||||
->rows(3)
|
||||
->helperText(__('label.search_box.custom_fields_display_help')),
|
||||
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TorrentCustomFields\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TorrentCustomFieldsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id'),
|
||||
TextColumn::make('name')->label(__('label.field.name')),
|
||||
TextColumn::make('label')->label(__('label.field.field_label')),
|
||||
TextColumn::make('type')->label(__('label.field.type')),
|
||||
IconColumn::make('required')->boolean()->label(__('label.field.required')),
|
||||
IconColumn::make('is_single_row')->boolean()->label(__('label.field.is_single_row')),
|
||||
TextColumn::make('priority')->label(__('label.priority')),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TorrentCustomFields;
|
||||
|
||||
use App\Filament\Resources\TorrentCustomFields\Pages\ListTorrentCustomFields;
|
||||
use App\Filament\Resources\TorrentCustomFields\Schemas\TorrentCustomFieldForm;
|
||||
use App\Filament\Resources\TorrentCustomFields\Tables\TorrentCustomFieldsTable;
|
||||
use App\Models\TorrentCustomField;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class TorrentCustomFieldResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TorrentCustomField::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static string|null|UnitEnum $navigationGroup = 'Section';
|
||||
|
||||
protected static ?int $navigationSort = 12;
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('label.field.label');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TorrentCustomFieldForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TorrentCustomFieldsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTorrentCustomFields::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -139,6 +139,7 @@ class UserMedalResource extends Resource
|
||||
DeleteAction::make()->using(function (NexusModel $record) {
|
||||
$record->delete();
|
||||
clear_user_cache($record->uid);
|
||||
send_admin_success_notification();
|
||||
})
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
@@ -42,11 +42,16 @@ class UserResource extends JsonResource
|
||||
'bonus_human' => number_format($this->seedbonus, 1),
|
||||
'seed_points' => floatval($this->seed_points),
|
||||
'seed_points_human' => number_format($this->seed_points, 1),
|
||||
'seed_points_per_hour' => floatval($this->seed_points_per_hour),
|
||||
'seed_points_per_hour_human' => number_format($this->seed_points_per_hour, 1),
|
||||
'seed_bonus_per_hour' => floatval($this->seed_bonus_per_hour),
|
||||
'seed_bonus_per_hour_human' => number_format($this->seed_bonus_per_hour, 1),
|
||||
'seedtime' => $this->seedtime,
|
||||
'seedtime_text' => mkprettytime($this->seedtime),
|
||||
'leechtime' => $this->leechtime,
|
||||
'leechtime_text' => mkprettytime($this->leechtime),
|
||||
'share_ratio' => get_ratio($this->id),
|
||||
'seeding_leeching_data' => $this->whenHas('seeding_leeching_data'),
|
||||
'inviter' => new UserResource($this->whenLoaded('inviter')),
|
||||
'valid_medals' => MedalResource::collection($this->whenLoaded('valid_medals')),
|
||||
];
|
||||
|
||||
@@ -97,7 +97,7 @@ class CalculateUserSeedBonus implements ShouldQueue
|
||||
$logFile = getLogFile("seed-bonus-points");
|
||||
do_log("$logPrefix, [GET_UID_REAL], count: " . count($results) . ", logFile: $logFile");
|
||||
$fd = fopen($logFile, 'a');
|
||||
$seedPointsUpdates = $seedPointsPerHourUpdates = $seedBonusUpdates = [];
|
||||
$seedPointsUpdates = $seedPointsPerHourUpdates = $seedBonusPerHourUpdates = $seedBonusUpdates = [];
|
||||
$seedingTorrentCountUpdates = $seedingTorrentSizeUpdates = [];
|
||||
$logStr = "";
|
||||
$bonusLogInsert = [];
|
||||
@@ -160,6 +160,7 @@ class CalculateUserSeedBonus implements ShouldQueue
|
||||
// NexusDB::statement($sql);
|
||||
$seedPointsUpdates[] = sprintf("when %d then ifnull(seed_points, 0) + %f", $uid, $seed_points);
|
||||
$seedPointsPerHourUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['seed_points']);
|
||||
$seedBonusPerHourUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['seed_bonus']);
|
||||
$seedingTorrentCountUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['torrent_peer_count']);
|
||||
$seedingTorrentSizeUpdates[] = sprintf("when %d then %f", $uid, $seedBonusResult['size']);
|
||||
$seedBonusUpdates[] = sprintf("when %d then seedbonus + %f", $uid, $all_bonus);
|
||||
@@ -178,8 +179,8 @@ class CalculateUserSeedBonus implements ShouldQueue
|
||||
}
|
||||
$nowStr = now()->toDateTimeString();
|
||||
$sql = sprintf(
|
||||
"update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seedbonus = case id %s end, seeding_torrent_count = case id %s end, seeding_torrent_size = case id %s end, seed_points_updated_at = '%s' where id in (%s)",
|
||||
implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusUpdates), implode(" ", $seedingTorrentCountUpdates), implode(" ", $seedingTorrentSizeUpdates), $nowStr, $idStr
|
||||
"update users set seed_points = case id %s end, seed_points_per_hour = case id %s end, seed_bonus_per_hour = case id %s end, seedbonus = case id %s end, seeding_torrent_count = case id %s end, seeding_torrent_size = case id %s end, seed_points_updated_at = '%s' where id in (%s)",
|
||||
implode(" ", $seedPointsUpdates), implode(" ", $seedPointsPerHourUpdates), implode(" ", $seedBonusPerHourUpdates), implode(" ", $seedBonusUpdates), implode(" ", $seedingTorrentCountUpdates), implode(" ", $seedingTorrentSizeUpdates), $nowStr, $idStr
|
||||
);
|
||||
$result = NexusDB::statement($sql);
|
||||
if ($delIdRedisKey) {
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Models\SecondIcon;
|
||||
use App\Models\Source;
|
||||
use App\Models\Standard;
|
||||
use App\Models\Team;
|
||||
use App\Models\TorrentCustomField;
|
||||
use App\Models\User;
|
||||
use App\Policies\CodecPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
@@ -34,6 +35,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
Category::class => CodecPolicy::class,
|
||||
Icon::class => CodecPolicy::class,
|
||||
SecondIcon::class => CodecPolicy::class,
|
||||
TorrentCustomField::class => CodecPolicy::class,
|
||||
|
||||
Codec::class => CodecPolicy::class,
|
||||
AudioCodec::class => CodecPolicy::class,
|
||||
|
||||
@@ -36,6 +36,9 @@ use Nexus\Database\NexusDB;
|
||||
|
||||
class UserRepository extends BaseRepository
|
||||
{
|
||||
private static array $allowIncludes = ['inviter', 'valid_medals'];
|
||||
private static array $allowIncludeFields = ['seeding_leeching_data'];
|
||||
private static array $allowIncludeCounts = [];
|
||||
public function getList(array $params)
|
||||
{
|
||||
$query = User::query();
|
||||
@@ -66,28 +69,34 @@ class UserRepository extends BaseRepository
|
||||
{
|
||||
//query this info default
|
||||
$query = User::query()->with([]);
|
||||
$allowIncludes = ['inviter', 'valid_medals'];
|
||||
$allowIncludeCounts = [];
|
||||
$allowIncludeFields = [];
|
||||
$apiQueryBuilder = ApiQueryBuilder::for(UserResource::NAME, $query)
|
||||
->allowIncludes($allowIncludes)
|
||||
->allowIncludeCounts($allowIncludeCounts)
|
||||
->allowIncludeFields($allowIncludeFields)
|
||||
->allowIncludes(self::$allowIncludes)
|
||||
->allowIncludeCounts(self::$allowIncludeCounts)
|
||||
->allowIncludeFields(self::$allowIncludeFields)
|
||||
;
|
||||
$query = $apiQueryBuilder->build();
|
||||
$user = $query->findOrFail($id);
|
||||
Gate::authorize('view', $user);
|
||||
return $this->appendIncludeFields($apiQueryBuilder, $currentUser, $user);
|
||||
$userList = $this->appendIncludeFields($apiQueryBuilder, $currentUser, [$user]);
|
||||
return $userList[0];
|
||||
}
|
||||
|
||||
private function appendIncludeFields(ApiQueryBuilder $apiQueryBuilder, Authenticatable $currentUser, User $user): User
|
||||
private function appendIncludeFields(ApiQueryBuilder $apiQueryBuilder, Authenticatable $currentUser, $userList)
|
||||
{
|
||||
// $id = $torrent->id;
|
||||
// if ($apiQueryBuilder->hasIncludeField('has_bookmarked')) {
|
||||
// $torrent->has_bookmarked = (int)$user->bookmarks()->where('torrentid', $id)->exists();;
|
||||
// }
|
||||
|
||||
return $user;
|
||||
$idArr = [];
|
||||
foreach ($userList as $user) {
|
||||
$idArr[] = $user->id;
|
||||
}
|
||||
if ($hasFieldSeedingData = $apiQueryBuilder->hasIncludeField('seeding_leeching_data')) {
|
||||
$seedingData = $this->listUserSeedingLeechingData($idArr);
|
||||
}
|
||||
foreach ($userList as $user) {
|
||||
$id = $user->id;
|
||||
if ($hasFieldSeedingData && isset($seedingData[$id])) {
|
||||
$user->seeding_leeching_data = $seedingData[$id];
|
||||
}
|
||||
}
|
||||
return $userList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +268,7 @@ class UserRepository extends BaseRepository
|
||||
|
||||
private function setEnableLatelyCache(int $userId): void
|
||||
{
|
||||
NexusDB::cache_put(User::getUserEnableLatelyCacheKey($userId), now()->toDateTimeString());
|
||||
NexusDB::cache_put(User::getUserEnableLatelyCacheKey($userId), now()->toDateTimeString(), 86400);
|
||||
}
|
||||
|
||||
public function getInviteInfo($id)
|
||||
@@ -814,4 +823,38 @@ class UserRepository extends BaseRepository
|
||||
return $loginLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* get user seeding/leeching count and size
|
||||
*
|
||||
* @see calculate_seed_bonus()
|
||||
* @param array $userIdArr
|
||||
* @return array
|
||||
*/
|
||||
private function listUserSeedingLeechingData(array $userIdArr)
|
||||
{
|
||||
$minSize = get_setting('bonus.min_size', 0);
|
||||
$idStr = implode(",", $userIdArr);
|
||||
$sql = "select peers.userid, peers.seeder, torrents.size from torrents LEFT JOIN peers ON peers.torrent = torrents.id WHERE peers.userid in ($idStr) and torrents.size > $minSize group by peers.torrent, peers.peer_id, peers.userid, peers.seeder";
|
||||
$data = NexusDB::select($sql);
|
||||
$result = [];
|
||||
foreach ($data as $row) {
|
||||
if (!isset($result[$row['userid']])) {
|
||||
$result[$row['userid']] = [
|
||||
'seeding_count' => 0,
|
||||
'seeding_size' => 0,
|
||||
'leeching_count' => 0,
|
||||
'leeching_size' => 0,
|
||||
];
|
||||
}
|
||||
if ($row['seeder'] == 'yes') {
|
||||
$result[$row['userid']]['seeding_count'] += 1;
|
||||
$result[$row['userid']]['seeding_size'] += $row['size'];
|
||||
} else {
|
||||
$result[$row['userid']]['leeching_count'] += 1;
|
||||
$result[$row['userid']]['leeching_size'] += $row['size'];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->decimal('seed_bonus_per_hour', 20, 1)->default(0)->after('seed_points_per_hour');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('seed_bonus_per_hour');
|
||||
});
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -341,7 +341,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
|
||||
//rest seed_points_per_hour
|
||||
$seedPointsUpdatedAtMin = $carbonNow->subSeconds(2*intval($autoclean_interval_one))->toDateTimeString();
|
||||
sql_query("update users set seed_points_per_hour = 0 where seed_points_updated_at < " . sqlesc($seedPointsUpdatedAtMin));
|
||||
sql_query("update users set seed_points_per_hour = 0, seed_bonus_per_hour = 0, seeding_torrent_count = 0, seeding_torrent_size = 0 where seed_points_updated_at < " . sqlesc($seedPointsUpdatedAtMin));
|
||||
|
||||
\App\Repositories\CleanupRepository::runBatchJobCalculateUserSeedBonus($requestId);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.11');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-11-02');
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.13');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-12-28');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -3884,10 +3884,12 @@ foreach ($rows as $row)
|
||||
|
||||
if (user_can('torrentmanage'))
|
||||
{
|
||||
$actions = [];
|
||||
if (user_can('torrent-delete')) {
|
||||
print("<td class=\"rowfollow\"><a href=\"".htmlspecialchars("fastdelete.php?id=".$row['id'])."\"><img class=\"staff_delete\" src=\"pic/trans.gif\" alt=\"D\" title=\"".$lang_functions['text_delete']."\" /></a>");
|
||||
$actions[] = "<a href=\"".htmlspecialchars("fastdelete.php?id=".$row['id'])."\"><img class=\"staff_delete\" src=\"pic/trans.gif\" alt=\"D\" title=\"".$lang_functions['text_delete']."\" /></a>";
|
||||
}
|
||||
print("<br /><a href=\"edit.php?returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "&id=" . $row["id"] . "\"><img class=\"staff_edit\" src=\"pic/trans.gif\" alt=\"E\" title=\"".$lang_functions['text_edit']."\" /></a></td>\n");
|
||||
$actions[] = "<a href=\"edit.php?returnto=" . rawurlencode($_SERVER["REQUEST_URI"]) . "&id=" . $row["id"] . "\"><img class=\"staff_edit\" src=\"pic/trans.gif\" alt=\"E\" title=\"".$lang_functions['text_edit']."\" /></a>";
|
||||
echo sprintf("<td class=\"rowfollow\">%s</td>", implode("<br />", $actions));
|
||||
}
|
||||
print("</tr>\n");
|
||||
$counter++;
|
||||
|
||||
@@ -1669,6 +1669,14 @@ JS;
|
||||
\Nexus\Nexus::js($js, 'footer', false);
|
||||
}
|
||||
|
||||
function nexus_escape($data): array|string
|
||||
{
|
||||
if (is_array($data)) {
|
||||
return array_map('nexus_escape', $data);
|
||||
}
|
||||
return htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function is_fpm_mode(): bool
|
||||
{
|
||||
return php_sapi_name() === 'fpm-fcgi';
|
||||
|
||||
+9
-10
@@ -55,14 +55,13 @@ class Field
|
||||
|
||||
public function getTypeHuman($type)
|
||||
{
|
||||
global $lang_fields;
|
||||
$map = [
|
||||
self::TYPE_TEXT => $lang_fields['field_type_text'],
|
||||
self::TYPE_TEXTAREA => $lang_fields['field_type_textarea'],
|
||||
self::TYPE_RADIO => $lang_fields['field_type_radio'],
|
||||
self::TYPE_CHECKBOX => $lang_fields['field_type_checkbox'],
|
||||
self::TYPE_SELECT => $lang_fields['field_type_select'],
|
||||
self::TYPE_IMAGE => $lang_fields['field_type_image'],
|
||||
self::TYPE_TEXT => nexus_trans('field.type.text'),
|
||||
self::TYPE_TEXTAREA => nexus_trans('field.type.textarea'),
|
||||
self::TYPE_RADIO => nexus_trans('field.type.radio'),
|
||||
self::TYPE_CHECKBOX => nexus_trans('field.type.checkbox'),
|
||||
self::TYPE_SELECT => nexus_trans('field.type.select'),
|
||||
self::TYPE_IMAGE => nexus_trans('field.type.image'),
|
||||
];
|
||||
return $map[$type] ?? '';
|
||||
}
|
||||
@@ -439,7 +438,7 @@ JS;
|
||||
$customFieldDisplay = $field['display'];
|
||||
$customFieldDisplay = str_replace("<%{$field['name']}.label%>", $field['label'], $customFieldDisplay);
|
||||
$customFieldDisplay = str_replace("<%{$field['name']}.value%>", $contentNotFormatted, $customFieldDisplay);
|
||||
$rowByRowHtml .= tr($field['label'], format_comment($customFieldDisplay, false), 1);
|
||||
$rowByRowHtml .= tr($field['label'], format_comment($customFieldDisplay), 1);
|
||||
} else {
|
||||
$contentFormatted = $this->formatCustomFieldValue($field, true);
|
||||
$rowByRowHtml .= tr($field['label'], $contentFormatted, 1);
|
||||
@@ -463,13 +462,13 @@ JS;
|
||||
switch ($customFieldWithValue['type']) {
|
||||
case self::TYPE_TEXT:
|
||||
case self::TYPE_TEXTAREA:
|
||||
$result .= $doFormatComment ? format_comment($fieldValue, false) : $fieldValue;
|
||||
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||
break;
|
||||
case self::TYPE_IMAGE:
|
||||
if (substr($fieldValue, 0, 4) == 'http') {
|
||||
$result .= $doFormatComment ? formatImg($fieldValue, true, 700, 0, "attach{$customFieldWithValue['id']}") : $fieldValue;
|
||||
} else {
|
||||
$result .= $doFormatComment ? format_comment($fieldValue, false) : $fieldValue;
|
||||
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||
}
|
||||
break;
|
||||
case self::TYPE_RADIO:
|
||||
|
||||
@@ -84,14 +84,15 @@ class PTGen
|
||||
|
||||
public function generate(string $url, bool $withoutCache = false): array
|
||||
{
|
||||
$parsed = $this->parse($url);
|
||||
// $parsed = $this->parse($url);
|
||||
$targetUrl = trim($this->apiPoint, '/');
|
||||
if (Str::contains($targetUrl, '?')) {
|
||||
$targetUrl .= "&";
|
||||
} else {
|
||||
$targetUrl .= "?";
|
||||
}
|
||||
$targetUrl .= sprintf('site=%s&sid=%s&url=%s', $parsed['site'] , $parsed['id'], urlencode($parsed['url']));
|
||||
// $targetUrl .= sprintf('site=%s&sid=%s&url=%s', $parsed['site'] , $parsed['id'], urlencode($parsed['url']));
|
||||
$targetUrl .= "url=" . urlencode($url);
|
||||
return $this->request($targetUrl, $withoutCache);
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ HTML;
|
||||
}
|
||||
do_log("$logPrefix, going to send request...");
|
||||
$http = new Client();
|
||||
$response = $http->get($url, ['timeout' => 10]);
|
||||
$response = $http->post($url, ['timeout' => 10]);
|
||||
$statusCode = $response->getStatusCode();
|
||||
if ($statusCode != 200) {
|
||||
$msg = "api point response http status code: $statusCode";
|
||||
|
||||
+5
-6
@@ -29,7 +29,6 @@ $row = mysql_fetch_array($res);
|
||||
if (user_can('torrentmanage') || $CURUSER["id"] == $row["owner"])
|
||||
$owned = 1;
|
||||
else $owned = 0;
|
||||
|
||||
$settingMain = get_setting('main');
|
||||
if (!$row) {
|
||||
stderr($lang_details['std_error'], $lang_details['std_no_torrent_id']);
|
||||
@@ -308,20 +307,20 @@ JS;
|
||||
|
||||
//technical info
|
||||
if ($settingMain['enable_technical_info'] == 'yes') {
|
||||
$technicalData = $row['technical_info'] ?? '';
|
||||
|
||||
$technicalData = nexus_escape($row['technical_info'] ?? '');
|
||||
|
||||
// 判断是否为BDINFO格式
|
||||
$isBdInfo = false;
|
||||
if (!empty($technicalData)) {
|
||||
$firstLine = strtok($technicalData, "\n");
|
||||
if (strpos($firstLine, 'DISC INFO') !== false
|
||||
if (strpos($firstLine, 'DISC INFO') !== false
|
||||
|| strpos($firstLine, 'Disc Title') !== false
|
||||
|| strpos($firstLine, 'Disc Label') !== false
|
||||
) {
|
||||
$isBdInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($isBdInfo) {
|
||||
// 使用BdInfoExtra处理BDINFO格式
|
||||
$technicalInfo = new \Nexus\Torrent\BdInfoExtra($technicalData);
|
||||
@@ -329,7 +328,7 @@ JS;
|
||||
// 使用TechnicalInformation处理MediaInfo格式
|
||||
$technicalInfo = new \Nexus\Torrent\TechnicalInformation($technicalData);
|
||||
}
|
||||
|
||||
|
||||
$technicalInfoResult = $technicalInfo->renderOnDetailsPage();
|
||||
if (!empty($technicalInfoResult)) {
|
||||
tr($lang_functions['text_technical_info'], $technicalInfoResult, 1);
|
||||
|
||||
@@ -22,6 +22,7 @@ if ($action == 'view') {
|
||||
begin_main_frame();
|
||||
echo $field->buildFieldForm();
|
||||
} elseif ($action == 'submit') {
|
||||
die("This method is deprecated! This method is no longer available in 1.10, it does not save data correctly, please go to the management system!");
|
||||
try {
|
||||
$result = $field->save($_REQUEST);
|
||||
nexus_redirect('fields.php?action=view');
|
||||
|
||||
@@ -12,6 +12,7 @@ if(!empty($_POST['conusr'])) {
|
||||
// sql_query("UPDATE users SET status = 'confirmed', editsecret = '' WHERE id IN (" . implode(", ", $_POST['conusr']) . ") AND status='pending'");
|
||||
$userList = \App\Models\User::query()->whereIn('id', $_POST['conusr'])
|
||||
->where('status', 'pending')
|
||||
->where('invited_by', $id)
|
||||
->get(\App\Models\User::$commonFields)
|
||||
;
|
||||
if ($userList->isNotEmpty()) {
|
||||
@@ -21,6 +22,9 @@ if(!empty($_POST['conusr'])) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
stderr($lang_takeconfirm['std_sorry'],$lang_takeconfirm['std_no_buddy_to_confirm'].
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'type' => [
|
||||
'text' => 'Short text',
|
||||
'textarea' => 'Long text',
|
||||
'radio' => 'Horizontal single select',
|
||||
'checkbox' => 'Horizontal multiple select',
|
||||
'select' => 'Vertical single select',
|
||||
'image' => 'Image',
|
||||
],
|
||||
];
|
||||
@@ -456,4 +456,18 @@ Note: In 1.8, the 'searchbox_name' part can be omitted, i.e. the rule is 'pic/ca
|
||||
'select_section' => 'Selections',
|
||||
'select_section_help' => "If a selection is not defined, all options from the selection are allowed for the rule. At least one selection should be defined.",
|
||||
],
|
||||
'field' => [
|
||||
'label' => 'Custom field',
|
||||
'name' => 'Name',
|
||||
'name_help' => 'Only allow digit, alphabet, underline',
|
||||
'field_label' => 'Display label',
|
||||
'type' => 'Type',
|
||||
'required' => 'Required',
|
||||
'mod_only' => 'Mod only',
|
||||
'help' => 'Help text',
|
||||
'options' => 'Options',
|
||||
'options_help' => 'Required when type is radio, checkbox, select. One line, one option, format: value|display text',
|
||||
'is_single_row' => 'Display on a single row',
|
||||
'display' => 'Custom display',
|
||||
]
|
||||
];
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'type' => [
|
||||
'text' => '短文本',
|
||||
'textarea' => '长文本',
|
||||
'radio' => '横向单选',
|
||||
'checkbox' => '横向多选',
|
||||
'select' => '下拉单选',
|
||||
'image' => '图片',
|
||||
],
|
||||
];
|
||||
@@ -498,4 +498,18 @@ return [
|
||||
'select_section' => '选择',
|
||||
'select_section_help' => "如果某个选择未指定,其所有选项都符合此规则。必须至少指定一个选择。",
|
||||
],
|
||||
'field' => [
|
||||
'label' => '自定义字段',
|
||||
'name' => '名称',
|
||||
'name_help' => '仅允许数字、字母、下划线',
|
||||
'field_label' => '显示标签',
|
||||
'type' => '类型',
|
||||
'required' => '不能为空',
|
||||
'mod_only' => '仅管理组可见',
|
||||
'help' => '辅助说明',
|
||||
'options' => '选项',
|
||||
'options_help' => '类型为单选、多选、下拉时必填,一行一个,格式:选项值|选项描述文本',
|
||||
'is_single_row' => '展示时单独一行',
|
||||
'display' => '自定义展示',
|
||||
]
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user