/** * @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; }
/** * @brief 根据用户的权限过滤菜单 * @return array */ private function filterMenu() { $rights = ISession::get('admin_right'); //如果不是超级管理员则要过滤菜单 if ($rights != 'administrator') { foreach (self::$menu as $firstKey => $firstVal) { if (is_array($firstVal)) { foreach ($firstVal as $secondKey => $secondVal) { if (is_array($secondVal)) { foreach ($secondVal as $thirdKey => $thirdVal) { if (!in_array($thirdKey, self::$commonMenu) && stripos(str_replace('@', '/', $rights), ',' . substr($thirdKey, 1) . ',') === false) { unset(self::$menu[$firstKey][$secondKey][$thirdKey]); } } if (empty(self::$menu[$firstKey][$secondKey])) { unset(self::$menu[$firstKey][$secondKey]); } } } if (empty(self::$menu[$firstKey])) { unset(self::$menu[$firstKey]); } } } } }
public function getUserInfo() { require_once dirname(__FILE__) . "/API/qqConnectAPI.php"; $qc = new QC(ISession::get('access_token'), ISession::get('openid'), $this->apiId); $arr = $qc->get_user_info(); $userInfo['id'] = ISession::get('openid'); $userInfo['name'] = isset($arr['nickname']) ? $arr['nickname'] : ''; return $userInfo; }
protected function insert(ISession $Session) { $symbols = str_split('qw1er2ty3ui4op5as6df7gh8jk9lz0xcvbnm'); shuffle($symbols); $length = count($symbols) - 1; for ($try = 0; $try < 1000; ++$try) { $key = ''; for ($i = 0; $i < 32; ++$i) { $key .= $symbols[mt_rand(0, $length)]; } $Session->setID($key); if ($this->Storage->add($key, $Session, $this->expiration_time)) { return true; } } trigger_error("Can't insert session after 1000 tries", E_USER_WARNING); return false; }
function getUserInfo() { $c = new WeiboClient(ISession::get('apiKey'), ISession::get('apiSecret'), $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']); $ms = $c->home_timeline(); $me = $c->verify_credentials(); $userInfo = array(); $userInfo['id'] = isset($me['id']) ? $me['id'] : ''; $userInfo['name'] = isset($me['name']) ? $me['name'] : ''; return $userInfo; }
public function getUserInfo() { //获取用户信息的接口地址, 不要更改!! $url = "http://openapi.qzone.qq.com/user/get_user_info"; $info = $this->do_get($url, $this->apiId, $this->apiKey, ISession::get('token'), ISession::get('secret'), ISession::get('openid')); $arr = JSON::decode($info); $userInfo = array(); $userInfo['id'] = ISession::get('openid'); $userInfo['name'] = isset($arr['nickname']) ? $arr['nickname'] : ''; return $userInfo; }
/** * @brief Session的安全验证 * @return int 1:通过验证,0:未通过验证 */ private static function checkSafe() { self::$pre = self::getPre(); if (isset($_SESSION[self::$pre . 'safecode'])) { if ($_SESSION[self::$pre . 'safecode'] == self::sessionId()) { return 1; } else { return 0; } } else { return -1; } }
function getUserInfo() { require_once dirname(__FILE__) . "/API/saetv2.ex.class.php"; $token = ISession::get('token'); $c = new SaeTClientV2(ISession::get('apiKey'), ISession::get('apiSecret'), $token['access_token']); $ms = $c->home_timeline(); $uid_get = $c->get_uid(); $uid = $uid_get['uid']; $user_message = $c->show_user_by_id($uid); $userInfo = array(); $userInfo['id'] = $uid; $userInfo['name'] = isset($user_message['screen_name']) ? $user_message['screen_name'] : ''; return $userInfo; }
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); } }
/** * Get a list of USB devices attached to a given VM * * @param array $args array of arguments. See function body for details. * @return array list of devices */ public function remote_consoleGetUSBDevices($args) { // Connect to vboxwebsrv $this->connect(); /* @var $machine IMachine */ $machine = $this->vbox->findMachine($args['vm']); $this->session = $this->websessionManager->getSessionObject($this->vbox->handle); $machine->lockMachine($this->session->handle, 'Shared'); $response = array(); foreach ($this->session->console->USBDevices as $u) { /* @var $u IUSBDevice */ $response[$u->id] = array('id' => $u->id, 'remote' => $u->remote); $u->releaseRemote(); } $this->session->unlockMachine(); unset($this->session); $machine->releaseRemote(); return $response; }
public function getUserInfo() { $url = 'http://gw.api.taobao.com/router/rest?'; $paramArr = array('method' => 'taobao.user.get', 'session' => ISession::get('access_token'), 'timestamp' => date('Y-m-d H:i:s'), 'format' => 'json', 'app_key' => $this->apiKey, 'v' => '2.0', 'sign_method' => 'md5', 'fields' => 'user_id,nick,sex,email'); $sign = $this->createSign($paramArr, $this->apiSecret); //组织参数 $strParam = $this->createStrParam($paramArr); $strParam .= 'sign=' . $sign; //构造Url $urls = $url . $strParam; $userInfo = array(); $results = file_get_contents($urls); $resultsArray = JSON::decode($results); if (isset($resultsArray['user_get_response']['user'])) { $userArray = $resultsArray['user_get_response']['user']; $userInfo['id'] = isset($userArray['user_id']) ? $userArray['user_id'] : ''; $userInfo['name'] = isset($userArray['nick']) ? $userArray['nick'] : ''; $userInfo['sex'] = isset($userArray['sex']) ? $userArray['sex'] == 'm' ? 1 : 2 : ''; } return $userInfo; }
public function getUserInfo() { $apiUrl = 'http://api.renren.com/restserver.do'; $parms = array('access_token' => ISession::get('access_token'), 'call_id' => time(), 'method' => 'users.getInfo', 'v' => '1.0', 'format' => 'json'); $sign = $this->createSign($parms); $parms['sig'] = $sign; $userInfo = array(); //模拟post提交 $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parms)); $renrenUser = JSON::decode(curl_exec($ch)); $userInfo['id'] = isset($renrenUser[0]['uid']) ? $renrenUser[0]['uid'] : ''; $userInfo['name'] = isset($renrenUser[0]['name']) ? $renrenUser[0]['name'] : ''; $userInfo['sex'] = isset($renrenUser[0]['sex']) ? $renrenUser[0]['sex'] == 1 ? 1 : 2 : ''; return $userInfo; }
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; }
/** * Runtime initializations based on the application specification. * Derived classes can override this method to provide additional initializations. */ protected function init() { foreach ($this->preload as $namespace) { using($namespace); } $locatorClass = $this->handlers['locator']; $parserClass = $this->handlers['parser']; $cacheClass = $this->handlers['cache']; $errorClass = $this->handlers['error']; $requestClass = $this->handlers['request']; $sessionClass = $this->handlers['session']; $vsmClass = $this->handlers['vsmanager']; $globalizationClass = $this->handlers['globalization']; $serviceManagerClass = $this->handlers['services']; $this->resourceLocator = new $locatorClass($this->specification->locator); $this->resourceParser = new $parserClass($this->specification->parser); $this->cacheManager = new $cacheClass($this->specification->cache); $this->errorHandler = new $errorClass($this->specification->error); $this->request = new $requestClass($this->specification->request); $this->session = new $sessionClass($this->specification->session); $this->vsm = new $vsmClass($this->specification->vsmanager); $this->services = new $serviceManagerClass($this->specification->services); $this->session->start(); $userClass = $this->handlers['user']; if (!empty($userClass)) { if ($this->session->has($this->id . ':' . self::SESSION_USER)) { $this->user = pradoUnserializeObject($this->session->get($this->id . ':' . self::SESSION_USER)); } if (!$this->user instanceof IUser) { $this->user = new $userClass($this->specification->user); } if (!$this->user instanceof IUser) { throw new Exception('User class must implement IUser interface.'); } } // load the theme if one was declared in the app.spec file if (is_file($this->getThemeFile())) { $this->theme = $this->getResourceParser()->parseTheme(file_get_contents($this->getThemeFile())); } //globalization should be last, it may require Request, Session, Resource and User if ($this->specification->globalization->length) { $this->globalization = new $globalizationClass($this->specification->globalization); } }
public function bind_nexists_user() { $username = IFilter::act(IReq::get('username')); $email = IFilter::act(IReq::get('email')); $oauth_id = IFilter::act(ISession::get('oauth_id')); $oauth_userInfo = IFilter::act(ISession::get('oauth_userInfo')); /*注册信息校验*/ if (IValidate::email($email) == false) { $message = '邮箱格式不正确'; } else { if (!Util::is_username($username)) { $message = '用户名必须是由2-20个字符,可以为字数,数字下划线和中文'; } else { $userObj = new IModel('user'); $where = 'email = "' . $email . '" or username = "******" or username = "******"'; $userRow = $userObj->getObj($where); if (!empty($userRow)) { if ($email == $userRow['email']) { $message = '此邮箱已经被注册过,请重新更换'; } else { $message = "此用户名已经被注册过,请重新更换"; } } else { $userData = array('email' => $email, 'username' => $username, 'password' => md5(ITime::getDateTime())); $userObj->setData($userData); $user_id = $userObj->add(); $memberObj = new IModel('member'); $memberData = array('user_id' => $user_id, 'true_name' => $oauth_userInfo['name'], 'last_login' => ITime::getDateTime(), 'sex' => isset($oauth_userInfo['sex']) ? $oauth_userInfo['sex'] : 1, 'time' => ITime::getDateTime()); $memberObj->setData($memberData); $memberObj->add(); $oauthUserObj = new IModel('oauth_user'); //插入关系表 $oauthUserData = array('oauth_user_id' => $oauth_userInfo['id'], 'oauth_id' => $oauth_id, 'user_id' => $user_id, 'datetime' => ITime::getDateTime()); $oauthUserObj->setData($oauthUserData); $oauthUserObj->add(); $userRow = CheckRights::isValidUser($userData['email'], $userData['password']); CheckRights::loginAfter($userRow); //自定义跳转页面 $callback = ISafe::get('callback'); $this->redirect('/site/success?message=' . urlencode("注册成功!") . '&callback=' . $callback); } } } if ($message != '') { $this->message = $message; $this->redirect('bind_user', false); } }
public function clear() { $cartName = $this->getCartName(); if ($this->saveType == 'session') { ISession::clear($cartName); } else { ICookie::clear($cartName); } }