Example #1
0
 /**
  * @brief 发送短信
  * @param string $mobile 手机号
  * @param string $content 短信内容
  * @param int $delay 延迟设置
  * @return success or fail
  */
 public static function send($mobile, $content, $delay = 1)
 {
     if (self::$smsInstance == null) {
         $platform = self::getPlatForm();
         switch ($platform) {
             case "zhutong":
                 $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/zhutong.php';
                 require $classFile;
                 self::$smsInstance = new zhutong();
                 break;
             default:
                 $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/haiyan.php';
                 require $classFile;
                 self::$smsInstance = new haiyan();
         }
     }
     if (IValidate::mobi($mobile) && $content) {
         $ip = IClient::getIp();
         if ($ip) {
             if ($delay == 1) {
                 $mobileKey = md5($ip);
                 $sendTime = ISession::get($mobileKey);
                 if ($sendTime && time() - $sendTime < 60) {
                     return false;
                 }
                 ISession::set($mobileKey, time());
             }
             return self::$smsInstance->send($mobile, $content);
         }
     }
     return false;
 }
Example #2
0
 public function getAccessToken($parms)
 {
     $url = "http://openapi.qzone.qq.com/oauth/qzoneoauth_access_token?";
     $sigstr = "GET" . "&" . rawurlencode("http://openapi.qzone.qq.com/oauth/qzoneoauth_access_token") . "&";
     $params = array();
     $params["oauth_version"] = "1.0";
     $params["oauth_signature_method"] = "HMAC-SHA1";
     $params["oauth_timestamp"] = time();
     $params["oauth_nonce"] = mt_rand();
     $params["oauth_consumer_key"] = $this->apiId;
     $params["oauth_token"] = $parms['oauth_token'];
     $params["oauth_vericode"] = $parms['oauth_vericode'];
     //对参数按照字母升序做序列化
     $normalized_str = $this->get_normalized_string($params);
     $sigstr .= rawurlencode($normalized_str);
     //(2)构造密钥
     $key = $this->apiKey . "&" . ISession::get('secret');
     //(3)生成oauth_signature签名值。这里需要确保PHP版本支持hash_hmac函数
     $signature = $this->get_signature($sigstr, $key);
     //构造请求url
     $url .= $normalized_str . "&" . "oauth_signature=" . rawurlencode($signature);
     $result = array();
     $access_str = file_get_contents($url);
     parse_str($access_str, $result);
     if (isset($result["oauth_token"]) && isset($result["oauth_token_secret"]) && isset($result["openid"])) {
         ISession::set('token', $result["oauth_token"]);
         ISession::set('secret', $result["oauth_token_secret"]);
         ISession::set('openid', $result["openid"]);
     } else {
         die($access_str);
     }
 }
Example #3
0
 public function getAccessToken($parms)
 {
     require_once dirname(__FILE__) . "/API/qqConnectAPI.php";
     $qc = new QC();
     $access_token = $qc->qq_callback($this->apiId, parent::getReturnUrl(), $this->apiKey);
     $openid = $qc->get_openid();
     ISession::set('openid', $openid);
     ISession::set('access_token', $access_token);
 }
Example #4
0
 public function setMyCart($goodsInfo)
 {
     $goodsInfo = str_replace(array('"', ','), array('&', '$'), JSON::encode($goodsInfo));
     $cartName = $this->getCartName();
     if ($this->saveType == 'session') {
         ISession::set($cartName, $goodsInfo);
     } else {
         ICookie::set($cartName, $goodsInfo, '7200');
     }
     return true;
 }
Example #5
0
 function login_act()
 {
     $admin_name = IFilter::act(IReq::get('admin_name'));
     $password = IReq::get('password');
     $captcha = IReq::get('captcha', 'post');
     $message = '';
     if ($admin_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             if ($captcha != ISafe::get('captcha')) {
                 $message = '验证码输入不正确';
             } else {
                 $adminObj = new IModel('admin');
                 $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
                 if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
                     $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
                     $adminObj->setData($dataArray);
                     $where = 'id = ' . $adminRow["id"];
                     $adminObj->update($where);
                     //根据角色分配权限
                     if ($adminRow['role_id'] == 0) {
                         ISession::set('admin_right', 'administrator');
                         ISafe::set('admin_role_name', '超级管理员');
                     } else {
                         $roleObj = new IModel('admin_role');
                         $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
                         $roleRow = $roleObj->getObj($where);
                         ISession::set('admin_right', $roleRow['rights']);
                         ISafe::set('admin_role_name', $roleRow['name']);
                     }
                     ISafe::set('admin_id', $adminRow['id']);
                     ISafe::set('admin_name', $adminRow['admin_name']);
                     ISafe::set('admin_pwd', $adminRow['password']);
                     $this->redirect('/system/default');
                 } else {
                     $message = '用户名与密码不匹配';
                 }
             }
         }
     }
     if ($message != '') {
         $this->admin_name = $admin_name;
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
Example #6
0
 public function getAccessToken($parm)
 {
     $accessTokenUrl = $this->getAccessTokenUrl($parm);
     if ($accessTokenUrl) {
         $accessToken = file_get_contents($accessTokenUrl);
         $tokenArray = JSON::decode($accessToken);
         if (isset($tokenArray['access_token'])) {
             ISession::set('access_token', $tokenArray['access_token']);
         } else {
             die($accessToken);
         }
     } else {
         return false;
     }
 }
Example #7
0
 public function getAccessToken($parms)
 {
     $url = 'https://oauth.taobao.com/token';
     $urlParmsArray = array('grant_type' => 'authorization_code', 'code' => $parms['code'], 'redirect_uri' => parent::getReturnUrl(), 'client_id' => $this->apiKey, 'client_secret' => $this->apiSecret);
     //模拟post提交
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($urlParmsArray));
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     $tokenInfo = JSON::decode(curl_exec($ch));
     if (!isset($tokenInfo['access_token'])) {
         die(var_export($tokenInfo));
     }
     ISession::set('access_token', $tokenInfo['access_token']);
 }
Example #8
0
 function getAccessToken($parms)
 {
     require_once dirname(__FILE__) . "/API/saetv2.ex.class.php";
     $o = new SaeTOAuthV2(ISession::get('apiKey'), ISession::get('apiSecret'));
     $token = '';
     if (isset($_REQUEST['code'])) {
         $keys = array();
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = parent::getReturnUrl();
         try {
             $token = $o->getAccessToken('code', $keys);
         } catch (OAuthException $e) {
         }
     }
     if ($token) {
         ISession::set('token', $token);
         setcookie('weibojs_' . $o->client_id, http_build_query($token));
     }
 }
 /**
  * Request cleanup work.
  * Default implementation will save the user object to session if possible.
  * The method is invoked at the end of {@link run} and {@link transfer}.
  * Derived classes can override this method to provide customized cleanup work.
  * Parent implementation should be invoked.
  */
 protected function endRequest()
 {
     if (!is_null($this->session) && $this->session->isStarted() && !is_null($this->user)) {
         $this->session->set($this->id . ':' . self::SESSION_USER, pradoSerializeObject($this->user));
     }
     foreach ($this->modules as $module) {
         $module->onUnload(new TEventParameter());
     }
 }
Example #10
0
 function __construct($config)
 {
     ISession::set('apiKey', $config['apiKey']);
     ISession::set('apiSecret', $config['apiSecret']);
 }
Example #11
0
 public function bindUser($userInfo, $oauthId)
 {
     $oauthUserObj = new IModel('oauth_user');
     $oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
     //没有绑定账号
     if (empty($oauthUserRow)) {
         $userObj = new IModel('user');
         $userCount = $userObj->getObj("username = '******'name']}'", 'count(*) as num');
         //没有重复的用户名
         if ($userCount['num'] == 0) {
             $username = $userInfo['name'];
         } else {
             //随即分配一个用户名
             $username = $userInfo['name'] . $userCount['num'];
         }
         ISafe::set('oauth_username', $username);
         ISession::set('oauth_id', $oauthId);
         ISession::set('oauth_userInfo', $userInfo);
         $this->redirect('bind_user');
     } else {
         $userObj = new IModel('user');
         $tempRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
         $userRow = CheckRights::isValidUser($tempRow['username'], $tempRow['password']);
         CheckRights::loginAfter($userRow);
         //自定义跳转页面
         $callback = ISafe::get('callback');
         if ($callback && !strpos($callback, 'reg') && !strpos($callback, 'login')) {
             $this->redirect($callback);
         } else {
             $this->redirect('/ucenter/index');
         }
     }
 }
Example #12
0
 public function bindUser($userInfo, $oauthId)
 {
     $oauthUserObj = new IModel('oauth_user');
     $oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
     //没有绑定账号
     if (empty($oauthUserRow)) {
         $userObj = new IModel('user');
         $userCount = $userObj->getObj("username = '******'name']}'", 'count(*) as num');
         //没有重复的用户名
         if ($userCount['num'] == 0) {
             $username = $userInfo['name'];
         } else {
             //随即分配一个用户名
             $username = $userInfo['name'] . $userCount['num'];
         }
         ISafe::set('oauth_username', $username);
         ISession::set('oauth_id', $oauthId);
         ISession::set('oauth_userInfo', $userInfo);
         $this->redirect('bind_user');
     } else {
         $userObj = new IModel('user');
         $userRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
         $this->loginAfter($userRow);
         //自定义跳转页面
         $callback = ISafe::get('callback');
         if ($callback != null && $callback != '' && $callback != "/simple/reg" && $callback != "/simple/login") {
             $this->redirect($callback);
         } else {
             $this->redirect('/ucenter/index');
         }
     }
 }