<?php require_once('Connections/incidentlog.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1,2";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php?fail";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "staffreports")) {
$insertSQL = sprintf("INSERT INTO reports (incidentid, name, report) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['incidentid'], "int"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['report'], "text"));
mysql_select_db($database_incidentlog, $incidentlog);
$Result1 = mysql_query($insertSQL, $incidentlog) or die(mysql_error());
$insertGoTo = "report_submitted.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_incidentlog, $incidentlog);
$query_reports = "SELECT * FROM reports";
$reports = mysql_query($query_reports, $incidentlog) or die(mysql_error());
$row_reports = mysql_fetch_assoc($reports);
$totalRows_reports = mysql_num_rows($reports);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Incident Log - Add a staff report</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include("inc/header.php");
?>
<?php
include("inc/menu.html");
?>
<h2><?php echo "$RStaff" ?></h2>
<p><?php echo "$AddToRecord" ?><strong> <?php echo $_GET[id]; ?></strong></p>
<form action="<?php echo $editFormAction; ?>" method="POST" name="staffreports"><input name="incidentid" type="hidden" value="<?php echo $_GET[id]; ?>" /><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td><p>Name <i>(of reporter)</i>:</p></td>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td><p>Report:</p></td>
<td><textarea name="report" id="report" cols="50" rows="10"></textarea></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="staffreports" />
<input name="submit" type="submit" />
</form>
<?php
include("inc/footer.php");
?>
</body>
</html>
<?php
mysql_free_result($reports);
?>