2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('../inc/util.inc');
|
|
|
|
|
|
|
|
// database-related functions.
|
|
|
|
// Presentation code (HTML) shouldn't be here
|
|
|
|
|
2004-02-03 21:48:49 +00:00
|
|
|
function db_init() {
|
2004-02-02 23:34:39 +00:00
|
|
|
if (project_is_stopped()) {
|
|
|
|
echo "Project is shut down for maintenance - please try again later\n";
|
|
|
|
exit();
|
|
|
|
}
|
2004-02-03 21:48:49 +00:00
|
|
|
$user = parse_config("<db_user>");
|
|
|
|
$pass = parse_config("<db_passwd>");
|
2004-02-02 23:34:39 +00:00
|
|
|
$retval = mysql_pconnect("localhost", $user, $pass);
|
|
|
|
if (!$retval) {
|
|
|
|
echo "Unable to connect to database - please try again later";
|
|
|
|
echo mysql_error();
|
|
|
|
exit();
|
|
|
|
}
|
2004-02-03 21:48:49 +00:00
|
|
|
$db_name = parse_config("<db_name>");
|
2004-02-02 23:34:39 +00:00
|
|
|
if(!mysql_select_db($db_name)) {
|
|
|
|
echo "Unable to select database - please try again later";
|
|
|
|
echo mysql_error();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_user_auth($auth) {
|
|
|
|
$result = mysql_query("select * from user where authenticator='$auth'");
|
|
|
|
if ($result) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_host($id) {
|
|
|
|
$result = mysql_query("select * from host where id=$id");
|
|
|
|
if ($result) {
|
|
|
|
$host = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $host;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_team($id) {
|
|
|
|
$result = mysql_query("select * from team where id=$id");
|
|
|
|
if ($result) {
|
|
|
|
$team = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $team;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_wu($id) {
|
|
|
|
$result = mysql_query("select * from workunit where id=$id");
|
|
|
|
if ($result) {
|
|
|
|
$wu = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $wu;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function lookup_app($id) {
|
|
|
|
$result = mysql_query("select * from app where id=$id");
|
|
|
|
if ($result) {
|
|
|
|
$app = mysql_fetch_object($result);
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $app;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|