當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_OpenId::paramsToQuery方法代碼示例

本文整理匯總了PHP中Zend_OpenId::paramsToQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_OpenId::paramsToQuery方法的具體用法?PHP Zend_OpenId::paramsToQuery怎麽用?PHP Zend_OpenId::paramsToQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_OpenId的用法示例。


在下文中一共展示了Zend_OpenId::paramsToQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testParamsToQuery

 /**
  * testing testParamsToQuery
  *
  */
 public function testParamsToQuery()
 {
     $this->assertSame( '', Zend_OpenId::paramsToQuery(array()) );
     $this->assertSame( 'a=1', Zend_OpenId::paramsToQuery(array('a'=>1)) );
     $this->assertSame( 'a=1&b=2', Zend_OpenId::paramsToQuery(array('a'=>1,'b'=>2)) );
     $this->assertSame( 'a=x+y', Zend_OpenId::paramsToQuery(array('a'=>'x y')) );
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:11,代碼來源:OpenIdTest.php

示例2: _checkId

 /**
  * Performs authentication (or authentication check).
  *
  * @param float $version OpenID version
  * @param array $params GET or POST request variables
  * @param bool $immediate enables or disables interaction with user
  * @param mixed $extensions extension object or array of extensions objects
  * @param Zend_Controller_Response_Abstract $response
  * @return array
  */
 protected function _checkId($version, $params, $immediate, $extensions = null, Zend_Controller_Response_Abstract $response = null)
 {
     $ret = array();
     if ($version >= 2.0) {
         $ret['openid.ns'] = Zend_OpenId::NS_2_0;
     }
     $root = $this->getSiteRoot($params);
     if ($root === false) {
         return false;
     }
     if (isset($params['openid_identity']) && !$this->_storage->hasUser($params['openid_identity'])) {
         $ret['openid.mode'] = $immediate && $version >= 2.0 ? 'setup_needed' : 'cancel';
         return $ret;
     }
     /* Check if user already logged in into the server */
     if (!isset($params['openid_identity']) || $this->_user->getLoggedInUser() !== $params['openid_identity']) {
         $params2 = array();
         foreach ($params as $key => $val) {
             if (strpos($key, 'openid_ns_') === 0) {
                 $key = 'openid.ns.' . substr($key, strlen('openid_ns_'));
             } else {
                 if (strpos($key, 'openid_sreg_') === 0) {
                     $key = 'openid.sreg.' . substr($key, strlen('openid_sreg_'));
                 } else {
                     if (strpos($key, 'openid_') === 0) {
                         $key = 'openid.' . substr($key, strlen('openid_'));
                     }
                 }
             }
             $params2[$key] = $val;
         }
         if ($immediate) {
             $params2['openid.mode'] = 'checkid_setup';
             $ret['openid.mode'] = $version >= 2.0 ? 'setup_needed' : 'id_res';
             $ret['openid.user_setup_url'] = $this->_loginUrl . (strpos($this->_loginUrl, '?') === false ? '?' : '&') . Zend_OpenId::paramsToQuery($params2);
             return $ret;
         } else {
             /* Redirect to Server Login Screen */
             Zend_OpenId::redirect($this->_loginUrl, $params2, $response);
             return true;
         }
     }
     if (!Zend_OpenId_Extension::forAll($extensions, 'parseRequest', $params)) {
         $ret['openid.mode'] = $immediate && $version >= 2.0 ? 'setup_needed' : 'cancel';
         return $ret;
     }
     /* Check if user trusts to the consumer */
     $trusted = null;
     $sites = $this->_storage->getTrustedSites($params['openid_identity']);
     if (isset($params['openid_return_to'])) {
         $root = $params['openid_return_to'];
     }
     if (isset($sites[$root])) {
         $trusted = $sites[$root];
     } else {
         foreach ($sites as $site => $t) {
             if (strpos($root, $site) === 0) {
                 $trusted = $t;
                 break;
             } else {
                 /* OpenID 2.0 (9.2) check for realm wild-card matching */
                 $n = strpos($site, '://*.');
                 if ($n != false) {
                     $regex = '/^' . preg_quote(substr($site, 0, $n + 3), '/') . '[A-Za-z1-9_\\.]+?' . preg_quote(substr($site, $n + 4), '/') . '/';
                     if (preg_match($regex, $root)) {
                         $trusted = $t;
                         break;
                     }
                 }
             }
         }
     }
     if (is_array($trusted)) {
         if (!Zend_OpenId_Extension::forAll($extensions, 'checkTrustData', $trusted)) {
             $trusted = null;
         }
     }
     if ($trusted === false) {
         $ret['openid.mode'] = 'cancel';
         return $ret;
     } else {
         if ($trusted === null) {
             /* Redirect to Server Trust Screen */
             $params2 = array();
             foreach ($params as $key => $val) {
                 if (strpos($key, 'openid_ns_') === 0) {
                     $key = 'openid.ns.' . substr($key, strlen('openid_ns_'));
                 } else {
                     if (strpos($key, 'openid_sreg_') === 0) {
                         $key = 'openid.sreg.' . substr($key, strlen('openid_sreg_'));
//.........這裏部分代碼省略.........
開發者ID:chucky515,項目名稱:Magento-CE-Mirror,代碼行數:101,代碼來源:Provider.php

示例3: set_include_path

OCP\App::checkAppEnabled('user_openid_provider');
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/3rdparty');
require_once 'Zend/OpenId/Provider.php';
if (!isset($_REQUEST['openid_mode'])) {
    OC_Template::printGuestPage('user_openid_provider', 'main');
    die;
}
$session = new OC_OpenIdProviderUserSession();
$storage = new OC_OpenIdProviderStorage();
$server = new Zend_OpenId_Provider(null, null, $session, $storage);
if (OCP\User::isLoggedIn() and !$session->getLoggedInUser()) {
    $session->setLoggedInUser(OCP\Util::linkToAbsolute('', '?') . OCP\User::getUser());
}
if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'login') {
    unset($_GET['openid_action']);
    $params = '?' . Zend_OpenId::paramsToQuery($_GET);
    $next = OCP\Util::linkToRemote('openid_provider') . $params;
    $loginPage = OCP\Util::linkToAbsolute('', 'index.php') . '?redirect_url=' . urlencode($next);
    header('Location: ' . $loginPage);
} else {
    if (isset($_GET['openid_action']) and $_GET['openid_action'] == 'trust') {
        OCP\User::checkLoggedIn();
        if (isset($_POST['allow'])) {
            if (isset($_POST['forever'])) {
                $server->allowSite($server->getSiteRoot($_GET));
            }
            $server->respondToConsumer($_GET);
        } else {
            if (isset($_POST['deny'])) {
                if (isset($_POST['forever'])) {
                    $server->denySite($server->getSiteRoot($_GET));
開發者ID:netcon-source,項目名稱:apps,代碼行數:31,代碼來源:provider.php


注:本文中的Zend_OpenId::paramsToQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。