2002-04-30 22:22:54 +00:00
|
|
|
<?php
|
|
|
|
|
2003-08-14 00:59:09 +00:00
|
|
|
require_once('util.inc');
|
|
|
|
|
2002-11-08 17:21:45 +00:00
|
|
|
// database-related functions.
|
|
|
|
// Presentation code (HTML) shouldn't be here
|
|
|
|
|
2003-08-14 00:59:09 +00:00
|
|
|
function db_init($pathMod='') {
|
2003-11-25 19:40:54 +00:00
|
|
|
$retval = mysql_pconnect();
|
2002-05-29 23:25:21 +00:00
|
|
|
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();
|
|
|
|
}
|
2003-08-14 00:59:09 +00:00
|
|
|
$db_name = parse_config("<db_name>", $pathMod);
|
2003-06-19 22:38:53 +00:00
|
|
|
if(!mysql_select_db($db_name)) {
|
2003-08-22 05:36:25 +00:00
|
|
|
echo "Unable to select database - please try again later";
|
|
|
|
exit();
|
2003-06-19 22:38:53 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2003-07-17 18:15:49 +00:00
|
|
|
function lookup_user_id($id) {
|
|
|
|
$result = mysql_query("select * from user where id='$id'");
|
|
|
|
if ($result) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
?>
|