From c47de27c114c9998acc01fd2c6df185cd271ec2f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 7 May 2008 12:48:07 -0400 Subject: [PATCH] beginnings of PHP darcs-hash:20080507164807-84dde-ef7d205a0fedca42064a337786d2f203cdcc5a45.gz --- actions/login.php | 25 ++++++++++++++++++++++ actions/showstream.php | 6 ++++++ classes/profile.php | 0 classes/remote_profile.php | 0 classes/update.php | 0 classes/user.php | 0 common.php | 44 ++++++++++++++++++++++++++++++++++++++ config.php | 24 +++++++++++++++++++++ index.php | 19 ++++++++++++++++ 9 files changed, 118 insertions(+) create mode 100644 actions/login.php create mode 100644 actions/showstream.php create mode 100644 classes/profile.php create mode 100644 classes/remote_profile.php create mode 100644 classes/update.php create mode 100644 classes/user.php create mode 100644 common.php create mode 100644 config.php create mode 100644 index.php diff --git a/actions/login.php b/actions/login.php new file mode 100644 index 0000000000..a95dc9e3a3 --- /dev/null +++ b/actions/login.php @@ -0,0 +1,25 @@ + + array('name' => 'Just another µB'), + 'dsn' => + array('phptype' => 'mysql', + 'username' => 'stoica', + 'password' => 'apasswd', + 'hostspec' => 'localhost', + 'database' => 'thedb') + 'dboptions' => + array('debug' => 2, + 'portability' => DB_PORTABILITY_ALL)); + +require_once(INSTALLDIR . '/config.php'); +require_once('DB.php'); + +function common_database() { + global $config; + $db =& DB::connect($config['dsn'], $config['dboptions']); + if (PEAR::isError($db)) { + common_server_error($db->getMessage()); + } else { + return $db; + } +} + +function common_read_database() { + // XXX: read from slave server + return common_database(); +} + +function common_server_error($msg) { + header('Status: 500 Server Error'); + header('Content-type: text/plain'); + + print $msg; + exit(); +} diff --git a/config.php b/config.php new file mode 100644 index 0000000000..c178baf9c9 --- /dev/null +++ b/config.php @@ -0,0 +1,24 @@ + 'pgsql', + 'username' => 'someuser', + 'password' => 'apasswd', + 'hostspec' => 'localhost', + 'database' => 'thedb', + ); + +$options = array( + 'debug' => 2, + 'portability' => DB_PORTABILITY_ALL, + ); + +$db =& DB::connect($dsn, $options); +if (PEAR::isError($db)) { + die($db->getMessage()); +} + +$config['db'] = + array( 'username' => 'stoica', + 'password' => 'replaceme', + diff --git a/index.php b/index.php new file mode 100644 index 0000000000..d63d09edf5 --- /dev/null +++ b/index.php @@ -0,0 +1,19 @@ + \ No newline at end of file -- 2.39.5