version_upgrade 版本升级信息表
CREATE TABLE `version_upgrade` (
`id` smallint(4) unsigned NOT NULL AUTO_INCREMENT,
`app_id` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '客户端设备id 1安卓pad 2安卓手机 3ios手机 4iospad',
`version_id` smallint(4) unsigned DEFAULT '0' COMMENT '大版本号id',
`version_mini` mediumint(8) unsigned DEFAULT '0' COMMENT '小版本号',
`version_code` varchar(10) DEFAULT NULL COMMENT '版本标识 1.2',
`type` tinyint(2) unsigned DEFAULT NULL COMMENT '是否升级 1升级,0不升级,2强制升级',
`apk_url` varchar(255) DEFAULT NULL,
`upgrade_point` varchar(255) DEFAULT NULL COMMENT '升级提示',
`status` tinyint(2) DEFAULT NULL,
`create_time` int(11) DEFAULT NULL,
`update_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
app表 客户端表
CREATE TABLE `app` (
`id` smallint(4) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`name` varchar(10) DEFAULT NULL COMMENT 'APP类型名称 如 : 安卓手机',
`is_encryption` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否加密 1加密 0不加密',
`key` varchar(20) NOT NULL DEFAULT '0' COMMENT '加密key',
`image_size` text COMMENT '按json_encode存储',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`update_time` int(11) NOT NULL COMMENT '更新时间',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 1正常 0删除',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
init.php
<?php
var_dump($_SERVER);
?>
数据库数据
test.html
<html>
<form action="http://127.0.0.1/testapp/init.php" method="post">
设备号:<input type="text" value="" name="did"/><br/>
版本号:<input type="text" value="" name="version_id"/><br/>
小版本号:<input type="text" value="" name="version_mini"/><br/>
APP类型:<input type="text" value="" name="app_id"/><br/>
encrypt_did:<input type="text" value="c39f07bf54425745d642498395ce144c" name="encrypt_did"/><br/>
<input type="submit" value="提交"/>
</form>
</html>
common.php
<?php
/*
* 处理接口公共业务
*/
require_once 'response.php';
require_once 'Db.php';
class Common
{
public $params;
public $app;
public function check()
{
$this->params['app_id'] = $appId = isset($_POST['app_id']) ? $_POST['app_id'] : '';
$this->params['version_id'] = $versionId = isset($_POST['version_id']) ? $_POST['version_id'] : '';
$this->params['version_mini'] = $versionMini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
$this->params['did'] = $dId = isset($_POST['did']) ? $_POST['did'] : '';
$this->params['encrypt_did'] = $encryptDid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
if (!is_numeric($appId) || !is_numeric($versionId)) {
return Response::show(401, '参数不合法');
}
//判定app是否需要加密
$this->app = $this->getApp($appId);
if (!$this->app) {
return Response::show(402, 'app_id不存在');
}
if ($this->app['is_encryption'] && $encryptDid != md5($dId . $this->app['key'])) {
return Response::show(402, '没有权限');
}
}
public function getApp($id)
{
$sql = "select * from app where id = " . $id . " and status = 1 limit 1";
$connect = Db::getInstance()->connect();
$result = mysql_query($sql, $connect);
return mysql_fetch_assoc($result);
}
}
init.php
<?php
require_once 'common.php';
class Init extends Common
{
public function index(){
$this->check();
}
}
$init=new Init();
$init->index();
?>
encrypt_did-------c39f07bf54425745d642498395ce144c