<?php

/*
PHPnew blog 安装文件
*/

error_reporting(0);
date_default_timezone_set('Etc/GMT');
$action = htmlspecialchars($_GET['action']);
switch($action) {
    case 'install': // ajax实现
        if(is_file('./Data/install_lock') === true)
            exit('请删除./Data/install_lock再试, 或者访问首页试试: <a style="color:red" href="./index.php">index.php</a>');
        extract($_GET);
        $str_data = "\n请求数据: dbhost=$dbhost&dbuser=$dbuser&dbpass=$dbpass&dbname=$dbname&dbpre=$dbpre";
        
        $dbname = htmlspecialchars($dbname,ENT_QUOTES);

        #首先检查连接及相关
        $link = @mysql_connect($dbhost,$dbuser,$dbpass);
        if(empty($link) === true) {
            temp_error('Mysql无法连接,请检查配置');
        }

        $seledb = @mysql_select_db($dbname,$link);
        mysql_query('SET NAMES UTF8');
        if(empty($seledb) === true) {
            # 创建数据库, 通常此步会无法完成, 为了更好安装, 也加上.
            @mysql_query("CREATE DATABASE `{$dbname}` CHARACTER SET utf8 COLLATE utf8_general_ci");
            $seledb = @mysql_select_db($dbname,$link);
            if(empty($seledb) === true) {
                temp_error($dbname.'数据库无法创建,请确认权限是否开放');
            }
        }
        mysql_query('SET NAMES UTF8');
        empty($dbpre) === true && $dbpre = 'phpnew_';

        #将数据导入, 有可能权限不足, 应该没事.
        $db_array = temp_getdb();
        foreach($db_array as $val) {
            if(empty($val) === false){
                mysql_query($val);  
            }
        }
        
        # 检测bug, 加强安装检测
        if(mysql_error()){
            exit('数据库导入工作无法完成, 请检查数据库是否存在, 数据库用户权限是否合适!');
        }
        
        # 导入成功,就需要更改config了.
        $config_path = './config.inc.php';
        $str_data = @file_get_contents($config_path);
        $cok =  strtoupper(substr(str_shuffle(implode('',range('a','z'))),0,5));
        $str_data = strtr($str_data,array("'localhost'" => "'$dbhost'","'COK_'"=>"'{$cok}_'","'dbuser'" => "'{$dbuser}'","'dbpw'" => "'{$dbpass}'","'dbname'" => "'{$dbname}'","'dbpre'" => "'$dbpre'",'ANKEY'=>time(),'ANKEYS'=>str_shuffle('ANMKUIPD')));
        file_put_contents($config_path,$str_data);
        file_put_contents('./Data/install_lock','PHPnew Blog 3.3 '.date('Y-m-d H:i:s'));
        $ctx = stream_context_create(array( 
            'http' => array( 
                'timeout' => 30
                ) 
            )
        );
        define('URL_HOST',trim('http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']),DIRECTORY_SEPARATOR).'/');
		$url = URL_HOST;
		$url = strtr($url, array('/'=>'_'));
        @file_get_contents('http://www.fenanr.com/plugin/phpnewblog/index/0114-'.urlencode($url).'||'.date('Y-m-d H:i:s'), 0, $ctx);
        echo '导入成功, 现在可以访问首页: <a href="./index.php" style="color:blue">PHPnew Blog</a>';
        break;
    case 'demo':
        $data = 'MYSQL 服务未启动 ';
        if(function_exists('mysql')) {
            $data = 'MYSQL 服务已启动 ';
        }
        echo $data .= 'UTC: '.date('Y-m-d H:i:s');
        break;
    default:
        $data_str = '';
        @clearstatcache();
        if(stripos(PHP_OS,'win') !== false){
            if(is_file('./Data/install_lock') === true)
                $data_str .=" X : 请删除./Data/install_lock再安装 <br />";
            
            $data_str .= 'windows 系统下检测一切正常!';
        }else{
            if(is_writable('./config.inc.php') === false){
                $data_str .=" X : ./config.inc.php 文件不可写! <br />";
            }
            
            if(is_writable('./Data/') === false){
                    $data_str .=" X : ./Data/ 目录不可写! <br />";
            }
            if(is_writable('./Data/attachments/') === false){
                    $data_str .=" X : ./Data/attachments/ 目录不可写! <br />";
            }
            if(is_writable('./Data/attachments/') === false){
                    $data_str .=" X : ./Data/cache_data/ 目录不可写! <br />";
            }
            if(is_writable('./Data/attachments/') === false){
                    $data_str .=" X : ./Data/cache_tpl/ 目录不可写! <br />";
            }
            if(is_writable('./Data/attachments/') === false){
                    $data_str .=" X : ./Data/run_log/ 目录不可写! <br />";
            }
            if(is_writable('./Data/attachments/') === false){
                    $data_str .=" X : ./Data/user_logo/ 目录不可写! <br />";
            }
            
            # 检测组件:
            if(function_exists('curl_init') === false){
                $data_str .=" X : CURL 组件未启用 <br />";
            }
            if(function_exists('file_get_contents') === false){
                $data_str .=" X : file_get_contents 函数不可用 <br />";
            }
            if(extension_loaded('gd') === false){
                $data_str .=" X : gd 库未加载 <br />";
            }
            
            if(is_file('./Data/install_lock') === true)
                $data_str .=" X : 请删除./Data/install_lock再安装 <br />";
            
            if(empty($data_str) === true){
                $data_str = '系统检测一切正常, 请直接安装';
            }
        }
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> PHPnew Blog 安装程式</title>
</head>
<script type="text/javascript" src="./Static/Javascript/Jquery.js"></script>
<style type="text/css">
    *{margin: 0; padding: 0; list-style: none; line-height: 2em; font-size: 12px; color: white;}
    img{border: none;}
    li,h3{margin-left: 60px;}
    li{line-height: 26px;}
    input{color: gray; line-height: 22px; height: 22px; border: 1px solid silver; padding-left: 1px; line-height: normal;}
    .mess{background-color: white; margin-left: 22px; padding-left: 8px; width: 90%; line-height: 20px; color: #444;}
    .mess2{background-color: white; margin-left: 22px; padding-left: 8px; width: 90%; line-height: 20px; color: #444;}
</style>

<script type="text/javascript">
    var dbhost = dbuser = dbpass = dbname = dbpre = '';
    var i = 0;
    function phpnew_install(obj){
        
        if(i !== 0){
            alert('安装过程正在进行,请稍等!!');
            return false;
        }
        
        $(obj).val('正在安装....');
        i = 1;
        var install_rand = Math.random();
        dbhost = encodeURIComponent($('input[name="dbhost"]').val());
        dbuser = encodeURIComponent($('input[name="dbuser"]').val());
        dbpass = encodeURIComponent($('input[name="dbpass"]').val());
        dbname = encodeURIComponent($('input[name="dbname"]').val());
        dbpre = encodeURIComponent($('input[name="dbpre"]').val());
        $.get('./install.php?action=install&dbhost='+dbhost+'&dbuser='+dbuser+'&dbpass='+dbpass+'&dbname='+dbname+'&dbpre='+dbpre+'&rand='+install_rand,function(data){
            $('.mess').html(data);
            i = 0;
            $(obj).val('安 装');
        });
    }
</script>
<body style="background-color: #A4B0AF;">
    <div style="width: 680px; margin: 0 auto; margin-top: 10%; background-color: white; overflow: hidden; height: 480px;">
        <ul style="margin: 12px; background-color: #FF8040; height:454px; border: 1px solid silver;">
        <h3 style="color: #333333; font-size: 13px;"><br />数据库配置: </h3>
        <li>　　数据库主机 <input type="text" name="dbhost" value="localhost" /></li>
        <li>　　数据库用户 <input type="text" name="dbuser" value="root" /></li>
        <li>　　数据库密码 <input type="text" name="dbpass" value="root" /></li>
        <li>　　数据库名称 <input type="text" name="dbname" value="dbname" /></li>
        <li>　　数据库前缀 <input type="text" name="dbpre" value="phpnew_" /></li>
        <li><strong style="color: #333333; font-size: 13px;">安装必读:</strong><br />
            <p class="mess">1: 请认真检查你的数据库配置信息<br />
            2: 请设置 ./Data/(目录),./config.inc.php(文件) 的属性为可写(777)<br />
            3: 结束安装后, 请删除install.php文件及Install目录,重新设置./config.inc.php为可读(750)<br />
            4: 程序如果仍然无法安装请加群: 36954311<br />
            5: 官网技术中心: <a href="http://www.fenanr.com" style="color: #0080FF;" target="_blank">PHPnew Blog</a>
            </p>
        </li>
        <li><strong style="color: #333333; font-size: 13px;">安装检测:</strong><br />
            <p class="mess2"><?php echo $data_str;?>
            </p>
        </li>
        <li><br />
        <input type="button" onclick="phpnew_install(this);" value="安装" style="color: #008040; width: 80px; cursor: pointer;" /> <input type="button" onclick="$.get('./install.php?action=demo&rand='+Math.random(),function(data){alert(data)})" value="检测mysql" style="color: #008040; width: 80px; cursor: pointer;" />
        </li>
        </ul>
    </div>
</body>
</html> 
        <?php

        break;
}

# 函数开始

function temp_error($mess) {
    global $str_data;
    echo (mysql_error()."<br />{$mess}:<br />".$str_data);
    exit();
}

function temp_getdb() {
    global $dbpre;
    $db = array();
    $db[] = "CREATE TABLE IF NOT EXISTS `[DB]attachments` (
  `aid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tid` int(10) unsigned DEFAULT '0',
  `fid` int(10) unsigned DEFAULT '0',
  `aname` varchar(200) DEFAULT '0',
  `atype` varchar(60) DEFAULT '0',
  `asize` int(10) unsigned DEFAULT '0',
  `amname` varchar(60) DEFAULT '0',
  `atime` int(10) unsigned DEFAULT '0',
  `adown` int(10) unsigned DEFAULT '0',
  `temp` tinyint(1) unsigned DEFAULT '0',
  `aistype` tinyint(1) unsigned DEFAULT '0',
  `atag` text,
  PRIMARY KEY (`aid`),
  KEY `temp` (`temp`),
  KEY `tid` (`tid`),
  KEY `atype` (`atype`),
  KEY `aistype` (`aistype`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";

    $db[] = "CREATE TABLE IF NOT EXISTS `[DB]cat` (
  `c_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c_top` int(10) unsigned DEFAULT '0',
  `c_name` varchar(200) DEFAULT '0',
  `c_tags` text,
  `c_asc` tinyint(3) DEFAULT '0',
  `c_tpl` varchar(10) DEFAULT '0',
  `c_time` int(10) unsigned DEFAULT '0',
  PRIMARY KEY (`c_id`),
  KEY `c_name` (`c_name`),
  KEY `c_asc` (`c_asc`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";

    $db[] = "CREATE TABLE IF NOT EXISTS `[DB]source` (
   `keys` char(32) DEFAULT '0',
  `vals` longtext,
  `types` tinyint(1) unsigned DEFAULT '0',
  UNIQUE KEY `keys` (`keys`),
  KEY `types` (`types`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8";

    $db[]="CREATE TABLE IF NOT EXISTS `[DB]thread` (
 `thread_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `thread_uid` int(10) unsigned DEFAULT '0',
  `thread_fid` int(10) unsigned DEFAULT '0',
  `thread_first` int(10) unsigned DEFAULT '0',
  `thread_title` varchar(200) DEFAULT NULL,
  `thread_message` text,
  `thread_update` int(10) unsigned DEFAULT NULL,
  `thread_date` int(10) unsigned DEFAULT NULL,
  `thread_ip` varchar(15) DEFAULT NULL,
  `thread_admin` tinyint(1) unsigned DEFAULT '0',
  `thread_attch` tinyint(1) unsigned DEFAULT '0',
  `thread_state` tinyint(1) unsigned DEFAULT '0',
  `thread_view` int(10) unsigned DEFAULT '0',
  `thread_history` text,
  `thread_thum` varchar(100) DEFAULT '0',
  `thread_index_img` varchar(100) DEFAULT '0',
  `thread_replay_count` int(10) unsigned DEFAULT '0',
  PRIMARY KEY (`thread_id`),
  KEY `thread_fid` (`thread_fid`),
  KEY `thread_first` (`thread_first`),
  KEY `thread_uid` (`thread_uid`),
  KEY `thread_admin` (`thread_admin`),
  KEY `thread_date` (`thread_date`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";

    $db[] = "CREATE TABLE IF NOT EXISTS `[DB]user` (
  `user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_name` varchar(80) DEFAULT '0',
  `user_pass` varchar(32) DEFAULT '0',
  `user_email` varchar(200) DEFAULT '0',
  `user_logo` tinyint(1) unsigned DEFAULT '0',
  `user_admin` tinyint(3) unsigned DEFAULT '0',
  `user_regtime` int(10) unsigned DEFAULT '0',
  `user_posts` tinyint(1) unsigned DEFAULT '0',
  `user_edits` tinyint(1) unsigned DEFAULT '0',
  `user_deles` tinyint(1) unsigned DEFAULT '0',
  `user_app` int(10) unsigned DEFAULT '0',
  `useropenid` varchar(32) DEFAULT '0',
  `user_exp` bigint(20) unsigned DEFAULT '0',
  `user_logtime` int(10) unsigned DEFAULT '0',
  PRIMARY KEY (`user_id`),
  KEY `user_name` (`user_name`),
  KEY `user_pass` (`user_pass`),
  KEY `useropenid` (`useropenid`),
  KEY `user_admin` (`user_admin`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";

    $db[] = 'REPLACE INTO `[DB]source` (`keys`, `vals`, `types`) VALUES
(\'setting\', \'sitename=PHPnew+Blog&sitekeywords=PHPnew+Blog+3.3&sitedescription=PHPnew+Blog+3.3&sitegenerator=PHPnew+Blog+3.3&siteicp=icp+123456&htaccess=0&editday=15&catstop=15&indexcount=20&user_exp=5000&replay_exp=2&post_exp=5&maxsize=1024&attch_array=jpg%2Cgif%2Crar&img_maxread=20&attch_look=0&qq_content=1&qq_appid=0&qq_appkey=0&qq_callback=0&timeoffset=0&redate=23%3D00&login_redate=23%3D00&replay_time=30\', 0),
(\'plugin\', \'\', 0),
(\'safechecktime\', \'0=1347976699\', 0),
(\'setlink\', \'0[link_name]=%E5%88%86%E4%BA%AB%E7%BD%91&0[link_alink]=http%3A%2F%2Fwww.fenanr.com%2F&0[link_tags]=phpnew+%E5%AE%98%E7%BD%91&0[link_ico]=&0[link_asc]=0&0[link_time]=1349968611\', 0),
(\'allcode\', \'77202e07e8a7e420245eb65a8e0c700a[types]=4&77202e07e8a7e420245eb65a8e0c700a[vars]=user_link_sys&77202e07e8a7e420245eb65a8e0c700a[tags]=%E7%BD%91%E5%9D%80%E6%94%B6%E8%97%8F%E9%87%8D%E8%A6%81%E9%9C%80%E8%A6%81.&77202e07e8a7e420245eb65a8e0c700a[codes]=http%3A%2F%2Fwww.tnrcw.com%2Fresume%2Fresume-show.php%3Fid%3D2046++%E7%AE%80%E5%8E%86.&77202e07e8a7e420245eb65a8e0c700a[times]=1348123794&4eed10f4fabc277c8b5e25e58c911989[types]=0&4eed10f4fabc277c8b5e25e58c911989[vars]=Hook_Cat_Right_5&4eed10f4fabc277c8b5e25e58c911989[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%8F%B3%E4%BE%A75&4eed10f4fabc277c8b5e25e58c911989[codes]=0&4eed10f4fabc277c8b5e25e58c911989[times]=1347519521&a2d5101e130b9ba441d3c66e82f64701[types]=0&a2d5101e130b9ba441d3c66e82f64701[vars]=Hook_Bottom_Statistics&a2d5101e130b9ba441d3c66e82f64701[tags]=%E5%85%A8%E5%B1%80%E5%BA%95%E9%83%A8%E6%89%A7%E8%A1%8C%E4%BB%A3%E7%A0%81.&a2d5101e130b9ba441d3c66e82f64701[codes]=0&a2d5101e130b9ba441d3c66e82f64701[times]=1347460299&0508e500e7dd1b28d0952c703bd9600e[types]=0&0508e500e7dd1b28d0952c703bd9600e[vars]=Hook_Header_JS&0508e500e7dd1b28d0952c703bd9600e[tags]=%E5%85%A8%E5%B1%80JS%E4%BB%A3%E7%A0%81&0508e500e7dd1b28d0952c703bd9600e[codes]=0&0508e500e7dd1b28d0952c703bd9600e[times]=1347460272&7e17282a196d3217317d741de08a6af2[types]=0&7e17282a196d3217317d741de08a6af2[vars]=Hook_Header_Css&7e17282a196d3217317d741de08a6af2[tags]=%E5%85%A8%E5%B1%80CSS&7e17282a196d3217317d741de08a6af2[codes]=0&7e17282a196d3217317d741de08a6af2[times]=1347460254&7661205ef304f830f6cec9d7969a8b40[types]=0&7661205ef304f830f6cec9d7969a8b40[vars]=Hook_Thread_Right_4&7661205ef304f830f6cec9d7969a8b40[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E5%8F%B3%E4%BE%A74&7661205ef304f830f6cec9d7969a8b40[codes]=0&7661205ef304f830f6cec9d7969a8b40[times]=1347460195&619673d968507b0caf8448cdc00979c2[types]=0&619673d968507b0caf8448cdc00979c2[vars]=Hook_Thread_Right_3&619673d968507b0caf8448cdc00979c2[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E5%8F%B3%E4%BE%A73&619673d968507b0caf8448cdc00979c2[codes]=0&619673d968507b0caf8448cdc00979c2[times]=1347460183&16d365f639dd26f9337646bf650ca97d[types]=0&16d365f639dd26f9337646bf650ca97d[vars]=Hook_Thread_Right_2&16d365f639dd26f9337646bf650ca97d[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E5%8F%B3%E4%BE%A72&16d365f639dd26f9337646bf650ca97d[codes]=0&16d365f639dd26f9337646bf650ca97d[times]=1347460164&610a93c0b428565efc20b927f721ca78[types]=0&610a93c0b428565efc20b927f721ca78[vars]=Hook_Thread_Right_1&610a93c0b428565efc20b927f721ca78[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E5%8F%B3%E4%BE%A71&610a93c0b428565efc20b927f721ca78[codes]=0&610a93c0b428565efc20b927f721ca78[times]=1347460150&318e41bd278a50c46d9976088e7580e1[types]=0&318e41bd278a50c46d9976088e7580e1[vars]=Hook_Thread_Bottom&318e41bd278a50c46d9976088e7580e1[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E5%BA%95%E9%83%A8&318e41bd278a50c46d9976088e7580e1[codes]=0&318e41bd278a50c46d9976088e7580e1[times]=1347460132&6f21b4e6aee7eb3f4755d8780576607d[types]=0&6f21b4e6aee7eb3f4755d8780576607d[vars]=Hook_Thread_Top&6f21b4e6aee7eb3f4755d8780576607d[tags]=%E5%86%85%E5%AE%B9%E6%98%BE%E7%A4%BA%E9%A1%B5%E9%A1%B6%E9%83%A8.&6f21b4e6aee7eb3f4755d8780576607d[codes]=0&6f21b4e6aee7eb3f4755d8780576607d[times]=1347460116&d2239e106ee22d9f312524a13306ca72[types]=0&d2239e106ee22d9f312524a13306ca72[vars]=Hook_Cat_Right_4&d2239e106ee22d9f312524a13306ca72[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%8F%B3%E4%BE%A74&d2239e106ee22d9f312524a13306ca72[codes]=0&d2239e106ee22d9f312524a13306ca72[times]=1347460053&5f43f2c40aa62585587cdf0021ba54b2[types]=0&5f43f2c40aa62585587cdf0021ba54b2[vars]=Hook_Cat_Right_3&5f43f2c40aa62585587cdf0021ba54b2[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%8F%B3%E4%BE%A73&5f43f2c40aa62585587cdf0021ba54b2[codes]=0&5f43f2c40aa62585587cdf0021ba54b2[times]=1347460042&4cae84a4c3bf4c4dbf936d23a012dbbf[types]=0&4cae84a4c3bf4c4dbf936d23a012dbbf[vars]=Hook_Cat_Right_2&4cae84a4c3bf4c4dbf936d23a012dbbf[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%8F%B3%E4%BE%A72&4cae84a4c3bf4c4dbf936d23a012dbbf[codes]=0&4cae84a4c3bf4c4dbf936d23a012dbbf[times]=1347460026&cf4f36ebb5e3d536ed5e722a9172d171[types]=0&cf4f36ebb5e3d536ed5e722a9172d171[vars]=Hook_Cat_Right_1&cf4f36ebb5e3d536ed5e722a9172d171[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%8F%B3%E4%BE%A71&cf4f36ebb5e3d536ed5e722a9172d171[codes]=0&cf4f36ebb5e3d536ed5e722a9172d171[times]=1347460016&505a33cf9b2597b142776d5e0839598c[types]=0&505a33cf9b2597b142776d5e0839598c[vars]=Hook_Cat_Bottom&505a33cf9b2597b142776d5e0839598c[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E5%BA%95%E9%83%A8&505a33cf9b2597b142776d5e0839598c[codes]=0&505a33cf9b2597b142776d5e0839598c[times]=1347459991&532462f6533977abf3451316f89bb7f3[types]=0&532462f6533977abf3451316f89bb7f3[vars]=Hook_Cat_Top&532462f6533977abf3451316f89bb7f3[tags]=%E5%88%97%E8%A1%A8%E9%A1%B5%E9%A1%B6%E9%83%A8.&532462f6533977abf3451316f89bb7f3[codes]=0&532462f6533977abf3451316f89bb7f3[times]=1347459975&b35975d49a9f7720041398f0d2f25753[types]=0&b35975d49a9f7720041398f0d2f25753[vars]=Hook_Index_Right_5&b35975d49a9f7720041398f0d2f25753[tags]=%E9%A6%96%E9%A1%B5%E5%8F%B3%E4%BE%A75&b35975d49a9f7720041398f0d2f25753[codes]=0&b35975d49a9f7720041398f0d2f25753[times]=1347459891&4e4d1aca39dd18215588494699a7a5aa[types]=0&4e4d1aca39dd18215588494699a7a5aa[vars]=Hook_Index_Right_4&4e4d1aca39dd18215588494699a7a5aa[tags]=%E9%A6%96%E9%A1%B5%E5%8F%B3%E4%BE%A74&4e4d1aca39dd18215588494699a7a5aa[codes]=0&4e4d1aca39dd18215588494699a7a5aa[times]=1347459799&bec0039b1dad4f941a14e6618911e3d0[types]=0&bec0039b1dad4f941a14e6618911e3d0[vars]=Hook_Index_Right_2&bec0039b1dad4f941a14e6618911e3d0[tags]=%E9%A6%96%E9%A1%B5%E5%8F%B3%E4%BE%A72&bec0039b1dad4f941a14e6618911e3d0[codes]=0&bec0039b1dad4f941a14e6618911e3d0[times]=1347459726&02c365e1701f348c60ff84659229ae81[types]=0&02c365e1701f348c60ff84659229ae81[vars]=Hook_Index_Right_3&02c365e1701f348c60ff84659229ae81[tags]=%E9%A6%96%E9%A1%B5%E5%8F%B3%E4%BE%A73&02c365e1701f348c60ff84659229ae81[codes]=0&02c365e1701f348c60ff84659229ae81[times]=1347459723&e5b179642fb4781a170ac5ddca4ca3be[types]=0&e5b179642fb4781a170ac5ddca4ca3be[vars]=Hook_Index_Right_1&e5b179642fb4781a170ac5ddca4ca3be[tags]=%E9%A6%96%E9%A1%B5%E5%8F%B3%E4%BE%A71&e5b179642fb4781a170ac5ddca4ca3be[codes]=0&e5b179642fb4781a170ac5ddca4ca3be[times]=1347459675&4557d217ae6df5b19ade6ec73419f23f[types]=0&4557d217ae6df5b19ade6ec73419f23f[vars]=Hook_Index_0&4557d217ae6df5b19ade6ec73419f23f[tags]=%E9%A6%96%E9%A1%B5%E5%8B%BE%E6%B3%A8%E5%8A%9F%E8%83%BD.&4557d217ae6df5b19ade6ec73419f23f[codes]=0&4557d217ae6df5b19ade6ec73419f23f[times]=1347459444&9ea99cb2bc9a032531dc751ddc3ff581[types]=0&9ea99cb2bc9a032531dc751ddc3ff581[vars]=All_var&9ea99cb2bc9a032531dc751ddc3ff581[tags]=%E6%89%80%E6%9C%89%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E5%90%8D%E8%A7%84%E5%88%99%E8%AF%B4%E6%98%8E&9ea99cb2bc9a032531dc751ddc3ff581[codes]=%E9%A6%96%E9%A1%B5%3A%0D%0AHook_Index_tid+++%28%E8%AF%B7%E5%B0%86tid%E6%8D%A2%E6%88%90%E4%B8%BB%E9%A2%98%E7%9A%84id%E5%80%BC%E5%8D%B3%E5%8F%AF+%2A%29%0D%0AHook_Index_Right_1+++%28%E5%8F%B3%E4%BE%A7%E6%B3%A8%E5%85%A5%E4%BB%A5%E9%A1%BA%E5%BA%8F%E6%8E%92%E5%88%97%29%0D%0A%0D%0A%E5%88%97%E8%A1%A8%E9%A1%B5%3A%0D%0AHook_Cat_Top++++++%28%E5%88%97%E8%A1%A8%E9%A1%B6%E9%83%A8%E6%B3%A8%E5%85%A5%29++%0D%0AHook_Cat_Bottom+++%28%E5%88%97%E8%A1%A8%E5%BA%95%E9%83%A8%29%0D%0AHook_Cat_Right_1+++%28%E5%8F%B3%E4%BE%A7%E6%B3%A8%E5%85%A5%E4%BB%A5%E9%A1%BA%E5%BA%8F%E6%8E%92%E5%88%97%29%0D%0A%0D%0A%E5%86%85%E5%AE%B9%E9%A1%B5%3A%0D%0AHook_Thread_Top+++++%28%E6%96%87%E7%AB%A0%E9%A1%B6%E9%83%A8%29%0D%0AHook_Thread_Bottom++%28%E6%96%87%E7%AB%A0%E5%8F%B3%E5%BA%95%E9%83%A8%29%0D%0AHook_Thread_Right_1+++%28%E5%8F%B3%E4%BE%A7%E6%B3%A8%E5%85%A5%E4%BB%A5%E9%A1%BA%E5%BA%8F%E6%8E%92%E5%88%97%29%0D%0A%0D%0A%E5%85%A8%E5%B1%80%3A+%0D%0AHook_Header_Css+++++%28%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AECSS%29%0D%0AHook_Header_JS+++++%28%E5%85%A8%E5%B1%80%E9%85%8D%E7%BD%AEJS%29%0D%0AHook_Bottom_Statistics++%28%E5%BA%95%E9%83%A8%E6%89%A7%E8%A1%8C%E4%BB%A3%E7%A0%81.%29%0D%0A%0D%0A%0D%0A%E5%85%B6%E5%AE%83%E5%AE%9A%E4%B9%89%E4%BF%A1%E6%81%AF%E5%9D%87%E7%94%B1%E7%94%A8%E6%88%B7%E8%87%AA%E5%B7%B1%E5%8F%91%E6%8C%A5%2C+%E5%AE%98%E6%96%B9%E9%BB%98%E8%AE%A4%E7%9A%84%E5%87%A0%E9%A1%B9%E8%AF%B7%E4%B8%8D%E8%A6%81%E9%9A%8F%E6%84%8F%E5%88%A0%E9%99%A4.%0D%0A%E5%9B%BE%E7%89%87%E8%B5%84%E6%96%99%E5%8F%AF%E7%94%A8%E8%B5%84%E6%BA%90%E7%AE%A1%E7%90%86%E4%B8%8A%E4%BC%A0%2C+%E7%84%B6%E5%90%8E%E5%B0%86%E8%B7%AF%E5%BE%84%E5%A4%8D%E5%88%B6%E8%BF%87%E6%9D%A5.+%E4%BB%A3%E7%A0%81%E6%94%AF%E6%8C%81%E6%89%80%E6%9C%89html%2C+%E9%9D%9E%E5%B8%B8%E8%87%AA%E5%AE%9A%E6%80%A7%E9%AB%98.&9ea99cb2bc9a032531dc751ddc3ff581[times]=1347457010\', 0),
(\'upfile\', \'\', 0);
';
    foreach($db as $key => $val) {
        $val = strtr($val,array('[DB]' => $dbpre));
        $db[$key] = $val;
    }
    return $db;
}