stanley-king 1 year ago
parent
commit
6a3122efba

+ 10 - 0
data/api/aliyun-oss-php-sdk-2.3.0/tests/TestRedisTest.php

@@ -0,0 +1,10 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+class TestRedisTest extends TestCase
+{
+//    public function
+
+}

+ 64 - 72
helper/algorithm.php

@@ -7,7 +7,7 @@ declare(strict_types=1);
  * Date: 16/6/24
  * Time: 上午1:18
  */
-function less($x,$y)
+function less($x, $y)
 {
     return $x < $y;
 }
@@ -15,14 +15,17 @@ function less($x,$y)
 class full_set
 {
     private static $stInstance = null;
+
     public static function instance()
     {
-        if(static::$stInstance == null) {
+        if (static::$stInstance == null) {
             static::$stInstance = new full_set();
         }
     }
+
     private function __clone()
     {
+
     }
 }
 
@@ -31,7 +34,7 @@ class algorithm
     static function bsearch($x, $list)
     {
         $left = 0;
-        $right = count($list)-1;
+        $right = count($list) - 1;
 
         while ($left <= $right) {
             $mid = ($left + $right) >> 1;
@@ -51,29 +54,26 @@ class algorithm
     static function binary_search($sortarr, $val, $compare = "less")
     {
         $last = count($sortarr);
-        $first = self::lower_bonud($sortarr,$val,$compare);
+        $first = self::lower_bonud($sortarr, $val, $compare);
         return $first != $last && !$compare($val, $sortarr[$first]);
     }
 
     //返回位置标记了一个 >= value 的值。
-    static function lower_bonud($container, $val,$compare = "less")
+    static function lower_bonud($container, $val, $compare = "less")
     {
-        if(!is_array($container)) {
+        if (!is_array($container)) {
             return -1;
         }
 
         $len = count($container);
         $first = 0;
-        while ($len != 0)
-        {
+        while ($len != 0) {
             $l2 = intval($len / 2);
             $m = $first + $l2;
-            if ($compare($container[$m],$val))
-            {
+            if ($compare($container[$m], $val)) {
                 $first = ++$m;
                 $len -= $l2 + 1;
-            }
-            else {
+            } else {
                 $len = $l2;
             }
         }
@@ -82,7 +82,7 @@ class algorithm
     }
 
     //返回位置标记了一个 > value 的值。
-    static function upper_bound($container, $val,$compare = "less")
+    static function upper_bound($container, $val, $compare = "less")
     {
         if (!is_array($container)) {
             return -1;
@@ -90,11 +90,10 @@ class algorithm
 
         $len = count($container);
         $first = 0;
-        while ($len != 0)
-        {
+        while ($len != 0) {
             $l2 = intval($len / 2);
             $m = $first + $l2;
-            if ($compare($val,$container[$m])) {
+            if ($compare($val, $container[$m])) {
                 $len = $l2;
             } else {
                 $first = ++$m;
@@ -105,29 +104,29 @@ class algorithm
         return $first;
     }
 
-    static function array_insert(&$arr,$pos,$val)
+    static function array_insert(&$arr, $pos, $val)
     {
-        if(is_array($val)) {
+        if (is_array($val)) {
             $left = array_slice($arr, 0, $pos);
             $left[] = $val;
             $right = array_slice($arr, $pos);
             $arr = array_merge($left, $right);
-        }
-        else {
-            array_splice($arr,$pos,0,$val);
+        } else {
+            array_splice($arr, $pos, 0, $val);
         }
     }
-    static function array_erase(&$arr,$pos)
+
+    static function array_erase(&$arr, $pos)
     {
-        return array_splice($arr,$pos,1);
+        return array_splice($arr, $pos, 1);
     }
 
     static function set_intersection($ar1, $ar2)
     {
-        if($ar1 === full_set::instance()) {
+        if ($ar1 === full_set::instance()) {
             return $ar2;
         }
-        if($ar2 === full_set::instance()) {
+        if ($ar2 === full_set::instance()) {
             return $ar1;
         }
 
@@ -137,37 +136,34 @@ class algorithm
         $pos2 = 0;
 
         $result = [];
-        while ($pos1 != $count1 && $pos2 != $count2)
-        {
+        while ($pos1 != $count1 && $pos2 != $count2) {
             $val1 = $ar1[$pos1];
             $val2 = $ar2[$pos2];
 
             if ($val1 < $val2) {
                 ++$pos1;
-            }
-            elseif($val1 == $val2) {
+            } elseif ($val1 == $val2) {
                 $result[] = $val1;
                 ++$pos1;
                 ++$pos2;
-            }
-            else {
+            } else {
                 ++$pos2;
             }
         }
         return $result;
     }
 
-    private static function copy($src,$pos,&$result)
+    private static function copy($src, $pos, &$result)
     {
         $count = count($src);
-        for (;$pos < $count;++$pos) {
+        for (; $pos < $count; ++$pos) {
             $result[] = $src[$pos];
         }
 
         return $result;
     }
 
-    static function set_union($ar1,$ar2)
+    static function set_union($ar1, $ar2)
     {
         $count1 = count($ar1);
         $count2 = count($ar2);
@@ -175,36 +171,32 @@ class algorithm
         $pos2 = 0;
 
         $result = [];
-        for (; $pos1 != $count1; )
+        for (; $pos1 != $count1;)
         {
             if ($pos2 == $count2) {
                 return self::copy($ar1, $pos1, $result);
             }
 
-            if ($ar1[$pos1] > $ar2[$pos2])
-            {
+            if ($ar1[$pos1] > $ar2[$pos2]) {
                 $result[] = $ar2[$pos2];
                 ++$pos2;
-            }
-            elseif($ar1[$pos1] == $ar2[$pos2]) {
+            } elseif ($ar1[$pos1] == $ar2[$pos2]) {
                 $result[] = $ar1[$pos1];
                 ++$pos1;
                 ++$pos2;
-            }
-            else
-            {
+            } else {
                 $result[] = $ar1[$pos1];
                 ++$pos1;
             }
         }
 
-        return self::copy($ar2,$pos2,$result);
+        return self::copy($ar2, $pos2, $result);
     }
 
-    public static function not_in($src,$avables)
+    public static function not_in($src, $avables)
     {
-        if(empty($src)) return array();
-        if(empty($avables)) return $src;
+        if (empty($src)) return [];
+        if (empty($avables)) return $src;
 
         $src = array_unique($src);
         $avables = array_unique($avables);
@@ -212,9 +204,8 @@ class algorithm
         sort($avables);
 
         $result = [];
-        foreach ($src as $val)
-        {
-            if(algorithm::binary_search($avables,$val) == false) {
+        foreach ($src as $val) {
+            if (algorithm::binary_search($avables, $val) == false) {
                 $result[] = $val;
             }
         }
@@ -236,71 +227,72 @@ class uniquer
 
     public function add_value($val)
     {
-        if(algorithm::binary_search($this->mContainer,$val,$this->mCompare) == false) {
-            $pos = algorithm::lower_bonud($this->mContainer,$val,$this->mCompare);
-            algorithm::array_insert($this->mContainer,$pos,$val);
+        if (algorithm::binary_search($this->mContainer, $val, $this->mCompare) == false) {
+            $pos = algorithm::lower_bonud($this->mContainer, $val, $this->mCompare);
+            algorithm::array_insert($this->mContainer, $pos, $val);
             return true;
         } else {
             return false;
         }
     }
+
     public function add_values(array $datas)
     {
-        if(!is_array($datas)) return false;
+        if (!is_array($datas)) return false;
         foreach ($datas as $val) {
             $this->add_value($val);
         }
         return true;
     }
+
     public function remove_value($val)
     {
-        if(algorithm::binary_search($this->mContainer,$val,$this->mCompare) != false) {
-            $pos = algorithm::lower_bonud($this->mContainer,$val);
-            algorithm::array_erase($this->mContainer,$pos);
+        if (algorithm::binary_search($this->mContainer, $val, $this->mCompare) != false) {
+            $pos = algorithm::lower_bonud($this->mContainer, $val);
+            algorithm::array_erase($this->mContainer, $pos);
             return true;
         } else {
             return false;
         }
     }
 
-    public function values() {
+    public function values()
+    {
         return $this->mContainer;
     }
+
     public function find($val)
     {
-        return algorithm::binary_search($this->mContainer,$val,$this->mCompare);
+        return algorithm::binary_search($this->mContainer, $val, $this->mCompare);
     }
 
-    public function range($lower,$high)
+    public function range($lower, $high)
     {
-        if(empty($lower)) {
+        if (empty($lower)) {
             $pos_low = 0;
-        }
-        else {
-            $pos_low = algorithm::lower_bonud($this->mContainer,$lower,$this->mCompare);
+        } else {
+            $pos_low = algorithm::lower_bonud($this->mContainer, $lower, $this->mCompare);
         }
 
-        if(empty($high)) {
+        if (empty($high)) {
             $pos_high = count($this->mContainer);
-        }
-        else {
-            $pos_high = algorithm::lower_bonud($this->mContainer,$high,$this->mCompare);
+        } else {
+            $pos_high = algorithm::lower_bonud($this->mContainer, $high, $this->mCompare);
         }
 
-        if($pos_low < 0) return [];
+        if ($pos_low < 0) return [];
         return array_slice($this->mContainer, $pos_low, $pos_high - $pos_low);
     }
 }
 
 class array_helper
 {
-    public static function mapper($items,callable $func)
+    public static function mapper($items, callable $func)
     {
         $result = [];
-        foreach ($items as $item)
-        {
+        foreach ($items as $item) {
             $key = $func($item);
-            if($key === false) continue;
+            if ($key === false) continue;
             $result[$key] = $item;
         }
 

+ 11 - 16
helper/area_helper.php

@@ -15,12 +15,10 @@ class area_helper
     static private $stInstance = null;
     private $mValidator;
 
-
     private function __construct()
     {
         $this->mValidator = new area\area_validator('area_origion');
     }
-
     static public function instance()
     {
         if (self::$stInstance == null) {
@@ -28,7 +26,6 @@ class area_helper
         }
         return self::$stInstance;
     }
-
     public function province($areaid)
     {
         return $this->mValidator->province($areaid);
@@ -45,12 +42,12 @@ class area_helper
         $fail_count = 0;
         if($maxid > 0)
         {
-            $items = $mod_area->where(array('area_name' => array('like',"%其它区%")))->field('area_id')->limit(false)->select();
+            $items = $mod_area->where(['area_name' => ['like',"%其它区%"]])->field('area_id')->limit(false)->select();
             foreach ($items as $item)
             {
                 $maxid += 1;
                 $area_id = $item['area_id'];
-                $ret = $mod_area->where(array('area_id' => $area_id))->update(array('area_id' => $maxid));
+                $ret = $mod_area->where(['area_id' => $area_id])->update(['area_id' => $maxid]);
                 if($ret == false) {
                     $fail_count++;
                 } else {
@@ -58,7 +55,7 @@ class area_helper
                 }
             }
         }
-        Log::record("area_helper uplast_country total update success {$success_count},fail {$fail_count}");
+        Log::record("area_helper uplast_country total update success $success_count,fail $fail_count");
         return true;
     }
 
@@ -67,13 +64,13 @@ class area_helper
         $validator = new area\area_validator('area_origion');
 
         $mod_addr = Model('address');
-        $addres = $mod_addr->where(array('handled' => 0))->field('address_id,area_id,city_id,area_info')->order('address_id asc')->limit(false)->select();
+        $addres = $mod_addr->where(['handled' => 0])->field('address_id,area_id,city_id,area_info')->order('address_id asc')->limit(false)->select();
 
         foreach ($addres as $addr)
         {
             $address_id = $addr['address_id'];
             $area_info = trim($addr['area_info']);
-            $area_info = str_replace(array(" "),array("\t"),$area_info);
+            $area_info = str_replace([" "], ["\t"],$area_info);
 
             $areas = explode("\t",$area_info);
             $count = count($areas);
@@ -86,10 +83,10 @@ class area_helper
                     $city_id = $result_name['city']['area_id'];
                     $country_id = $result_name['country']['area_id'];
                     $narea_info = "{$result_name['province']['area_name']}\t{$result_name['city']['area_name']}\t{$result_name['country']['area_name']}";
-                    $ret = $mod_addr->where(array('address_id' => $address_id))->update(array('city_id' => $city_id,
+                    $ret = $mod_addr->where(['address_id' => $address_id])->update(['city_id' => $city_id,
                         'area_id' => $country_id,
                         'handled' => 10,
-                        'area_info' => $narea_info));
+                        'area_info' => $narea_info]);
                     Log::record("fix_areaid address_id = {$address_id} handled",Log::DEBUG);
 
                 }
@@ -108,18 +105,16 @@ class area_helper
         $validator = new area\area_validator('area');
 
         $mod_addr = Model('address');
-        $addres = $mod_addr->where(array('handled' => 10))->field('address_id,area_id,city_id,area_info')->order('address_id asc')->limit(false)->select();
+        $addres = $mod_addr->where(['handled' => 10])->field('address_id,area_id,city_id,area_info')->order('address_id asc')->limit(false)->select();
 
-        foreach ($addres as $addr)
-        {
+        foreach ($addres as $addr) {
             $address_id = $addr['address_id'];
             $area_id = $addr['area_id'];
             $area = $validator->country($area_id);
             $area_info = "{$area['province']['area_name']}\t{$area['city']['area_name']}\t{$area['country']['area_name']}";
-            $mod_addr->where(array('address_id' => $address_id))->update(array('handled' => 11,'area_info' => $area_info));
-
-            Log::record("fix_areainfo address_id = {$address_id} handled",Log::DEBUG);
+            $mod_addr->where(['address_id' => $address_id])->update(['handled' => 11, 'area_info' => $area_info]);
 
+            Log::record("fix_areainfo address_id=$address_id handled", Log::DEBUG);
         }
     }
 }

+ 5 - 5
helper/bonus_helper.php

@@ -58,10 +58,10 @@ class bonus_helper
         }
 
         $type_sn = $type->getType_sn();
-        $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn={$type_sn}";
+        $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&client_type=wap&type_sn=$type_sn";
         $ret['url'] = $url;
 
-        $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn={$type_sn}";
+        $detail_url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=detail&client_type=wap&type_sn=$type_sn";
         $ret['detail_url'] = $detail_url;
 
         return $ret;
@@ -165,7 +165,7 @@ class bonus_helper
             if($ret) self::onBinded($bonus_sn,$mobile,$userid);
             return $ret;
         } catch (Exception $ex) {
-            return array($ex->getCode(),$ex->getMessage());
+            return [$ex->getCode(),$ex->getMessage()];
         }
     }
     static public function shake($bonus_sn,$strength,$direction)
@@ -220,10 +220,10 @@ class bonus_helper
 
             $tmout = time() - $bonus_shake['time'];
             if($tmout <= $shake_expire) {
-                return array('code' => errcode::ErrBonus, 'msg' => '请不要摇得太快~');
+                return ['code' => errcode::ErrBonus, 'msg' => '请不要摇得太快~'];
             } elseif($bonus_shake['count'] > $shake_maxcount) {
                 ++$bonus_shake['count'];
-                return array('code' => errcode::ErrBonus, 'msg' => '该红包只允许被摇' . $shake_maxcount .'次~');
+                return ['code' => errcode::ErrBonus, 'msg' => '该红包只允许被摇' . $shake_maxcount .'次~'];
             } else {
                 return true;
             }