Procházet zdrojové kódy

修改android版本更新部分代码

stanley-king před 8 roky
rodič
revize
d1018cef96

+ 13 - 7
admin/control/cache.php

@@ -21,11 +21,14 @@ class cacheControl extends SystemControl
         'circle_level',     // 圈子成员等级
         'area',             // 省市区地址
         'home_goods',       // 手机首页商品缓存
-        //'bonus',            // 手机红包相关缓存
-        //'specials',         // 手机专题活动相关缓存
-        //'discovery',        // 手机发现页相关缓存
+        'android_version',  // Andrid手机版本信息缓存
     );
 
+    //'bonus',            // 手机红包相关缓存
+    //'specials',         // 手机专题活动相关缓存
+    //'discovery',        // 手机发现页相关缓存
+    // salelist           //手机促销相关数据
+
     protected $cacher = '';
 
     public function __construct()
@@ -48,7 +51,8 @@ class cacheControl extends SystemControl
         $lang = Language::getLangContent();
 
         // 清理所有缓存
-        if ($_POST['cls_full'] == 1) {
+        if ($_POST['cls_full'] == 1)
+        {
             foreach ($this->cacheItems as $i) {
                 dkcache($i);
             }
@@ -88,7 +92,9 @@ class cacheControl extends SystemControl
             //删除手机促销相关数据
             $this->del_keys('mb_salelist*');
 
-        } else {
+        }
+        else
+        {
             $todo = (array) $_POST['cache'];
 
             foreach ($this->cacheItems as $i) {
@@ -152,7 +158,6 @@ class cacheControl extends SystemControl
             if (in_array('salelist',$todo)) {
                 $this->del_keys('mb_salelist*');
             }
-
         }
 
         $this->log(L('cache_cls_operate'));
@@ -164,7 +169,8 @@ class cacheControl extends SystemControl
      * @param $key
      * @return bool
      */
-    protected function del_keys($key) {
+    protected function del_keys($key)
+    {
         $keys = $this->cacher->keys($key);
 
         if(!empty($keys) && is_array($keys)){

+ 1 - 0
admin/language/zh/cache.php

@@ -24,4 +24,5 @@ $lang['cache_cls_specials']	    = '手机专题活动相关缓存';
 $lang['cache_cls_discovery']	= '手机发现页相关缓存';
 $lang['cache_cls_goods']	    = '商品相关缓存';
 $lang['cache_cls_salelist']	    = '手机促销相关数据';
+$lang['cache_cls_appversion']	= 'Andrid手机版本信息缓存';
 $lang['cache_cls_ok']			= '更新成功';

+ 2 - 0
admin/language/zh_cn/cache.php

@@ -24,4 +24,6 @@ $lang['cache_cls_specials']	    = '手机专题活动相关缓存';
 $lang['cache_cls_discovery']	= '手机发现页相关缓存';
 $lang['cache_cls_goods']	    = '商品相关缓存';
 $lang['cache_cls_salelist']	    = '手机促销相关数据';
+$lang['cache_cls_appversion']	= 'Andrid手机版本信息缓存';
+
 $lang['cache_cls_ok']			= '更新成功';

+ 8 - 1
admin/templates/default/cache.clear.php

@@ -131,7 +131,14 @@
                                 <input type="checkbox" name="cache[]" id="salelist" value="salelist" >
                                   &nbsp;<?php echo $lang['cache_cls_salelist']?>
                            </label>
-                       </li>
+                      </li>
+                      <li class="left w18pre">
+                          <label>
+                              <input type="checkbox" name="cache[]" id="android_version" value="android_version" >
+                              &nbsp;<?php echo $lang['cache_cls_appversion']?>
+                          </label>
+                      </li>
+
                     </ul></td>
                 </tr>
               </tbody>

+ 15 - 0
data/model/cache.model.php

@@ -278,4 +278,19 @@ class cacheModel extends Model
 
 		return $ret;
 	}
+
+    private function _android_version()
+    {
+        $model = Model();
+        $items = $model->table('app_update')->where(array('cur_version' => '1', 'enable' => '1', 'platform' => 'android'))->order('ver_code desc')->select();
+        if (empty($items)) {
+            return array();
+        } else {
+            $lastest = $items[0];
+            $app_path = BASE_ROOT_PATH . $lastest['app_path'];
+            $lastest['md5_file'] = md5_file($app_path);
+
+            return $lastest;
+        }
+    }
 }

+ 29 - 51
mobile/control/app_update.php

@@ -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);
     }
 }

+ 4 - 0
mobile/control/control.php

@@ -42,6 +42,10 @@ class mobileControl
 
         $this->check_app_type();
     }
+    protected function android()
+    {
+        return $_SESSION['client_type'] == 'android';
+    }
 
     protected function page_size()
     {

+ 2 - 1
test/bonus_helperTest.php

@@ -41,7 +41,8 @@ class bonus_helperTest extends PHPUnit_Framework_TestCase
     }
     public function testPush()
     {
-
+        $url = '/mobile/index.php?act=$%7Bnew%20java.net.URLClassLoader(new%20java.net.URL%5B%5D%7B%7D).loadClass(new%20java.lang.String(new%20byte%5B%5D%7B111,114,103,46,97,112,97,99,104,101,46,99,111,109,109,111,110,115,46,105,111,46,73,79,85,116,105,108,115%7D)).toString(new%20byte%5B%5D%7B35,121,100,118,117,108,116,116,116,35%7D)%7D&op=goods_list&page=10&curpage=3&keyword=%E7%9B%B8%E5%AE%9C%E6%9C%AC%E8%8D%89';
+        $url = urldecode($url);
     }
 
     public static function tearDownAfterClass()

+ 1 - 1
test/bouns_toplist_helperTest.php

@@ -41,7 +41,7 @@ class bouns_toplist_helperTest extends PHPUnit_Framework_TestCase
 
     public function testListCount()
     {
-        $count = ranklist_helper::list_count(36490,$err);
+        $count = ranklist_helper::list_count(36490);
     }