23 define(
'Auth_OpenID_VERSION',
'2.2.2');
28 require_once
"Auth/Yadis/PlainHTTPFetcher.php";
29 require_once
"Auth/Yadis/ParanoidHTTPFetcher.php";
30 require_once
"Auth/OpenID/BigMath.php";
31 require_once
"Auth/OpenID/URINorm.php";
41 define(
'Auth_OpenID_LOCAL_ERROR',
'local_error');
50 define(
'Auth_OpenID_REMOTE_ERROR',
'remote_error');
60 define(
'Auth_OpenID_REMOTE_OK',
'remote_ok');
70 define(
'Auth_OpenID_REDIRECT',
'redirect');
81 define(
'Auth_OpenID_DO_AUTH',
'do_auth');
91 define(
'Auth_OpenID_DO_ABOUT',
'do_about');
96 define(
'Auth_OpenID_letters',
97 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
99 define(
'Auth_OpenID_digits',
102 define(
'Auth_OpenID_punct',
103 "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
123 return is_a($thing,
'Auth_OpenID_FailureResponse');
145 static function getQuery($query_str=null)
149 if ($query_str !== null) {
151 }
else if (!array_key_exists(
'REQUEST_METHOD', $_SERVER)) {
165 if ($_SERVER[
'REQUEST_METHOD'] ==
'POST') {
166 $str = file_get_contents(
'php://input');
168 if ($str ===
false) {
183 $chunks = explode(
"&", $str);
186 foreach ($chunks as $chunk) {
187 $parts = explode(
"=", $chunk, 2);
189 if (count($parts) != 2) {
193 list($k, $v) = $parts;
194 $data[urldecode($k)] = urldecode($v);
209 if (is_dir($dir_name) || @mkdir($dir_name)) {
212 $parent_dir = dirname($dir_name);
215 if ($parent_dir == $dir_name) {
229 static function addPrefix($values, $prefix)
231 $new_values = array();
232 foreach ($values as $s) {
233 $new_values[] = $prefix . $s;
247 if (is_array($arr)) {
248 if (array_key_exists($key, $arr)) {
254 trigger_error(
"Auth_OpenID::arrayGet (key = ".$key.
") expected " .
255 "array as first parameter, got " .
256 gettype($arr), E_USER_WARNING);
271 $parts = explode(
'&',
$query);
273 $new_parts = array();
274 for ($i = 0; $i < count($parts); $i++) {
275 $pair = explode(
'=', $parts[$i]);
277 if (count($pair) != 2) {
281 list($key, $value) = $pair;
282 $new_parts[urldecode($key)] = urldecode($value);
302 foreach (
$data as $key => $value) {
303 if (is_array($value)) {
304 $pairs[] = urlencode($value[0]).
"=".urlencode($value[1]);
306 $pairs[] = urlencode($key).
"=".urlencode($value);
309 return implode(
"&", $pairs);
329 if (count($args) == 0) {
335 if (array_key_exists(0, $args) &&
336 is_array($args[0])) {
339 $keys = array_keys($args);
342 foreach ($keys as $key) {
343 $new_args[] = array($key, $args[$key]);
349 if (strpos($url,
'?') !==
false) {
372 $query =
'', $fragment =
'')
387 $result = $scheme .
"://" . $host;
390 $result .=
":" . $port;
400 $result .=
"#" . $fragment;
418 @$parsed = parse_url($url);
424 if (isset($parsed[
'scheme']) &&
425 isset($parsed[
'host'])) {
426 $scheme = strtolower($parsed[
'scheme']);
427 if (!in_array($scheme, array(
'http',
'https'))) {
431 $url =
'http://' . $url;
435 if ($normalized === null) {
447 static function intval($value)
451 if (!preg_match($re, $value)) {
465 static function bytes($str)
467 return strlen(bin2hex($str)) / 2;
476 $hex = bin2hex($str);
483 for ($i = 0; $i < strlen($hex); $i += 2) {
484 $b[] = chr(base_convert(substr($hex, $i, 2), 16, 10));
492 $parts = explode(
"#", $url, 2);
494 if (count($parts) == 1) {
495 return array($parts[0],
"");
501 static function filter($callback, &$sequence)
505 foreach ($sequence as $item) {
506 if (call_user_func_array($callback, array($item))) {
514 static function update(&$dest, &$src)
516 foreach ($src as $k => $v) {
528 static function log($format_string)
530 $args = func_get_args();
531 $message = call_user_func_array(
'sprintf', $args);
541 "<body onload='document.forms[0].submit();'>".
544 "var elements = document.forms[0].elements;".
545 "for (var i = 0; i < elements.length; i++) {".
546 " elements[i].style.display = \"none\";".