本文整理汇总了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')) );
}
示例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_'));
//.........这里部分代码省略.........
示例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));