summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-01-24 23:02:53 +0000
committertailor <cygnus@janrain.com>2006-01-24 23:02:53 +0000
commitd0e5c8ba3dec0d8054e0ed7c87c680ef17b96ec0 (patch)
tree7af2fcc7cab3b7c6648f6c6212e2cec567f6986c
parentc5d321de7dcf01587a251a6e0c34b9eb0070f4da (diff)
downloadphp-openid-d0e5c8ba3dec0d8054e0ed7c87c680ef17b96ec0.zip
php-openid-d0e5c8ba3dec0d8054e0ed7c87c680ef17b96ec0.tar.gz
php-openid-d0e5c8ba3dec0d8054e0ed7c87c680ef17b96ec0.tar.bz2
[project @ Removed extra store example code from consumer demo to help simplify script.]
-rw-r--r--examples/consumer.php145
1 files changed, 17 insertions, 128 deletions
diff --git a/examples/consumer.php b/examples/consumer.php
index 12bf669..9aa60da 100644
--- a/examples/consumer.php
+++ b/examples/consumer.php
@@ -11,139 +11,28 @@
require_once "Auth/OpenID/Consumer/Consumer.php";
/**
- * Create the OpenID store and consumer objects, which we'll use to
- * perform the authentication. Based on the value of $store_type,
- * create a different kind of store. These are here as examples of
- * how you'd create the types of available OpenID stores. The
- * fallback store (if you specify an invalid value for $store_type) is
- * to use a FileStore. The settings for each store are contained in
- * the respective if blocks below. In addition, the require lines are
- * included in each block to show which file you'll need to include to
- * use the store.
+ * Require the "file store" module, which we'll need to store OpenID
+ * information.
*/
-$store_type = 'file';
+require_once "Auth/OpenID/Store/FileStore.php";
-if ($store_type == 'sqlite') {
-
- require_once "Auth/OpenID/Store/SQLStore.php";
-
- /**
- * This is where the example will store its OpenID information.
- * You should change this path if you want the example store to be
- * created elsewhere. After you're done playing with the example
- * script, you'll have to remove this directory manually.
- */
- $store_path = "/tmp/_php_consumer_test";
-
- if (!file_exists($store_path) && !mkdir($store_path)) {
- print "Could not create the SQLiteStore directory '$store_path'. ".
- " Please check the effective permissions.";
- exit(0);
- }
-
- $dsn = sprintf("sqlite:///%s/file.db", $store_path);
-
- $db =& DB::connect($dsn);
-
- $store = new Auth_OpenID_SQLiteStore($db);
-
- /**
- * This needs to be called once for the lifetime of the store, but
- * calling it each time you use the store won't hurt anything
- * (although it'll incur a slight performance pentalty because the
- * tables will already exist).
- */
- $store->createTables();
-
-} else if ($store_type == 'mysql') {
-
- require_once "Auth/OpenID/Store/SQLStore.php";
-
- /**
- * Assume that the database used by the MySQL store has already
- * been created.
- */
- $dsn = array(
- 'phptype' => 'mysql',
- 'username' => 'openid_test',
- 'password' => '',
- 'hostspec' => 'dbtest',
- 'database' => 'openid_test',
- );
-
- $db =& DB::connect($dsn);
-
- if (PEAR::isError($db)) {
- print "Database connection error: " .
- $db->getMessage();
- exit(0);
- }
-
- $store = new Auth_OpenID_MySQLStore($db);
-
- /**
- * This needs to be called once for the lifetime of the store, but
- * calling it each time you use the store won't hurt anything
- * (although it'll incur a slight performance pentalty because the
- * tables will already exist).
- */
- $store->createTables();
-
-} else if ($store_type == 'pgsql') {
-
- require_once "Auth/OpenID/Store/SQLStore.php";
-
- /**
- * Assume that the database used by the PostgreSQL store has
- * already been created.
- */
- $dsn = array(
- 'phptype' => 'pgsql',
- 'username' => 'openid_test',
- 'password' => '',
- 'hostspec' => 'dbtest',
- 'database' => 'openid_test',
- );
-
- $db =& DB::connect($dsn);
-
- if (PEAR::isError($db)) {
- print "Database connection error: " .
- $db->getMessage();
- exit(0);
- }
-
- $store = new Auth_OpenID_PostgreSQLStore($db);
-
- /**
- * This needs to be called once for the lifetime of the store, but
- * calling it each time you use the store won't hurt anything
- * (although it'll incur a slight performance pentalty because the
- * tables will already exist).
- */
- $store->createTables();
-
-} else {
-
- require_once "Auth/OpenID/Store/FileStore.php";
-
- /**
- * This is where the example will store its OpenID information.
- * You should change this path if you want the example store to be
- * created elsewhere. After you're done playing with the example
- * script, you'll have to remove this directory manually.
- */
- $store_path = "/tmp/_php_consumer_test";
-
- if (!file_exists($store_path) && !mkdir($store_path)) {
- print "Could not create the FileStore directory '$store_path'. ".
- " Please check the effective permissions.";
- exit(0);
- }
+/**
+ * This is where the example will store its OpenID information. You
+ * should change this path if you want the example store to be created
+ * elsewhere. After you're done playing with the example script,
+ * you'll have to remove this directory manually.
+ */
+$store_path = "/tmp/_php_consumer_test";
- $store = new Auth_OpenID_FileStore($store_path);
+if (!file_exists($store_path) &&
+ !mkdir($store_path)) {
+ print "Could not create the FileStore directory '$store_path'. ".
+ " Please check the effective permissions.";
+ exit(0);
}
+$store = new Auth_OpenID_FileStore($store_path);
+
/**
* Create a consumer object using the store object created earlier.
*/