diff --git a/www/dbdefs.php3.in b/www/dbdefs.php3.in index 627c04364fa0c347eb3c47266f18c56953ef8c0b..64f7fef01877d86c463f14164beb05b17416cde7 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 e0eaf14f155d66719dee627d4fbc85829487da5a..c27a180ce614c5592a02e1beb411cbfa1483c790 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); }