Ejemplo n.º 1
0
 public function autoinAction($appid)
 {
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     $encode = $user->eno . ",{$user->openid},x,y," . time();
     $appid2 = DES::decrypt($appid);
     $da = $this->get('we_data_access');
     $ds = $da->GetData("app", "select appkey from we_appcenter_apps where appid=? ", array((string) $appid2));
     $auth = DES::encrypt2($encode, $ds["app"]["rows"][0]["appkey"]);
     //获取url
     $url = $_SERVER['QUERY_STRING'];
     //$urlsource=$request->get("_urlSource");
     //$this->get("logger")->err("wefafa=>".$url);
     if (!empty($url)) {
         $url = "&url=" . $this->parseurl(str_replace(array("url=", "%25"), array("", "%"), $url));
     }
     //if(!empty($urlsource))
     //   $url .= "%2526urlsource=".($urlsource);
     //$this->get("logger")->err("query_string=>".$_SERVER['QUERY_STRING']);
     //生成应用中心地址
     $appcenterUrl = $this->container->getParameter('fafa_appcenter_url') . "/appcenter/link/{$appid}";
     $appcenterUrl .= "?auth={$auth}" . $url;
     $this->get("logger")->err("appcenterUrl=>" . $appcenterUrl);
     return $this->redirect($appcenterUrl);
 }
Ejemplo n.º 2
0
 public static function bindBatAction($controller, $con, $appid, $eno, $encrypt, $params)
 {
     $re = array('s' => '1', 'm' => '');
     try {
         $openids = $params->get("openids");
         if ($openids == 'all') {
             $sql = "select openid from we_staff where eno=? and auth_level!='J'";
             $param = array($eno);
             $ds = $con->getdata('info', $sql, $param);
             $rows = $ds['info']['rows'];
             foreach ($rows as $row) {
                 $openidArr[] = $row['openid'];
             }
         } else {
             $openidArr = explode(',', $openids);
         }
         $sql = "select appkey from we_appcenter_apps where appid=?";
         $ds = $con->GetData("t", $sql, array((string) $appid));
         $appkey = '';
         if (count($ds["t"]["rows"]) > 0) {
             $appkey = $ds["t"]["rows"][0]["appkey"];
         }
         $sqls = [];
         $paras = [];
         for ($i = 0; $i < count($openidArr); $i++) {
             $sql = "select mobile,nick_name,birthday,sex_id,login_account from we_staff where openid=?";
             $params = array($openidArr[$i]);
             $ds = $con->getdata('info', $sql, $params);
             if ($ds['info']['recordcount'] > 0) {
                 $pam_account = array();
                 $pam_account['login_name'] = $ds['info']['rows'][0]['login_account'];
                 $pam_account['login_password'] = '******';
                 $pam_account['psw_confirm'] = '123456';
                 $auth = array('userid' => $pam_account['login_name'], 'passwd' => $pam_account['login_password']);
                 $auth = json_encode($auth);
                 //$auth=DES::encrypt2($auth,'_sddb74+');
                 $auth = DES::encrypt2($auth, $appkey);
                 $pam_account = json_encode($pam_account);
                 $pam_account = DES::encrypt2($pam_account, 'ecstore');
                 $addr = "";
                 $name = $ds['info']['rows'][0]['nick_name'];
                 $phone = $ds['info']['rows'][0]['phone'];
                 $qq = "";
                 $zipcode = "";
                 $birthday = $ds['info']['rows'][0]['birthday'];
                 $gender = $ds['info']['rows'][0]['sex_id'] == '女' ? 'female' : 'male';
                 $data = "pam_account={$pam_account}&addr={$addr}&name={$name}&phone={$phone}&qq={$qq}&zipcode={$zipcode}&birthday={$birthday}&gender={$gender}";
                 $result = Utils::do_post_request(self::$bind_url . "&" . $data);
                 $result = json_decode($result, true);
                 if ($result['rsp'] != 'fail') {
                     $sql = "delete from we_staff_account_bind where bind_account=? and bind_type=? and appid=?";
                     $params = array($openidArr[$i], self::$bind_type, $appid);
                     array_push($sqls, $sql);
                     array_push($paras, $params);
                     $sql = "insert into we_staff_account_bind(bind_account,appid,bind_uid,authkey,bind_type,bind_created)values(?,?,?,?,?,now())";
                     $params = array($openidArr[$i], (string) $appid, $ds['info']['rows'][0]['login_account'], (string) $auth, self::$bind_type);
                     array_push($sqls, $sql);
                     array_push($paras, $params);
                 }
             }
         }
         if (count($sqls) > 0) {
             if (!$con->ExecSQLs($sqls, $paras)) {
                 $re = array('s' => '0', 'm' => '操作失败');
             }
         }
     } catch (\Exception $e) {
         $re = array('s' => '0', 'm' => $e->getMessage());
     }
     return $re;
 }
Ejemplo n.º 3
0
 public function getAppSig($appid, $appkey)
 {
     //格式orgid,acc,pass,p1,p2  des加密
     try {
         //获取当前用户在该应用中的唯一标识
         if (!empty($this->openid)) {
             $resultAcc = DES::encrypt2($this->eno . "," . $this->openid . "," . $this->nick_name . "," . $this->identify . ",FaFa:SNS", $appkey);
             return $resultAcc;
         } else {
             return "";
         }
     } catch (Exception $e) {
         return "";
     }
 }