app_update.php 4.0 KB

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