app_update.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /**
  3. * 更新
  4. */
  5. defined('InShopNC') or exit('Access Invalid!');
  6. require_once(BASE_ROOT_PATH . '/helper/area/area_upgrade.php');
  7. require_once(BASE_ROOT_PATH . '/helper/area/area_check.php');
  8. class app_updateControl extends mobileHomeControl
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. public function check_versionOp()
  15. {
  16. $ver_code = $_GET['ver_code'];
  17. if($_SESSION['client_type'] == 'ios')
  18. {
  19. $cur_ver = $GLOBALS['setting_config']['mobile_ios_version'];
  20. $cur_ver = intval($cur_ver * 100 + 0.5);
  21. $ver_code = intval($ver_code * 100 + 0.5);
  22. if($ver_code < $cur_ver) {
  23. $url = $GLOBALS['setting_config']['mobile_ios'];
  24. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  25. return self::outsuccess(array("open_url" => $url,'tip' => $tips));
  26. } else {
  27. return self::outsuccess(null);
  28. }
  29. }
  30. elseif($_SESSION['client_type'] == 'android')
  31. {
  32. $cur_ver = $GLOBALS['setting_config']['mobile_apk_version'];
  33. $cur_ver = intval($cur_ver * 100 + 0.5);
  34. $ver_code = intval($ver_code * 100 + 0.5);
  35. if($ver_code < $cur_ver) {
  36. $url = $GLOBALS['setting_config']['mobile_apk'];
  37. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  38. return self::outsuccess(array("open_url" => $url,'tip' => $tips,'force' => false));
  39. } else {
  40. return self::outsuccess(null);
  41. }
  42. }
  43. else {
  44. return self::outerr(errcode::ErrApptype);
  45. }
  46. }
  47. public function areaOp()
  48. {
  49. global $config;
  50. $ver_code = intval($_GET['version']);
  51. if($ver_code < $config['area_version'])
  52. {
  53. static $data = null;
  54. if($data == null)
  55. {
  56. $items = rcache('area', 'mb_');
  57. if(empty($items)) {
  58. $area = new area\area_check();
  59. $data = $area->export();
  60. wcache('area', array('data' => serialize($data)), 'mb_');
  61. } else {
  62. $data = unserialize($items['data']);
  63. }
  64. }
  65. return self::outsuccess(array('version' => $config['area_version'],'areas' => $data));
  66. }
  67. else {
  68. return self::outsuccess(null);
  69. }
  70. }
  71. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  72. public function check_verOp()
  73. {
  74. $ver_code = $_GET['ver_code'];
  75. if($_SESSION['client_type'] == 'ios')
  76. {
  77. $cur_ver = $GLOBALS['setting_config']['mobile_ios_version'];
  78. $cur_ver = intval($cur_ver * 100 + 0.5);
  79. $ver_code = intval($ver_code * 100 + 0.5);
  80. if($ver_code < $cur_ver) {
  81. $url = $GLOBALS['setting_config']['mobile_ios'];
  82. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  83. return self::outsuccess(array("open_url" => $url,'tip' => $tips));
  84. } else {
  85. return self::outsuccess(null);
  86. }
  87. }
  88. elseif($_SESSION['client_type'] == 'android') {
  89. return $this->checkVersionOp();
  90. }
  91. else {
  92. return self::outerr(errcode::ErrApptype);
  93. }
  94. }
  95. public function checkVersionOp()
  96. {
  97. $ver_code = $_GET['ver_code'];
  98. if($this->android() == false || !isset($ver_code) || empty($ver_code) || intval($ver_code) <= 0) {
  99. return self::outerr(errcode::ErrParamter,"需要带入手机及版本信息");
  100. }
  101. $verinfo = rkcache('android_version',true);
  102. $result = array();
  103. if ($ver_code == $verinfo['ver_code']) {
  104. $result['latest'] = 0; //设计协议设计反了,0 表示目前是最新版本,1 表示不是最新版本
  105. }
  106. else
  107. {
  108. $result['latest'] = 1;
  109. $lowest_compatible_version = intval($verinfo['lowest_compatible_version']);
  110. if ($lowest_compatible_version > intval($ver_code)) {
  111. $result['force_update'] = 1;
  112. } else {
  113. $result['force_update'] = 0;
  114. }
  115. $update_info = array();
  116. $update_info['ver_code'] = $verinfo['ver_code'];
  117. $update_info['app_path'] = $verinfo['app_path'];
  118. $update_info['release_note'] = $verinfo['release_note'];
  119. $update_info['remind_time'] = $verinfo['remind_time'];
  120. $update_info['md5_file'] = $verinfo['md5_file'];
  121. $update_info['app_path'] = BASE_SITE_URL . $verinfo['app_path'];
  122. $result['update_info'] = $update_info;
  123. }
  124. self::outsuccess($result);
  125. }
  126. }