mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
backup export path configurable + fix some warning
This commit is contained in:
@@ -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_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_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.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_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'))),
|
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);
|
])->columns(2);
|
||||||
|
|||||||
@@ -243,5 +243,10 @@ class Setting extends NexusModel
|
|||||||
return self::get("permission.user_token_allowed");
|
return self::get("permission.user_token_allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getBackupExportPath(): string
|
||||||
|
{
|
||||||
|
return self::get("backup.export_path", sys_get_temp_dir());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class ToolRepository extends BaseRepository
|
|||||||
$webRoot = base_path();
|
$webRoot = base_path();
|
||||||
$dirName = basename($webRoot);
|
$dirName = basename($webRoot);
|
||||||
$excludes = self::BACKUP_EXCLUDES;
|
$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)) {
|
if (command_exists('tar') && ($method === 'tar' || $method === null)) {
|
||||||
$filename = $baseFilename . ".tar.gz";
|
$filename = $baseFilename . ".tar.gz";
|
||||||
$command = "tar";
|
$command = "tar";
|
||||||
@@ -89,7 +89,7 @@ class ToolRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
$connectionName = config('database.default');
|
$connectionName = config('database.default');
|
||||||
$config = config("database.connections.$connectionName");
|
$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(
|
$command = sprintf(
|
||||||
'mysqldump --user=%s --password=%s --host=%s --port=%s --single-transaction --no-create-db %s >> %s 2>&1',
|
'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,
|
$config['username'], $config['password'], $config['host'], $config['port'], $config['database'], $filename,
|
||||||
@@ -115,7 +115,7 @@ class ToolRepository extends BaseRepository
|
|||||||
if ($backupDatabase['result_code'] != 0) {
|
if ($backupDatabase['result_code'] != 0) {
|
||||||
throw new \RuntimeException("backup database fail: " . json_encode($backupDatabase));
|
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)) {
|
if (command_exists('tar') && ($method === 'tar' || $method === null)) {
|
||||||
$filename = $baseFilename . ".tar.gz";
|
$filename = $baseFilename . ".tar.gz";
|
||||||
$command = sprintf(
|
$command = sprintf(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.0');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.0');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-05-11');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-05-13');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
@@ -4287,10 +4287,10 @@ function permissiondenied($allowMinimumClass = null){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gettime($time, $withago = true, $twoline = false, $forceago = false, $oneunit = false, $isfuturetime = false){
|
function gettime($time, $withago = true, $twoline = false, $forceago = false, $oneunit = false, $isfuturetime = false){
|
||||||
|
if (empty($time)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!IN_NEXUS) {
|
if (!IN_NEXUS) {
|
||||||
if (empty($time)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return \Carbon\Carbon::parse($time)->diffForHumans();
|
return \Carbon\Carbon::parse($time)->diffForHumans();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class Imdb
|
|||||||
$temp = "";
|
$temp = "";
|
||||||
foreach ($movie->alsoknow() as $ak)
|
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), ",");
|
$autodata .= rtrim(trim($temp), ",");
|
||||||
$runtimes = str_replace(" min",$lang_details['text_mins'], $movie->runtime() ?? '');
|
$runtimes = str_replace(" min",$lang_details['text_mins'], $movie->runtime() ?? '');
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ class Torrent
|
|||||||
*/
|
*/
|
||||||
public function listLeechingSeedingStatus(int $uid, array $torrentIdArr)
|
public function listLeechingSeedingStatus(int $uid, array $torrentIdArr)
|
||||||
{
|
{
|
||||||
|
if (empty($torrentIdArr)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$torrentIdStr = implode(',', $torrentIdArr);
|
$torrentIdStr = implode(',', $torrentIdArr);
|
||||||
//seeding or leeching, from peers
|
//seeding or leeching, from peers
|
||||||
$whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr);
|
$whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST")
|
|||||||
{
|
{
|
||||||
if ($iv == "yes")
|
if ($iv == "yes")
|
||||||
check_code ($_POST['imagehash'], $_POST['imagestring'],"confirm_resend.php",true);
|
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"])));
|
$wantpassword = unesc(htmlspecialchars(trim($_POST["wantpassword"])));
|
||||||
$passagain = unesc(htmlspecialchars(trim($_POST["passagain"])));
|
$passagain = unesc(htmlspecialchars(trim($_POST["passagain"])));
|
||||||
|
|
||||||
|
|||||||
@@ -115,13 +115,13 @@ if ($type == 'new'){
|
|||||||
foreach (['yes', 'no'] as $item) {
|
foreach (['yes', 'no'] as $item) {
|
||||||
$enabledOptions .= sprintf(
|
$enabledOptions .= sprintf(
|
||||||
'<option value="%s"%s>%s</option>',
|
'<option value="%s"%s>%s</option>',
|
||||||
$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) {
|
foreach (['pending' => $lang_invite['text_pending'], 'confirmed' => $lang_invite['text_confirmed']] as $name => $text) {
|
||||||
$statusOptions .= sprintf(
|
$statusOptions .= sprintf(
|
||||||
'<option value="%s"%s>%s</option>',
|
'<option value="%s"%s>%s</option>',
|
||||||
$name, $_GET['status'] == $name ? ' selected' : '', $text
|
$name, isset($_GET['status']) && $_GET['status'] == $name ? ' selected' : '', $text
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ JS;
|
|||||||
print("</form>");
|
print("</form>");
|
||||||
}
|
}
|
||||||
print("</table>");
|
print("</table>");
|
||||||
print("</td></tr></table>$pagertop");
|
print("</td></tr></table>" . ($pagertop ?? ''));
|
||||||
} elseif (in_array($menuSelected, ['sent', 'tmp'])) {
|
} elseif (in_array($menuSelected, ['sent', 'tmp'])) {
|
||||||
$whereStr = "inviter = " . sqlesc($id);
|
$whereStr = "inviter = " . sqlesc($id);
|
||||||
if ($menuSelected == 'sent') {
|
if ($menuSelected == 'sent') {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST")
|
|||||||
{
|
{
|
||||||
if ($iv == "yes")
|
if ($iv == "yes")
|
||||||
check_code ($_POST['imagehash'], $_POST['imagestring'],"recover.php",true);
|
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);
|
$email = safe_email($email);
|
||||||
if (!$email)
|
if (!$email)
|
||||||
failedlogins($lang_recover['std_missing_email_address'],true);
|
failedlogins($lang_recover['std_missing_email_address'],true);
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ tr($lang_usercp['row_school'], "<select name=school>$schools</select>", 1);
|
|||||||
case "tracker":
|
case "tracker":
|
||||||
$showaddisabled = true;
|
$showaddisabled = true;
|
||||||
if ($enablead_advertisement == 'yes'){
|
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;
|
$showaddisabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel doc</a>',
|
'via_ftp_help' => 'Whether to save via FTP. If so, add the configuration information to the .env file, refer to <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel doc</a>',
|
||||||
'via_sftp' => 'Backup via SFTP',
|
'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 <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel doc</a>',
|
'via_sftp_help' => 'Whether to save via FTP. If so, add the configuration information to the .env file, refer to <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel doc</a>',
|
||||||
|
'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' => [
|
'hr' => [
|
||||||
'tab_header' => 'H&R',
|
'tab_header' => 'H&R',
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ return [
|
|||||||
'frequency' => '频率',
|
'frequency' => '频率',
|
||||||
'frequency_help' => '备份频率',
|
'frequency_help' => '备份频率',
|
||||||
'hour' => '小时',
|
'hour' => '小时',
|
||||||
'hour_help' => '在这个点钟数进行备份',
|
'hour_help' => '在这个点钟数进行备份。如果频率是按 \'hourly\',此值会被忽略',
|
||||||
'minute' => '分钟',
|
'minute' => '分钟',
|
||||||
'minute_help' => "在前面点钟数的这一分钟进行备份。如果频率是按 'hourly',此值会被忽略",
|
'minute_help' => "在前面点钟数的这一分钟进行备份。",
|
||||||
'google_drive_client_id' => 'Google Drive client ID',
|
'google_drive_client_id' => 'Google Drive client ID',
|
||||||
'google_drive_client_secret' => 'Google Drive client secret',
|
'google_drive_client_secret' => 'Google Drive client secret',
|
||||||
'google_drive_refresh_token' => 'Google Drive refresh token',
|
'google_drive_refresh_token' => 'Google Drive refresh token',
|
||||||
@@ -66,6 +66,8 @@ return [
|
|||||||
'via_ftp_help' => '是否通过 FTP 保存。如果通过,把配置信息添加到 .env 文件,参考 <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel 文档</a>',
|
'via_ftp_help' => '是否通过 FTP 保存。如果通过,把配置信息添加到 .env 文件,参考 <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel 文档</a>',
|
||||||
'via_sftp' => '通过 SFTP 保存',
|
'via_sftp' => '通过 SFTP 保存',
|
||||||
'via_sftp_help' => '是否通过 SFTP 保存。如果通过,把配置信息添加到 .env 文件,参考 <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel 文档</a>',
|
'via_sftp_help' => '是否通过 SFTP 保存。如果通过,把配置信息添加到 .env 文件,参考 <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel 文档</a>',
|
||||||
|
'export_path' => '导出到目录',
|
||||||
|
'export_path_help' => '不设置使用系统临时目录::default_path。可以使用第三方专业工具转移异地保存。',
|
||||||
],
|
],
|
||||||
'hr' => [
|
'hr' => [
|
||||||
'tab_header' => 'H&R',
|
'tab_header' => 'H&R',
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ return [
|
|||||||
'frequency' => '頻率',
|
'frequency' => '頻率',
|
||||||
'frequency_help' => '備份頻率',
|
'frequency_help' => '備份頻率',
|
||||||
'hour' => '小時',
|
'hour' => '小時',
|
||||||
'hour_help' => '在這個點鐘數進行備份',
|
'hour_help' => '在這個點鐘數進行備份。如果頻率是按 \'hourly\',此值會被忽略',
|
||||||
'minute' => '分鐘',
|
'minute' => '分鐘',
|
||||||
'minute_help' => "在前面點鐘數的這一分鐘進行備份。如果頻率是按 'hourly',此值會被忽略",
|
'minute_help' => "在前面點鐘數的這一分鐘進行備份",
|
||||||
'google_drive_client_id' => 'Google Drive client ID',
|
'google_drive_client_id' => 'Google Drive client ID',
|
||||||
'google_drive_client_secret' => 'Google Drive client secret',
|
'google_drive_client_secret' => 'Google Drive client secret',
|
||||||
'google_drive_refresh_token' => 'Google Drive refresh token',
|
'google_drive_refresh_token' => 'Google Drive refresh token',
|
||||||
@@ -66,6 +66,8 @@ return [
|
|||||||
'via_ftp_help' => '是否通過 FTP 保存。如果通過,把配置信息添加到 .env 文件,參考 <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel 文檔</a>',
|
'via_ftp_help' => '是否通過 FTP 保存。如果通過,把配置信息添加到 .env 文件,參考 <a href="https://laravel.com/docs/master/filesystem#ftp-driver-configuration">Laravel 文檔</a>',
|
||||||
'via_sftp' => '通過 SFTP 保存',
|
'via_sftp' => '通過 SFTP 保存',
|
||||||
'via_sftp_help' => '是否通過 SFTP 保存。如果通過,把配置信息添加到 .env 文件,參考 <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel 文檔</a>',
|
'via_sftp_help' => '是否通過 SFTP 保存。如果通過,把配置信息添加到 .env 文件,參考 <a href="https://laravel.com/docs/master/filesystem#sftp-driver-configuration">Laravel 文檔</a>',
|
||||||
|
'export_path' => '導出到目錄',
|
||||||
|
'export_path_help' => '不設置使用系統臨時目錄::default_path。可以使用第三方專業工具轉移異地保存。',
|
||||||
],
|
],
|
||||||
'hr' => [
|
'hr' => [
|
||||||
'tab_header' => 'H&R',
|
'tab_header' => 'H&R',
|
||||||
|
|||||||
Reference in New Issue
Block a user