本文整理汇总了PHP中OAuthUtil::urldecode_rfc3986方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuthUtil::urldecode_rfc3986方法的具体用法?PHP OAuthUtil::urldecode_rfc3986怎么用?PHP OAuthUtil::urldecode_rfc3986使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OAuthUtil
的用法示例。
在下文中一共展示了OAuthUtil::urldecode_rfc3986方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_parameters
public static function parse_parameters($input)
{
if (!isset($input) || !$input) {
return array();
}
$pairs = split('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = split('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
示例2: split_header
public static function split_header($header, $only_allow_oauth_parameters = true)
{
$params = array();
if (preg_match_all('/(' . ($only_allow_oauth_parameters ? 'oauth_' : '') . '[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
foreach ($matches[1] as $i => $h) {
$params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
}
return $params;
}
示例3: testUrldecode
public function testUrldecode()
{
// Tests taken from
// http://wiki.oauth.net/TestCases ("Parameter Encoding")
$this->assertEquals('abcABC123', OAuthUtil::urldecode_rfc3986('abcABC123'));
$this->assertEquals('-._~', OAuthUtil::urldecode_rfc3986('-._~'));
$this->assertEquals('%', OAuthUtil::urldecode_rfc3986('%25'));
$this->assertEquals('+', OAuthUtil::urldecode_rfc3986('%2B'));
$this->assertEquals("\n", OAuthUtil::urldecode_rfc3986('%0A'));
$this->assertEquals(' ', OAuthUtil::urldecode_rfc3986('%20'));
$this->assertEquals("", OAuthUtil::urldecode_rfc3986('%7F'));
//$this->assertEquals("\x00\x80", OAuthUtil::urldecode_rfc3986('%C2%80'));
//$this->assertEquals("\x30\x01", OAuthUtil::urldecode_rfc3986('%E3%80%81'));
// Last two checks disabled because of lack of UTF-8 support, or lack
// of knowledge from me (morten.fangel) on how to use it properly..
}
示例4: lti_parse_request_OLD
function lti_parse_request_OLD($wp)
{
if (!is_basic_lti_request()) {
$good_message_type = $_REQUEST[LTI_MESSAGE_TYPE] == LTI_MESSAGE_TYPE_VALUE;
$good_lti_version = $_REQUEST[LTI_VERSION] == LTI_VERSION_VALUE;
$resource_link_id = $_REQUEST[RESOURCE_LINK_ID];
if ($good_message_type && $good_lti_version && !isset($resource_link_id)) {
$launch_presentation_return_url = $_REQUEST[LAUNCH_PRESENTATION_URL];
if (isset($launch_presentation_return_url)) {
header('Location: ' . $launch_presentation_return_url);
exit;
}
}
return;
}
// See if we get a context, do not set session, do not redirect
$secret = lti_get_secret_from_consumer_key();
$context = new bltiUocWrapper(false, false, null, $secret);
if (!$context->valid) {
//var_dump($_POST);
echo "<hr>OAuthUtil::urldecode_rfc3986('%2B') " . OAuthUtil::urldecode_rfc3986('%2B') . "<br>";
echo "<hr>OAuthUtil::urldecode_rfc3986('%5C') " . OAuthUtil::urldecode_rfc3986('%5C') . "<br>";
wp_die("BASIC LTI Authentication Failed, not valid request (make sure that consumer is authorized and secret is correct) " . $context->message);
return;
}
$error = is_lti_error_data($context);
if ($error !== FALSE) {
$launch_presentation_return_url = $_REQUEST[LAUNCH_PRESENTATION_URL];
if (isset($launch_presentation_return_url)) {
$error = '<p>' . $error . '</p><p>Return to site <a href="' . $launch_presentation_return_url . '">' . $launch_presentation_return_url . '</a></p>';
}
wp_die($error, '');
}
$blogType = new blogTypeLoader($context);
if ($blogType->error < 0) {
wp_die("BASIC LTI loading Types Aula Failed " . $blogType->error_miss);
return;
}
// Set up the user...
$userkey = getUserkeyLTI($context);
$userkey = apply_filters('pre_user_login', $userkey);
$userkey = trim($userkey);
if (empty($userkey)) {
wp_die('<p>Empty username</p><p>Cannot create a user without username</p>');
}
$uinfo = get_user_by('login', $userkey);
if (isset($uinfo) && $uinfo != false) {
// og LTI: set the user_login and user_nicename to the same value,
// , because we want the wordpress-login cookie to have the username
// otherwise caching won't work properly!
$ret_id = wp_insert_user(array('ID' => $uinfo->ID, 'user_login' => $userkey, 'user_nicename' => $userkey, 'first_name' => $context->getUserFirstName(), 'last_name' => $context->getUserLastName(), 'user_email' => $context->getUserEmail(), 'user_url' => 'http://b', 'display_name' => $context->getUserName(), 'role' => get_option('default_role')));
//error_log("og old role is set");
if (is_object($ret_id) && isset($ret_id->errors)) {
$msg = '';
foreach ($ret_id->errors as $key => $error) {
$msg .= "<p><b>{$key}</b> ";
foreach ($error as $erroMsg) {
$msg .= "<p> {$erroMsg}</p>";
}
$msg .= "</p>";
}
wp_die($msg);
}
} else {
// new user!!!!
$ret_id = wp_insert_user(array('user_login' => $userkey, 'user_nicename' => $context->getUserName(), 'first_name' => $context->getUserFirstName(), 'last_name' => $context->getUserLastName(), 'user_email' => $context->getUserEmail(), 'user_url' => 'http://c', 'display_name' => $context->getUserName()));
if (is_object($ret_id) && isset($ret_id->errors)) {
$msg = '';
foreach ($ret_id->errors as $key => $error) {
$msg .= "<p><b>{$key}</b> ";
foreach ($error as $erroMsg) {
$msg .= "<p> {$erroMsg}</p>";
}
$msg .= "</p>";
}
wp_die($msg);
}
$uinfo = get_user_by('login', $userkey);
}
//Eliminem del blog Principal (si no es admin) http://jira.uoc.edu/jira/browse/BLOGA-218
if (!$is_admin) {
$user = new WP_User($uinfo->ID);
$user->remove_all_caps();
}
$_SERVER['REMOTE_USER'] = $userkey;
$password = md5($uinfo->user_pass);
// User is now authorized; force WordPress to use the generated password
//login, set cookies, and set current user
wp_authenticate($userkey, $password);
wp_set_auth_cookie($user->ID, false);
wp_set_current_user($user->ID, $userkey);
$siteUrl = substr(get_option("siteurl"), 7);
// - "http://"
$siteUrlArray = explode("/", $siteUrl);
$domain = $siteUrlArray[0];
unset($siteUrlArray[0]);
//error_log("og LTI domain: ". $domain);
$course = $blogType->getCoursePath($context, $siteUrlArray, $domain);
if (isset($context->info[RESOURCE_LINK_ID]) && $context->info[RESOURCE_LINK_ID]) {
$course .= '-' . $context->info[RESOURCE_LINK_ID];
//.........这里部分代码省略.........
示例5: split_header
/**
* util function for turning the Authorization: header into
* parameters, has to do some unescaping
*/
private static function split_header($header)
{
/*{{{*/
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = isset($matches[5]) ? $matches[5][0] : $matches[4][0];
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
示例6: parse_parameters
public static function parse_parameters($input)
{
if (!isset($input) || !$input) {
return array();
}
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
// Addition - KH
// only accept parameters prefixed with 'oauth', this allows additional GET parameters to be used by the script
if (!preg_match("/^oauth_/i", $split[0])) {
continue;
}
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
示例7: parse_parameters
public static function parse_parameters($input)
{
if (!isset($input) || !$input) {
return array();
}
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
if (is_scalar($parsed_parameters[$parameter])) {
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
示例8: split_header
static function split_header($header, $only_allow_oauth_parameters = true) {
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
$offset = 0;
$params = array();
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$match = $matches[0];
$header_name = $matches[2][0];
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
$params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
}
$offset = $match[1] + strlen($match[0]);
}
if (isset($params['realm'])) {
unset($params['realm']);
}
return $params;
}
示例9: parse_parameters
public static function parse_parameters($input)
{
//var_dump($input);
if (!isset($input) || !$input) {
return array();
}
if (substr($input, 0, 5) == '<?xml') {
return (array) @simplexml_load_string($input);
}
if (preg_match('/^[\\{\\[]/', $input)) {
return @json_decode($input, true);
}
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = trim(OAuthUtil::urldecode_rfc3986($split[0]));
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}
示例10: parse_parameters
public static function parse_parameters($input)
{
if (!isset($input) || !$input) {
return array();
}
$pairs = explode('&', $input);
$parsed_parameters = array();
foreach ($pairs as $pair) {
$split = explode('=', $pair, 2);
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
// if we received an empty parameter (can happen with sth like "...php?&key=v..."
// which we do not send with our signedrequests, we omit it from the signature
// as well
if (!$parameter) {
continue;
}
if (isset($parsed_parameters[$parameter])) {
// We have already recieved parameter(s) with this name, so add to the list
// of parameters with this name
if (is_scalar($parsed_parameters[$parameter])) {
// This is the first duplicate, so transform scalar (string) into an array
// so we can add the duplicates
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
}
$parsed_parameters[$parameter][] = $value;
} else {
$parsed_parameters[$parameter] = $value;
}
}
return $parsed_parameters;
}