?? openid.php
字號(hào):
{ $pairs = array(); foreach ($data as $key => $value) { if (is_array($value)) { $pairs[] = urlencode($value[0])."=".urlencode($value[1]); } else { $pairs[] = urlencode($key)."=".urlencode($value); } } return implode("&", $pairs); } /** * "Appends" query arguments onto a URL. The URL may or may not * already have arguments (following a question mark). * * @access private * @param string $url A URL, which may or may not already have * arguments. * @param array $args Either an array key/value pairs or an array of * arrays, each of which holding two values: a key and a value, * sequentially. If $args is an ordinary key/value array, the * parameters will be added to the URL in sorted alphabetical order; * if $args is an array of arrays, their order will be preserved. * @return string $url The original URL with the new parameters added. * */ function appendArgs($url, $args) { if (count($args) == 0) { return $url; } // Non-empty array; if it is an array of arrays, use // multisort; otherwise use sort. if (array_key_exists(0, $args) && is_array($args[0])) { // Do nothing here. } else { $keys = array_keys($args); sort($keys); $new_args = array(); foreach ($keys as $key) { $new_args[] = array($key, $args[$key]); } $args = $new_args; } $sep = '?'; if (strpos($url, '?') !== false) { $sep = '&'; } return $url . $sep . Auth_OpenID::httpBuildQuery($args); } /** * Turn a string into an ASCII string. * * Replace non-ascii characters with a %-encoded, UTF-8 * encoding. This function will fail if the input is a string and * there are non-7-bit-safe characters. It is assumed that the * caller will have already translated the input into a Unicode * character sequence, according to the encoding of the HTTP POST * or GET. * * Do not escape anything that is already 7-bit safe, so we do the * minimal transform on the identity URL * * @access private */ function quoteMinimal($s) { $res = array(); for ($i = 0; $i < strlen($s); $i++) { $c = $s[$i]; if ($c >= "\x80") { for ($j = 0; $j < count(utf8_encode($c)); $j++) { array_push($res, sprintf("%02X", ord($c[$j]))); } } else { array_push($res, $c); } } return implode('', $res); } /** * Implements python's urlunparse, which is not available in PHP. * Given the specified components of a URL, this function rebuilds * and returns the URL. * * @access private * @param string $scheme The scheme (e.g. 'http'). Defaults to 'http'. * @param string $host The host. Required. * @param string $port The port. * @param string $path The path. * @param string $query The query. * @param string $fragment The fragment. * @return string $url The URL resulting from assembling the * specified components. */ function urlunparse($scheme, $host, $port = null, $path = '/', $query = '', $fragment = '') { if (!$scheme) { $scheme = 'http'; } if (!$host) { return false; } if (!$path) { $path = ''; } $result = $scheme . "://" . $host; if ($port) { $result .= ":" . $port; } $result .= $path; if ($query) { $result .= "?" . $query; } if ($fragment) { $result .= "#" . $fragment; } return $result; } /** * Given a URL, this "normalizes" it by adding a trailing slash * and / or a leading http:// scheme where necessary. Returns * null if the original URL is malformed and cannot be normalized. * * @access private * @param string $url The URL to be normalized. * @return mixed $new_url The URL after normalization, or null if * $url was malformed. */ function normalizeUrl($url) { if ($url === null) { return null; } assert(is_string($url)); $old_url = $url; $url = trim($url); if (strpos($url, "://") === false) { $url = "http://" . $url; } $parsed = @parse_url($url); if ($parsed === false) { return null; } $defaults = array( 'scheme' => '', 'host' => '', 'path' => '', 'query' => '', 'fragment' => '', 'port' => '' ); $parsed = array_merge($defaults, $parsed); if (($parsed['scheme'] == '') || ($parsed['host'] == '')) { if ($parsed['path'] == '' && $parsed['query'] == '') { return null; } $url = 'http://' + $url; $parsed = parse_url($url); $parsed = array_merge($defaults, $parsed); } $tail = array_map(array('Auth_OpenID', 'quoteMinimal'), array($parsed['path'], $parsed['query'])); if ($tail[0] == '') { $tail[0] = '/'; } $url = Auth_OpenID::urlunparse($parsed['scheme'], $parsed['host'], $parsed['port'], $tail[0], $tail[1]); assert(is_string($url)); return $url; } /** * Replacement (wrapper) for PHP's intval() because it's broken. * * @access private */ function intval($value) { $re = "/^\\d+$/"; if (!preg_match($re, $value)) { return false; } return intval($value); } /** * Count the number of bytes in a string independently of * multibyte support conditions. * * @param string $str The string of bytes to count. * @return int The number of bytes in $str. */ function bytes($str) { return strlen(bin2hex($str)) / 2; } /** * Get the bytes in a string independently of multibyte support * conditions. */ function toBytes($str) { $hex = bin2hex($str); if (!$hex) { return array(); } $b = array(); for ($i = 0; $i < strlen($hex); $i += 2) { $b[] = chr(base_convert(substr($hex, $i, 2), 16, 10)); } return $b; } function urldefrag($url) { $parts = explode("#", $url, 2); if (count($parts) == 1) { return array($parts[0], ""); } else { return $parts; } } function filter($callback, &$sequence) { $result = array(); foreach ($sequence as $item) { if (call_user_func_array($callback, array($item))) { $result[] = $item; } } return $result; } function update(&$dest, &$src) { foreach ($src as $k => $v) { $dest[$k] = $v; } }}?>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -