From 82e86dba713c01edd3c299b5693cede5980ab3a0 Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Fri, 21 Jun 2002 22:48:01 +0000
Subject: [PATCH] Add TBExptLogFile() function and use that in spewlogfile
 instead of the actual query.

---
 www/dbdefs.php3.in   | 14 ++++++++++++++
 www/spewlogfile.php3 |  6 +-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/www/dbdefs.php3.in b/www/dbdefs.php3.in
index 627c04364f..64f7fef018 100644
--- a/www/dbdefs.php3.in
+++ b/www/dbdefs.php3.in
@@ -1122,6 +1122,20 @@ function TBUserPCs($uid)
     return mysql_num_rows($query_result);
 }
 
+function TBExptLogFile($pid, $eid)
+{
+    $query_result =
+	DBQueryFatal("select logfile from experiments ".
+		     "where pid='$pid' and eid='$eid' and ".
+		     " logfile is not null");
+
+    if (mysql_num_rows($query_result) == 0) {
+	return 0;
+    }
+    $row = mysql_fetch_row($query_result);
+    return $row[0];
+}
+
 function TBWebdbAllowed($uid) {
     $query_result =
         DBQueryFatal("select dbedit from users ".
diff --git a/www/spewlogfile.php3 b/www/spewlogfile.php3
index e0eaf14f15..c27a180ce6 100644
--- a/www/spewlogfile.php3
+++ b/www/spewlogfile.php3
@@ -45,11 +45,7 @@ if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
 # Check for a logfile. This file is transient, so it could be gone by
 # the time we get to reading it.
 #
-$query_result =
-    DBQueryFatal("select logfile from experiments ".
-		 "where pid='$pid' and eid='$eid' and logfile is not null");
-
-if (mysql_num_rows($query_result) == 0) {
+if (! TBExptLogFile($pid, $eid)) {
     USERERROR("Experiment $pid/$eid is no longer in transition!", 1);
 }
 
-- 
GitLab