<?php
/**
* Modoer 1.0.x 升级到 1.1
* @author moufer<moufer@163.com>
* @package 
* @copyright wa666.cn
* @version $Id$
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);

@ob_start();

@set_time_limit(1000);
set_magic_quotes_runtime(0);

define('PRODUCT', 'Modoer');
define('IN_MUDDER', TRUE);
define('MUDDER_ROOT', '../');

$timestamp = time();
$_POST = (array)$_POST;
$_GET = (array)$_GET;
if(!get_magic_quotes_gpc()) {
	$_POST = add_slashes($_POST);
	$_GET = add_slashes($_GET);
	$_COOKIE = add_slashes($_COOKIE);
}
@extract($_POST, EXTR_SKIP);
@extract($_GET, EXTR_SKIP);
unset($_POST, $_GET);

$phpself = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];

require_once(MUDDER_ROOT.'config.inc.php');
require_once(MUDDER_ROOT.'include/mysql.class.php');

$db = new Db_class($dbhost, $dbuser, $dbpw, $dbname);

header('Content-type: text/html; charset='.$charset);

$oldversion = '1.0.x';
$newversion = '1.1';
$lockname = 'upgrade_10to11.lock';

$lockfile = MUDDER_ROOT.'data/'.$lockname;
$sqlfile = MUDDER_ROOT.'install/'.$sqlname;

file_exists($lockfile) && redirect(PRODUCT.'系统已升级，如需重新升级，请删除 ./data/'.$lockname.' 文件。',1,'stop');

empty($step) && $step = 1;

if($step == 1) {

} elseif($step == 2) {

    // 新建表

    $array = array(
        'modoer_ads'=> "
              adid smallint(5) NOT NULL auto_increment,
              callid smallint(5) unsigned NOT NULL default '0',
              subject varchar(60) NOT NULL default '',
              adtype tinyint(3) unsigned NOT NULL default '1',
              begintime int(10) NOT NULL default '0',
              endtime int(10) NOT NULL default '0',
              content mediumtext NOT NULL,
              code mediumtext NOT NULL,
              isclosed tinyint(1) NOT NULL default '0',
              attr varchar(10) NOT NULL default '',
              PRIMARY KEY  (adid)" ,
        'modoer_articledata'=> "
              articleid mediumint(8) unsigned NOT NULL default '0',
              content longtext NOT NULL,
              PRIMARY KEY  (articleid)" ,
        'modoer_articleclass'=> "
              classid smallint(5) unsigned NOT NULL auto_increment,
              classname varchar(20) NOT NULL default '',
              displayorder smallint(5) NOT NULL default '0',
              articlenum mediumint(8) unsigned NOT NULL default '0',
              PRIMARY KEY  (classid)" ,
        'modoer_articles'=> "
              articleid mediumint(8) unsigned NOT NULL auto_increment,
              classid smallint(5) unsigned NOT NULL default '0',
              shopid mediumint(8) NOT NULL default '0',
              dateline int(10) NOT NULL default '0',
              att tinyint(1) NOT NULL default '0',
              author varchar(20) NOT NULL default '',
              subject varchar(60) NOT NULL default '',
              keywords varchar(100) NOT NULL default '',
              pageview mediumint(8) unsigned NOT NULL default '0',
              digg mediumint(8) NOT NULL default '0',
              copyfrom varchar(200) NOT NULL default '',
              introduce mediumtext NOT NULL,
              status tinyint(1) NOT NULL default '1',
              checker varchar(30) NOT NULL default '',
              PRIMARY KEY  (articleid),
              KEY classid (classid),
              KEY shopid (shopid),
              KEY dateline (dateline),
              KEY digg (digg)" ,
        'modoer_coupons'=> "
              couponid mediumint(8) unsigned NOT NULL auto_increment,
              shopid mediumint(8) unsigned NOT NULL default '0',
              uid mediumint(8) NOT NULL default '0',
              username varchar(30) NOT NULL default '',
              thumb varchar(255) NOT NULL default '',
              picture varchar(255) NOT NULL default '',
              starttime int(10) NOT NULL default '0',
              endtime int(10) NOT NULL default '0',
              subject varchar(100) NOT NULL default '',
              des varchar(50) NOT NULL default '',
              content text NOT NULL,
              effect1 mediumint(8) unsigned NOT NULL default '0',
              flag tinyint(1) unsigned NOT NULL default '1',
              dateline int(10) unsigned NOT NULL default '0',
              pageview int(10) NOT NULL default '0',
              PRIMARY KEY  (couponid),
              KEY shopid (shopid),
              KEY uid (uid),
              KEY dateline (dateline)" ,
        'modoer_datacall'=> "
              callid smallint(5) unsigned NOT NULL auto_increment,
              module varchar(60) NOT NULL default '',
              calltype varchar(60) NOT NULL default '',
              name varchar(50) NOT NULL default '',
              fun varchar(60) NOT NULL default '',
              var varchar(60) NOT NULL default '',
              expression text NOT NULL,
              tplname varchar(200) NOT NULL default '',
              empty_tplname varchar(200) NOT NULL default '',
              closed tinyint(1) unsigned NOT NULL default '0',
              hash varchar(32) NOT NULL default '',
              PRIMARY KEY  (callid)" ,
        'modoer_itemapply'=> "
              applyid mediumint(8) unsigned NOT NULL auto_increment,
              shopid mediumint(8) unsigned NOT NULL default '0',
              uid mediumint(8) unsigned NOT NULL default '0',
              username varchar(20) NOT NULL default '',
              status tinyint(1) unsigned NOT NULL default '2',
              applyname varchar(100) NOT NULL default '',
              contact varchar(255) NOT NULL default '',
              pic varchar(255) NOT NULL default '',
              content mediumtext NOT NULL,
              dateline int(10) unsigned NOT NULL default '0',
              checker varchar(30) NOT NULL default '',
              returned text NOT NULL,
              PRIMARY KEY  (applyid)" ,
        'modoer_membereffect'=> "
              id mediumint(8) unsigned NOT NULL default '0',
              idtype varchar(15) NOT NULL default '',
              uid mediumint(8) unsigned NOT NULL default '0',
              username varchar(20) NOT NULL default '',
              dateline int(10) NOT NULL default '0',
              effect1 tinyint(1) unsigned NOT NULL default '0',
              effect2 tinyint(1) unsigned NOT NULL default '0',
              KEY id (id,idtype)" ,
        'modoer_menus'=> "
              menuid smallint(5) unsigned NOT NULL auto_increment,
              isclosed tinyint(1) NOT NULL default '0',
              flag varchar(60) NOT NULL default '',
              isfolder tinyint(1) unsigned NOT NULL default '0',
              clicks int(10) unsigned NOT NULL default '0',
              title varchar(100) NOT NULL default '',
              scriptnav varchar(60) NOT NULL default '',
              mkey varchar(60) NOT NULL default '',
              url varchar(255) NOT NULL default '',
              icon varchar(60) NOT NULL default '',
              listorder smallint(5) NOT NULL default '0',
              PRIMARY KEY  (menuid)" ,
        'modoer_modules'=> "
              moduleid smallint(5) unsigned NOT NULL auto_increment,
              flag varchar(30) NOT NULL default '',
              iscore tinyint(1) NOT NULL default '0',
              name varchar(60) NOT NULL default '',
              directory varchar(100) NOT NULL default '',
              disable tinyint(1) unsigned NOT NULL default '0',
              config text NOT NULL,
              version varchar(60) NOT NULL default '',
              releasetime date NOT NULL default '0000-00-00',
              reliant varchar(255) NOT NULL default '',
              author varchar(255) NOT NULL default '',
              introduce text NOT NULL,
              siteurl varchar(255) NOT NULL default '',
              email varchar(255) NOT NULL default '',
              copyright varchar(255) NOT NULL default '',
              checkurl varchar(255) NOT NULL default '',
              PRIMARY KEY  (moduleid)" ,
        'modoer_mylinks'=> "
              linkid mediumint(8) unsigned NOT NULL auto_increment,
              title varchar(40) NOT NULL default '',
              link varchar(100) NOT NULL default '',
              logo varchar(100) NOT NULL default '',
              des varchar(255) NOT NULL default '',
              displayorder int(8) NOT NULL default '0',
              ischeck tinyint(1) NOT NULL default '0',
              PRIMARY KEY  (linkid)" ,
        'modoer_words'=> "
              id smallint(5) unsigned NOT NULL auto_increment,
              keyword varchar(255) NOT NULL default '',
              expression varchar(255) NOT NULL default '',
              admin varchar(20) NOT NULL default '',
              PRIMARY KEY  (id)" ,
    );
    create_table($array);

    redirect('新建表完毕!下一步更新表字段...',3);

} elseif($step == 3) {

    // 更新表字段
    
    $array = array(
        array(
            "modoer_members",
            "point",
            "ALTER TABLE modoer_members CHANGE point point INT(10) NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "coin",
            "ALTER TABLE modoer_members CHANGE coin coin INT(10) NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "addshops",
            "ALTER TABLE modoer_members CHANGE addshops addshops INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "reviews",
            "ALTER TABLE modoer_members CHANGE reviews reviews INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "responds",
            "ALTER TABLE modoer_members CHANGE responds responds INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "flowers",
            "ALTER TABLE modoer_members CHANGE flowers flowers INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "pictures",
            "ALTER TABLE modoer_members CHANGE pictures pictures INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        array(
            "modoer_members",
            "favorites",
            "ALTER TABLE modoer_members CHANGE favorites favorites INT(10) UNSIGNED NOT NULL DEFAULT '0'"),
        
        array(
            "modoer_upshops",
            "disposal",
            "ALTER TABLE modoer_upshops CHANGE disposal disposal TINYINT(1) NOT NULL DEFAULT '2'"),
        
        array(
            "modoer_reports",
            "disposal",
            "ALTER TABLE modoer_reports CHANGE disposal disposal TINYINT(1) NOT NULL DEFAULT '2'"),

        array(
            "modoer_tags",
            "panelcode",
            "ALTER TABLE modoer_tags CHANGE panelcode panelcode VARCHAR(2) NOT NULL default ''"),

        array(
            "modoer_shops",
            "mappoint",
            "ALTER TABLE modoer_shops CHANGE mappoint mappoint VARCHAR(60) NOT NULL DEFAULT ''"),
        array(
            "modoer_shops",
            "templateid",
            "ALTER TABLE modoer_shops ADD templateid smallint(5) UNSIGNED NOT NULL DEFAULT '0' AFTER subname"),
        array(
            "modoer_shops",
            "ownerid",
            "ALTER TABLE modoer_shops ADD ownerid mediumint(8) UNSIGNED NOT NULL DEFAULT '0' AFTER pageviews"),
        array(
            "modoer_shops",
            "owner",
            "ALTER TABLE modoer_shops ADD owner VARCHAR(20) NOT NULL DEFAULT '' AFTER ownerid"),
        array(
            "modoer_shops",
            "addname",
            "ALTER TABLE modoer_shops ADD addname VARCHAR(20) NOT NULL DEFAULT '' AFTER adduid"),
        array(
            "modoer_shops",
            "firstname",
            "ALTER TABLE modoer_shops ADD firstname VARCHAR(20) NOT NULL DEFAULT '' AFTER firstuid"),
        array(
            "modoer_shops",
            "coupons",
            "ALTER TABLE modoer_shops ADD coupons int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER finer"),
        array(
            "modoer_shops",
            "effect1",
            "ALTER TABLE modoer_shops ADD effect1 int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER coupons"),
        array(
            "modoer_shops",
            "effect2",
            "ALTER TABLE modoer_shops ADD effect2 int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER effect1"),

        array(
            "modoer_reviews",
            "username",
            "ALTER TABLE modoer_reviews ADD username VARCHAR(20) NOT NULL DEFAULT '' AFTER uid"),
        array(
            "modoer_reviews",
            "ip",
            "ALTER TABLE modoer_reviews ADD ip VARCHAR(15) NOT NULL DEFAULT '' AFTER uid"),
        
        array(
            "modoer_responds",
            "username",
            "ALTER TABLE modoer_responds ADD username VARCHAR(20) NOT NULL DEFAULT '' AFTER uid"),
        array(
            "modoer_responds",
            "ip",
            "ALTER TABLE modoer_responds ADD ip VARCHAR(15) NOT NULL DEFAULT '' AFTER uid"),

        array(
            "modoer_templates",
            "tpltype",
            "ALTER TABLE modoer_templates ADD tpltype VARCHAR(15) NOT NULL DEFAULT '' AFTER copyright"),
        array(
            "modoer_templates",
            "bind",
            "ALTER TABLE modoer_templates ADD bind tinyint(1) NOT NULL DEFAULT '0' AFTER tpltype"),

        array(
            "modoer_pmsgs",
            "delflag",
            "ALTER TABLE modoer_pmsgs ADD delflag tinyint(1) NOT NULL DEFAULT '0' AFTER new"),

    );
    alterfield($array);
    redirect('更新表字段完毕!下一步更新表索引...',4);

} elseif($step == 4) {

    //其他更新表索引
    $array = array(
        array('modoer_shops','DROP','cate', 'cate'),
        array('modoer_shops','DROP','search_name', 'search_name'),
        array('modoer_shops','DROP','search_address', 'search_address'),
        array('modoer_shops','DROP','adduid', 'adduid'),
        array('modoer_shops','DROP','firstuid', 'firstuid'),
        array('modoer_shops','DROP','shopname', 'shopname'),
        array('modoer_shops','DROP','sort', 'sort'),

        array('modoer_shops','ADD','finer','(finer)'),
        array('modoer_shops','ADD','cate','cate (classcode,areacode,status)'),
        array('modoer_shops','ADD','adduid','adduid (adduid,status,addtime)'),
        array('modoer_shops','ADD','firstuid','firstuid (firstuid,status,addtime)'),
        array('modoer_shops','ADD','ownerid','ownerid (ownerid,status,addtime)'),
    );
    alterindex($array);
    redirect('表索引更新完毕!下一步插入表数据...',5);

} elseif($step == 5) {

    //  插入表数据
	/*$array = array(
		array('数据库语句',"是否需要更改为REPLACE INTO"),
	);*/

    $array = array(
        array("INSERT INTO modoer_config (variable, value) VALUES ('tplext','.htm')",1),
        array("INSERT INTO modoer_config (variable, value) VALUES ('siteurl','".get_url()."')",1),

        array("INSERT INTO modoer_ads (callid,subject,adtype,begintime,endtime,content,code,isclosed,attr) VALUES ('28','各页侧边广告','4','1224172800','2000000000','a:12:{s:10:\"font_title\";s:0:\"\";s:9:\"font_size\";s:0:\"\";s:9:\"font_href\";s:0:\"\";s:5:\"title\";s:0:\"\";s:7:\"img_src\";s:0:\"\";s:9:\"img_width\";s:0:\"\";s:10:\"img_height\";s:0:\"\";s:8:\"img_href\";s:0:\"\";s:9:\"flash_src\";s:0:\"\";s:11:\"flash_width\";s:0:\"\";s:12:\"flash_height\";s:0:\"\";s:4:\"code\";s:345:\"<script type=\\\"text/javascript\\\">\r\ngoogle_ad_client = \\\"pub-8359185413963124\\\";\r\ngoogle_language = \\\"zh-CN\\\"; \r\n/* 234x60, 创建于 08-10-17 */\r\ngoogle_ad_slot = \\\"7130063547\\\";\r\ngoogle_ad_width = 234;\r\ngoogle_ad_height = 60;\r\n</script>\r\n<script type=\\\"text/javascript\\\"\r\nsrc=\\\"http://pagead2.googlesyndication.com/pagead/show_ads.js\\\">\r\n</script>\";}','<script type=\"text/javascript\">\r\ngoogle_ad_client = \"pub-8359185413963124\";\r\ngoogle_language = \"zh-CN\"; \r\n/* 234x60, 创建于 08-10-17 */\r\ngoogle_ad_slot = \"7130063547\";\r\ngoogle_ad_width = 234;\r\ngoogle_ad_height = 60;\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>','0','1')",0),
        array("INSERT INTO modoer_ads (callid,subject,adtype,begintime,endtime,content,code,isclosed,attr) VALUES ('29','新闻内容页广告','4','1224172800','2000000000','a:12:{s:10:\"font_title\";s:0:\"\";s:9:\"font_size\";s:0:\"\";s:9:\"font_href\";s:0:\"\";s:5:\"title\";s:0:\"\";s:7:\"img_src\";s:0:\"\";s:9:\"img_width\";s:0:\"\";s:10:\"img_height\";s:0:\"\";s:8:\"img_href\";s:0:\"\";s:9:\"flash_src\";s:0:\"\";s:11:\"flash_width\";s:0:\"\";s:12:\"flash_height\";s:0:\"\";s:4:\"code\";s:356:\"<script type=\\\"text/javascript\\\"><!--\r\ngoogle_ad_client = \\\"pub-8359185413963124\\\";\r\ngoogle_language = \\\"zh-CN\\\"; \r\n/* 468x60, 创建于 08-10-21 */\r\ngoogle_ad_slot = \\\"0495261940\\\";\r\ngoogle_ad_width = 468;\r\ngoogle_ad_height = 60;\r\n//-->\r\n</script>\r\n<script type=\\\"text/javascript\\\"\r\nsrc=\\\"http://pagead2.googlesyndication.com/pagead/show_ads.js\\\">\r\n</script>\";}','<script type=\"text/javascript\"><!--\r\ngoogle_ad_client = \"pub-8359185413963124\";\r\ngoogle_language = \"zh-CN\"; \r\n/* 468x60, 创建于 08-10-21 */\r\ngoogle_ad_slot = \"0495261940\";\r\ngoogle_ad_width = 468;\r\ngoogle_ad_height = 60;\r\n//-->\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>','0','1')",0),
        array("INSERT INTO modoer_ads (callid,subject,adtype,begintime,endtime,content,code,isclosed,attr) VALUES ('30','首页中上468x60','4','1224172800','2000000000','a:12:{s:10:\"font_title\";s:0:\"\";s:9:\"font_size\";s:0:\"\";s:9:\"font_href\";s:0:\"\";s:5:\"title\";s:0:\"\";s:7:\"img_src\";s:0:\"\";s:9:\"img_width\";s:0:\"\";s:10:\"img_height\";s:0:\"\";s:8:\"img_href\";s:0:\"\";s:9:\"flash_src\";s:0:\"\";s:11:\"flash_width\";s:0:\"\";s:12:\"flash_height\";s:0:\"\";s:4:\"code\";s:356:\"<script type=\\\"text/javascript\\\"><!--\r\ngoogle_ad_client = \\\"pub-8359185413963124\\\";\r\ngoogle_language = \\\"zh-CN\\\"; \r\n/* 468x60, 创建于 08-10-17 */\r\ngoogle_ad_slot = \\\"6053443059\\\";\r\ngoogle_ad_width = 468;\r\ngoogle_ad_height = 60;\r\n//-->\r\n</script>\r\n<script type=\\\"text/javascript\\\"\r\nsrc=\\\"http://pagead2.googlesyndication.com/pagead/show_ads.js\\\">\r\n</script>\";}','<script type=\"text/javascript\"><!--\r\ngoogle_ad_client = \"pub-8359185413963124\";\r\ngoogle_language = \"zh-CN\"; \r\n/* 468x60, 创建于 08-10-17 */\r\ngoogle_ad_slot = \"6053443059\";\r\ngoogle_ad_width = 468;\r\ngoogle_ad_height = 60;\r\n//-->\r\n</script>\r\n<script type=\"text/javascript\"\r\nsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\r\n</script>','0','1')",0),

        array("INSERT INTO modoer_articleclass (classid,classname,displayorder,articlenum) VALUES ('1','默认分类','1','2')",1),

        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('1','shop','fun','首页_最新点评','reviews','review','a:4:{s:9:\"cachetime\";s:3:\"600\";s:3:\"row\";s:1:\"3\";s:5:\"order\";s:13:\"posttime DESC\";s:8:\"showitem\";s:1:\"1\";}','index_reviews','empty_li','0','fae7b7b9')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('2','coupon','fun','优惠券_热门优惠券','coupon','coupon_hot','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:14:\"c.effect1 DESC\";s:0:\"\";s:0:\"\";}','coupon_hot_li','empty_li','0','185ee4fd')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('3','coupon','fun','优惠券_最新发布','coupon','coupon_new','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:15:\"c.dateline DESC\";s:0:\"\";s:0:\"\";}','coupon_new_li','empty_li','0','a06ee56a')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('4','coupon','fun','优惠券_其他热门','coupon','coupon_other_hot','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:14:\"c.effect1 DESC\";s:0:\"\";s:0:\"\";}','coupon_other_li','empty_li','0','185ee4fd')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('5','article','fun','首页_新闻资讯_推荐','article','articles','a:4:{s:9:\"cachetime\";s:4:\"3000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:3:\"att\";s:1:\"1\";}','index_article_li','empty_li','0','f22c72d6')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('6','article','fun','首页_新闻资讯_关注','article','articles','a:4:{s:9:\"cachetime\";s:4:\"3100\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:9:\"digg DESC\";s:4:\"digg\";s:1:\"1\";}','index_article_li','empty_li','0','3033649c')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('7','article','fun','首页_新闻资讯_最新','article','articles','a:4:{s:9:\"cachetime\";s:4:\"1200\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:0:\"\";N;}','index_article_li','empty_li','0','2e2240c3')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('8','shop','fun','首页_热门商铺','items','items','a:4:{s:9:\"cachetime\";s:4:\"1000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:12:\"reviews DESC\";s:0:\"\";N;}','index_item_li','empty_li','0','4f98bd7e')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('9','shop','fun','首页_最新商铺','items','items','a:4:{s:9:\"cachetime\";s:4:\"1000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:12:\"addtime DESC\";s:0:\"\";N;}','index_item_li','empty_li','0','317c307b')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('10','shop','fun','首页_推荐商铺','items','items','a:4:{s:9:\"cachetime\";s:4:\"1000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:10:\"finer DESC\";s:5:\"finer\";s:1:\"1\";}','index_item_finer_li','empty_li','0','f7c7d9d5')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('11','card','fun','首页_会员卡','cards','cards','a:4:{s:9:\"cachetime\";s:4:\"2000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:14:\"c.addtime DESC\";s:0:\"\";N;}','index_item_card_li','empty_li','0','1c7b3994')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('12','member','fun','会员排行_专家','members','members','a:4:{s:9:\"cachetime\";s:4:\"1000\";s:3:\"row\";s:1:\"9\";s:5:\"order\";s:10:\"point DESC\";s:7:\"groupid\";s:2:\"10\";}','member_face_li','empty_li','0','bc1f5d37')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('13','member','fun','会员排行_最新加入','members','members','a:4:{s:9:\"cachetime\";s:3:\"800\";s:3:\"row\";s:1:\"9\";s:5:\"order\";s:12:\"regdate DESC\";s:7:\"groupid\";s:2:\"10\";}','member_face_li','empty_li','0','2f8ddd92')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('14','member','fun','会员排行_活跃会员','members','members','a:5:{s:9:\"cachetime\";s:4:\"3000\";s:3:\"row\";s:1:\"9\";s:5:\"order\";s:14:\"m.reviews DESC\";s:5:\"group\";s:2:\"10\";s:6:\"active\";s:1:\"1\";}','member_face_li','empty_li','0','8113d184')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('15','member','fun','会员排行_财富榜','members','members','a:4:{s:9:\"cachetime\";s:4:\"2000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:9:\"coin DESC\";s:7:\"groupid\";s:2:\"10\";}','member_smallface_li','empty_li','0','8f6034fd')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('16','space','sql','首页_个人空间','sql','spaces','a:7:{s:9:\"cachetime\";s:4:\"5000\";s:4:\"from\";s:13:\"{dbpre}spaces\";s:6:\"select\";s:1:\"*\";s:5:\"where\";s:12:\"pageview>\'0\'\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:13:\"pageview DESC\";s:5:\"limit\";s:4:\"0,10\";}','index_space_li','empty_li','0','0539c971')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('17','exchange','sql','首页_兑换奖品','sql','gifts','a:7:{s:9:\"cachetime\";s:4:\"3000\";s:4:\"from\";s:12:\"{dbpre}gifts\";s:6:\"select\";s:38:\"giftid,name,price,num,thumb,salevolume\";s:5:\"where\";s:11:\"available=1\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:12:\"displayorder\";s:5:\"limit\";s:3:\"0,3\";}','index_gitf_div','empty_li','0','2a6486d6')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('18','exchange','sql','兑奖中心_最新兑换_聚合','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"6000\";s:4:\"from\";s:15:\"{dbpre}exchange\";s:6:\"select\";s:30:\"exchangeid,uid,giftid,giftname\";s:5:\"where\";s:17:\"status IN (1,2,3)\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:17:\"exchangetime DESC\";s:5:\"limit\";s:4:\"0,10\";}','exchange_new_li','empty_li','0','f0298c38')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('19','exchange','sql','兑奖中心_热门兑换_聚合','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"8000\";s:4:\"from\";s:12:\"{dbpre}gifts\";s:6:\"select\";s:28:\"giftid,name,salevolume,thumb\";s:5:\"where\";s:28:\"salevolume>0 AND available=1\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:15:\"salevolume DESC\";s:5:\"limit\";s:4:\"0,10\";}','exchange_hot_li','empty_li','0','ad0c6c32')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('20','shop','sql','首页_热门标签','sql','tags','a:7:{s:9:\"cachetime\";s:5:\"10000\";s:4:\"from\";s:11:\"{dbpre}tags\";s:6:\"select\";s:1:\"*\";s:5:\"where\";s:20:\"closed=0 AND total>0\";s:5:\"other\";s:16:\"GROUP BY tagname\";s:7:\"orderby\";s:10:\"total DESC\";s:5:\"limit\";s:4:\"0,20\";}','index_tag_li','empty_li','0','a51f8e9f')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('21','shop','sql','头部_热门搜索','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"7200\";s:4:\"from\";s:18:\"{dbpre}searchindex\";s:6:\"select\";s:34:\"max(searchid) as searchid, keyword\";s:5:\"where\";s:7:\"total>0\";s:5:\"other\";s:16:\"GROUP BY keyword\";s:7:\"orderby\";s:8:\"searchid\";s:5:\"limit\";s:3:\"0,5\";}','header_hotsearch','empty','0','50af0baf')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('40','shop','fun','cate页热门商铺','items','mydata','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:14:\"pageviews DESC\";s:9:\"panelcode\";s:5:\"{\$cd}\";}','shop_cate_hotshop_li','empty_li','0','a7773092')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('41','shop','fun','详细页_补充信息的会员列表','uplog','mydata','a:4:{s:9:\"cachetime\";s:4:\"8000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"posttime DESC\";s:6:\"shopid\";s:9:\"{\$shopid}\";}','shop_detail_uplog_li','empty','0','93cf3f08')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('39','shop','sql','cate页热门分类','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"8000\";s:4:\"from\";s:16:\"{dbpre}classcode\";s:6:\"select\";s:29:\"cid,classname,classcode,total\";s:5:\"where\";s:57:\"(classcode BETWEEN \'{\$pcd}00\' AND \'{\$pcd}99\') AND total>0\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:10:\"total DESC\";s:5:\"limit\";s:4:\"0,10\";}','shop_cate_hotclass_li','empty_li','0','4b3821cc')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('28','ads','sql','各页侧边广告','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"5000\";s:4:\"from\";s:10:\"{dbpre}ads\";s:6:\"select\";s:1:\"*\";s:5:\"where\";s:8:\"adid=\'1\'\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:4:\"adid\";s:5:\"limit\";s:3:\"0,1\";}','ad_div','empty_ad_div','0','327f5b96')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('29','ads','sql','新闻内容页广告','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"5000\";s:4:\"from\";s:10:\"{dbpre}ads\";s:6:\"select\";s:1:\"*\";s:5:\"where\";s:8:\"adid=\'2\'\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:4:\"adid\";s:5:\"limit\";s:3:\"0,1\";}','ad_div','empty_ad_div','0','5349a93f')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('30','ads','sql','首页中上468x60','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"5000\";s:4:\"from\";s:10:\"{dbpre}ads\";s:6:\"select\";s:1:\"*\";s:5:\"where\";s:8:\"adid=\'3\'\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:4:\"adid\";s:5:\"limit\";s:3:\"0,1\";}','ad_div','empty_ad_div','0','a492875a')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('46','article','fun','新闻列表_本栏目推荐新闻','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:3:\"att\";s:1:\"1\";}','article_list_li','empty_li','0','f6e3dd49')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('47','links','fun','新闻列表_本栏目最新发布','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"3000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:7:\"classid\";s:10:\"{\$classid}\";}','article_list_li','empty_li','0','e5b715f5')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('45','article','fun','详细页_商铺资讯','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"4000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:6:\"shopid\";s:9:\"{\$shopid}\";}','shop_cate_article_li','empty_li','0','a6172bec')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('44','shop','fun','详细页_附近热铺','items','mydata','a:4:{s:9:\"cachetime\";s:4:\"8000\";s:3:\"row\";s:1:\"5\";s:5:\"order\";s:12:\"reviews DESC\";s:10:\"streetcode\";s:13:\"{\$streetcode}\";}','shop_detail_shop_li','empty_li','0','8b97a09b')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('42','shop','fun','详细页_全部分店列表','items','mydata','a:4:{s:9:\"cachetime\";s:4:\"8000\";s:3:\"row\";s:2:\"50\";s:5:\"order\";s:12:\"reviews DESC\";s:8:\"shopname\";s:11:\"{\$shopname}\";}','shop_detail_shop_li','empty_li','0','63163f44')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('43','shop','fun','详细页_同类型热铺','items','mydata','a:4:{s:9:\"cachetime\";s:4:\"8500\";s:3:\"row\";s:1:\"5\";s:5:\"order\";s:12:\"reviews DESC\";s:9:\"panelcode\";s:14:\"\$sameclasscode\";}','shop_detail_shop_li','empty_li','0','8fb15040')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('48','article','fun','新闻列表_本栏目周热门新闻','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"6000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"pageview DESC\";s:7:\"classid\";s:10:\"{\$classid}\";}','article_list_li','empty_li','0','4598f822')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('49','article','fun','新闻列表_推荐新闻','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:3:\"att\";s:1:\"1\";}','article_list_li','empty_li','0','f6e3dd49')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('50','article','fun','新闻列表_最新发布','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"4000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:0:\"\";s:0:\"\";}','article_list_li','empty_li','0','e18b9f4b')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('51','article','fun','新闻列表_周热门新闻','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"pageview DESC\";s:0:\"\";s:0:\"\";}','article_list_li','empty_li','0','6473141e')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('52','article','fun','新闻内容_推荐资讯','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"6000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:3:\"att\";s:1:\"1\";}','article_detail_list_li','empty_li','0','db09f991')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('53','article','fun','新闻内容_资讯排行','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"8000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"pageview DESC\";s:0:\"\";s:0:\"\";}','article_detail_list_li','empty_li','0','f94d2a2f')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('54','article','fun','商铺资讯_本周热门新闻','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"5000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"pageview DESC\";s:6:\"shopid\";s:9:\"{\$shopid}\";}','article_list_li','empty_li','0','0dc2d6d2')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('55','article','fun','商铺资讯_本商铺资讯','article','mydata','a:4:{s:9:\"cachetime\";s:4:\"7000\";s:3:\"row\";s:2:\"10\";s:5:\"order\";s:13:\"dateline DESC\";s:6:\"shopid\";s:9:\"{\$shopid}\";}','article_detail_list_li','empty_li','0','92854581')",0),
        array("INSERT INTO modoer_datacall (callid,module,calltype,name,fun,var,expression,tplname,empty_tplname,closed,hash) VALUES ('56','shop','sql','首页_最新上传','sql','mydata','a:7:{s:9:\"cachetime\";s:4:\"1000\";s:4:\"from\";s:15:\"{dbpre}pictures\";s:6:\"select\";s:40:\"pid,shopid,title,folder,filename,addtime\";s:5:\"where\";s:8:\"status=1\";s:5:\"other\";s:0:\"\";s:7:\"orderby\";s:12:\"addtime DESC\";s:5:\"limit\";s:3:\"0,5\";}','index_item_newpic','empty','0','758f50ca')",0),


        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('1','0','website','0','0','首页','index','','{SITE}','','1')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('2','0','website','0','0','{article-name}','article','','{article-url}','','2')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('3','0','website','0','0','美食餐馆','shop-cate-10','','{shop-url}cate.php?cd=10','','3')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('4','0','website','0','0','{card-name}','card','','{card-url}','','6')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('5','0','website','0','0','{coupon-name}','coupon','','{coupon-url}','','7')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('6','0','website','0','0','{exchange-name}','exchange','','{exchange-url}','','8')",0),
        array("INSERT INTO modoer_menus (menuid,isclosed,flag,isfolder,clicks,title,scriptnav,mkey,url,icon,listorder) VALUES ('7','0','website','0','0','Modoer点评系统','','','http://bbs.modoer.com/','','9')",0),

        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('3','member','1','会员','member','0',' ','1.1','2008-09-30','','Moufer Studio',' ','http://www.modoer.com','moufer@163.com','Moufer Studio','')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('4','shop','1','商铺点评','shop','0',' ','1.1','2008-09-30','','Moufer Studio',' ','http://www.modoer.com','moufer@163.com','Moufer Studio','')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('5','space','1','个人空间','space','0',' ','1.1','2008-09-30','','Moufer Studio','','http://www.modoer.com','moufer@163.com','Moufer Studio','')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('6','card','1','会员卡','card','0',' ','1.0','2008-09-01','shop','Moufer Studio','','http://www.modoer.com','moufer@163.com','Moufer Studio','')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('7','exchange','1','兑奖中心','exchange','0','a:3:{s:11:\"thumb_width\";s:3:\"124\";s:12:\"thumb_height\";s:2:\"94\";s:7:\"seccode\";i:1;}','1.0','2008-09-01','','Moufer Studio','','http://www.modoer.com','moufer@163.com','Moufer Studio','')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('8','coupon','1','优惠券','coupon','0','a:5:{s:5:\"check\";s:1:\"0\";s:9:\"watermark\";s:1:\"0\";s:11:\"thumb_width\";s:2:\"72\";s:12:\"thumb_height\";s:2:\"47\";s:7:\"seccode\";s:1:\"1\";}','1.0','2008-10-03','shop','moufer','商铺优惠券模块','http://www.modoer.com','moufer@163.com','Moufer Studio','http://www.modoer.com/info/module/coupon.php')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('9','article','0','新闻咨询','article','0','a:3:{s:9:\"ownernews\";s:1:\"1\";s:17:\"ownernews_classid\";s:1:\"1\";s:15:\"ownernews_check\";s:1:\"0\";}','1.0','2008-09-18','','moufer','本地新闻发布，产品/商铺信息发布','http://www.modoer.com','moufer@163.com','Moufer Studio','http://www.modoer.com/info/module/article.php')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('10','links','0','友情链接','links','0','a:3:{s:8:\"num_logo\";i:10;s:8:\"num_char\";i:20;s:10:\"open_apply\";i:1;}','1.0','2008-09-18','','moufer','友情链接模块','http://www.modoer.com','moufer@163.com','Moufer Studio','http://www.modoer.com/info/module/links.php')",0),
        array("INSERT INTO modoer_modules (moduleid,flag,iscore,name,directory,disable,config,version,releasetime,reliant,author,introduce,siteurl,email,copyright,checkurl) VALUES ('11','ads','0','广告','ads','0','','1.0','2008-10-12','','moufer','网站广告管理','http://www.modoer.com','moufer@163.com','Moufer Studio','http://www.modoer.com/info/module/ads.php')",0),

        array("INSERT INTO modoer_mylinks (title,link,logo,des,displayorder,ischeck) VALUES ('Modoer点评系统','http://www.modoer.com','','Modoer 是一款点评网站管理系统，采用 PHP+MYSQL 设计，开放全部源码','0','1')",0),

    );
    insertdata($array);

    redirect('插入表数据完毕!下一步数据表会员数据...',6,'upindex=1');

} elseif($step == 6) {

    // 更新表数据值
    $uptables = array(
        1 => 'shops|adduid=>addname,firstuid=>firstname',
        2 => 'reviews|uid=>username',
        3 => 'responds|uid=>username',
    );
    // 表信息
    $upindex = empty($upindex) ? 1 : intval($upindex);
    $tbtotal = count($uptables);
    if($tbtotal == 0 || $tbtotal <= $upindex) {
        redirect("数据表会员数据调整完毕！下一步其他的数据更新...", 7);
    }
    list($table,$upfieldstr) = explode('|', $uptables[$upindex]);
    $table = $dbpre.$table;
    // 会员数据
    $start = empty($start) ? 0 : intval($start);
    $offset = 50;
    $limit = $start.','.$offset;
    $query = $db->query("SELECT uid,username FROM {$dbpre}members ORDER BY uid LIMIT $limit");
    if($db->num_rows($query) > 0) {
        $fields = explode(',', $upfieldstr);
        while($member = $db->fetch_array($query)) {
            foreach($fields as $val) {
                list($uid,$username) = explode('=>', $val);
                $member['username'] = addslashes($member['username']);
                $db->update("UPDATE $table SET $username='{$member[username]}' WHERE $uid='{$member['uid']}'");
                $uid = 0;
                $username = '';
            }
        }
        $start = $start + $offset;
        $end = $start + $offset - 1;
        redirect($table.'表本组会员数据调整，进入下一组调整 '.$start.' to '.$end.' ...',6,'upindex='.$upindex.'&start='.$start);
    } else {
        $upindex++;
        redirect($table.'表会员数据调整完毕，进入下一张表的调整...',6,'upindex='.$upindex);
    }

} elseif($step == 7) {

    //其他更新
    $db->update("UPDATE {$dbpre}templates SET tpltype='main' WHERE tpltype=''");
    $db->update("UPDATE {$dbpre}templates SET directory='./templates/main/default',bind='1' WHERE templateid=1");

    redirect('数据更新完毕!下一步删除失效数据表...',8);

} elseif($step == 8) {
    // 删除表
    $deltables = array(
        'modoer_space_styles',
    );
    deletetables($deltables);
    redirect('删除失效的数据表完毕!下一步建立更新标记，并完成操作...','finish');

} elseif($step == 'finish') {

    @unlink(MUDDER_ROOT.'data/cachefiles/cache_config.php');
    
    if(!@$fp = fopen($lockfile, 'x+')) {
        die('无法在 ./data/ 下创建 '.$lockname.'，可能是权限问题，可手动在 ./data/ 下创建一个名为 '.$lockname.' 的空文件。');
    } else {
        fclose($fp);
    }

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset?>" />
<title><?php echo PRODUCT?> 程序升级</title>
<link href="install.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
    <form method="post" action="<?php echo $php_self?>">
    <h1 id="subject">
        <span id="title">升级 <?php echo PRODUCT.' '.$oldversion?> 至 <?php echo $newversion?></span>
        <span id="copyright">Copyright &copy; 2007-2008 <a href="http://www.modoer.com/" target="_blank">Moufer Studio</a></span>
        <div style="clear:both;"></div>
    </h1>
    <?php if($step == '1') {?>
    <div id="step">第一步：升级说明</div>
    <input type="hidden" name="step" value="2" />
    <table>
        <tr><td>本升级程序为 <?php echo PRODUCT.' '.$oldversion?> 升级至 <?php echo $newversion?>，请在升级前确认当前的版本。</td></tr>
        <tr><td>下一步将直接进行数据库升级，请认真做好确认。</td></tr>
    </table>
    <div id="comment"><b>在进行前，<span class="font_1">请务必备份当前版本的所有内容</span>（包括程序和数据库文件），以防升级失败。</b></div>
    <div id="next"><button type="submit" name="name"<?php echo $next_enable?>>开始升级</button></div>
    <?php } elseif($step == 'finish') { ?>
    <table>
        <tr><td>数据库升级完毕！您可以进后台设置新增的功能选项，然后更新缓存，模块配置缓存和优化表数据。</td></tr>
        <tr><td><a href="../admincp.php">点击进入 <?php echo PRODUCT?> 点评系统 后台管理</a></td></tr>
        <tr><td><a href="http://www.modoer.com/">Moufer Studio</a></td></tr>
    </table>
    <?php } ?>
</div>
</body>
</html>
<?php

// 输入表数据

function insertdata($array) {
    global $db,$dbcharset,$dbpre;
    (!$array || !is_array($array)) && $array = array();
    foreach($array as $val) {
		$val[1] && strtolower(substr($val[0], 0, 6)) == 'insert' && $val[0] = 'REPLACE'.substr($val[0],6);
		$db->query(str_replace("modoer_", $dbpre, $val[0]));
    }
}

// 修改表字段

function alterfield($array) {
    global $db,$dbcharset,$dbpre;
    (!$array || !is_array($array)) && $array = array();
    foreach($array as $val) {
        $val[0] = str_replace("modoer_", $dbpre, $val[0]);
        $val[2] = str_replace("modoer_", $dbpre, $val[2]);
        $rt = $db->get_one("SHOW COLUMNS FROM $val[0] LIKE '{$val[1]}'");
        $lowersql = strtolower($val[2]);
		if ((strpos($lowersql,' add ')!==false && $rt['Field']!=$val[1]) || ((strpos($lowersql,' drop ')!==false || strpos($lowersql,' change ')!==false) && $rt['Field'] == $val[1])) {
			$db->query($val[2]);
		}
    }
}

// 修改索引

function alterindex($array) {
    global $db,$dbcharset,$dbpre;
    (!$array || !is_array($array)) && $array = array();
    foreach($array as $val) {
        $val[0] = str_replace("modoer_", $dbpre, $val[0]);
        $val[3] = "ALTER TABLE {$val[0]} $val[1] INDEX {$val[3]}";
        $rt = false;
        $query = $db->query("SHOW INDEX FROM $val[0]");
        while($row=$db->fetch_array($query)) {
            if($row['Key_name'] == $val[2]) {
                $rt = true;
                break;
            }
        }
        $db->free_result($query);
        unset($row);
        if(($rt && $val[1]=='DROP') || (!$rt && $val[1]=='ADD')) {
            $db->query($val[3]);
        }
    }
}

// 建表

function create_table($array) {
    global $db,$dbcharset,$dbpre;
    (!$array || !is_array($array)) && $array = array();
    foreach($array as $key => $val) {
        $sql = "CREATE TABLE IF NOT EXISTS $key ($val) ";
		if ($db->version() > '4.1') {
			$sql .= "ENGINE=MyISAM".($dbcharset ? " DEFAULT CHARSET=$dbcharset" : '');
		} else {
			$sql .= "TYPE=MyISAM";
		}
        $db->query(str_replace('modoer_', $dbpre, $sql));
    }
}

function deletetables($array) {
    global $db,$dbpre;
    (!$array || !is_array($array)) && $array = array();
    foreach($array as $val) {
        $sql = "DROP TABLE $val";
        $db->query(str_replace('modoer_', $dbpre, $sql));
    }
}

function getdirname($path){
	if(strpos($path,'\\')!==false){
		return substr($path,0,strrpos($path,'\\'));
	} elseif(strpos($path,'/')!==false){
		return substr($path,0,strrpos($path,'/'));
	} else{
		return '/';
	}
}

function add_slashes($string) {
    if(is_array($string))
        foreach($string as $key => $val) $string[$key] = add_slashes($val); 
    else
        $string = is_string($string) ? addslashes($string) : $string;
    return $string;
}

function redirect($msg, $step, $extar = '') {
    global $charset, $phpself;
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" /></head><body>';
    if($extar === 'back') {
        $url = "javascript:history.go(-1);";
    } elseif($extar === 'stop') {
        $url = '';
    } elseif(!empty($extar)) {
        $url = $phpself.'?step='.$step.'&'.$extar;
    } else {
        $url = $phpself.'?step='.$step;
    }

    if($url) {
        echo '<script type="text/javascript">
        window.onload = function() { setTimeout(do_location, 2000); }
        function do_location() { document.location.href = \''.$url.'\';}
        </script>';
    }
    echo '<div style="width:100%;">';
    echo '<div style="padding:10px;">'.$msg.'</div>';
    if($url) echo '<div style="padding:10px;"><a href="'.$url.'">如果您的浏览器没有自动跳转，请点击这里</a></div>';
    echo '</div></body></html>';
    exit;
}

function get_url() {
    $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    $php_domain = $_SERVER['SERVER_NAME'];
    $php_agent = $_SERVER['HTTP_USER_AGENT'];
    $php_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    $php_scheme = $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
    $php_reuri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    $php_port = $_SERVER['SERVER_PORT'] == '80' ? '' : ':'.$_SERVER['SERVER_PORT'];
    $host_url = $php_scheme . $php_domain . $php_port;
    $site_url = $host_url . substr($php_self, 0, strrpos($php_self, '/'));
    $site_url = str_replace('/install', '', $site_url);

    return $site_url;
}
?>
