From e6f89245d1895d7f51c410856301eec6c5e530b0 Mon Sep 17 00:00:00 2001 From: tianya Date: Mon, 28 Nov 2022 23:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/api.php | 51 ++++++++++++++++++++++-- src/install/index.php | 2 +- src/install/sql-dftables.txt | 3 +- src/install/update.txt | 8 ++-- src/system/database/dedesqlite.class.php | 21 ++++++---- 5 files changed, 68 insertions(+), 17 deletions(-) diff --git a/src/admin/api.php b/src/admin/api.php index c70517cc..51ed614d 100644 --- a/src/admin/api.php +++ b/src/admin/api.php @@ -17,6 +17,24 @@ AjaxHead(); helper('cache'); $action = isset($action) && in_array($action, array('is_need_check_code', 'has_new_version', 'get_changed_files', 'update_backup', 'get_update_versions', 'update')) ? $action : ''; $curDir = dirname(GetCurUrl()); //当前目录 +/** + * 表中是否存在某个字段 + * + * @param mixed $tablename 表名称 + * @param mixed $field 字段名 + * @return void + */ +function TableHasField($tablename,$field) +{ + global $dsql; + $dsql->GetTableFields($tablename,"tfd"); + while ($r = $dsql->GetFieldObject("tfd")) { + if ($r->name === $field) { + return true; + } + } + return false; +} /** * 登录鉴权 * @@ -46,6 +64,33 @@ if ($action === 'is_need_check_code') { )); exit; } else if ($action === 'has_new_version') { + //判断版本更新差异sql + $unQueryVer = array(); + if (!TableHasField("#@__tagindex", "keywords")) { + $unQueryVer[] = "6.0.2"; + } + if (!TableHasField("#@__feedback", "replycount")) { + $unQueryVer[] = "6.0.3"; + } + if (!TableHasField("#@__arctype", "litimg")) { + $unQueryVer[] = "6.1.0"; + } + if (!$dsql->IsTable("#@__statistics")) { + $unQueryVer[] = "6.1.7"; + } + if (TableHasField("#@__tagindex", "tag_pinyin")) { + $unQueryVer[] = "6.1.8"; + } + if (!TableHasField("#@__admin", "pwd_new")) { + $unQueryVer[] = "6.1.9"; + } + if (!TableHasField("#@__arctype", "cnoverview")) { + $unQueryVer[] = "6.1.10"; + } + if (!TableHasField("#@__admin", "loginerr")) { + $unQueryVer[] = "6.2.0"; + } + require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); checkLogin(); //是否存在更新版本 @@ -64,7 +109,7 @@ if ($action === 'is_need_check_code') { } else if ($action === 'get_changed_files') { require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); checkLogin(); - // 获取本地更改过的文件 + //获取本地更改过的文件 $hashUrl = DEDEBIZCDN.'/release/'.$cfg_version_detail.'.json'; $dhd = new DedeHttpDown(); $dhd->OpenUrl($hashUrl); @@ -95,7 +140,7 @@ if ($action === 'is_need_check_code') { } else if ($action === 'update_backup') { require_once(DEDEINC.'/libraries/dedehttpdown.class.php'); checkLogin(); - // 获取本地更改过的文件 + //获取本地更改过的文件 $hashUrl = DEDEBIZCDN.'/release/'.$cfg_version_detail.'.json'; $dhd = new DedeHttpDown(); $dhd->OpenUrl($hashUrl); @@ -115,7 +160,7 @@ if ($action === 'is_need_check_code') { foreach ($data as $file) { $realFile = DEDEROOT.str_replace("\\", '/', $file->filename); if (file_exists($realFile) && md5_file($realFile) !== $file->hash) { - // 备份文件 + //备份文件 $dstFile = $backupPath.'/'.str_replace("\\", '/', $file->filename); @mkdir(dirname($dstFile), 0777, true); copy($realFile, $dstFile); diff --git a/src/install/index.php b/src/install/index.php index c6496d46..19ad3d52 100644 --- a/src/install/index.php +++ b/src/install/index.php @@ -176,7 +176,7 @@ else if ($step==2) if ( $dbtype == 'sqlite' ) { $query = preg_replace('/character set (.*?) /i','',$query); - $query = str_replace('unsigned','',$query); + $query = preg_replace('/unsigned/i','',$query); $query = str_replace('TYPE=MyISAM','',$query); $query = preg_replace ('/TINYINT\(([\d]+)\)/i','INTEGER',$query); $query = preg_replace ('/mediumint\(([\d]+)\)/i','INTEGER',$query); diff --git a/src/install/sql-dftables.txt b/src/install/sql-dftables.txt index 7b755fb1..621d096c 100755 --- a/src/install/sql-dftables.txt +++ b/src/install/sql-dftables.txt @@ -974,12 +974,11 @@ CREATE TABLE `#@__sysconfig` ( DROP TABLE IF EXISTS `#@__tagindex`; CREATE TABLE `#@__tagindex` ( - `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `id` INT(10) NOT NULL AUTO_INCREMENT, `tag` CHAR(12) NOT NULL DEFAULT '', `keywords` varchar(255) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `title` varchar(255) DEFAULT NULL, - `tag_pinyin` varchar(255) DEFAULT NULL, `typeid` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', `count` INT(10) UNSIGNED NOT NULL DEFAULT '0', `total` INT(10) UNSIGNED NOT NULL DEFAULT '0', diff --git a/src/install/update.txt b/src/install/update.txt index 10e58b39..a826591e 100644 --- a/src/install/update.txt +++ b/src/install/update.txt @@ -22,12 +22,12 @@ CREATE TABLE `#@__feedback_goodbad` ( `fid` INT(11) NOT NULL DEFAULT '0', `fgtype` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '0:good 1:bad', PRIMARY KEY (`fgid`) -) ENGINE=MyISAM; +) TYPE=MyISAM; CREATE TABLE `#@__search_limits` ( `ip` VARCHAR(200) NOT NULL, `searchtime` INT(11) NULL DEFAULT NULL, PRIMARY KEY (`ip`) -) ENGINE=MyISAM; +) TYPE=MyISAM; -- 6.1.0 ALTER TABLE `#@__arctype` @@ -46,7 +46,7 @@ CREATE TABLE `#@__statistics` ( `ip` int DEFAULT NULL COMMENT 'IP', `vv` int DEFAULT NULL COMMENT 'vv', PRIMARY KEY (`id`) -) ENGINE=MyISAM; +) TYPE=MyISAM; CREATE TABLE `#@__statistics_detail` ( `id` int NOT NULL AUTO_INCREMENT, `t` int DEFAULT NULL COMMENT 'unixtime', @@ -67,7 +67,7 @@ CREATE TABLE `#@__statistics_detail` ( KEY `idx_created_date_dduuid` (`created_date`,`dduuid`), KEY `idx_created_date_ip` (`created_date`,`ip`), KEY `idx_created_date_ssid` (`created_date`,`ssid`) -) ENGINE=MyISAM; +) TYPE=MyISAM; ALTER TABLE `#@__addonarticle` MODIFY COLUMN `userip` char(46) NOT NULL DEFAULT '' AFTER `templet`; ALTER TABLE `#@__addonimages` MODIFY COLUMN `userip` char(46) NOT NULL DEFAULT '' AFTER `templet`; ALTER TABLE `#@__addoninfos` MODIFY COLUMN `userip` varchar(46) NOT NULL DEFAULT '' AFTER `litpic`; diff --git a/src/system/database/dedesqlite.class.php b/src/system/database/dedesqlite.class.php index c26e6fbc..84861d64 100755 --- a/src/system/database/dedesqlite.class.php +++ b/src/system/database/dedesqlite.class.php @@ -57,6 +57,7 @@ class DedeSqlite var $isInit = false; var $pconnect = false; var $_fixObject; + var $_fieldIdx = 1; //这里最好是数组,对应id,但由于用的地方不多,暂时先这样处理 //用外部定义的变量初始类,并连接数据库 function __construct($pconnect = FALSE, $nconnect = FALSE) { @@ -391,20 +392,27 @@ class DedeSqlite } $prefix = "#@__"; $tbname = str_replace($prefix, $GLOBALS['cfg_dbprefix'], $tbname); - $query = "SELECT * FROM {$tbname} LIMIT 0,1"; + $query = "SELECT * FROM {$tbname} LIMIT 1"; $this->result[$id] = $this->linkID->query($query); } //获取字段详细信息 function GetFieldObject($id = "me") { $cols = $this->result[$id]->numColumns(); - $fields = array(); - while ($row = $this->result[$id]->fetchArray()) { - for ($i = 1; $i < $cols; $i++) { - $fields[] = $this->result[$id]->columnName($i); + if ($this->_fieldIdx >= $cols) { + $this->_fieldIdx = 1; + return false; + } + for ($i = 1; $i <= $cols; $i++) { + $field = new stdClass; + $n = $this->result[$id]->columnName($i); + $field->name = $n; + if ($this->_fieldIdx === $i) { + $this->_fieldIdx++; + return $field; } } - return (object)$fields; + return false; } //获得查询的总记录数 function GetTotalRow($id = "me") @@ -543,4 +551,3 @@ function CopySQLiPoint(&$ndsql) { $GLOBALS['dsqlite'] = $ndsql; } -?> \ No newline at end of file