From 76e8841a51b14d5f7e285c5a14f124260dabb85c Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 8 May 2015 14:46:11 +0800 Subject: [PATCH] * finish task #2247. --- module/common/control.php | 5 ++--- module/editor/control.php | 5 +++++ module/editor/lang/en.php | 1 + module/editor/lang/zh-cn.php | 1 + module/extension/control.php | 7 +++++++ module/extension/lang/en.php | 8 ++++++++ module/extension/lang/zh-cn.php | 8 ++++++++ module/upgrade/model.php | 12 ++++++++++++ 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/module/common/control.php b/module/common/control.php index 8ac281c97c..658d610d4c 100644 --- a/module/common/control.php +++ b/module/common/control.php @@ -38,10 +38,9 @@ class common extends control */ public function checkUpgradeStatus() { - $statusFile = $this->app->getAppRoot() . 'www' . $this->pathFix . 'ok.txt'; - if(!file_exists($statusFile) or time() - filemtime($statusFile) > 3600) + $statusFile = $this->loadModel('upgrade')->checkSafeFile(); + if($statusFile) { - $this->app->loadLang('upgrade'); echo ""; echo "
"; printf($this->lang->upgrade->setStatusFile, $statusFile, $statusFile, $statusFile); diff --git a/module/editor/control.php b/module/editor/control.php index 157b99f361..764be8515e 100644 --- a/module/editor/control.php +++ b/module/editor/control.php @@ -134,6 +134,11 @@ class editor extends control */ public function save($filePath = '', $action = '') { + $statusFile = $this->loadModel('upgrade')->checkSafeFile(); + if($statusFile) + { + die(js::alert(sprintf($this->lang->editor->noticeOkFile, $statusFile, $statusFile, $statusFile))); + } if($filePath and $_POST) { $filePath = helper::safe64Decode($filePath); diff --git a/module/editor/lang/en.php b/module/editor/lang/en.php index 6b4cd29000..93ac1ec684 100644 --- a/module/editor/lang/en.php +++ b/module/editor/lang/en.php @@ -30,6 +30,7 @@ $lang->editor->deleteConfirm = 'Are you sure?'; $lang->editor->extendConfirm = 'Would you reuse the code.'; $lang->editor->repeatFile = 'File name repeat'; $lang->editor->repeatPage = 'This page has extisted. Is override?'; +$lang->editor->noticeOkFile = 'The ok file does not exist or has expired\nFor safe, please re create the ok file\nYou can perform the following commands on the server: \nFor windows:echo ok > %s\nFor linux:touch %s;'; $lang->editor->notWritable = "Can not writable, maybe no power. please try chmod 777 -R "; $lang->editor->notDelete = "Can not delete, please check power!"; diff --git a/module/editor/lang/zh-cn.php b/module/editor/lang/zh-cn.php index 805b7e1683..2f05eaae31 100644 --- a/module/editor/lang/zh-cn.php +++ b/module/editor/lang/zh-cn.php @@ -30,6 +30,7 @@ $lang->editor->deleteConfirm = '是否要删除?'; $lang->editor->extendConfirm = '是否要重用原来代码?'; $lang->editor->repeatFile = '文件名重复'; $lang->editor->repeatPage = '已经有此页面。是否覆盖?'; +$lang->editor->noticeOkFile = 'ok文件不存在或文件已过期\n为了系统的安全,请重新创建ok文件\n您可在服务器执行下面相应的命令:\nwindows: 打开命令行,执行 echo ok > %s\nlinux: touch %s;\n或者删掉 %s 这个文件 ,重新创建一个ok.txt文件,不需要内容。'; $lang->editor->notWritable = "无法写入,可能没有权限。请尝试执行 chmod 777 -R "; $lang->editor->notDelete = '无法删除,请检查权限!'; diff --git a/module/extension/control.php b/module/extension/control.php index 37360e6b09..859927940d 100644 --- a/module/extension/control.php +++ b/module/extension/control.php @@ -120,6 +120,13 @@ class extension extends control $this->view->upgrade = $upgrade; $this->view->title = $installTitle . $extension; + + $statusFile = $this->loadModel('upgrade')->checkSafeFile(); + if($statusFile) + { + $this->view->error = sprintf($this->lang->extension->noticeOkFile, $statusFile, $statusFile, $statusFile); + die($this->display()); + } /* Get the package file name. */ $packageFile = $this->extension->getPackageFile($extension); diff --git a/module/extension/lang/en.php b/module/extension/lang/en.php index dd5d184172..24ea514998 100644 --- a/module/extension/lang/en.php +++ b/module/extension/lang/en.php @@ -81,6 +81,14 @@ $lang->extension->viewInstalled = 'View installed extensions.'; $lang->extension->viewAvailable = 'View available extensions'; $lang->extension->viewDeactivated = 'View deactivated extensions'; $lang->extension->backDBFile = 'Plug-related data has been backed up to %s file!'; +$lang->extension->noticeOkFile = '

The ok file does not exist or has expired

+

For safe, please re create the ok file

+

You can perform the following commands on the server:

+
    +
  • For linux:touch %s;
  • +
  • For windows:echo ok > %s
  • +
'; + $lang->extension->upgradeExt = 'Upgrade'; $lang->extension->installExt = 'Install'; diff --git a/module/extension/lang/zh-cn.php b/module/extension/lang/zh-cn.php index f67003dea8..b550f4fde7 100644 --- a/module/extension/lang/zh-cn.php +++ b/module/extension/lang/zh-cn.php @@ -81,6 +81,14 @@ $lang->extension->viewInstalled = '查看已安装插件'; $lang->extension->viewAvailable = '查看可安装插件'; $lang->extension->viewDeactivated = '查看已禁用插件'; $lang->extension->backDBFile = '插件相关数据已经备份到 %s 文件中!'; +$lang->extension->noticeOkFile = '

ok文件不存在或文件已过期

+

为了系统的安全,请重新创建ok文件

+

您可在服务器执行下面相应的命令:

+
    +
  • windows: 打开命令行,执行echo ok > %s
  • +
  • linux: touch %s;
  • +
  • 或者删掉 "%s" 这个文件 ,重新创建一个ok.txt文件,不需要内容。
  • +
'; $lang->extension->upgradeExt = '升级'; $lang->extension->installExt = '安装'; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 257f67b306..184ba55f60 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -960,4 +960,16 @@ class upgradeModel extends model self::$errors = array(); return $errors; } + + /** + * Check safe file. + * + * @access public + * @return string|false + */ + public function checkSafeFile() + { + $statusFile = $this->app->getAppRoot() . 'www' . DIRECTORY_SEPARATOR . 'ok.txt'; + return (!file_exists($statusFile) or time() - filemtime($statusFile) > 3600) ? $statusFile : false; + } }