\n";
foreach( $buildings as $building)
{ //echo "Which: $whichbuilding and $building
\n"; // debug
$whichbuilding = trim($whichbuilding );
if( $whichbuilding == $building )
{ $retval .= "\t\t\t\n";
}else
{ $retval .= "\t\t\t\n";
}
}
$retval .= "\t\t\t\n";
return $retval;
}
function selectdepartment($whichdepartment, $whichcategory )
{ $departments = array( "Department of Physics and Astronomy", "Brockhouse Institute of Materials Research", "?");
if($whichdepartment == "" )
{ $whichdepartment = "?";
}
$retval = "";
$retval .= "\n";
return $retval;
}
function selectionbox( $input, $whichbox )
{ global $listbox;
$categories = $listbox[$whichbox];
$retval = "";
$retval .= "\n";
return ($retval);
}
// debug block
/*
echo "
\n";
print_r( $_REQUEST );
echo "
\n";
*/
// retrieve form output
$getdepartment = trim( $_REQUEST['getdepartment'] );
$getbuilding = trim( $_REQUEST['getbuilding'] );
$getroom = trim( $_REQUEST['getroom'] );
//echo "$getdepartment
\n"; // debug
#
# script to generate safety information form from previously recorded
# data or from scratch if this is the first time.
$listbox['roomletters'] = array( 'A', 'B', 'C', 'D', 'E', '?' );
$listbox['hazards'] = array( " ", "natural gas lines", "compressed air", "110/220 volt equipment", "liquid nitrogen" );
$listbox['precautions'] = array( " ", "wear safety glasses when appropriate", "wear protective clothing", "no solvents allowed" );
$listbox['safety_equip'] = array( " ", "fire extinguisher", "first aid kit", "lab coats", "protective gloves" );
//print_r( $listbox ); // debug
# translate to lower case and and underline spaces
$dept = preg_replace("/ +/", "_", strtolower($getdepartment));
# construct path from department name
$rootpath = '/1/upload/Safety/';
$path = $rootpath . 'dept/';
//$stripgetroom = preg_replace( "!/!", "%slash%", $getroom ); // replace any potential backslashes
$rootname = $getbuilding . '_' . strtoupper($getroom);
$date = date( "" );
# read in link information from departmental directories
//$rootpath = "/1/upload/Safety/dept/";
//echo "$rootname
\n"; // debug
if( ( $safetydir = opendir( "$path/" )) !== false )
{ while( $infodirs = readdir($safetydir) )
{ //echo "$infodirs
\n"; // debug
if( !preg_match( "/\./", $infodirs) )
{ //$deptdir[] = "$rootpath$infodirs";
//echo "$path$infodirs/$rootname.info
\n" ; // debug
if( file_exists( "$path$infodirs/$rootname.info" ) )
{ $filename = "$path$infodirs/$rootname.info";
//$getdepartment = $infodirs;
}
/*
if( ( $deptdir = opendir($rootpath . $infodirs)) !== false )
{ while( $infofiles = readdir($deptdir))
{ if( preg_match( "/\.info$/", $infofiles ) && !preg_match( "/[\._]bak/", $infofiles ) )
{ $location = preg_split( "/\./", $infofiles);
$thisbldgroom = preg_split("/_/", $location[0]);
if( $thisbldgroom[0] == $building )
{ $links .= $thisbldgroom[1] . '&' . $infodirs . ' ';
}
}
}
}
*/
//closedir($deptdir);
}
}
closedir($safetydir);
}else
{ echo "Can't find safety directories.
\n";
}
//echo "$getdepartment- $getbuilding - $getroom
\n"; // debug
# construct filename
//$filename = $path . $rootname . '.info';
// read in data from file if it exists
if( "" != $filename && ($infofile = fopen( $filename, "r")) !== false )
{ //echo "file $infofilename opened.
\n"; // debug
$line = fgets( $infofile, 255);
chop($line);
//echo "$line
\n"; // debug
while( !feof($infofile) )
{ if( preg_match("/=/", $line ) )
{ list( $name, $value ) = preg_split("/=/", $line);
//echo "${keydata[0]} = $keydata[1]
\n"; // debug
$$name .= trim(stripslashes($value));
//echo "$${keydata[0]}= " . $$keydata[0]. "\n"; // debug
}else
{ $$name .= "\n" . trim(stripslashes($line));
}
//echo "${keydata[0]} = $keydata[1]\n"; // debug
$line = fgets( $infofile, 255);
chop($line);
//echo "new line: $line
\n"; // debug
}
$getdepartment = $department;
fclose( $infofile );
}else
{ //echo "$getdepartment
$department = $getdepartment;
$building = $getbuilding;
$room = $getroom;
}
/*
if( !isset( $roomletters ) )
{ if( preg_match( "/\(([ABCDE,]+)\)/", $getroom, $matches ) )
{ $roomletters = $matches[1];
}else
{
$roomletters = ' ';
}
}
*/
/*
$splitroom = preg_split( "/ /", $room );
$bareroomnumber = $splitroom[0];
*/
//echo "$getdepartment = $department?
\n"; // debug
$striproom = preg_replace( "!/!", "%SLASH%", $room );
if( $getdepartment == $department && $getbuilding == $building && $getroom == $striproom ) // preg_replace( "/ /", "_", strtolower( $department ) )
{
if( "" == $getdepartment || "?" == $getdepartment )
{ $frwddepartment = selectdepartment( $department, 'department' );
}else
{ $frwddepartment = "$department";
}
?>
Safety Sheet Form