* [refac] Refactor the delete files page after upgrading.
This commit is contained in:
@@ -220,6 +220,7 @@ $config->openMethods[] = 'sso.gettodolist';
|
||||
$config->openMethods[] = 'sso.login';
|
||||
$config->openMethods[] = 'sso.logout';
|
||||
$config->openMethods[] = 'upgrade.ajaxupdatefile';
|
||||
$config->openMethods[] = 'upgrade.safedelete';
|
||||
$config->openMethods[] = 'user.forgetpassword';
|
||||
$config->openMethods[] = 'user.login';
|
||||
$config->openMethods[] = 'user.refreshrandom';
|
||||
|
||||
@@ -1113,6 +1113,8 @@ class commonModel extends model
|
||||
|
||||
if($this->app->getModuleName() == 'upgrade' and $this->session->upgrading) return false;
|
||||
|
||||
if($this->app->getModuleName() == 'upgrade' && $this->app->getMethodName() == 'safedelete') return false;
|
||||
|
||||
$statusFile = $this->app->getAppRoot() . 'www' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'ok.txt';
|
||||
return (!is_file($statusFile) or (time() - filemtime($statusFile)) > $this->config->safeFileTimeout) ? $statusFile : false;
|
||||
}
|
||||
|
||||
@@ -811,6 +811,32 @@ class upgrade extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除安装和升级文件。
|
||||
* Safe delete install and upgrade files.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function safeDelete()
|
||||
{
|
||||
$files = [];
|
||||
$wwwRoot = $this->app->getWwwRoot();
|
||||
foreach(['install', 'upgrade'] as $file)
|
||||
{
|
||||
if(is_file($wwwRoot . $file . '.php')) $files[] = $wwwRoot . $file . '.php';
|
||||
}
|
||||
|
||||
if($files)
|
||||
{
|
||||
$command = 'rm -f ' . implode(' ', $files);
|
||||
$tips = $this->lang->upgrade->safeDeleteFile . ' ' . $this->lang->upgrade->execCommand;
|
||||
return $this->displayCommand($command, $tips);
|
||||
}
|
||||
|
||||
$this->locate($this->config->webRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务:处理内置关联关系。
|
||||
* AJAX: Process object relation.
|
||||
|
||||
@@ -2,10 +2,10 @@ function confirmStatusFile(event)
|
||||
{
|
||||
if($(event.target).prop('checked'))
|
||||
{
|
||||
$('#confirm').removeClass('disabled').attr('href', $.createLink('upgrade', 'index'));
|
||||
$('#confirm').removeClass('disabled').attr('onclick', 'loadCurrentPage()');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#confirm').addClass('disabled').removeAttr('href');
|
||||
$('#confirm').addClass('disabled').removeAttr('onclick');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ $lang->upgrade->createWinFile = 'Open command line and execute <span id="co
|
||||
$lang->upgrade->createLinuxFile = 'Execute <span id="command" class="font-bold text-danger">touch %s</span> in the command line';
|
||||
$lang->upgrade->deleteStatusFile = 'Or delete <span class="font-bold text-danger">%s</span> and create <span class="font-bold text-danger">ok.txt</span> and leave it blank.';
|
||||
$lang->upgrade->confirmStatusFile = 'I have read and done as instructed above.';
|
||||
$lang->upgrade->safeDeleteFile = 'For system security, the files need to be deleted.';
|
||||
|
||||
$lang->upgrade->selectVersion = 'Version';
|
||||
$lang->upgrade->copyCommand = 'Copy';
|
||||
|
||||
@@ -60,6 +60,7 @@ $lang->upgrade->createWinFile = '打开命令行,执行 <span id="command
|
||||
$lang->upgrade->createLinuxFile = '在命令行执行 <span id="command" class="font-bold text-danger">touch %s</span>';
|
||||
$lang->upgrade->deleteStatusFile = '或者删除 <span class="font-bold text-danger">%s</span> 这个文件,重新创建一个 <span class="font-bold text-danger">ok.txt</span> 文件,不需要内容。';
|
||||
$lang->upgrade->confirmStatusFile = '我已经仔细阅读上面提示且完成上述工作';
|
||||
$lang->upgrade->safeDeleteFile = '为了系统安全,需要删除文件。';
|
||||
|
||||
$lang->upgrade->selectVersion = '选择版本';
|
||||
$lang->upgrade->copyCommand = '复制命令';
|
||||
|
||||
@@ -48,7 +48,7 @@ div
|
||||
div
|
||||
(
|
||||
setClass('text-warning'),
|
||||
$lang->upgrade->execCommand
|
||||
$tips
|
||||
),
|
||||
row
|
||||
(
|
||||
|
||||
@@ -1125,15 +1125,16 @@ class upgradeZen extends upgrade
|
||||
* Display command.
|
||||
*
|
||||
* @param string $command
|
||||
* @param string $tips
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function displayCommand(string $command): void
|
||||
protected function displayCommand(string $command, string $tips = ''): void
|
||||
{
|
||||
$this->view->title = $this->lang->upgrade->common;
|
||||
$this->view->result = 'fail';
|
||||
$this->view->command = $command;
|
||||
|
||||
$this->view->tips = $tips ?: $this->lang->upgrade->execCommand;
|
||||
$this->display('upgrade', 'command');
|
||||
}
|
||||
|
||||
|
||||
+19
-25
@@ -49,31 +49,6 @@ $handler = static function ()
|
||||
/* Check the request is getconfig or not. */
|
||||
if(isset($_GET['mode']) and $_GET['mode'] == 'getconfig') die(helper::removeUTF8Bom($app->exportConfig()));
|
||||
|
||||
/* Remove install.php and upgrade.php. */
|
||||
if(file_exists('install.php') or file_exists('upgrade.php'))
|
||||
{
|
||||
if(!empty($config->inContainer) && !isset($_SESSION['installing']))
|
||||
{
|
||||
if(file_exists('install.php')) unlink('install.php');
|
||||
if(file_exists('upgrade.php')) unlink('upgrade.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
$undeletedFiles = array();
|
||||
if(file_exists('install.php')) $undeletedFiles[] = '<strong style="color:#ed980f">install.php</strong>';
|
||||
if(file_exists('upgrade.php')) $undeletedFiles[] = '<strong style="color:#ed980f">upgrade.php</strong>';
|
||||
$wwwDir = dirname(__FILE__);
|
||||
if($undeletedFiles)
|
||||
{
|
||||
echo "<html><head><meta charset='utf-8'></head>
|
||||
<body><table align='center' style='width:700px; margin-top:100px; border:1px solid gray; font-size:14px;'><tr><td style='padding:8px'>";
|
||||
echo "<div style='margin-bottom:8px;'>安全起见,请删除 <strong style='color:#ed980f'>{$wwwDir}</strong> 目录下的 " . join(' 和 ', $undeletedFiles) . " 文件。</div>";
|
||||
echo "<div>Please remove " . join(' and ', $undeletedFiles) . " under <strong style='color:#ed980f'>$wwwDir</strong> dir for security reason.</div>";
|
||||
die("</td></tr></table></body></html>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_GET['display']) && $_GET['display'] == 'card') $config->default->view = 'xhtml';
|
||||
|
||||
try
|
||||
@@ -87,6 +62,25 @@ $handler = static function ()
|
||||
$isClient = strpos($_SERVER['HTTP_USER_AGENT'], 'xuanxuan') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'uni-app') !== false;
|
||||
if($app->getViewType() != 'json' && session_id() != $app->sessionID && !$isClient) helper::restartSession($app->sessionID);
|
||||
|
||||
/* Remove install.php and upgrade.php. */
|
||||
$wwwDir = dirname(__FILE__);
|
||||
if(file_exists("{$wwwDir}/install.php") || file_exists("{$wwwDir}/upgrade.php"))
|
||||
{
|
||||
if(!empty($config->inContainer) && !isset($_SESSION['installing']))
|
||||
{
|
||||
if(file_exists('install.php')) unlink('install.php');
|
||||
if(file_exists('upgrade.php')) unlink('upgrade.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($app->getModuleName() != 'upgrade' && $app->getMethodName() != 'safedelete')
|
||||
{
|
||||
$url = helper::createLink('upgrade', 'safeDelete');
|
||||
die(header("location: $url"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$app->loadModule();
|
||||
}
|
||||
catch (EndResponseException $endResponseException)
|
||||
|
||||
Reference in New Issue
Block a user