Ejemplo n.º 1
0
 public function RegistUser($umobile, $password, $captcha)
 {
     $ret = array('ret' => 7, 'msg' => 'regist user failed!');
     $proxy = "http://182.92.97.3:13128";
     $api = 'https://webapi.sms.mob.com';
     //(例:https://webapi.sms.mob.com);
     $appkey = 'f40f0f41f1d1';
     //您的appkey
     $zone = '86';
     $apiurl = $api . '/sms/verify';
     $param = array('appkey' => $appkey, 'phone' => $umobile, 'zone' => $zone, 'code' => $captcha);
     $vrest = VerificationCode_proxy($apiurl, $proxy, $param);
     if (!$vrest) {
         $ret['ret'] = 1;
         $ret['msg'] = 'verify cathcha error!';
     } else {
         $user = new UserService();
         $capacity = 1 * 1024 * 1024 * 1024;
         $reg_ret = $user->RegistUser($umobile, $password, $capacity);
         $cb_ret = '';
         if ($reg_ret['status'] == 0) {
             $host = CEPH_HOST;
             $aws_key = session('user_key');
             $aws_secret_key = session('user_secret_key');
             $Buckets = array();
             $userTypes = self::_get_user_all_ftype();
             foreach ($userTypes as $type) {
                 $bucketname = self::_get_bucket_name_by_ftype($type);
                 //$cb_ret = $conn->createUserBucket($bucketname);
                 try {
                     $pythonpath = '/usr/bin/python';
                     $python_script = __DIR__ . '/lib/createUserBucket.py';
                     $param = '-a ' . session('user_key') . ' -s ' . session('user_secret_key') . ' -b ' . $bucketname;
                     $command = $pythonpath . ' ' . $python_script . ' ' . $param;
                     exec($command, $output, $ret_var);
                 } catch (\Exception $e) {
                     $reg_ret['status'] = 7;
                     $reg_ret['msg'] = 'create user bucket have a exeption!';
                     break;
                 }
                 $conn = new cephService($host, $aws_key, $aws_secret_key);
                 if (!$conn->queryBucketExist($bucketname)) {
                     $reg_ret['status'] = 2;
                     $reg_ret['msg'] = 'create user bucket failed!';
                     break;
                 }
             }
         }
         $ret = array('ret' => $reg_ret['status'], 'msg' => $reg_ret['msg']);
     }
     $ret_h = new \proto\RetHead($ret);
     return $ret_h;
 }
Ejemplo n.º 2
0
 public function DeleteBucketAllObj($token, $ftype)
 {
     $ret = array('ret' => 4, 'msg' => 'delete user bucket all object token invalid!');
     $token_c = new \lib\Token_Core();
     $ualias = '';
     if ($token_c->is_token($token)) {
         $host = CEPH_HOST;
         $aws_key = session('user_key');
         $aws_secret_key = session('user_secret_key');
         $conn = new cephService($host, $aws_key, $aws_secret_key);
         $bucket_name = self::_get_bucket_name_by_ftype($ftype);
         $del_ret = $conn->deleteAllObjectByBucket($bucket_name);
         if ($del_ret) {
             $ret = array('ret' => 0, 'msg' => '');
         } else {
             $ret = array('ret' => 2, 'msg' => 'delete all object failed!');
         }
     }
     $ret_h = new \proto\RetHead($ret);
     return $ret_h;
 }