Selaa lähdekoodia

修改下载链接无效的问题

stanley-king 8 vuotta sitten
vanhempi
commit
e7f4e486c9
3 muutettua tiedostoa jossa 44 lisäystä ja 24 poistoa
  1. 34 14
      helper/algorithm_helper.php
  2. 8 8
      helper/relation/mem_relation.php
  3. 2 2
      mobile/control/bonusex.php

+ 34 - 14
helper/algorithm_helper.php

@@ -8,24 +8,44 @@
  */
 class algorithm_helper
 {
-    static public function bsearch($needle, $haystack)
+//    static public function bsearch($needle, $haystack)
+//    {
+//        $high = count($haystack);
+//        $low = 0;
+//
+//        while ($high - $low >= 1){
+//            $probe = ($high + $low) / 2;
+//            if ($haystack[$probe] < $needle){
+//                $low = $probe;
+//            }else{
+//                $high = $probe;
+//            }
+//        }
+//
+//        if ($high == count($haystack) || $haystack[$high] != $needle) {
+//            return false;
+//        }else {
+//            return $high;
+//        }
+//    }
+
+    static function bsearch($x, $list)
     {
-        $high = count($haystack);
-        $low = 0;
+        $left = 0;
+        $right = count($list)-1;
+
+        while ($left <= $right) {
+            $mid = ($left + $right) >> 1;
 
-        while ($high - $low > 1){
-            $probe = ($high + $low) / 2;
-            if ($haystack[$probe] < $needle){
-                $low = $probe;
-            }else{
-                $high = $probe;
+            if ($list[$mid] == $x) {
+                return $mid;
+            } elseif ($list[$mid] > $x) {
+                $right = $mid - 1;
+            } elseif ($list[$mid] < $x) {
+                $left = $mid + 1;
             }
         }
 
-        if ($high == count($haystack) || $haystack[$high] != $needle) {
-            return false;
-        }else {
-            return $high;
-        }
+        return -1;
     }
 }

+ 8 - 8
helper/relation/mem_relation.php

@@ -90,14 +90,14 @@ class mem_relation
     private function subscrib_me($member_id)
     {
         $ret = algorithm_helper::bsearch($member_id,$this->subscriber);
-        if($ret == false) {
+        if($ret == -1) {
             array_push($this->subscriber,$member_id);
             sort($this->subscriber);
             $this->dirty = true;
         }
 
         $ret = algorithm_helper::bsearch($member_id,$this->new_subscriber);
-        if($ret == false) {
+        if($ret == -1) {
             array_push($this->new_subscriber,$member_id);
             sort($this->new_subscriber);
             $this->dirty = true;
@@ -131,10 +131,10 @@ class mem_relation
     }
     private function subscribed($mobile)
     {
-        if(algorithm_helper::bsearch($mobile,$this->build_mobiles) != false) {
+        if(algorithm_helper::bsearch($mobile,$this->build_mobiles) != -1) {
             return true;
         }
-        if(algorithm_helper::bsearch($mobile,$this->unbuild_mobiles) != false) {
+        if(algorithm_helper::bsearch($mobile,$this->unbuild_mobiles) != -1) {
             return true;
         }
         return false;
@@ -142,7 +142,7 @@ class mem_relation
 
     public function add_fllower($someone_id)
     {
-        if(algorithm_helper::bsearch($someone_id,$this->follower) != false) {
+        if(algorithm_helper::bsearch($someone_id,$this->follower) != -1) {
             array_push($this->follower,$someone_id);
             sort($this->follower);
             $this->dirty = true;
@@ -152,7 +152,7 @@ class mem_relation
     private function add_unbuild($mobile)
     {
         $ret = algorithm_helper::bsearch($mobile,$this->unbuild_mobiles);
-        if($ret == false) {
+        if($ret == -1) {
             array_push($this->unbuild_mobiles,$mobile);
             sort($this->unbuild_mobiles);
             $this->dirty = true;
@@ -162,7 +162,7 @@ class mem_relation
     private function remove_unbuild($mobile)
     {
         $ret = algorithm_helper::bsearch($mobile,$this->unbuild_mobiles);
-        if($ret != false) {
+        if($ret != -1) {
             unset($this->unbuild_mobiles[$ret]);
             $this->dirty = true;
         }
@@ -171,7 +171,7 @@ class mem_relation
     private function add_build($mobile)
     {
         $ret = algorithm_helper::bsearch($mobile,$this->build_mobiles);
-        if($ret == false) {
+        if($ret == -1) {
             array_push($this->build_mobiles,$mobile);
             sort($this->build_mobiles);
             $this->dirty = true;

+ 2 - 2
mobile/control/bonusex.php

@@ -469,8 +469,8 @@ function bonus_output_mine($output)
         echo('<input type="hidden" id="mine_bonus" value=' ."{$bonus->bonus_sn()}>");
 
         if($bonus->isBinded()) {
-            echo('<div class="link">');
-            echo('<p style="margin: 20px 0"><a href="javascript:void(0)">请下载熊猫美妆APP,享用红包</a></p>');
+            echo('<div class="link" id="link">');
+            echo('<p style="margin: 20px 0" ><a href="javascript:void(0)">请下载熊猫美妆APP,享用红包</a></p>');
             echo('</div>');
         }
     }