| 1 |
<?php |
<?php |
| 2 |
// $Id: openid.inc,v 1.2.2.2 2007/05/24 15:01:21 walkah Exp $ |
// $Id: openid.inc,v 1.2.2.3 2007/10/14 20:19:21 walkah Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 193 |
$rel = preg_quote($rel); |
$rel = preg_quote($rel); |
| 194 |
preg_match('|<link\s+rel=["\'](.*)'. $rel .'(.*)["\'](.*)/?>|iU', $html, $matches); |
preg_match('|<link\s+rel=["\'](.*)'. $rel .'(.*)["\'](.*)/?>|iU', $html, $matches); |
| 195 |
if (isset($matches[3])) { |
if (isset($matches[3])) { |
| 196 |
preg_match('|href=["\']([^"]+)["\']|iU', $matches[0], $href); |
preg_match('|href=["\']([^"]+)["\']|iU', $matches[3], $href); |
| 197 |
return trim($href[1]); |
return trim($href[1]); |
| 198 |
} |
} |
| 199 |
return FALSE; |
return FALSE; |
| 206 |
preg_match('|<meta\s+http-equiv=["\']'. $equiv .'["\'](.*)/?>|iU', $html, $matches); |
preg_match('|<meta\s+http-equiv=["\']'. $equiv .'["\'](.*)/?>|iU', $html, $matches); |
| 207 |
if (isset($matches[1])) { |
if (isset($matches[1])) { |
| 208 |
preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content); |
preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content); |
| 209 |
return $content[1]; |
if (isset($content[1])) { |
| 210 |
|
return $content[1]; |
| 211 |
|
} |
| 212 |
} |
} |
| 213 |
return FALSE; |
return FALSE; |
| 214 |
} |
} |
| 384 |
return $bytes; |
return $bytes; |
| 385 |
} |
} |
| 386 |
|
|
| 387 |
/** |
function _openid_response($str = NULL) { |
| 388 |
* Fix PHP's habit of replacing '.' by '_' in posted data. |
$data = array(); |
| 389 |
*/ |
|
| 390 |
function _openid_fix_post(&$post) { |
if (isset($_SERVER['REQUEST_METHOD'])) { |
| 391 |
$extensions = module_invoke_all('openid', 'extension'); |
$data = _openid_get_params($_SERVER['QUERY_STRING']); |
| 392 |
foreach ($post as $key => $value) { |
|
| 393 |
if (strpos($key, 'openid_') === 0) { |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
| 394 |
$fixed_key = str_replace('openid_', 'openid.', $key); |
$str = file_get_contents('php://input'); |
| 395 |
$fixed_key = str_replace('openid.ns_', 'openid.ns.', $fixed_key); |
|
| 396 |
$fixed_key = str_replace('openid.sreg_', 'openid.sreg.', $fixed_key); |
$post = array(); |
| 397 |
foreach ($extensions as $ext) { |
if ($str !== false) { |
| 398 |
$fixed_key = str_replace('openid.'.$ext.'_', 'openid.'.$ext.'.', $fixed_key); |
$post = _openid_get_params($str); |
| 399 |
} |
} |
| 400 |
unset($post[$key]); |
|
| 401 |
$post[$fixed_key] = $value; |
$data = array_merge($data, $post); |
| 402 |
|
} |
| 403 |
|
} |
| 404 |
|
|
| 405 |
|
return $data; |
| 406 |
|
} |
| 407 |
|
|
| 408 |
|
function _openid_get_params($str) { |
| 409 |
|
$chunks = explode("&", $str); |
| 410 |
|
|
| 411 |
|
$data = array(); |
| 412 |
|
foreach ($chunks as $chunk) { |
| 413 |
|
$parts = explode("=", $chunk, 2); |
| 414 |
|
|
| 415 |
|
if (count($parts) == 2) { |
| 416 |
|
list($k, $v) = $parts; |
| 417 |
|
$data[$k] = urldecode($v); |
| 418 |
} |
} |
| 419 |
} |
} |
| 420 |
|
return $data; |
| 421 |
} |
} |
| 422 |
|
|
| 423 |
/** |
/** |