From 9e1b61e0f0a16a0e99886b3a27fd1d6b02d319be Mon Sep 17 00:00:00 2001 From: joyqi Date: Mon, 30 Oct 2017 12:11:13 +0800 Subject: [PATCH] fix #637 --- var/Upgrade.php | 44 +++++++++++++++++++++++++---------------- var/Widget/Security.php | 6 ++++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/var/Upgrade.php b/var/Upgrade.php index 89a4ac6c..613a8a1c 100644 --- a/var/Upgrade.php +++ b/var/Upgrade.php @@ -1086,8 +1086,7 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public function v0_9r13_12_6($db, $options) { - $frontArchive = $db->fetchRow($db->select()->from('table.options')->where('name = ?', 'frontArchive')); - if (empty($frontArchive)) { + if (!isset($options->frontArchive)) { $db->query($db->insert('table.options') ->rows(array('name' => 'frontArchive', 'user' => 0, 'value' => 0))); } @@ -1103,8 +1102,7 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public function v0_9r13_12_20($db, $options) { - $commentsWhitelist = $db->fetchRow($db->select()->from('table.options')->where('name = ?', 'commentsWhitelist')); - if (empty($commentsWhitelist)) { + if (!isset($options->commentsWhitelist)) { $db->query($db->insert('table.options') ->rows(array('name' => 'commentsWhitelist', 'user' => 0, 'value' => 0))); } @@ -1175,8 +1173,10 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public function v0_9r14_3_14($db, $options) { - $db->query($db->insert('table.options') - ->rows(array('name' => 'secret', 'user' => 0, 'value' => Typecho_Common::randString(32, true)))); + if (!isset($options->secret)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'secret', 'user' => 0, 'value' => Typecho_Common::randString(32, true)))); + } } /** @@ -1189,8 +1189,10 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public function v1_0r14_9_2($db, $options) { - $db->query($db->insert('table.options') - ->rows(array('name' => 'lang', 'user' => 0, 'value' => 'zh_CN'))); + if (!isset($options->lang)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'lang', 'user' => 0, 'value' => 'zh_CN'))); + } } /** @@ -1203,8 +1205,10 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public function v1_0r14_10_10($db, $options) { - $db->query($db->insert('table.options') - ->rows(array('name' => 'commentsAntiSpam', 'user' => 0, 'value' => 1))); + if (!isset($options->commentsAntiSpam)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'commentsAntiSpam', 'user' => 0, 'value' => 1))); + } } /** @@ -1219,8 +1223,10 @@ Typecho_Date::setTimezoneOffset($options->timezone); public static function v1_1r17_4_24($db, $options) { // 增加markdown - $db->query($db->insert('table.options') - ->rows(array('name' => 'xmlrpcMarkdown', 'user' => 0, 'value' => 0))); + if (!isset($options->xmlrpcMarkdown)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'xmlrpcMarkdown', 'user' => 0, 'value' => 0))); + } } /** @@ -1235,8 +1241,10 @@ Typecho_Date::setTimezoneOffset($options->timezone); public static function v1_1r17_10_24($db, $options) { // 增加installed - $db->query($db->insert('table.options') - ->rows(array('name' => 'installed', 'user' => 0, 'value' => 1))); + if (!isset($options->installed)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'installed', 'user' => 0, 'value' => 1))); + } } /** @@ -1250,9 +1258,11 @@ Typecho_Date::setTimezoneOffset($options->timezone); */ public static function v1_1r17_10_27($db, $options) { - // 增加installed - $db->query($db->insert('table.options') - ->rows(array('name' => 'allowXmlRpc', 'user' => 0, 'value' => 2))); + // 增加xmlRpc开关 + if (!isset($options->allowXmlRpc)) { + $db->query($db->insert('table.options') + ->rows(array('name' => 'allowXmlRpc', 'user' => 0, 'value' => 2))); + } } } diff --git a/var/Widget/Security.php b/var/Widget/Security.php index 0df4cbea..03e2b9b4 100644 --- a/var/Widget/Security.php +++ b/var/Widget/Security.php @@ -63,6 +63,12 @@ class Widget_Security extends Typecho_Widget } } + // 验证入口文件 + $indexFile = __TYPECHO_ROOT_DIR__ . '/index.php'; + if (md5_file($indexFile) != 'f4dae7ceb7002cf4f95d380f5ced906b') { + $errors[] = _t('当前网站的入口文件 %s 与最新版中的不一致, 请更新', $indexFile); + } + return $errors; }