2002-04-30 22:22:54 +00:00
|
|
|
<?php
|
|
|
|
|
2002-11-08 17:21:45 +00:00
|
|
|
// database-related functions.
|
|
|
|
// Presentation code (HTML) shouldn't be here
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
function db_init() {
|
2002-05-29 23:25:21 +00:00
|
|
|
$retval = mysql_pconnect();
|
|
|
|
if (!$retval) {
|
2003-06-19 22:38:53 +00:00
|
|
|
echo "Unable to connect to database - please try again later";
|
2002-05-29 23:25:21 +00:00
|
|
|
exit();
|
|
|
|
}
|
2002-11-09 20:26:50 +00:00
|
|
|
$db_name = parse_config("<db_name>");
|
2003-06-19 22:38:53 +00:00
|
|
|
if(!mysql_select_db($db_name)) {
|
|
|
|
echo "Unable to select database - please try again later";
|
|
|
|
exit();
|
|
|
|
}
|
2003-03-06 19:53:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_user_auth($auth) {
|
|
|
|
$result = mysql_query("select * from user where authenticator='$auth'");
|
2002-08-12 22:16:34 +00:00
|
|
|
if ($result) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $user;
|
|
|
|
}
|
2003-03-06 17:42:49 +00:00
|
|
|
return null;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|