summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-02-14 01:03:46 +0000
committertailor <cygnus@janrain.com>2006-02-14 01:03:46 +0000
commit7a6b92642e5be25033846ac49ece447eda526701 (patch)
tree88220f416931aabf63f7758f976a2079edbfa9a2
parent480ae2abfc23162453d7d675f782858c14fa46ab (diff)
downloadphp-openid-7a6b92642e5be25033846ac49ece447eda526701.zip
php-openid-7a6b92642e5be25033846ac49ece447eda526701.tar.gz
php-openid-7a6b92642e5be25033846ac49ece447eda526701.tar.bz2
[project @ Moved arrayGet from Util to OpenID]
-rw-r--r--Auth/OpenID.php20
-rw-r--r--Auth/OpenID/Consumer.php30
-rw-r--r--Auth/OpenID/Parse.php8
-rw-r--r--Auth/OpenID/Util.php20
4 files changed, 39 insertions, 39 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php
index d46e808..60bcb6f 100644
--- a/Auth/OpenID.php
+++ b/Auth/OpenID.php
@@ -139,6 +139,26 @@ class Auth_OpenID {
}
}
}
+
+ /**
+ * Convenience function for getting array values.
+ *
+ * @access private
+ */
+ function arrayGet($arr, $key, $fallback = null)
+ {
+ if (is_array($arr)) {
+ if (array_key_exists($key, $arr)) {
+ return $arr[$key];
+ } else {
+ return $fallback;
+ }
+ } else {
+ trigger_error("Auth_OpenID::arrayGet expected " .
+ "array as first parameter", E_USER_WARNING);
+ return false;
+ }
+ }
}
?> \ No newline at end of file
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php
index caf1b52..2a8561e 100644
--- a/Auth/OpenID/Consumer.php
+++ b/Auth/OpenID/Consumer.php
@@ -510,13 +510,13 @@ class Auth_OpenID_Consumer {
{
$query = Auth_OpenID::fixArgs($query);
- $mode = Auth_OpenID_arrayGet($query, 'openid.mode', '');
+ $mode = Auth_OpenID::arrayGet($query, 'openid.mode', '');
if ($mode == 'cancel') {
return array(Auth_OpenID_SUCCESS, null);
} elseif ($mode == 'error') {
- $error = Auth_OpenID_arrayGet($query, 'openid.error', null);
+ $error = Auth_OpenID::arrayGet($query, 'openid.error', null);
if ($error !== null) {
trigger_error("In OpenID completeAuth: $error", E_USER_NOTICE);
@@ -545,9 +545,9 @@ class Auth_OpenID_Consumer {
list($nonce, $consumer_id, $server_id, $server_url) = $ret;
- $return_to = Auth_OpenID_arrayGet($query, 'openid.return_to', null);
- $server_id2 = Auth_OpenID_arrayGet($query, 'openid.identity', null);
- $assoc_handle = Auth_OpenID_arrayGet($query,
+ $return_to = Auth_OpenID::arrayGet($query, 'openid.return_to', null);
+ $server_id2 = Auth_OpenID::arrayGet($query, 'openid.identity', null);
+ $assoc_handle = Auth_OpenID::arrayGet($query,
'openid.assoc_handle', null);
if (($return_to === null) ||
@@ -560,7 +560,7 @@ class Auth_OpenID_Consumer {
return array(Auth_OpenID_FAILURE, $consumer_id);
}
- $user_setup_url = Auth_OpenID_arrayGet($query,
+ $user_setup_url = Auth_OpenID::arrayGet($query,
'openid.user_setup_url', null);
if ($user_setup_url !== null) {
@@ -579,8 +579,8 @@ class Auth_OpenID_Consumer {
}
// Check the signature
- $sig = Auth_OpenID_arrayGet($query, 'openid.sig', null);
- $signed = Auth_OpenID_arrayGet($query, 'openid.signed', null);
+ $sig = Auth_OpenID::arrayGet($query, 'openid.sig', null);
+ $signed = Auth_OpenID::arrayGet($query, 'openid.signed', null);
if (($sig === null) ||
($signed === null)) {
return array(Auth_OpenID_FAILURE, $consumer_id);
@@ -605,7 +605,7 @@ class Auth_OpenID_Consumer {
*/
function _checkAuth($nonce, $query, $server_url)
{
- $signed = Auth_OpenID_arrayGet($query, 'openid.signed', null);
+ $signed = Auth_OpenID::arrayGet($query, 'openid.signed', null);
if ($signed === null) {
return Auth_OpenID_FAILURE;
}
@@ -632,10 +632,10 @@ class Auth_OpenID_Consumer {
}
$results = Auth_OpenID_KVForm::toArray($ret[2]);
- $is_valid = Auth_OpenID_arrayGet($results, 'is_valid', 'false');
+ $is_valid = Auth_OpenID::arrayGet($results, 'is_valid', 'false');
if ($is_valid == 'true') {
- $invalidate_handle = Auth_OpenID_arrayGet($results,
+ $invalidate_handle = Auth_OpenID::arrayGet($results,
'invalidate_handle',
null);
if ($invalidate_handle !== null) {
@@ -650,7 +650,7 @@ class Auth_OpenID_Consumer {
return Auth_OpenID_SUCCESS;
}
- $error = Auth_OpenID_arrayGet($results, 'error', null);
+ $error = Auth_OpenID::arrayGet($results, 'error', null);
if ($error !== null) {
$msg = sprintf("Error message from server during " .
"check_authentication: %s", $error);
@@ -772,7 +772,7 @@ class Auth_OpenID_Consumer {
list($http_code, $url, $data) = $ret;
$results = Auth_OpenID_KVForm::toArray($data);
if ($http_code == 400) {
- $error = Auth_OpenID_arrayGet($results, 'error',
+ $error = Auth_OpenID::arrayGet($results, 'error',
'<no message from server>');
$fmt = 'Getting association: error returned from server %s: %s';
@@ -816,10 +816,10 @@ class Auth_OpenID_Consumer {
}
$assoc_handle = $results['assoc_handle'];
- $expires_in = intval(Auth_OpenID_arrayGet($results, 'expires_in',
+ $expires_in = intval(Auth_OpenID::arrayGet($results, 'expires_in',
'0'));
- $session_type = Auth_OpenID_arrayGet($results, 'session_type', null);
+ $session_type = Auth_OpenID::arrayGet($results, 'session_type', null);
if ($session_type === null) {
$secret = base64_decode($results['mac_key']);
} else {
diff --git a/Auth/OpenID/Parse.php b/Auth/OpenID/Parse.php
index 999c032..48b1c31 100644
--- a/Auth/OpenID/Parse.php
+++ b/Auth/OpenID/Parse.php
@@ -80,9 +80,9 @@
*/
/**
- * Require Auth_OpenID_arrayGet.
+ * Require Auth_OpenID::arrayGet().
*/
-require_once "Util.php";
+require_once "Auth/OpenID.php";
class Auth_OpenID_Parse {
@@ -252,7 +252,7 @@ class Auth_OpenID_Parse {
{
// Does this link have target_rel as a relationship?
// XXX: TESTME
- $rel_attr = Auth_OpeniD_arrayGet($link_attrs, 'rel', null);
+ $rel_attr = Auth_OpeniD::arrayGet($link_attrs, 'rel', null);
return ($rel_attr && $this->relMatches($rel_attr,
$target_rel));
}
@@ -283,7 +283,7 @@ class Auth_OpenID_Parse {
return null;
}
$first = $matches[0];
- return Auth_OpenID_arrayGet($first, 'href', null);
+ return Auth_OpenID::arrayGet($first, 'href', null);
}
}
diff --git a/Auth/OpenID/Util.php b/Auth/OpenID/Util.php
index 6894ca1..7dd2859 100644
--- a/Auth/OpenID/Util.php
+++ b/Auth/OpenID/Util.php
@@ -21,26 +21,6 @@ $_Auth_OpenID_digits = "0123456789";
$_Auth_OpenID_punct = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
/**
- * Convenience function for getting array values.
- *
- * @access private
- */
-function Auth_OpenID_arrayGet($arr, $key, $fallback = null)
-{
- if (is_array($arr)) {
- if (array_key_exists($key, $arr)) {
- return $arr[$key];
- } else {
- return $fallback;
- }
- } else {
- trigger_error("Auth_OpenID_arrayGet expected " .
- "array as first parameter", E_USER_WARNING);
- return false;
- }
-}
-
-/**
* Implements the PHP 5 'http_build_query' functionality.
*
* @access private