|
@@ -7,71 +7,49 @@ defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
class app_updateControl extends mobileHomeControl
|
|
|
{
|
|
|
- const CACHE_KEY = "app_update";
|
|
|
- const CACHE_CHECK_VERSION_ID = 6;
|
|
|
-
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 版本验证
|
|
|
- *
|
|
|
- * 输入参数:
|
|
|
- * ver_code:版本号
|
|
|
- * platform: 平台
|
|
|
- */
|
|
|
+ public function check_verOp()
|
|
|
+ {
|
|
|
+ return $this->checkVersionOp();
|
|
|
+ }
|
|
|
+
|
|
|
public function checkVersionOp()
|
|
|
{
|
|
|
$ver_code = $_GET['ver_code'];
|
|
|
- $app_platform = $_GET['platform'];
|
|
|
+ if($this->android() == false || !isset($ver_code) || empty($ver_code) || intval($ver_code) <= 0) {
|
|
|
+ return self::outerr(errcode::ErrParamter,"需要带入手机及版本信息");
|
|
|
+ }
|
|
|
|
|
|
- if (isset($app_platform) && isset($ver_code))
|
|
|
+ $verinfo = rkcache('android_version',true);
|
|
|
+ $result = array();
|
|
|
+ if ($ver_code === $verinfo['ver_code']) {
|
|
|
+ $result['latest'] = 0; //设计协议设计反了,0 表示目前是最新版本,1 表示不是最新版本
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- $ret = rcache(self::CACHE_KEY, self::CACHE_CHECK_VERSION_ID);
|
|
|
- if (empty($ret)) {
|
|
|
- $model = Model();
|
|
|
- $data = $model->table('app_update')->where(array('cur_version' => '1', 'enable' => '1', 'platform' => $app_platform))->limit(1)->select();
|
|
|
- if (empty($data)) {
|
|
|
- return joutput_error(errcode::ErrDB);
|
|
|
- }
|
|
|
- wcache(self::CACHE_KEY, array("cur_version" => serialize($data)), self::CACHE_CHECK_VERSION_ID);
|
|
|
+ $result['latest'] = 1;
|
|
|
+ $lowest_compatible_version = intval($verinfo['lowest_compatible_version']);
|
|
|
+ if ($lowest_compatible_version > intval($ver_code)) {
|
|
|
+ $result['force_update'] = 1;
|
|
|
} else {
|
|
|
- $data = unserialize($ret['cur_version']);
|
|
|
+ $result['force_update'] = 0;
|
|
|
}
|
|
|
|
|
|
- $result = array();
|
|
|
- $lowest_compatible_version = intval($data[0]['lowest_compatible_version']);
|
|
|
- if ($ver_code === $data[0]['ver_code']) {
|
|
|
- $result['latest'] = 0;
|
|
|
- } else {
|
|
|
- $result['latest'] = 1;
|
|
|
- if ($lowest_compatible_version > intval($ver_code)) {
|
|
|
- $result['force_update'] = 1;
|
|
|
- } else {
|
|
|
- $result['force_update'] = 0;
|
|
|
- }
|
|
|
-
|
|
|
- $update_info = array();
|
|
|
- $update_info['ver_code'] = $data[0]['ver_code'];
|
|
|
- $update_info['app_path'] = $data[0]['app_path'];
|
|
|
- $update_info['release_note'] = $data[0]['release_note'];
|
|
|
- $update_info['remind_time'] = $data[0]['remind_time'];
|
|
|
-
|
|
|
- $parse_url = parse_url($update_info['app_path']);
|
|
|
- $file_path = BASE_ROOT_PATH . $parse_url['path'];
|
|
|
- if(file_exists($file_path)) {
|
|
|
- $update_info['md5_file'] = md5_file($file_path);
|
|
|
- } else {
|
|
|
- $update_info['md5_file'] = '';
|
|
|
- }
|
|
|
+ $update_info = array();
|
|
|
+ $update_info['ver_code'] = $verinfo['ver_code'];
|
|
|
+ $update_info['app_path'] = $verinfo['app_path'];
|
|
|
+ $update_info['release_note'] = $verinfo['release_note'];
|
|
|
+ $update_info['remind_time'] = $verinfo['remind_time'];
|
|
|
+ $update_info['md5_file'] = $verinfo['md5_file'];
|
|
|
+ $update_info['app_path'] = BASE_SITE_URL . $verinfo['app_path'];
|
|
|
|
|
|
- $result['update_info'] = $update_info;
|
|
|
- }
|
|
|
- joutput_data($result);
|
|
|
- } else {
|
|
|
- output_error('请输入平台和版本号!');
|
|
|
+ $result['update_info'] = $update_info;
|
|
|
}
|
|
|
+
|
|
|
+ self::outsuccess($result);
|
|
|
}
|
|
|
}
|