PHP数据库基于PDO操作类(mysql)

这是网上找的关于Mysql的操作类,非常适合初学者使用

<?php

class Mysql {

        protected static $_dbh = null; //静态属性,所有数据库实例共用,避免重复连接数据库
        protected $_dbType = 'mysql';
        protected $_pconnect = true; //是否使用长连接
        protected $_host = 'localhost';
        protected $_port = 3306;
        protected $_user = 'root';
        protected $_pass = '';
        protected $_dbName = null; //数据库名
        protected $_sql = false; //最后一条sql语句
        protected $_where = '';
        protected $_order = '';
        protected $_limit = '';
        protected $_field = '*';
        protected $_clear = 0; //状态,0表示查询条件干净,1表示查询条件污染
        protected $_trans = 0; //事务指令数 

        /**
         * 初始化类
         * @param array $conf 数据库配置
         */
        public function __construct(array $conf) {
            class_exists('PDO') or die("PDO: class not exists.");
            $this->_host = $conf['host'];
            $this->_port = $conf['port'];
            $this->_user = $conf['user'];
            $this->_pass = $conf['password'];
            $this->_dbName = $conf['dbname'];
            //连接数据库
            if ( is_null(self::$_dbh) ) {
                $this->_connect();
            }
        }

        /**
         * 连接数据库的方法
         */
        protected function _connect() {
            $dsn = $this->_dbType.':host='.$this->_host.';port='.$this->_port.';dbname='.$this->_dbName;
            //持久化连接
            $options = $this->_pconnect ? array(PDO::ATTR_PERSISTENT=>true) : array();
            try { 
                $dbh = new PDO($dsn, $this->_user, $this->_pass, $options);
                $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  //设置如果sql语句执行错误则抛出异常,事务会自动回滚
                $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //禁用prepared statements的仿真效果(防SQL注入)
            } catch (PDOException $e) { 
                die('Connection failed: ' . $e->getMessage());
            }
            $dbh->exec('SET NAMES utf8');
            self::$_dbh = $dbh;
        }

        /** 
        * 字段和表名添加 `符号
        * 保证指令中使用关键字不出错 针对mysql 
        * @param string $value 
        * @return string 
        */
        protected function _addChar($value) { 
            if ('*'==$value || false!==strpos($value,'(') || false!==strpos($value,'.') || false!==strpos($value,'`')) { 
                //如果包含* 或者 使用了sql方法 则不作处理 
            } elseif (false === strpos($value,'`') ) { 
                $value = '`'.trim($value).'`';
            } 
            return $value; 
        }

        /** 
        * 取得数据表的字段信息 
        * @param string $tbName 表名
        * @return array 
        */
        protected function _tbFields($tbName) {
            $sql = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="'.$tbName.'" AND TABLE_SCHEMA="'.$this->_dbName.'"';
            $stmt = self::$_dbh->prepare($sql);
            $stmt->execute();
            $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
            $ret = array();
            foreach ($result as $key=>$value) {
                $ret[$value['COLUMN_NAME']] = 1;
            }
            return $ret;
        }

        /** 
        * 过滤并格式化数据表字段
        * @param string $tbName 数据表名 
        * @param array $data POST提交数据 
        * @return array $newdata 
        */
        protected function _dataFormat($tbName,$data) {
            if (!is_array($data)) return array();
            $table_column = $this->_tbFields($tbName);
            $ret=array();
            foreach ($data as $key=>$val) {
                if (!is_scalar($val)) continue; //值不是标量则跳过
                if (array_key_exists($key,$table_column)) {
                    $key = $this->_addChar($key);
                    if (is_int($val)) { 
                        $val = intval($val); 
                    } elseif (is_float($val)) { 
                        $val = floatval($val); 
                    } elseif (preg_match('/^\(\w*(\+|\-|\*|\/)?\w*\)$/i', $val)) {
                        // 支持在字段的值里面直接使用其它字段 ,例如 (score+1) (name) 必须包含括号
                        $val = $val;
                    } elseif (is_string($val)) { 
                        //将字符串中的单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符转义
                        $val = '"'.addslashes($val).'"';
                    }
                    $ret[$key] = $val;
                }
            }
            return $ret;
        }

        /**
        * 执行查询 主要针对 SELECT, SHOW 等指令
        * @param string $sql sql指令 
        * @return mixed 
        */
        protected function _doQuery($sql='') {
            $this->_sql = $sql;
            $pdostmt = self::$_dbh->prepare($this->_sql); //prepare或者query 返回一个PDOStatement
            $pdostmt->execute();
            $result = $pdostmt->fetchAll(PDO::FETCH_ASSOC);
            return $result;
        }

        /** 
        * 执行语句 针对 INSERT, UPDATE 以及DELETE,exec结果返回受影响的行数
        * @param string $sql sql指令 
        * @return integer 
        */
        protected function _doExec($sql='') {
            $this->_sql = $sql;
            return self::$_dbh->exec($this->_sql);
        }

        /** 
        * 执行sql语句,自动判断进行查询或者执行操作 
        * @param string $sql SQL指令 
        * @return mixed 
        */
        public function doSql($sql='') {
            $queryIps = 'INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|SELECT .* INTO|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK'; 
            if (preg_match('/^\s*"?(' . $queryIps . ')\s+/i', $sql)) { 
                return $this->_doExec($sql);
            }
            else {
                //查询操作
                return $this->_doQuery($sql);
            }
        }

        /** 
        * 获取最近一次查询的sql语句 
        * @return String 执行的SQL 
        */
        public function getLastSql() { 
            return $this->_sql;
        }

        /**
         * 插入方法
         * @param string $tbName 操作的数据表名
         * @param array $data 字段-值的一维数组
         * @return int 受影响的行数
         */
        public function insert($tbName,array $data){
            $data = $this->_dataFormat($tbName,$data);
            if (!$data) return;
            $sql = "insert into ".$tbName."(".implode(',',array_keys($data)).") values(".implode(',',array_values($data)).")";
            return $this->_doExec($sql);
        }

        /**
         * 删除方法
         * @param string $tbName 操作的数据表名
         * @return int 受影响的行数
         */
        public function delete($tbName) {
            //安全考虑,阻止全表删除
            if (!trim($this->_where)) return false;
            $sql = "delete from ".$tbName." ".$this->_where;
            $this->_clear = 1;
            $this->_clear();
            return $this->_doExec($sql);
        }

        /**
         * 更新函数
         * @param string $tbName 操作的数据表名
         * @param array $data 参数数组
         * @return int 受影响的行数
         */
        public function update($tbName,array $data) {
            //安全考虑,阻止全表更新
            if (!trim($this->_where)) return false;
            $data = $this->_dataFormat($tbName,$data);
            if (!$data) return;
            $valArr = '';
            foreach($data as $k=>$v){
                $valArr[] = $k.'='.$v;
            }
            $valStr = implode(',', $valArr);
            $sql = "update ".trim($tbName)." set ".trim($valStr)." ".trim($this->_where);
            return $this->_doExec($sql);
        }

        /**
         * 查询函数
         * @param string $tbName 操作的数据表名
         * @return array 结果集
         */
        public function select($tbName='') {
            $sql = "select ".trim($this->_field)." from ".$tbName." ".trim($this->_where)." ".trim($this->_order)." ".trim($this->_limit);
            //echo $sql;
            $this->_clear = 1;
            $this->_clear();
            return $this->_doQuery(trim($sql));
        }

        /**
         * @param mixed $option 组合条件的二维数组,例:$option['field1'] = array(1,'=>','or')
         * @return $this
         */
        public function where($option) {
            if ($this->_clear>0) $this->_clear();
            $this->_where = ' where ';
            $logic = 'and';
            if (is_string($option)) {
                $this->_where .= $option;
            }
            elseif (is_array($option)) {
                foreach($option as $k=>$v) {
                    if (is_array($v)) {
                        $relative = isset($v[1]) ? $v[1] : '=';
                        $logic    = isset($v[2]) ? $v[2] : 'and';
                        $condition = ' ('.$this->_addChar($k).' '.$relative.' '.$v[0].') ';
                    }
                    else {
                        $logic = 'and';
                        $condition = ' ('.$this->_addChar($k).'='.$v.') ';
                    }
                    $this->_where .= isset($mark) ? $logic.$condition : $condition;
                    $mark = 1;
                }
            }
            return $this;
        }

        /**
         * 设置排序
         * @param mixed $option 排序条件数组 例:array('sort'=>'desc')
         * @return $this
         */
        public function order($option) {
            if ($this->_clear>0) $this->_clear();
            $this->_order = ' order by ';
            if (is_string($option)) {
                $this->_order .= $option;
            }
            elseif (is_array($option)) {
                foreach($option as $k=>$v){
                    $order = $this->_addChar($k).' '.$v;
                    $this->_order .= isset($mark) ? ','.$order : $order;
                    $mark = 1;
                }
            }
            return $this;
        }

        /**
         * 设置查询行数及页数
         * @param int $page pageSize不为空时为页数,否则为行数
         * @param int $pageSize 为空则函数设定取出行数,不为空则设定取出行数及页数
         * @return $this
         */
        public function limit($page,$pageSize=null) {
            if ($this->_clear>0) $this->_clear();
            if ($pageSize===null) {
                $this->_limit = "limit ".$page;
            }
            else {
                $pageval = intval( ($page - 1) * $pageSize);
                $this->_limit = "limit ".$pageval.",".$pageSize;
            }
            return $this;
        }

        /**
         * 设置查询字段
         * @param mixed $field 字段数组
         * @return $this
         */
        public function field($field){
            if ($this->_clear>0) $this->_clear();
            if (is_string($field)) {
                $field = explode(',', $field);
            }
            $nField = array_map(array($this,'_addChar'), $field);
            $this->_field = implode(',', $nField);
            return $this;
        }

        /**
         * 清理标记函数
         */
        protected function _clear() {
            $this->_where = '';
            $this->_order = '';
            $this->_limit = '';
            $this->_field = '*';
            $this->_clear = 0;
        }

        /**
         * 手动清理标记
         * @return $this
         */
        public function clearKey() {
            $this->_clear();
            return $this;
        }

        /**
        * 启动事务 
        * @return void 
        */
        public function startTrans() { 
            //数据rollback 支持 
            if ($this->_trans==0) self::$_dbh->beginTransaction();
            $this->_trans++; 
            return; 
        }

        /** 
        * 用于非自动提交状态下面的查询提交 
        * @return boolen 
        */
        public function commit() {
            $result = true;
            if ($this->_trans>0) { 
                $result = self::$_dbh->commit(); 
                $this->_trans = 0;
            } 
            return $result;
        }

        /** 
        * 事务回滚 
        * @return boolen 
        */
        public function rollback() {
            $result = true;
            if ($this->_trans>0) {
                $result = self::$_dbh->rollback();
                $this->_trans = 0;
            }
            return $result;
        }

        /**
        * 关闭连接
        * PHP 在脚本结束时会自动关闭连接。
        */
        public function close() {
            if (!is_null(self::$_dbh)) self::$_dbh = null;
        }

}

PHP进行tcp连接

原生PHP的写法。

$host = '服务端IP';
    $port = 端口号;
    $timeout = 5;

    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if (socket_connect($socket, $host, $port) === false) { // 创建连接
        socket_close($socket);
        $message = 'create socket error';
        throw new Exception($message, socket_last_error());
    }   

    if (socket_write($socket, $buffer) === false) { // 发包
        socket_close($socket);
        $message = sprintf("write socket error:%s", socket_strerror(socket_last_error()));
        throw new Exception($message, socket_last_error());
    }   

    socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout);

    $rspBuffer = socket_read($socket, 65536); // 接收回包

    socket_close($socket);

使用swoole的写法。

$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC);
$ret = $client->connect('服务端IP', 端口号, 0.5, 0);  // 创建连接
if (!$ret) {
    throw new Exception('connect error', $client->errCode);
}   

$client->send($buffer); // 发包

$rspBuffer = $client->recv(); // 接收回包

转载地址

https://www.liudon.org/1324.html

php hex16进制数据 BBC异或值计算

1.前言
物联网的通信。想要远程通信,必须要用指定的协议发送给机器才可以实现智能开锁。需要发送的数据是16进制的hex,并且最后一位的数据必须用BBC异或校验得到的数据才行。网上查询了一下php生成BBC异或校验码的相关资料,记录一下
在线效验异或值地址:http://www.metools.info/code/c48.html,
http://www.ip33.com/bcc.html

BBC校验
BCC(Block Check Character/信息组校验码),因校验码是将所有数据异或得出,故俗称异或校验。具体算法是:将每一个字节的数据(一般是两个16进制的字符)进行异或后即得到校验码。
例如16进制数据:01 A0 7C FF 02
计算:01 xor A0 xor 7C xor FF xor 02 = 20
校验码是:20

计算思路
把十六进制的字符按照顺序两个异或之后拿得到的结果再和下一个异或,

hex数据BBC异或校验(两两比较)
/**
* @param $byte1
* @param $byte2
* @return string
* hex数据BBC异或校验(两两比较)
*/
function hexOr($byte1, $byte2)
{
$result=”;
$byte1= str_pad(base_convert($byte1, 16, 2), ‘8’, ‘0’, STR_PAD_LEFT);
$byte2= str_pad(base_convert($byte2, 16, 2), ‘8’, ‘0’, STR_PAD_LEFT);
$len1 = strlen($byte1);
for ($i = 0; $i < $len1 ; $i++) {
$result .= $byte1[$i] == $byte2[$i] ? ‘0’ : ‘1’;
}
return strtoupper(base_convert($result, 2, 16));
}

hex数据BBC异或校验(多个hex数据进行校验)
/**
* @param $data
* @return mixed
* hex数据BBC异或校验(多个hex数据进行校验)
*/
function hexOrArr($data)
{
$result = $data[0];
for ($i = 0; $i < count($data) – 1; $i++) {
$result = hexOr($result, $data[$i + 1]);
}
return $result;
}

字符串根据字节长度拆分为数组

/**
* @param $string
* @param int $len
* @return array
* 字符串根据字节长度拆分为数组
*/
function mbStrSplit($string, $len = 1)
{
$start = 0;
$strlen = mb_strlen($string);
while ($strlen) {
$array[] = strtoupper(mb_substr($string, $start, $len, “utf8”));
$string = mb_substr($string, $len, $strlen, “utf8”);
$strlen = mb_strlen($string);
}
return $array;
}
$message=01A07CFF02
$sum=hexOrArr(mbStrSplit($message, 2));//异或值
echo $sum;
————————————————
版权声明:本文为CSDN博主「傅先生的傅」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44243111/article/details/112593099

php hexdec()与dechex()十六进制转换为十进制互换

jquery中文网为您提供php hexdec()与dechex()十六进制转换为十进制互换等资源,欢迎您收藏本站,我们将为您提供最新的php hexdec()与dechex()十六进制转换为十进制互换资源

hexdec() 函数把十六进制转换为十进制。

语法
hexdec(hex_string)

<blockquote>echo hexdec(’77’);       //输出119
echo “<br>”;
echo hexdec(dechex(43));      //输出43
echo “<br>”;
echo hexdec(‘3a’);       //输出58</blockquote>
dechex() 函数把十进制转换为十六进制。

语法
dechex(dec_number)

JavaScript返回到上一页的三种方法

window.history.go(-1); //返回上一页

window.history.back(); //返回上一页

window.location.go(-1); //刷新上一页

window.history.back();location.reload();//强行刷新(返回上一页刷新页面)

 

//如果要强行刷新的话就是:window.history.back();//刷新当前页 window.location.reload();

Javascript 返回上一页:

1. history.go(-1), 返回两个页面: history.go(-2);

2. history.back().

3. window.history.forward()返回下一页

4. window.history.go(返回第几页,也可以使用访问过的URL)

例:

<a href=”javascript:history.go(-1);”>向上一页</a>

response.Write(“<script language=javascript>”)

response.Write(“if(!confirm(‘完成任务?’)){history.back();}”)

response.Write(“</script>”)

response.Write(“<script language=javascript>history.go(-1);</script>”)

<a href=”javascript:history.go(-1);”>向上一页</a>

页面跳转:οnclick=”window.location.href=’index.aspx'”

P.S.

小技巧(JS引用JS):

<script type=text/javascript>

<!–

if (typeof SWFObject == “undefined”) {
document.write(‘<scr’ + ‘ipt type=”text/javascript” src=”/scripts/swfobject-1.5.js”></scr’ + ‘ipt>’);}

//–>

</script>
————————————————
版权声明:本文为CSDN博主「一路繁华相送」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/hui_3_6/article/details/81282609

微擎系统表结构以及数据关系说明

-- phpMyAdmin SQL Dump
-- version 4.1.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: 2015-01-27 11:00:31
-- 服务器版本: 5.5.39
-- PHP Version: 5.4.31
 
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
 
--
-- Database: `we7_pro`
--
 
--
-- 表的结构 `ims_account`
--
 
CREATE TABLE IF NOT EXISTS `ims_account` (
  `acid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `hash` VARCHAR(8) NOT NULL,
  `type` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1为微信,2为易信',
  `isconnect` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`acid`),
  KEY `idx_uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=437 ;
 
--
-- 表的结构 `ims_account_wechats`
--
 
CREATE TABLE IF NOT EXISTS `ims_account_wechats` (
  `acid` INT(10) UNSIGNED NOT NULL,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `token` VARCHAR(32) NOT NULL COMMENT '随机生成密钥',
  `encodingaeskey` VARCHAR(43) NOT NULL,
  `access_token` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '存取凭证结构',
  `jsapi_ticket` VARCHAR(1000) NOT NULL,
  `level` tinyint(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT '接口权限级别, 0 普通订阅号, 1 认证订阅号|普通服务号, 2认证服务号',
  `name` VARCHAR(30) NOT NULL COMMENT '公众号名称',
  `account` VARCHAR(30) NOT NULL COMMENT '微信帐号',
  `original` VARCHAR(50) NOT NULL,
  `signature` VARCHAR(100) NOT NULL COMMENT '功能介绍',
  `country` VARCHAR(10) NOT NULL,
  `province` VARCHAR(3) NOT NULL,
  `city` VARCHAR(15) NOT NULL,
  `username` VARCHAR(30) NOT NULL,
  `password` VARCHAR(32) NOT NULL,
  `lastupdate` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `key` VARCHAR(50) NOT NULL,
  `secret` VARCHAR(50) NOT NULL,
  `styleid` INT(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '风格ID',
  `subscribeurl` VARCHAR(120) NOT NULL DEFAULT '' COMMENT '引导素材',
  PRIMARY KEY (`acid`),
  KEY `idx_key` (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
--
-- 表的结构 `ims_activity_coupon`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_coupon` (
  `couponid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '公号序号',
  `type` tinyint(4) NOT NULL COMMENT '优惠券类型. 1为折扣券, 2为代金券',
  `title` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '标题',
  `couponsn` VARCHAR(50) NOT NULL,
  `description` text COMMENT '描述',
  `discount` DECIMAL(10,2) NOT NULL COMMENT '折扣券(折扣率), 代金券(面额)',
  `condition` DECIMAL(10,2) NOT NULL COMMENT '订单满多少可用',
  `starttime` INT(10) UNSIGNED NOT NULL COMMENT '开始时间',
  `endtime` INT(10) UNSIGNED NOT NULL COMMENT '结束时间',
  `limit` INT(11) NOT NULL DEFAULT '0' COMMENT '每人限领',
  `dosage` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '已领取数量',
  `amount` INT(11) UNSIGNED NOT NULL COMMENT '总发行数量',
  `thumb` VARCHAR(500) NOT NULL COMMENT '缩略图',
  `credittype` VARCHAR(20) NOT NULL,
  `credit` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`couponid`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=39 ;
 
--
-- 表的结构 `ims_activity_coupon_allocation`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_coupon_allocation` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `couponid` INT(10) UNSIGNED NOT NULL,
  `groupid` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`,`couponid`,`groupid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=407 ;
 
--
-- 表的结构 `ims_activity_coupon_password`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_coupon_password` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL DEFAULT '',
  `password` VARCHAR(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ;
 
--
-- 表的结构 `ims_activity_coupon_record`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_coupon_record` (
  `recid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '序号',
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL COMMENT '用户编号',
  `grantmodule` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '发放模块',
  `granttime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '发放时间',
  `usemodule` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '使用模块',
  `usetime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '使用时间',
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态: 0 未发放, 1 已发放, 2 已使用',
  `operator` VARCHAR(30) NOT NULL COMMENT '操作员',
  `remark` VARCHAR(300) NOT NULL DEFAULT '',
  `couponid` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`recid`),
  KEY `couponid` (`uid`,`grantmodule`,`usemodule`,`status`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=60 ;
 
--
-- 表的结构 `ims_activity_exchange`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_exchange` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(11) NOT NULL,
  `title` VARCHAR(100) NOT NULL COMMENT '物品名称',
  `description` VARCHAR(1000) NOT NULL COMMENT '描述信息',
  `thumb` VARCHAR(500) NOT NULL COMMENT '缩略图',
  `type` tinyint(1) UNSIGNED NOT NULL COMMENT '物品类型,1折扣券,2代金券,3实物,4虚拟物品(未启用),5营销模块操作次数',
  `extra` VARCHAR(3000) NOT NULL DEFAULT '' COMMENT '兑换产品属性',
  `credit` INT(10) UNSIGNED NOT NULL COMMENT '兑换积分数量',
  `credittype` VARCHAR(10) NOT NULL COMMENT '兑换积分类型',
  `pretotal` INT(11) NOT NULL COMMENT '每个人最大兑换次数',
  `num` INT(11) NOT NULL COMMENT '已兑换礼品数量',
  `total` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '总量',
  `status` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '状态',
  `starttime` INT(10) UNSIGNED NOT NULL,
  `endtime` INT(10) NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL,
  `couponid` INT(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=72 ;
 
--
-- 表的结构 `ims_activity_exchange_trades`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_exchange_trades` (
  `tid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '统一公号',
  `uid` INT(10) UNSIGNED NOT NULL COMMENT '用户(粉丝)id',
  `exid` INT(10) UNSIGNED NOT NULL COMMENT '兑换产品 exchangeid',
  `type` INT(10) UNSIGNED NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '交换记录创建时间',
  PRIMARY KEY (`tid`),
  KEY `uniacid` (`uniacid`,`uid`,`exid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;
 
--
-- 表的结构 `ims_activity_exchange_trades_shipping`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_exchange_trades_shipping` (
  `tid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `exid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单状态,0为正常,-1为关闭,1为已发货,2为已完成',
  `createtime` INT(10) UNSIGNED NOT NULL,
  `province` VARCHAR(30) NOT NULL,
  `city` VARCHAR(30) NOT NULL,
  `district` VARCHAR(30) NOT NULL,
  `address` VARCHAR(255) NOT NULL,
  `zipcode` VARCHAR(6) NOT NULL,
  `mobile` VARCHAR(30) NOT NULL,
  `name` VARCHAR(30) NOT NULL COMMENT '收件人',
  PRIMARY KEY (`tid`),
  KEY `uniacid` (`uniacid`),
  KEY `uid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;
 
--
-- 表的结构 `ims_activity_modules`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_modules` (
  `mid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '公号ID',
  `exid` INT(10) UNSIGNED NOT NULL COMMENT '活动参与次数id',
  `module` VARCHAR(50) NOT NULL COMMENT '模块名称',
  `uid` INT(10) UNSIGNED NOT NULL COMMENT '用户ID',
  `available` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '可用次数',
  PRIMARY KEY (`mid`),
  KEY `uniacid` (`uniacid`),
  KEY `module` (`module`),
  KEY `uid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ;
 
--
-- 表的结构 `ims_activity_modules_record`
--
 
CREATE TABLE IF NOT EXISTS `ims_activity_modules_record` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mid` INT(10) UNSIGNED NOT NULL,
  `num` tinyint(3) NOT NULL DEFAULT '0' COMMENT 'num=1表示兑换,num=-1表示消费',
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `mid` (`mid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
 
--
-- 表的结构 `ims_basic_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_basic_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `content` VARCHAR(1000) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=246 ;
 
--
-- 表的结构 `ims_core_attachment`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_attachment` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `filename` VARCHAR(255) NOT NULL,
  `attachment` VARCHAR(255) NOT NULL,
  `type` tinyint(3) UNSIGNED NOT NULL COMMENT '1.图片; 2.音乐;',
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=694 ;
 
--
-- 表的结构 `ims_core_cache`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_cache` (
  `key` VARCHAR(50) NOT NULL COMMENT '缓存键名',
  `value` mediumtext NOT NULL COMMENT '缓存内容',
  PRIMARY KEY (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='缓存表';
 
 
 
--
-- 表的结构 `ims_core_paylog`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_paylog` (
  `plid` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `type` VARCHAR(20) NOT NULL DEFAULT '',
  `uniacid` INT(11) NOT NULL,
  `acid` INT(11) NOT NULL,
  `openid` VARCHAR(40) NOT NULL DEFAULT '',
  `tid` VARCHAR(64) NOT NULL,
  `fee` DECIMAL(10,2) NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '0',
  `module` VARCHAR(50) NOT NULL DEFAULT '',
  `tag` VARCHAR(2000) NOT NULL DEFAULT '',
  PRIMARY KEY (`plid`),
  KEY `idx_openid` (`openid`),
  KEY `idx_tid` (`tid`),
  KEY `idx_uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=51 ;
 
--
-- 表的结构 `ims_core_performance`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_performance` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `type` tinyint(1) NOT NULL COMMENT '1:系统,2:数据库',
  `runtime` VARCHAR(10) NOT NULL COMMENT '运行时间',
  `runurl` VARCHAR(512) NOT NULL COMMENT '运行页面url',
  `runsql` VARCHAR(512) NOT NULL COMMENT '运行sql语句',
  `createtime` INT(10) NOT NULL COMMENT '记录时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=297223 ;
 
--
-- 表的结构 `ims_core_queue`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_queue` (
  `qid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '逻辑主键',
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `acid` INT(10) UNSIGNED NOT NULL,
  `message` VARCHAR(2000) NOT NULL DEFAULT '',
  `params` VARCHAR(1000) NOT NULL DEFAULT '',
  `keyword` VARCHAR(1000) NOT NULL DEFAULT '',
  `response` VARCHAR(2000) NOT NULL DEFAULT '',
  `module` VARCHAR(50) NOT NULL DEFAULT '',
  `dateline` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`qid`),
  KEY `uniacid` (`uniacid`,`acid`),
  KEY `module` (`module`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5475 ;
 
--
-- 表的结构 `ims_core_resource`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_resource` (
  `mid` INT(11) NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `media_id` VARCHAR(100) NOT NULL,
  `trunk` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `type` VARCHAR(10) NOT NULL,
  `dateline` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`mid`),
  KEY `acid` (`uniacid`),
  KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 
--
-- 表的结构 `ims_core_sessions`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_sessions` (
  `sid` CHAR(32) NOT NULL DEFAULT '' COMMENT 'sessionid唯一标识',
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '所属公众号',
  `openid` VARCHAR(50) NOT NULL COMMENT '用户唯一标识',
  `data` VARCHAR(500) NOT NULL,
  `expiretime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '超时时间',
  PRIMARY KEY (`sid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
--
-- 表的结构 `ims_core_settings`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_settings` (
  `key` VARCHAR(200) NOT NULL COMMENT '设置键名',
  `value` text NOT NULL COMMENT '设置内容,大量数据将序列化',
  PRIMARY KEY (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
--
-- 表的结构 `ims_core_wechats_attachment`
--
 
CREATE TABLE IF NOT EXISTS `ims_core_wechats_attachment` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `filename` VARCHAR(255) NOT NULL,
  `attachment` VARCHAR(255) NOT NULL,
  `media_id` VARCHAR(255) NOT NULL,
  `type` VARCHAR(15) NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`),
  KEY `media_id` (`media_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=650 ;
 
--
-- 表的结构 `ims_cover_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_cover_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `multiid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `rid` INT(10) UNSIGNED NOT NULL,
  `module` VARCHAR(30) NOT NULL DEFAULT '',
  `do` VARCHAR(30) NOT NULL DEFAULT '',
  `title` VARCHAR(255) NOT NULL DEFAULT '',
  `description` VARCHAR(255) NOT NULL DEFAULT '',
  `thumb` VARCHAR(255) NOT NULL DEFAULT '',
  `url` VARCHAR(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=96 ;
 
--
-- 表的结构 `ims_cron`
--
 
CREATE TABLE IF NOT EXISTS `ims_cron` (
  `cronid` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
  `available` tinyint(1) NOT NULL DEFAULT '0',
  `type` enum('user','system','plugin') NOT NULL DEFAULT 'user',
  `name` CHAR(50) NOT NULL DEFAULT '',
  `filename` CHAR(50) NOT NULL DEFAULT '',
  `lastrun` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `nextrun` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `weekday` tinyint(1) NOT NULL DEFAULT '0',
  `day` tinyint(2) NOT NULL DEFAULT '0',
  `hour` tinyint(2) NOT NULL DEFAULT '0',
  `minute` CHAR(36) NOT NULL DEFAULT '',
  PRIMARY KEY (`cronid`),
  KEY `nextrun` (`available`,`nextrun`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
 
--
-- 表的结构 `ims_custom_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_custom_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `start1` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `end1` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `start2` INT(10) UNSIGNED NOT NULL,
  `end2` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `rid` (`rid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
 
--
-- 表的结构 `ims_images_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_images_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '规则ID',
  `title` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '标题',
  `description` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '介绍',
  `mediaid` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '图片id',
  `createtime` INT(10) NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=131 ;
 
--
-- 表的结构 `ims_mc_card`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_card` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `title` VARCHAR(100) NOT NULL DEFAULT '',
  `color` VARCHAR(255) NOT NULL DEFAULT '',
  `background` VARCHAR(255) NOT NULL DEFAULT '',
  `logo` VARCHAR(255) NOT NULL DEFAULT '',
  `format` VARCHAR(50) NOT NULL DEFAULT '',
  `fields` VARCHAR(1000) NOT NULL DEFAULT '',
  `snpos` INT(11) NOT NULL DEFAULT '0',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用1:启用0:关闭',
  `business` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
 
--
-- 表的结构 `ims_mc_card_members`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_card_members` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) DEFAULT NULL,
  `cid` INT(10) NOT NULL DEFAULT '0',
  `cardsn` VARCHAR(20) NOT NULL DEFAULT '',
  `status` tinyint(1) NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=85 ;
 
--
-- 表的结构 `ims_mc_chats_record`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_chats_record` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `acid` INT(10) UNSIGNED NOT NULL,
  `flag` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
  `openid` VARCHAR(32) NOT NULL,
  `msgtype` VARCHAR(15) NOT NULL,
  `content` VARCHAR(10000) NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`,`acid`),
  KEY `openid` (`openid`),
  KEY `createtime` (`createtime`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=86 ;
 
--
-- 表的结构 `ims_mc_credits_recharge`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_credits_recharge` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `tid` VARCHAR(20) NOT NULL,
  `transid` VARCHAR(30) NOT NULL,
  `fee` VARCHAR(10) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0',
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_uniacid_uid` (`uniacid`,`uid`),
  KEY `idx_tid` (`tid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
 
--
-- 表的结构 `ims_mc_credits_record`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_credits_record` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `uid` INT(10) UNSIGNED NOT NULL,
  `uniacid` INT(11) NOT NULL,
  `credittype` VARCHAR(10) NOT NULL DEFAULT '',
  `num` DECIMAL(10,2) NOT NULL DEFAULT '0.00',
  `operator` INT(10) UNSIGNED NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL,
  `remark` VARCHAR(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`),
  KEY `uid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=367 ;
 
--
-- 表的结构 `ims_mc_fans_groups`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_fans_groups` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `acid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `groups` VARCHAR(10000) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
 
--
-- 表的结构 `ims_mc_groups`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_groups` (
  `groupid` INT(11) NOT NULL AUTO_INCREMENT,
  `uniacid` INT(11) NOT NULL DEFAULT '0',
  `title` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '会员组名称',
  `orderlist` tinyint(4) UNSIGNED NOT NULL DEFAULT '0',
  `isdefault` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`groupid`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=277 ;
 
--
-- 表的结构 `ims_mc_handsel`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_handsel` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) NOT NULL,
  `touid` INT(10) UNSIGNED NOT NULL COMMENT '用户uid',
  `fromuid` VARCHAR(32) NOT NULL COMMENT '来源',
  `module` VARCHAR(30) NOT NULL COMMENT '模块名称',
  `sign` VARCHAR(100) NOT NULL COMMENT '赠送积分的对象',
  `action` VARCHAR(20) NOT NULL COMMENT '动作(分享,阅读)',
  `credit_value` INT(10) UNSIGNED NOT NULL COMMENT '赠送积分多少',
  `createtime` INT(10) UNSIGNED NOT NULL COMMENT '记录添加时间',
  PRIMARY KEY (`id`),
  KEY `uid` (`touid`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
 
--
-- 表的结构 `ims_mc_mapping_fans`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_mapping_fans` (
  `fanid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `acid` INT(10) UNSIGNED NOT NULL COMMENT '公众号ID',
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '统一公号(冗余列)',
  `uid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '统一用户',
  `openid` VARCHAR(255) NOT NULL COMMENT '用户的唯一身份ID',
  `groupid` INT(10) UNSIGNED DEFAULT '0' COMMENT '粉丝所在组id',
  `salt` CHAR(8) NOT NULL DEFAULT '' COMMENT '加密盐',
  `follow` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '是否订阅',
  `followtime` INT(10) UNSIGNED NOT NULL,
  `unfollowtime` INT(10) UNSIGNED NOT NULL,
  `tag` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `updatetime` INT(10) UNSIGNED DEFAULT '0' COMMENT '粉丝信息最后更新时间',
  PRIMARY KEY (`fanid`),
  UNIQUE KEY `sasdf` (`salt`),
  KEY `acid` (`acid`),
  KEY `uniacid` (`uniacid`),
  KEY `openid` (`openid`),
  KEY `updatetime` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=75171 ;
 
--
-- 表的结构 `ims_mc_members`
--
 
CREATE TABLE IF NOT EXISTS `ims_mc_members` (
  `uid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '统一公号ID',
  `mobile` VARCHAR(11) NOT NULL DEFAULT '' COMMENT '手机号码',
  `email` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '电子邮箱',
  `password` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '密码',
  `salt` VARCHAR(8) NOT NULL DEFAULT '' COMMENT '盐',
  `groupid` INT(11) NOT NULL DEFAULT '0',
  `credit1` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '积分',
  `credit2` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '余额',
  `credit3` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00',
  `credit4` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00',
  `credit5` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00',
  `createtime` INT(10) UNSIGNED NOT NULL COMMENT '加入时间',
  `realname` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '真实姓名',
  `nickname` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '昵称',
  `avatar` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '头像',
  `qq` VARCHAR(15) NOT NULL DEFAULT '' COMMENT 'QQ号',
  `vip` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'VIP级别,0为普通会员',
  `gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别(0:保密 1:男 2:女)',
  `birthyear` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生日年',
  `birthmonth` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生日月',
  `birthday` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生日',
  `constellation` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '星座',
  `zodiac` VARCHAR(5) NOT NULL DEFAULT '' COMMENT '生肖',
  `telephone` VARCHAR(15) NOT NULL DEFAULT '' COMMENT '固定电话',
  `idcard` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '证件号码',
  `studentid` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '学号',
  `grade` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '班级',
  `address` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '邮寄地址',
  `zipcode` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '邮编',
  `nationality` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '国籍',
  `resideprovince` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '居住省份',
  `residecity` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '居住城市',
  `residedist` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '居住行政区/县',
  `graduateschool` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '毕业学校',
  `company` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '公司',
  `education` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '学历',
  `occupation` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '职业',
  `position` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '职位',
  `revenue` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '年收入',
  `affectivestatus` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '情感状态',
  `lookingfor` VARCHAR(255) NOT NULL DEFAULT '' COMMENT ' 交友目的',
  `bloodtype` VARCHAR(5) NOT NULL DEFAULT '' COMMENT '血型',
  `height` VARCHAR(5) NOT NULL DEFAULT '' COMMENT '身高',
  `weight` VARCHAR(5) NOT NULL DEFAULT '' COMMENT '体重',
  `alipay` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '支付宝帐号',
  `msn` VARCHAR(30) NOT NULL DEFAULT '' COMMENT 'MSN',
  `taobao` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '阿里旺旺',
  `site` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '主页',
  `bio` text NOT NULL COMMENT '自我介绍',
  `interest` text NOT NULL COMMENT '兴趣爱好',
  PRIMARY KEY (`uid`),
  KEY `groupid` (`groupid`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9983 ;
 
--
-- 表的结构 `ims_modules`
--
 
CREATE TABLE IF NOT EXISTS `ims_modules` (
  `mid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) NOT NULL COMMENT '标识',
  `type` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '类型',
  `title` VARCHAR(100) NOT NULL COMMENT '名称',
  `version` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '版本',
  `ability` VARCHAR(500) NOT NULL COMMENT '功能描述',
  `description` VARCHAR(1000) NOT NULL COMMENT '介绍',
  `author` VARCHAR(50) NOT NULL COMMENT '作者',
  `url` VARCHAR(255) NOT NULL COMMENT '发布页面',
  `settings` tinyint(1) NOT NULL DEFAULT '0' COMMENT '扩展设置项',
  `subscribes` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '订阅的消息类型',
  `handles` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '能够直接处理的消息类型',
  `isrulefields` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否有规则嵌入项',
  `issystem` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否是系统模块',
  `issolution` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `target` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`mid`),
  KEY `idx_name` (`name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=399 ;
 
--
-- 表的结构 `ims_modules_bindings`
--
 
CREATE TABLE IF NOT EXISTS `ims_modules_bindings` (
  `eid` INT(11) NOT NULL AUTO_INCREMENT,
  `module` VARCHAR(30) NOT NULL DEFAULT '',
  `entry` VARCHAR(10) NOT NULL DEFAULT '',
  `call` VARCHAR(50) NOT NULL DEFAULT '',
  `title` VARCHAR(50) NOT NULL,
  `do` VARCHAR(30) NOT NULL,
  `state` VARCHAR(200) NOT NULL,
  `direct` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`eid`),
  KEY `idx_module` (`module`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2670 ;
 
--
-- 表的结构 `ims_music_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_music_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '规则ID',
  `title` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '标题',
  `description` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '介绍',
  `url` VARCHAR(300) NOT NULL DEFAULT '' COMMENT '音乐地址',
  `hqurl` VARCHAR(300) NOT NULL DEFAULT '' COMMENT '高清地址',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=167 ;
 
--
-- 表的结构 `ims_news_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_news_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL,
  `title` VARCHAR(50) NOT NULL,
  `author` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '作者',
  `description` VARCHAR(255) NOT NULL,
  `thumb` VARCHAR(255) NOT NULL COMMENT '封面图片',
  `content` text NOT NULL,
  `url` VARCHAR(255) NOT NULL,
  `displayorder` INT(10) NOT NULL,
  `incontent` tinyint(1) NOT NULL DEFAULT '0' COMMENT '封面是否显示在正文中',
  `createtime` INT(10) NOT NULL COMMENT '发布时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=763 ;
 
--
-- 表的结构 `ims_profile_fields`
--
 
CREATE TABLE IF NOT EXISTS `ims_profile_fields` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `field` VARCHAR(255) NOT NULL,
  `available` tinyint(1) NOT NULL DEFAULT '1',
  `title` VARCHAR(255) NOT NULL,
  `description` VARCHAR(255) NOT NULL,
  `displayorder` SMALLINT(6) NOT NULL DEFAULT '0',
  `required` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否必填',
  `unchangeable` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否不可修改',
  `showinregister` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示在注册表单',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=37 ;
 
--
-- 表的结构 `ims_qrcode`
--
 
CREATE TABLE IF NOT EXISTS `ims_qrcode` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `acid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `qrcid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '二维码场景ID',
  `name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '场景名称',
  `keyword` VARCHAR(100) NOT NULL COMMENT '关联关键字',
  `model` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '模式,1临时,2为永久',
  `ticket` VARCHAR(250) NOT NULL DEFAULT '' COMMENT '标识',
  `expire` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '过期时间',
  `subnum` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '关注扫描次数',
  `createtime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生成时间',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0为未启用,1为启用',
  PRIMARY KEY (`id`),
  KEY `idx_qrcid` (`qrcid`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=24 ;
 
--
-- 表的结构 `ims_qrcode_stat`
--
 
CREATE TABLE IF NOT EXISTS `ims_qrcode_stat` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `acid` INT(10) UNSIGNED NOT NULL,
  `qid` INT(10) UNSIGNED NOT NULL,
  `openid` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户的唯一身份ID',
  `type` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否发生在订阅时',
  `qrcid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '二维码场景ID',
  `name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '场景名称',
  `createtime` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生成时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
 
--
-- 表的结构 `ims_rule`
--
 
CREATE TABLE IF NOT EXISTS `ims_rule` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `name` VARCHAR(50) NOT NULL DEFAULT '',
  `module` VARCHAR(50) NOT NULL,
  `displayorder` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '规则排序',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '规则状态,0禁用,1启用,2置顶',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=432 ;
 
--
-- 表的结构 `ims_rule_keyword`
--
 
CREATE TABLE IF NOT EXISTS `ims_rule_keyword` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '规则ID',
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '所属帐号',
  `module` VARCHAR(50) NOT NULL COMMENT '对应模块',
  `content` VARCHAR(255) NOT NULL COMMENT '内容',
  `type` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '类型1匹配,2包含,3正则',
  `displayorder` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '规则排序,255为置顶,其它为普通排序',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '规则状态,0禁用,1启用',
  PRIMARY KEY (`id`),
  KEY `idx_content` (`content`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1832 ;
 
--
-- 表的结构 `ims_site_article`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_article` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '关联规则id',
  `kid` INT(10) UNSIGNED NOT NULL COMMENT '关联关键字id',
  `iscommend` tinyint(1) NOT NULL DEFAULT '0',
  `ishot` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  `pcate` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '一级分类',
  `ccate` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '二级分类',
  `template` VARCHAR(30) NOT NULL COMMENT '内容模板',
  `title` VARCHAR(100) NOT NULL DEFAULT '',
  `description` VARCHAR(100) NOT NULL DEFAULT '',
  `content` mediumtext NOT NULL,
  `thumb` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '缩略图',
  `source` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '来源',
  `author` VARCHAR(50) NOT NULL COMMENT '作者',
  `displayorder` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `linkurl` VARCHAR(500) NOT NULL DEFAULT '',
  `createtime` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `type` VARCHAR(10) NOT NULL DEFAULT '',
  `credit` VARCHAR(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `idx_iscommend` (`iscommend`),
  KEY `idx_ishot` (`ishot`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
 
--
-- 表的结构 `ims_site_category`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_category` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '所属帐号',
  `nid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '关联导航id',
  `name` VARCHAR(50) NOT NULL COMMENT '分类名称',
  `parentid` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '上级分类ID,0为第一级',
  `displayorder` tinyint(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序',
  `enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '是否开启',
  `icon` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '分类图标',
  `description` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '分类描述',
  `styleid` INT(10) UNSIGNED NOT NULL COMMENT '风格id',
  `templatefile` VARCHAR(100) NOT NULL DEFAULT '',
  `linkurl` VARCHAR(500) NOT NULL DEFAULT '',
  `ishomepage` tinyint(1) NOT NULL DEFAULT '0',
  `icontype` tinyint(1) UNSIGNED NOT NULL,
  `css` VARCHAR(500) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
 
--
-- 表的结构 `ims_site_multi`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_multi` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `title` VARCHAR(30) NOT NULL,
  `styleid` INT(10) UNSIGNED NOT NULL COMMENT '风格id',
  `site_info` text NOT NULL,
  `quickmenu` VARCHAR(2000) NOT NULL,
  `status` tinyint(3) UNSIGNED NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='多微站' AUTO_INCREMENT=183 ;
 
--
-- 表的结构 `ims_site_nav`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_nav` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `multiid` INT(10) UNSIGNED NOT NULL,
  `section` tinyint(4) NOT NULL DEFAULT '0',
  `module` VARCHAR(50) NOT NULL DEFAULT '',
  `displayorder` SMALLINT(5) UNSIGNED NOT NULL COMMENT '排序',
  `name` VARCHAR(50) NOT NULL COMMENT '导航名称',
  `description` VARCHAR(1000) NOT NULL DEFAULT '',
  `position` tinyint(4) NOT NULL DEFAULT '1' COMMENT '显示位置,1首页,2个人中心',
  `url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '链接地址',
  `icon` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '图标',
  `css` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '扩展CSS',
  `status` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '0为隐藏,1为显示',
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`),
  KEY `muiltiid` (`multiid`),
  KEY `multiid` (`multiid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=381 ;
 
--
-- 表的结构 `ims_site_slide`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_slide` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `multiid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `title` VARCHAR(255) NOT NULL,
  `url` VARCHAR(255) NOT NULL DEFAULT '',
  `thumb` VARCHAR(255) NOT NULL DEFAULT '',
  `displayorder` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `uniacid` (`uniacid`),
  KEY `multiid` (`multiid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;
 
--
-- 表的结构 `ims_site_styles`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_styles` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `templateid` INT(10) UNSIGNED NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=170 ;
 
--
-- 表的结构 `ims_site_styles_vars`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_styles_vars` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `templateid` INT(10) UNSIGNED NOT NULL COMMENT '风格ID',
  `styleid` INT(10) UNSIGNED NOT NULL,
  `variable` VARCHAR(50) NOT NULL COMMENT '模板预设变量',
  `content` text NOT NULL COMMENT '变量值',
  `description` VARCHAR(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
 
--
-- 表的结构 `ims_site_templates`
--
 
CREATE TABLE IF NOT EXISTS `ims_site_templates` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '标识',
  `version` VARCHAR(10) NOT NULL,
  `title` VARCHAR(30) NOT NULL COMMENT '名称',
  `description` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '描述',
  `author` VARCHAR(50) NOT NULL COMMENT '作者',
  `url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '发布页面',
  `type` VARCHAR(20) NOT NULL DEFAULT '',
  `sections` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=212 ;
 
--
-- 表的结构 `ims_stat_keyword`
--
 
CREATE TABLE IF NOT EXISTS `ims_stat_keyword` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '所属帐号ID',
  `rid` VARCHAR(10) NOT NULL COMMENT '规则ID',
  `kid` INT(10) UNSIGNED NOT NULL COMMENT '关键字ID',
  `hit` INT(10) UNSIGNED NOT NULL COMMENT '命中次数',
  `lastupdate` INT(10) UNSIGNED NOT NULL COMMENT '最后触发时间',
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_createtime` (`createtime`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1028 ;
 
--
-- 表的结构 `ims_stat_msg_history`
--
 
CREATE TABLE IF NOT EXISTS `ims_stat_msg_history` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '所属帐号ID',
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '命中规则ID',
  `kid` INT(10) UNSIGNED NOT NULL COMMENT '命中关键字ID',
  `from_user` VARCHAR(50) NOT NULL COMMENT '用户的唯一身份ID',
  `module` VARCHAR(50) NOT NULL COMMENT '命中模块',
  `message` VARCHAR(1000) NOT NULL COMMENT '用户发送的消息',
  `type` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '消息类型',
  `createtime` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_createtime` (`createtime`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4221 ;
 
--
-- 表的结构 `ims_stat_rule`
--
 
CREATE TABLE IF NOT EXISTS `ims_stat_rule` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL COMMENT '所属帐号ID',
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '规则ID',
  `hit` INT(10) UNSIGNED NOT NULL COMMENT '命中次数',
  `lastupdate` INT(10) UNSIGNED NOT NULL COMMENT '最后触发时间',
  `createtime` INT(10) UNSIGNED NOT NULL COMMENT '记录新建的日期',
  PRIMARY KEY (`id`),
  KEY `idx_createtime` (`createtime`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2572 ;
 
--
-- 表的结构 `ims_uni_account`
--
 
CREATE TABLE IF NOT EXISTS `ims_uni_account` (
  `uniacid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `groupid` INT(10) NOT NULL DEFAULT '0',
  `name` VARCHAR(100) NOT NULL,
  `description` VARCHAR(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`uniacid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=444 ;
 
--
-- 表的结构 `ims_uni_account_modules`
--
 
CREATE TABLE IF NOT EXISTS `ims_uni_account_modules` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `module` VARCHAR(50) NOT NULL DEFAULT '',
  `enabled` tinyint(1) UNSIGNED NOT NULL,
  `settings` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_module` (`module`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1674 ;
 
--
-- 表的结构 `ims_uni_account_users`
--
 
CREATE TABLE IF NOT EXISTS `ims_uni_account_users` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `role` VARCHAR(255) NOT NULL COMMENT 'manager管理员,operator操作者',
  PRIMARY KEY (`id`),
  KEY `idx_memberid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=442 ;
 
--
-- 表的结构 `ims_uni_group`
--
 
CREATE TABLE IF NOT EXISTS `ims_uni_group` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(50) NOT NULL,
  `modules` VARCHAR(5000) NOT NULL DEFAULT '',
  `templates` VARCHAR(5000) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
 
--
-- 表的结构 `ims_uni_settings`
--
 
CREATE TABLE IF NOT EXISTS `ims_uni_settings` (
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `passport` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '会员中心注册参数',
  `oauth` VARCHAR(100) NOT NULL DEFAULT '',
  `jsauth_acid` INT(10) UNSIGNED NOT NULL,
  `uc` VARCHAR(500) NOT NULL COMMENT 'ucenter 通信参数',
  `notify` VARCHAR(2000) NOT NULL DEFAULT '',
  `creditnames` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '积分别名',
  `creditbehaviors` VARCHAR(500) NOT NULL DEFAULT '' COMMENT '积分行为说明',
  `welcome` VARCHAR(60) NOT NULL DEFAULT '',
  `default` VARCHAR(60) NOT NULL DEFAULT '',
  `default_message` VARCHAR(1000) NOT NULL DEFAULT '',
  `shortcuts` VARCHAR(5000) NOT NULL DEFAULT '',
  `payment` VARCHAR(2000) NOT NULL DEFAULT '',
  `groupdata` VARCHAR(100) NOT NULL,
  `stat` VARCHAR(300) NOT NULL,
  `menuset` text NOT NULL,
  `default_site` INT(10) UNSIGNED DEFAULT '0',
  `sync` tinyint(3) UNSIGNED NOT NULL,
  PRIMARY KEY (`uniacid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
--
-- 表的结构 `ims_users`
--
 
CREATE TABLE IF NOT EXISTS `ims_users` (
  `uid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户编号',
  `groupid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `username` VARCHAR(30) NOT NULL COMMENT '用户名',
  `password` VARCHAR(200) NOT NULL COMMENT '用户密码',
  `salt` VARCHAR(10) NOT NULL COMMENT '加密盐',
  `status` tinyint(4) NOT NULL DEFAULT '0',
  `joindate` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `joinip` VARCHAR(15) NOT NULL DEFAULT '',
  `lastvisit` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `lastip` VARCHAR(15) NOT NULL DEFAULT '',
  `remark` VARCHAR(500) NOT NULL DEFAULT '',
  PRIMARY KEY (`uid`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='用户表' AUTO_INCREMENT=74 ;
 
--
-- 表的结构 `ims_users_group`
--
 
CREATE TABLE IF NOT EXISTS `ims_users_group` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(50) NOT NULL,
  `package` VARCHAR(5000) NOT NULL DEFAULT '',
  `maxaccount` INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `maxsubaccount` INT(10) UNSIGNED NOT NULL COMMENT '子公号最多添加数量,为0为不可以添加',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
 
--
-- 表的结构 `ims_users_permission`
--
 
CREATE TABLE IF NOT EXISTS `ims_users_permission` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uniacid` INT(10) UNSIGNED NOT NULL,
  `uid` INT(10) UNSIGNED NOT NULL,
  `url` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
 
--
-- 表的结构 `ims_users_profile`
--
 
CREATE TABLE IF NOT EXISTS `ims_users_profile` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `uid` INT(10) UNSIGNED NOT NULL,
  `createtime` INT(10) UNSIGNED NOT NULL COMMENT '加入时间',
  `realname` VARCHAR(10) NOT NULL DEFAULT '',
  `nickname` VARCHAR(20) NOT NULL DEFAULT '',
  `avatar` VARCHAR(100) NOT NULL DEFAULT '',
  `qq` VARCHAR(15) NOT NULL DEFAULT '',
  `mobile` VARCHAR(11) NOT NULL DEFAULT '',
  `fakeid` VARCHAR(30) NOT NULL,
  `vip` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
  `gender` tinyint(1) NOT NULL DEFAULT '0',
  `birthyear` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
  `birthmonth` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
  `birthday` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
  `constellation` VARCHAR(10) NOT NULL DEFAULT '',
  `zodiac` VARCHAR(5) NOT NULL DEFAULT '',
  `telephone` VARCHAR(15) NOT NULL DEFAULT '',
  `idcard` VARCHAR(30) NOT NULL DEFAULT '',
  `studentid` VARCHAR(50) NOT NULL DEFAULT '',
  `grade` VARCHAR(10) NOT NULL DEFAULT '',
  `address` VARCHAR(255) NOT NULL DEFAULT '',
  `zipcode` VARCHAR(10) NOT NULL DEFAULT '',
  `nationality` VARCHAR(30) NOT NULL DEFAULT '',
  `resideprovince` VARCHAR(30) NOT NULL DEFAULT '',
  `residecity` VARCHAR(30) NOT NULL DEFAULT '',
  `residedist` VARCHAR(30) NOT NULL DEFAULT '',
  `graduateschool` VARCHAR(50) NOT NULL DEFAULT '',
  `company` VARCHAR(50) NOT NULL DEFAULT '',
  `education` VARCHAR(10) NOT NULL DEFAULT '',
  `occupation` VARCHAR(30) NOT NULL DEFAULT '',
  `position` VARCHAR(30) NOT NULL DEFAULT '',
  `revenue` VARCHAR(10) NOT NULL DEFAULT '',
  `affectivestatus` VARCHAR(30) NOT NULL DEFAULT '',
  `lookingfor` VARCHAR(255) NOT NULL DEFAULT '',
  `bloodtype` VARCHAR(5) NOT NULL DEFAULT '',
  `height` VARCHAR(5) NOT NULL DEFAULT '',
  `weight` VARCHAR(5) NOT NULL DEFAULT '',
  `alipay` VARCHAR(30) NOT NULL DEFAULT '',
  `msn` VARCHAR(30) NOT NULL DEFAULT '',
  `email` VARCHAR(50) NOT NULL DEFAULT '',
  `taobao` VARCHAR(30) NOT NULL DEFAULT '',
  `site` VARCHAR(30) NOT NULL DEFAULT '',
  `bio` text NOT NULL COMMENT '自我介绍',
  `interest` text NOT NULL COMMENT '兴趣爱好',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;
 
--
-- 表的结构 `ims_video_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_video_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '规则ID',
  `title` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '标题',
  `description` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '介绍',
  `mediaid` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '视频id',
  `createtime` INT(10) NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=157 ;
 
--
-- 表的结构 `ims_voice_reply`
--
 
CREATE TABLE IF NOT EXISTS `ims_voice_reply` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `rid` INT(10) UNSIGNED NOT NULL COMMENT '规则ID',
  `title` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '标题',
  `mediaid` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '语音id',
  `createtime` INT(10) NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;

 

【PHP7】微信小程序用户信息encryptedData解密

微信小程序出来已久,也没时间学习,近期在尝试做一个小程序玩玩,获取用户信息的时候,微信会返回一些数据,包括明文(json格式)的用户基本信息,同时也有一个加密的字段encryptedData,这里面包括了用户基本信息之外还多了一个参数watermark,里面存放的是用户的openid和小程序的appid,但是要得到这些数据就需要后台进行解密,下面我就说一说解密的过程。
小程序encryptedData
官方给了一些示例,网上也有根据这些改进的加解密方法,但是在我(菜鸟)看来都不是很清楚明了。php7.1之后的版本mcrypt扩展已被废弃,但是小程序官方只给了该版本的示例,对于使用php7.1之后版本的服务器来说就要用别的方法加解密了,最好的方法就是使用openssl扩展,这也是php官方推荐的方案。

小提示:在使用微信的wx.request进行POST请求时,服务器用$_POST可能接收不到数据,我是使用get_file_contents('php://input')解决的,接收到的是一个json格式字符串,但是也可以使用别的方法,利用设置header(具体方法不再赘述)。

准备工作#

之前,我在文章中有讲到PHP的AES加解密的方法,今天就是结合该AES类进行操作:
方法①: PHP进行AES/ECB/PKCS7 padding加密的例子(mcrypt)
方法②:PHP进行AES/ECB/PKCS7 padding加密的例子(openssl)

文章中的加密方法对于ECB模式不需要做什么改变,但是微信小程序使用的加密方式是CBC,该方法和ECB的主要表面差别在于CBC需要设置iv向量,而ECB不需要。

示例代码#

Copy
# 将自己的参数进行替换
$str = file_get_contents('https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code');
# 将json字符串转为数组
$data = json_decode($str, true);
# 这里解密用到的key就是获得的session_key,然后对其进行base64_decode操作
$key = base64_decode($data['session_key']);
# iv是微信返回给你的向量,同样进行base64_decode操作
$iv = base64_decode($_GET['iv']);
# 调用aes类,注意解密方法是AES-128-CBC
$aes = Aes::instance($key, 'AES-128-CBC', $iv);
# 对数据进行解密,得到解密后的json字符串
$data = $aes->decrypt($encryptedData);

至此,本记录结束,有问题欢迎给我提出来哦!

作者:凭栏知潇雨

出处:https://www.cnblogs.com/lantor/p/7522314.html

版权:本站使用「CC BY 4.0」创作共享协议,转载请在文章明显位置注明作者及出处。

webuploader一个页面中多实例使用示例

在使用webuploader上传文件过程中,如果同一个页面存在多个上传区域,如一个页面中需要传营业执照和资质证书,营业执照资质证书都允许上传多张图片,可以参考本示例代码

本示例依赖webuploader相关js及css,基础应用不在本例代码,本例代码提供更优雅的复用示例,只是一个思路,大部分可直接复制使用,特殊需求可根据此代码修改

<script type="text/javascript" src="/js/webuploadertool.js"></script>

页面调用div

<div id="zhizhaoUploader">
	<ul class="_queueList">
		<li class="_picker"><img src="/img/upload.png" alt=""></li>
	</ul>
</div>
 
<div id="zizhiUploader">
	<ul class="_queueList">
		<li class="_picker"><img src="/img/upload.png" alt=""></li>
	</ul>
</div>

页面js

<script style="text/javascript">
    var zhizhao,zhizhiaouploader,zizhi,zhizhiuploader;
    jQuery(function () {
        //执照上传成功后的回调操作,此处是将服务器返回的地址以"|"连接
        var zhizhaosucess = function (file, response) {
            console.log(response._raw);
            zhizhaoPath = zhizhaoPath + response._raw + "|";
            console.log(zhizhaoPath);
        };
        //执照上传失败时的操作,此处直接弹框提示
        var zhizhaoerror = function (message) {
            console.log("文件上传失败,message:" + message);
            alertx(message,true);
        };
        zhizhao = new $WebUpload($("#zhizhaoUploader"), '/imageUpload');
        zhizhao.custsuccess = zhizhaosucess;
        zhizhao.custerror = zhizhaoerror;
        zhizhiaouploader = zhizhao.init();
 
        var zizhisucess = function (file, response) {
            console.log(response._raw);
            zizhiPath = zizhiPath + response._raw + "|";
            console.log(zizhiPath);
        };
        var zizhierror = function (message) {
            console.log("文件上传失败,message:" + message);
            alertx(message,true);
        };
        zizhi = new $WebUpload($("#zizhiUploader"), '/imageUpload');
        zizhi.custsuccess = zizhisucess;
        zizhi.custerror = zizhierror;
        zizhiuploader = zizhi.init();
    });
    var zhizhaoPath = "";
    var zizhiPath = "";
    //提交操作
    function step3() {
        var mobile = ${mobile};
        var zhizhaoprogressNum = zhizhiaouploader.getStats().progressNum;
        var zizhiprogressNum = zizhiuploader.getStats().progressNum;
        console.log("zhizhaoprogressNum:"+zhizhaoprogressNum+",zizhiprogressNum:"+zizhiprogressNum)
        if(zhizhaoprogressNum>0||zizhiprogressNum>0){
            alert("文件正在上传中,请等待文件上传完成!");
            return false;
        }
        if(zhizhaoPath.length<1||zizhiPath.length<1){
            alert("营业执照和资质文件必填!");
            return false;
        }
        $.ajax({
            url: "/xxx",
            type: 'POST',
            data: {
                "mobile": mobile,
                "zhizhaoPath": zhizhaoPath,
                "zizhiPath": zizhiPath,
            },
            success: function (data) {
                if (data.code == '100') {
                    alert("注册成功,请等待审核!");
                    top.window.location = "login.html";
                } else {
                    alert(data.message);
                }
            },
            error: function () {
                alert("数据异常");
            }
        })
    }
</script>

webuploadertool.js

(function () {
    var $WebUpload = function (_uploader, url) {
        this._uploader = _uploader;
        this.serverurl = url;
        this.imageExtensions = 'gif,jpg,jpeg,bmp,png';
        this.mimeTypes ='image/gif,image/jpg,image/jpeg,image/bmp,image/png';
        // 缩略图大小
        this.ratio = window.devicePixelRatio || 1,
            this.thumbnailWidth = 160 * this.ratio;
        this.thumbnailHeight = 120 * this.ratio;
        this.fileSizeLimit = 10 * 1024 * 1024;
        this.fileNumLimit = 5;
        this.fileSingleSizeLimit = 10 * 1024 * 1024;
        this.swfurl = BASE_URL + '/js/Uploader.swf';
        this.custsuccess = null;
        this.custerror = null;
        this.fileCount = 0;
        this.WebUploader;
    };
    $WebUpload.prototype = {
        /**
         * 初始化webUploader
         */
        init: function () {
            var uploader = this.create();
            this.bindEvent(uploader);
            return uploader;
        },
 
        /**
         * 创建webuploader对象
         */
        create: function () {
            var webUploader = WebUploader.create({
                pick: $('._picker', $(this._uploader))[0],
                //dnd: $('._queueList', $(this._uploader))[0],
                // 这里如果要一个页面多个实例,有bug
                // https://github.com/fex-team/webuploader/issues/81#issuecomment-228499631
                accept: {
                    title: 'Images',
                    extensions: this.imageExtensions,
                    mimeTypes: this.mimeTypes
                },
                // swf文件路径
                swf: this.swfurl,
                disableGlobalDnd: true,
                duplicate: false,//不允许上传同一个文件
                auto: true,//自动上传
                server: this.serverurl,
                fileNumLimit: this.fileNumLimit,
                fileSingleSizeLimit: this.fileSingleSizeLimit * 1024 * 1024    // 3 M
            });
            return webUploader;
        },
 
        /**
         * 绑定事件
         */
        bindEvent: function (bindedObj) {
            var me = this;
            bindedObj.on('fileQueued', function (file) {
                var $li = $('<li id="' + $(me._uploader).attr("id") + "_" + file.id + '" class="file-item thumbnail">' +
                        '<img id="thumb_' + $(me._uploader).attr("id") + "_" + file.id + '" src="http://img2.bdstatic.com/static/searchresult/img/loading_circle_40b82ef.gif">' +
                        //'<div class="info" style="width: 200px;height: 185px;"><span class="mk" style=" color:#999;border-bottom:none;display: block;width: 200px;height: 30px;">' + file.name + '</span></div>' +
                        '</li>'
                    ),
                    $img = $li.find('img');
                // $list为容器jQuery实例
                $($('._queueList', $(me._uploader))[0]).append($li);
                // 创建缩略图
                // 如果为非图片文件,可以不用调用此方法。
                // thumbnailWidth x thumbnailHeight 为 100 x 100
                // bindedObj.makeThumb(file, function (error, src) {
                //     if (error) {
                //         $img.replaceWith('<span>不能预览</span>');
                //         return;
                //     }
                //     $img.attr('src', src);
                // }, me.thumbnailWidth, me.thumbnailHeight);
                me.fileCount++;
                if (me.fileNumLimit == me.fileCount) {
                    $($('._picker', $(me._uploader))[0]).css("display", "none");
                }
            });
            // 文件上传过程中创建进度条实时显示。
            bindedObj.on('uploadProgress', function (file, percentage) {
                var $li = $('#' + $(me._uploader).attr("id") + "_" + file.id),
                    $percent = $li.find('.progress span');
 
                // 避免重复创建
                if (!$percent.length) {
                    $percent = $('<p class="progress"><span></span></p>')
                        .appendTo($li)
                        .find('span');
                }
 
                $percent.css('width', percentage * 100 + '%');
            });
            // 文件上传成功,给item添加成功class, 用样式标记上传成功。
            bindedObj.on('uploadSuccess', function (file, response) {
                $('#' + $(me._uploader).attr("id") + "_" + file.id).addClass('upload-state-done');
                bindedObj.makeThumb(file, function (error, src) {
                    $img = $('#thumb_' + $(me._uploader).attr("id") + "_" + file.id);
                    if (error) {
                        $img.replaceWith('<span>不能预览</span>');
                        return;
                    }
                    $img.attr('src', src);
                }, me.thumbnailWidth, me.thumbnailHeight);
 
                if ('function' == typeof me.custsuccess) {
                    me.custsuccess(file, response);
                }
            });
 
            // 文件上传失败,显示上传出错。
            bindedObj.on('uploadError', function (file, reason) {
                var $li = $('#' + $(me._uploader).attr("id") + "_" + file.id),
                    $error = $li.find('div.error');
 
                // 避免重复创建
                if (!$error.length) {
                    $error = $('<div class="error"></div>').appendTo($li);
                }
 
                $error.text('上传失败,' + reason);
            });
 
            // 其他错误
            bindedObj.on('error', function (type) {
                console.log("webuploadertool error type:" + type);
                var message = "";
                if ("Q_EXCEED_NUM_LIMIT" == type) {
                    message = "最多只允许上传" + me.fileNumLimit + "张图片";
                } else if ("F_EXCEED_SIZE" == type) {
                    message = "单张只允许上传" + me.fileSingleSizeLimit + "M以内的图片";
                } else if ("Q_TYPE_DENIED" == type) {
                    message = "只允许上传类型为" + me.imageExtensions + "的图片";
                }
                if ('function' == typeof me.custerror) {
                    me.custerror(message);
                }
            });
 
            // 完成上传完了,成功或者失败
            bindedObj.on('uploadComplete', function (file) {
                $('#' + $(me._uploader).attr("id") + "_" + file.id).find('.progress').remove();
            });
        }
    };
    window.$WebUpload = $WebUpload;
}());