app_update.php 5.3 KB

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