app_update.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. $artips = explode('#',$tips);
  26. $tips = implode("\n",$artips);
  27. return self::outsuccess(array("open_url" => $url,'tip' => $tips));
  28. } else {
  29. return self::outsuccess(null);
  30. }
  31. }
  32. elseif($_SESSION['client_type'] == 'android')
  33. {
  34. $cur_ver = $GLOBALS['setting_config']['mobile_apk_version'];
  35. $cur_ver = intval($cur_ver * 100 + 0.5);
  36. $ver_code = intval($ver_code * 100 + 0.5);
  37. if($ver_code < $cur_ver) {
  38. $url = $GLOBALS['setting_config']['mobile_apk'];
  39. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  40. $artips = explode('#',$tips);
  41. $tips = implode("\n",$artips);
  42. return self::outsuccess(array("open_url" => $url,'tip' => $tips,'force' => false));
  43. } else {
  44. return self::outsuccess(null);
  45. }
  46. }
  47. else {
  48. return self::outerr(errcode::ErrApptype);
  49. }
  50. }
  51. public function areaOp()
  52. {
  53. global $config;
  54. $ver_code = intval($_GET['version']);
  55. if($ver_code < $config['area_version'])
  56. {
  57. static $data = null;
  58. if($data == null)
  59. {
  60. $items = rcache('area', 'mb_');
  61. if(empty($items)) {
  62. $area = new area\area_check();
  63. $data = $area->export();
  64. wcache('area', array('data' => serialize($data)), 'mb_');
  65. } else {
  66. $data = unserialize($items['data']);
  67. }
  68. }
  69. return self::outsuccess(array('version' => $config['area_version'],'areas' => $data));
  70. }
  71. else {
  72. return self::outsuccess(null);
  73. }
  74. }
  75. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. public function check_verOp()
  77. {
  78. $ver_code = $_GET['ver_code'];
  79. if($_SESSION['client_type'] == 'ios')
  80. {
  81. $cur_ver = $GLOBALS['setting_config']['mobile_ios_version'];
  82. $cur_ver = intval($cur_ver * 100 + 0.5);
  83. $ver_code = intval($ver_code * 100 + 0.5);
  84. if($ver_code < $cur_ver) {
  85. $url = $GLOBALS['setting_config']['mobile_ios'];
  86. $tips = $GLOBALS['setting_config']['mobile_update_tips'];
  87. return self::outsuccess(array("open_url" => $url,'tip' => $tips));
  88. } else {
  89. return self::outsuccess(null);
  90. }
  91. }
  92. elseif($_SESSION['client_type'] == 'android') {
  93. return $this->checkVersionOp();
  94. }
  95. else {
  96. return self::outerr(errcode::ErrApptype);
  97. }
  98. }
  99. public function checkVersionOp()
  100. {
  101. $ver_code = $_GET['ver_code'];
  102. if($this->android() == false || !isset($ver_code) || empty($ver_code) || intval($ver_code) <= 0) {
  103. return self::outerr(errcode::ErrParamter,"需要带入手机及版本信息");
  104. }
  105. $verinfo = rkcache('android_version',true);
  106. $result = array();
  107. if ($ver_code == $verinfo['ver_code']) {
  108. $result['latest'] = 0; //设计协议设计反了,0 表示目前是最新版本,1 表示不是最新版本
  109. }
  110. else
  111. {
  112. $result['latest'] = 1;
  113. $lowest_compatible_version = intval($verinfo['lowest_compatible_version']);
  114. if ($lowest_compatible_version > intval($ver_code)) {
  115. $result['force_update'] = 1;
  116. } else {
  117. $result['force_update'] = 0;
  118. }
  119. $update_info = array();
  120. $update_info['ver_code'] = $verinfo['ver_code'];
  121. $update_info['app_path'] = $verinfo['app_path'];
  122. $update_info['release_note'] = $verinfo['release_note'];
  123. $update_info['remind_time'] = $verinfo['remind_time'];
  124. $update_info['md5_file'] = $verinfo['md5_file'];
  125. $update_info['app_path'] = BASE_SITE_URL . $verinfo['app_path'];
  126. $result['update_info'] = $update_info;
  127. }
  128. self::outsuccess($result);
  129. }
  130. }