Commit 8dfb66fd authored by Leigh Stoller's avatar Leigh Stoller

Remove a bunch of uses of mysql_db_query(), converting to DBQueryFatal().

This call appears to always reselect the DB, which might be a problem
when the DB is busy.
parent b13f4ba7
......@@ -27,12 +27,7 @@ if (! $isadmin) {
# implies denying the project leader account, when there is just a single
# project pending for that project leader.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT * from projects where approved='0'");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting unapproved project list: $err\n", 1);
}
$query_result = DBQueryFatal("SELECT * from projects where approved='0'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("There are no projects to approve!", 1);
}
......@@ -65,8 +60,8 @@ while ($projectrow = mysql_fetch_array($query_result)) {
$Purl = $projectrow[URL];
$Pname = $projectrow[name];
$userinfo_result = mysql_db_query($TBDBNAME,
"SELECT * from users where uid=\"$headuid\"");
$userinfo_result =
DBQueryFatal("SELECT * from users where uid='$headuid'");
$row = mysql_fetch_array($userinfo_result);
$name = $row[usr_name];
......
......@@ -1195,8 +1195,9 @@ function DBQuery($query)
{
global $TBDBNAME;
global $DBErrorString;
global $DBlinkid;
$result = mysql_db_query($TBDBNAME, $query);
$result = mysql_query($query, $DBlinkid);
if (! $result) {
$DBErrorString =
......
......@@ -15,12 +15,7 @@ if (!isset($nid) ||
}
$pid = addslashes($pid);
$query_result = mysql_db_query($TBDBNAME,
"SELECT * from wires where node_id1='$nid'");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting node information: $err\n", 1);
}
$query_result = DBQueryFatal("SELECT * from wires where node_id1='$nid'");
echo "<table border=1 padding=1>\n";
echo "<tr>
......
......@@ -15,12 +15,7 @@ if (!isset($nid) ||
}
$pid = addslashes($pid);
$query_result = mysql_db_query($TBDBNAME,
"SELECT * from wires where node_id1='$nid'");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting node information: $err\n", 1);
}
$query_result = DBQueryFatal("SELECT * from wires where node_id1='$nid'");
echo "<table border=1 padding=1>\n";
echo "<tr>
......
......@@ -51,15 +51,11 @@ function GENPLIST ($query_result)
#
# Get the "active" project list.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid,name,URL,usr_affil FROM projects ".
$query_result =
DBQueryFatal("SELECT pid,name,URL,usr_affil FROM projects ".
"left join users on projects.head_uid=users.uid ".
"where public=1 and approved=1 and expt_count>0 order by name");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting active project list: $err\n", 1);
}
"where public=1 and approved=1 and expt_count>0 ".
"order by name");
echo "<table width=\"100%\" border=0 cellpadding=2 cellspacing=2
align='center'>\n";
......@@ -71,15 +67,11 @@ if (mysql_num_rows($query_result)) {
#
# Get the "inactive" project list.
#
$query_result = mysql_db_query($TBDBNAME,
"SELECT pid,name,URL,usr_affil FROM projects ".
$query_result =
DBQueryFatal("SELECT pid,name,URL,usr_affil FROM projects ".
"left join users on projects.head_uid=users.uid ".
"where public=1 and approved=1 and expt_count=0 order by name");
if (! $query_result) {
$err = mysql_error();
TBERROR("Database Error getting inactive project list: $err\n", 1);
}
"where public=1 and approved=1 and expt_count=0 ".
"order by name");
if (mysql_num_rows($query_result)) {
echo "<tr></tr>\n";
......
......@@ -47,7 +47,32 @@ if (! TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_READINFO)) {
USERERROR("You are not a member of Project $pid.", 1);
}
SHOWPROJECT($pid, $uid);
#
# A list of project experiments.
#
$query_result =
DBQueryFatal("SELECT eid,expt_name FROM experiments WHERE pid='$pid' order by eid");
if (mysql_num_rows($query_result)) {
echo "<center>
<h3>Project Experiments</h3>
</center>
<table align=center border=1>\n";
while ($row = mysql_fetch_row($query_result)) {
$eid = $row[0];
$name = $row[1];
if (!$name)
$name = "--";
echo "<tr>
<td>
<A href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>
</td>
<td>$name</td>
</tr>\n";
}
echo "</table>\n";
}
#
# A list of project members (from the default group).
......@@ -96,33 +121,6 @@ if (mysql_num_rows($query_result)) {
echo "</table>\n";
}
#
# A list of project experiments.
#
$query_result =
DBQueryFatal("SELECT eid,expt_name FROM experiments WHERE pid='$pid' order by eid");
if (mysql_num_rows($query_result)) {
echo "<center>
<h3>Project Experiments</h3>
</center>
<table align=center border=1>\n";
while ($row = mysql_fetch_row($query_result)) {
$eid = $row[0];
$name = $row[1];
if (!$name)
$name = "--";
echo "<tr>
<td>
<A href='showexp.php3?pid=$pid&eid=$eid'>$eid</a>
</td>
<td>$name</td>
</tr>\n";
}
echo "</table>\n";
}
#
# A list of project Groups (if more than just the default).
#
......@@ -164,6 +162,8 @@ echo "<p><center>
<A href='newgroup_form.php3?pid=$pid'>Create</a> a new Group?
</center>\n";
SHOWPROJECT($pid, $uid);
if ($isadmin) {
echo "<p>
<A href='deleteproject.php3?pid=$pid'>
......
......@@ -2,8 +2,7 @@
#
# This is an included file. No headers or footers or includes!
#
$query_result =
DBQueryFatal("SELECT * FROM projects WHERE pid='$pid'");
$query_result = DBQueryFatal("SELECT * FROM projects WHERE pid='$pid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The project $pid is not a valid project.", 1);
}
......@@ -91,8 +90,8 @@ echo "<tr>
echo "</table>\n";
$userinfo_result = mysql_db_query($TBDBNAME,
"SELECT * from users where uid=\"$proj_head_uid\"");
$userinfo_result =
DBQueryFatal("SELECT * from users where uid='$proj_head_uid'");
$row = mysql_fetch_array($userinfo_result);
$usr_expires = $row[usr_expires];
......
......@@ -11,11 +11,8 @@
function SHOWPROJECT($pid, $thisuid) {
global $TBDBNAME;
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM projects WHERE pid=\"$pid\"");
if (mysql_num_rows($query_result) == 0) {
USERERROR("The project $pid is not a valid project.", 1);
}
$query_result =
DBQueryFatal("SELECT * FROM projects WHERE pid='$pid'");
$row = mysql_fetch_array($query_result);
echo "<center>
......@@ -320,8 +317,8 @@ function SHOWGROUPMEMBERSHIP($uid) {
function SHOWUSER($uid) {
global $TBDBNAME;
$userinfo_result = mysql_db_query($TBDBNAME,
"SELECT * from users where uid=\"$uid\"");
$userinfo_result =
DBQueryFatal("SELECT * from users where uid='$uid'");
$row = mysql_fetch_array($userinfo_result);
$usr_expires = $row[usr_expires];
......@@ -587,9 +584,9 @@ function SHOWNODES($pid, $eid) {
global $TBDBNAME;
global $TBOPSPID;
$reserved_result = mysql_db_query($TBDBNAME,
"SELECT * FROM reserved WHERE ".
"eid=\"$eid\" and pid=\"$pid\"");
$reserved_result =
DBQueryFatal("SELECT * FROM reserved WHERE ".
"eid='$eid' and pid='$pid'");
# If this is an expt in emulab-ops, we don't care about vname,
# since it won't be defined. But we do want to know when the node
......@@ -620,8 +617,8 @@ function SHOWNODES($pid, $eid) {
<td align=center>Ready<br>Status[<b>3</b>]</td>
</tr>\n";
$query_result = mysql_db_query($TBDBNAME,
"SELECT nodes.*,reserved.vname, ".
$query_result =
DBQueryFatal("SELECT nodes.*,reserved.vname, ".
"date_format(rsrv_time,\"%Y-%m-%d&nbsp;%T\") as rsrvtime ".
"FROM nodes LEFT JOIN reserved ".
"ON nodes.node_id=reserved.node_id ".
......@@ -698,8 +695,8 @@ function SHOWNODES($pid, $eid) {
function SHOWOSINFO($osid) {
global $TBDBNAME;
$query_result = mysql_db_query($TBDBNAME,
"SELECT * FROM os_info WHERE osid='$osid'");
$query_result =
DBQueryFatal("SELECT * FROM os_info WHERE osid='$osid'");
$osrow = mysql_fetch_array($query_result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment