| @@ -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); | |||
| @@ -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); | |||
| @@ -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', | |||
| @@ -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`; | |||
| @@ -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; | |||
| } | |||
| ?> | |||