Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
version_upgrade 版本升級(jí)信息表
CREATE TABLE `version_upgrade` (
`id` smallint(4) unsigned NOT NULL AUTO_INCREMENT,
`app_id` smallint(4) unsigned NOT NULL DEFAULT '0' COMMENT '客戶端設(shè)備id 1安卓pad 2安卓手機(jī) 3ios手機(jī) 4iospad',
`version_id` smallint(4) unsigned DEFAULT '0' COMMENT '大版本號(hào)id',
`version_mini` mediumint(8) unsigned DEFAULT '0' COMMENT '小版本號(hào)',
`version_code` varchar(10) DEFAULT NULL COMMENT '版本標(biāo)識(shí) 1.2',
`type` tinyint(2) unsigned DEFAULT NULL COMMENT '是否升級(jí) 1升級(jí)吧黄,0不升級(jí),2強(qiáng)制升級(jí)',
`apk_url` varchar(255) DEFAULT NULL,
`upgrade_point` varchar(255) DEFAULT NULL COMMENT '升級(jí)提示',
`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類型名稱 如 : 安卓手機(jī)',
`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存儲(chǔ)',
`create_time` int(11) NOT NULL COMMENT '創(chuàng)建時(shí)間',
`update_time` int(11) NOT NULL COMMENT '更新時(shí)間',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '狀態(tài) 1正常 0刪除',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
Paste_Image.png
init.php
<?php
var_dump($_SERVER);
?>
Paste_Image.png
數(shù)據(jù)庫(kù)數(shù)據(jù)
Paste_Image.png
test.html
<html>
<form action="http://127.0.0.1/testapp/init.php" method="post">
設(shè)備號(hào):<input type="text" value="" name="did"/><br/>
版本號(hào):<input type="text" value="" name="version_id"/><br/>
小版本號(hào):<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
/*
* 處理接口公共業(yè)務(wù)
*/
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, '參數(shù)不合法');
}
//判定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, '沒(méi)有權(quán)限');
}
}
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();
?>
Paste_Image.png
encrypt_did-------c39f07bf54425745d642498395ce144c