summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-01-18 21:38:15 +0000
committertailor <cygnus@janrain.com>2006-01-18 21:38:15 +0000
commit5a390e4a940c2bf3e5aaabd32c6fe4893a2c4626 (patch)
treee634c3dca044fc5e61b789cd3553429999fde290
parentbbd89e668f542ab206eb62225a7af0f747e8f679 (diff)
downloadphp-openid-5a390e4a940c2bf3e5aaabd32c6fe4893a2c4626.zip
php-openid-5a390e4a940c2bf3e5aaabd32c6fe4893a2c4626.tar.gz
php-openid-5a390e4a940c2bf3e5aaabd32c6fe4893a2c4626.tar.bz2
[project @ Moved ensureDir function to OIDUtil and updated example script]
-rw-r--r--Auth/OpenID/OIDUtil.php14
-rw-r--r--Auth/OpenID/Store/FileStore.php22
-rw-r--r--examples/consumer.php9
3 files changed, 23 insertions, 22 deletions
diff --git a/Auth/OpenID/OIDUtil.php b/Auth/OpenID/OIDUtil.php
index 5a8c3b6..5107bf8 100644
--- a/Auth/OpenID/OIDUtil.php
+++ b/Auth/OpenID/OIDUtil.php
@@ -21,6 +21,20 @@ $_Auth_OpenID_digits = "0123456789";
$_Auth_OpenID_punct = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
/**
+ * Create dir_name as a directory if it does not exist. If it exists,
+ * make sure that it is, in fact, a directory. Returns true if the
+ * operation succeeded; false if not.
+ */
+function ensureDir($dir_name)
+{
+ if (@mkdir($dir_name) || is_dir($dir_name)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
* Convenience function for getting array values.
*/
function Auth_OpenID_array_get($arr, $key, $fallback = null)
diff --git a/Auth/OpenID/Store/FileStore.php b/Auth/OpenID/Store/FileStore.php
index 9505dc9..a45240b 100644
--- a/Auth/OpenID/Store/FileStore.php
+++ b/Auth/OpenID/Store/FileStore.php
@@ -135,20 +135,6 @@ function _removeIfPresent($filename)
}
/**
- * Create dir_name as a directory if it does not exist. If it exists,
- * make sure that it is, in fact, a directory. Returns true if the
- * operation succeeded; false if not.
- */
-function _ensureDir($dir_name)
-{
- if (@mkdir($dir_name) || is_dir($dir_name)) {
- return true;
- } else {
- return false;
- }
-}
-
-/**
* This is a filesystem-based store for OpenID associations and
* nonces. This store should be safe for use in concurrent systems on
* both windows and unix (excluding NFS filesystems). There are a
@@ -212,10 +198,10 @@ class Auth_OpenID_FileStore extends Auth_OpenID_OpenIDStore {
*/
function _setup()
{
- _ensureDir(dirname($this->auth_key_name));
- _ensureDir($this->nonce_dir);
- _ensureDir($this->association_dir);
- _ensureDir($this->temp_dir);
+ ensureDir(dirname($this->auth_key_name));
+ ensureDir($this->nonce_dir);
+ ensureDir($this->association_dir);
+ ensureDir($this->temp_dir);
}
/**
diff --git a/examples/consumer.php b/examples/consumer.php
index 7f7c6be..0915730 100644
--- a/examples/consumer.php
+++ b/examples/consumer.php
@@ -69,11 +69,12 @@ if ($store_type = 'pgsql') {
/**
- * Try to create the store directory.
+ * Try to create the store directory. ensureDir is provided by
+ * OIDUtil.php.
*/
- if (!_ensureDir($store_path)) {
- print "Could not create the FileStore directory '$store_path'. Please ".
- "check the effective permissions.";
+ if (!ensureDir($store_path)) {
+ print "Could not create the FileStore directory '$store_path'. ".
+ " Please check the effective permissions.";
exit(0);
}