diff --git a/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php b/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php index 7775c559..d4838b97 100644 --- a/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php +++ b/app/Filament/Resources/System/SettingResource/Pages/EditSetting.php @@ -122,6 +122,7 @@ class EditSetting extends Page implements Forms\Contracts\HasForms // Forms\Components\TextInput::make('backup.google_drive_client_secret')->label(__('label.setting.backup.google_drive_client_secret')), // Forms\Components\TextInput::make('backup.google_drive_refresh_token')->label(__('label.setting.backup.google_drive_refresh_token')), // Forms\Components\TextInput::make('backup.google_drive_folder_id')->label(__('label.setting.backup.google_drive_folder_id')), + Forms\Components\TextInput::make('backup.export_path')->label(__('label.setting.backup.export_path'))->helperText(new HtmlString(__('label.setting.backup.export_path_help', ['default_path' => sys_get_temp_dir()]))), Forms\Components\Radio::make('backup.via_ftp')->options(self::$yesOrNo)->inline(true)->label(__('label.setting.backup.via_ftp'))->helperText(new HtmlString(__('label.setting.backup.via_ftp_help'))), Forms\Components\Radio::make('backup.via_sftp')->options(self::$yesOrNo)->inline(true)->label(__('label.setting.backup.via_sftp'))->helperText(new HtmlString(__('label.setting.backup.via_sftp_help'))), ])->columns(2); diff --git a/app/Models/Setting.php b/app/Models/Setting.php index d3263cee..dfc87d77 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -243,5 +243,10 @@ class Setting extends NexusModel return self::get("permission.user_token_allowed"); } + public static function getBackupExportPath(): string + { + return self::get("backup.export_path", sys_get_temp_dir()); + } + } diff --git a/app/Repositories/ToolRepository.php b/app/Repositories/ToolRepository.php index 7bf461d2..1d11b761 100644 --- a/app/Repositories/ToolRepository.php +++ b/app/Repositories/ToolRepository.php @@ -32,7 +32,7 @@ class ToolRepository extends BaseRepository $webRoot = base_path(); $dirName = basename($webRoot); $excludes = self::BACKUP_EXCLUDES; - $baseFilename = sprintf('%s/%s.web.%s', sys_get_temp_dir(), $dirName, date('Ymd.His')); + $baseFilename = sprintf('%s/%s.web.%s', Setting::getBackupExportPath(), $dirName, date('Ymd.His')); if (command_exists('tar') && ($method === 'tar' || $method === null)) { $filename = $baseFilename . ".tar.gz"; $command = "tar"; @@ -89,7 +89,7 @@ class ToolRepository extends BaseRepository { $connectionName = config('database.default'); $config = config("database.connections.$connectionName"); - $filename = sprintf('%s/%s.database.%s.sql', sys_get_temp_dir(), basename(base_path()), date('Ymd.His')); + $filename = sprintf('%s/%s.database.%s.sql', Setting::getBackupExportPath(), basename(base_path()), date('Ymd.His')); $command = sprintf( 'mysqldump --user=%s --password=%s --host=%s --port=%s --single-transaction --no-create-db %s >> %s 2>&1', $config['username'], $config['password'], $config['host'], $config['port'], $config['database'], $filename, @@ -115,7 +115,7 @@ class ToolRepository extends BaseRepository if ($backupDatabase['result_code'] != 0) { throw new \RuntimeException("backup database fail: " . json_encode($backupDatabase)); } - $baseFilename = sprintf('%s/%s.%s', sys_get_temp_dir(), basename(base_path()), date('Ymd.His')); + $baseFilename = sprintf('%s/%s.%s', Setting::getBackupExportPath(), basename(base_path()), date('Ymd.His')); if (command_exists('tar') && ($method === 'tar' || $method === null)) { $filename = $baseFilename . ".tar.gz"; $command = sprintf( diff --git a/include/constants.php b/include/constants.php index 4f331c3e..eaa2aba6 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ diffForHumans(); } catch (\Exception $e) { diff --git a/nexus/Imdb/Imdb.php b/nexus/Imdb/Imdb.php index d8730ae5..4e9e95c2 100644 --- a/nexus/Imdb/Imdb.php +++ b/nexus/Imdb/Imdb.php @@ -174,7 +174,7 @@ class Imdb $temp = ""; foreach ($movie->alsoknow() as $ak) { - $temp .= $ak["title"].$ak["year"]. ($ak["country"] != "" ? " (".$ak["country"].")" : "") . ($ak["comment"] != "" ? " (" . $ak["comment"] . ")" : "") . ", "; + $temp .= $ak["title"].($ak["country"] != "" ? " (".$ak["country"].")" : "") . ($ak["comment"] != "" ? " (" . $ak["comment"] . ")" : "") . ", "; } $autodata .= rtrim(trim($temp), ","); $runtimes = str_replace(" min",$lang_details['text_mins'], $movie->runtime() ?? ''); diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php index e36026cc..3f21b8a7 100644 --- a/nexus/Torrent/Torrent.php +++ b/nexus/Torrent/Torrent.php @@ -19,6 +19,9 @@ class Torrent */ public function listLeechingSeedingStatus(int $uid, array $torrentIdArr) { + if (empty($torrentIdArr)) { + return []; + } $torrentIdStr = implode(',', $torrentIdArr); //seeding or leeching, from peers $whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr); diff --git a/public/confirm_resend.php b/public/confirm_resend.php index cc98c62a..c658a43f 100644 --- a/public/confirm_resend.php +++ b/public/confirm_resend.php @@ -29,7 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($iv == "yes") check_code ($_POST['imagehash'], $_POST['imagestring'],"confirm_resend.php",true); - $email = unesc(htmlspecialchars(trim($_POST["email"]))); + $email = unesc(htmlspecialchars(trim($_POST["email"] ?? ''))); $wantpassword = unesc(htmlspecialchars(trim($_POST["wantpassword"]))); $passagain = unesc(htmlspecialchars(trim($_POST["passagain"]))); diff --git a/public/invite.php b/public/invite.php index 764aa6bd..2eb719d3 100644 --- a/public/invite.php +++ b/public/invite.php @@ -115,13 +115,13 @@ if ($type == 'new'){ foreach (['yes', 'no'] as $item) { $enabledOptions .= sprintf( '', - $item, $_GET['enabled'] == $item ? ' selected' : '', strtoupper($item) + $item, isset($_GET['enabled']) && $_GET['enabled'] == $item ? ' selected' : '', strtoupper($item) ); } foreach (['pending' => $lang_invite['text_pending'], 'confirmed' => $lang_invite['text_confirmed']] as $name => $text) { $statusOptions .= sprintf( '', - $name, $_GET['status'] == $name ? ' selected' : '', $text + $name, isset($_GET['status']) && $_GET['status'] == $name ? ' selected' : '', $text ); } @@ -251,7 +251,7 @@ JS; print(""); } print(""); - print("$pagertop"); + print("" . ($pagertop ?? '')); } elseif (in_array($menuSelected, ['sent', 'tmp'])) { $whereStr = "inviter = " . sqlesc($id); if ($menuSelected == 'sent') { diff --git a/public/recover.php b/public/recover.php index df398fdc..a0c5e219 100644 --- a/public/recover.php +++ b/public/recover.php @@ -29,7 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($iv == "yes") check_code ($_POST['imagehash'], $_POST['imagestring'],"recover.php",true); - $email = unesc(htmlspecialchars(trim($_POST["email"]))); + $email = unesc(htmlspecialchars(trim($_POST["email"] ?? ''))); $email = safe_email($email); if (!$email) failedlogins($lang_recover['std_missing_email_address'],true); diff --git a/public/usercp.php b/public/usercp.php index 0cda46dd..fd93be73 100644 --- a/public/usercp.php +++ b/public/usercp.php @@ -225,7 +225,7 @@ tr($lang_usercp['row_school'], "", 1); case "tracker": $showaddisabled = true; if ($enablead_advertisement == 'yes'){ - if (get_user_class() >= $noad_advertisement || ($enablebonusnoad_advertisement == 'yes' && strtotime($CURUSER['noaduntil']) >= TIMENOW)){ + if (get_user_class() >= $noad_advertisement || ($enablebonusnoad_advertisement == 'yes' && !empty($CURUSER['noaduntil']) && strtotime($CURUSER['noaduntil']) >= TIMENOW)){ $showaddisabled = false; } } diff --git a/resources/lang/en/label.php b/resources/lang/en/label.php index ff81144c..2ec774bd 100644 --- a/resources/lang/en/label.php +++ b/resources/lang/en/label.php @@ -66,6 +66,8 @@ return [ 'via_ftp_help' => 'Whether to save via FTP. If so, add the configuration information to the .env file, refer to Laravel doc', 'via_sftp' => 'Backup via SFTP', 'via_sftp_help' => 'Whether to save via FTP. If so, add the configuration information to the .env file, refer to Laravel doc', + 'export_path' => 'Export to directory', + 'export_path_help' => 'Not set to use the system temporary directory::default_path. you can use third-party specialized tools to transfer offsite saves.' , ], 'hr' => [ 'tab_header' => 'H&R', diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index 404d930c..76d70355 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -55,9 +55,9 @@ return [ 'frequency' => '频率', 'frequency_help' => '备份频率', 'hour' => '小时', - 'hour_help' => '在这个点钟数进行备份', + 'hour_help' => '在这个点钟数进行备份。如果频率是按 \'hourly\',此值会被忽略', 'minute' => '分钟', - 'minute_help' => "在前面点钟数的这一分钟进行备份。如果频率是按 'hourly',此值会被忽略", + 'minute_help' => "在前面点钟数的这一分钟进行备份。", 'google_drive_client_id' => 'Google Drive client ID', 'google_drive_client_secret' => 'Google Drive client secret', 'google_drive_refresh_token' => 'Google Drive refresh token', @@ -66,6 +66,8 @@ return [ 'via_ftp_help' => '是否通过 FTP 保存。如果通过,把配置信息添加到 .env 文件,参考 Laravel 文档', 'via_sftp' => '通过 SFTP 保存', 'via_sftp_help' => '是否通过 SFTP 保存。如果通过,把配置信息添加到 .env 文件,参考 Laravel 文档', + 'export_path' => '导出到目录', + 'export_path_help' => '不设置使用系统临时目录::default_path。可以使用第三方专业工具转移异地保存。', ], 'hr' => [ 'tab_header' => 'H&R', diff --git a/resources/lang/zh_TW/label.php b/resources/lang/zh_TW/label.php index 123290c1..5ac2a0f0 100644 --- a/resources/lang/zh_TW/label.php +++ b/resources/lang/zh_TW/label.php @@ -55,9 +55,9 @@ return [ 'frequency' => '頻率', 'frequency_help' => '備份頻率', 'hour' => '小時', - 'hour_help' => '在這個點鐘數進行備份', + 'hour_help' => '在這個點鐘數進行備份。如果頻率是按 \'hourly\',此值會被忽略', 'minute' => '分鐘', - 'minute_help' => "在前面點鐘數的這一分鐘進行備份。如果頻率是按 'hourly',此值會被忽略", + 'minute_help' => "在前面點鐘數的這一分鐘進行備份", 'google_drive_client_id' => 'Google Drive client ID', 'google_drive_client_secret' => 'Google Drive client secret', 'google_drive_refresh_token' => 'Google Drive refresh token', @@ -66,6 +66,8 @@ return [ 'via_ftp_help' => '是否通過 FTP 保存。如果通過,把配置信息添加到 .env 文件,參考 Laravel 文檔', 'via_sftp' => '通過 SFTP 保存', 'via_sftp_help' => '是否通過 SFTP 保存。如果通過,把配置信息添加到 .env 文件,參考 Laravel 文檔', + 'export_path' => '導出到目錄', + 'export_path_help' => '不設置使用系統臨時目錄::default_path。可以使用第三方專業工具轉移異地保存。', ], 'hr' => [ 'tab_header' => 'H&R',