Browse Source

fix 上传通讯录bug

stanley-king 8 years ago
parent
commit
79967d4ebf

+ 1 - 1
helper/fcgi_server.php

@@ -110,7 +110,7 @@ class fcgi_server
             fcgi_headers_sent();
             $contents = ob_get_clean();
             fcgi_echo($contents);
-            //Log::record("return msg={$contents}",Log::DEBUG);
+            Log::record("return msg={$contents}",Log::DEBUG);
 
             session::instance()->end();
             fcgi_finish();

+ 7 - 1
helper/session_helper.php

@@ -21,8 +21,14 @@ class session_helper
             return false;
         }
 
+        $ret = preg_match('/^1(?:3[0-9]|5[012356789]|8[0256789]|7[0678])(-?)\d{4}\1\d{4}$/', $mobile, $arr);
+        if($ret == false || count($arr) <= 0) {
+            return false;
+        } else {
+            $mobile = $arr[0];
+        }
+        $mobile = str_replace('-','',$mobile);
         $mobile = substr($mobile,-self::mobile_len);
-
         $validate = new Validate();
         $validate->setValidate(Validate::verify_mobile($mobile));
         $err = $validate->validate();

+ 1 - 1
mobile/control/member_info.php

@@ -90,7 +90,7 @@ class member_infoControl extends mbMemberControl
 
     public function upcontactsOp()
     {
-        $contacts = session_helper::parse_contacts($_POST["contact_list"]); ;
+        $contacts = session_helper::parse_contacts($_POST["contact_list"]);
         if ($contacts == false) {
             return self::outerr(errcode::ErrParamter);
         }

+ 2 - 0
mobile/util/errcode.php

@@ -100,6 +100,8 @@ class errcode extends SplEnum
                 return '协议未启用';
             case errcode::ErrApptype :
                 return '应用类型错误';
+            case errcode::ErrParamter :
+                return '错误的参数.';
             case errcode::ErrLogin :
                 return '用户名或密码错误';
             case errcode::ErrHasLogined :

+ 12 - 0
test/relation_helperTest.php

@@ -39,4 +39,16 @@ class relation_helperTest extends PHPUnit_Framework_TestCase
         relation_helper::onLogin(36490);
         relation_helper::onLogin(36511);
     }
+    
+    public function testUpContactsC()
+    {
+        try
+        {
+            $contacts = '%5B%22178-0211-8910%22%2C%22182-6227-3057%22%2C%22189-6195-0030%22%5D';
+            $contacts = session_helper::parse_contacts($contacts);
+            relation_helper::onUpContacts(36511,'18612396521','秦梦洁',$contacts);
+        } catch (Exception $ex) {
+            echo $ex->getMessage();
+        }
+    }
 }