Created
July 10, 2017 08:57
-
-
Save why168/68f55cd0420e6ab0eefa5be2eca5b0ad to your computer and use it in GitHub Desktop.
处理接口公共业务
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 处理接口公共业务 | |
* Created by PhpStorm. | |
* User: edwin | |
* Date: 2017/7/2 | |
* Time: 16:50 | |
*/ | |
require_once("./Response.php"); | |
class Common | |
{ | |
public $params; | |
public $app; | |
/** | |
* @return string | |
*/ | |
public function check() | |
{ | |
$this->params['app_id'] = $appId = isset($_POST['app_id']) ? $_POST['app_id'] : ''; | |
$this->params['app_version'] = $appVersion = isset($_POST['app_version']) ? $_POST['app_version'] : ''; | |
$this->params['app_did'] = $appDid = isset($_POST['app_did']) ? $_POST['app_did'] : ''; | |
$this->params['app_version_mini'] = $appVersionMini = isset($_POST['app_version_mini']) ? $_POST['app_version_mini'] : ''; | |
$this->params['app_encrypt_did'] = $appEncryptDid = isset($_POST['app_encrypt_did']) ? $_POST['app_encrypt_did'] : ''; | |
if (!is_numeric($appId) || !is_numeric($appVersion)) { | |
return Response::show(401, "参数不合法"); | |
} | |
//TODO 判断APP是否需要加密 | |
$this->app = $this->getApp($appId); | |
if (!$this->app) { | |
return Response::show(402, "appId不存在"); | |
} | |
//TODO MD5校验 | |
if (!$this->params['app_encrypt_did'] && $appEncryptDid != md5($appDid)) { | |
return Response::show(403, '没有该权限'); | |
} | |
} | |
public function getApp($appId) | |
{ | |
$sql = "SELECT * | |
FROM app | |
WHERE status = 1 | |
LIMIT 1"; | |
if ($appId == 5) { | |
return "AA"; | |
} else { | |
return ''; | |
} | |
} | |
public function getVersionUpgrade($appId) | |
{ | |
return '数据库返回 appId = ' . $appId . ' 的版本信息'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment