Location: PHPKode > projects > Railway Incident Reporting System > log.php
<?php require_once('Connections/incidentlog.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** 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 == "") && true) { 
      $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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_logsbasic = 10;
$pageNum_logsbasic = 0;
if (isset($_GET['pageNum_logsbasic'])) {
  $pageNum_logsbasic = $_GET['pageNum_logsbasic'];
}
$startRow_logsbasic = $pageNum_logsbasic * $maxRows_logsbasic;

mysql_select_db($database_incidentlog, $incidentlog);
$query_logsbasic = "SELECT * FROM incident ORDER BY id DESC";
$query_limit_logsbasic = sprintf("%s LIMIT %d, %d", $query_logsbasic, $startRow_logsbasic, $maxRows_logsbasic);
$logsbasic = mysql_query($query_limit_logsbasic, $incidentlog) or die(mysql_error());
$row_logsbasic = mysql_fetch_assoc($logsbasic);

if (isset($_GET['totalRows_logsbasic'])) {
  $totalRows_logsbasic = $_GET['totalRows_logsbasic'];
} else {
  $all_logsbasic = mysql_query($query_logsbasic);
  $totalRows_logsbasic = mysql_num_rows($all_logsbasic);
}
$totalPages_logsbasic = ceil($totalRows_logsbasic/$maxRows_logsbasic)-1;

$queryString_logsbasic = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_logsbasic") == false && 
        stristr($param, "totalRows_logsbasic") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_logsbasic = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_logsbasic = sprintf("&totalRows_logsbasic=%d%s", $totalRows_logsbasic, $queryString_logsbasic);
?>
<!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 Logs - All Incidents</title>
<link href="css/main.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<?php
include("inc/header.php");
?>

<?php
include("inc/menu.html");
?>
<h2><?php echo "$ILAll" ?></h2>
<?php if ($totalRows_logsbasic == 0) { // Show if recordset empty ?>
  <p><?php echo "$nReport" ?></p>
  <?php } // Show if recordset empty ?>
<?php do { ?>
    <?php if ($totalRows_logsbasic > 0) { // Show if recordset not empty ?>
  <table width="100%" border="1" cellspacing="0" cellpadding="4">
    <tr>
      <td valign="top"><p><b><?php echo "$ID" ?>:</b><br /><?php echo $row_logsbasic['id']; ?></p></td>
      <td valign="top"><p><b><?php echo "$DT" ?>:</b><br /><?php echo $row_logsbasic['time']; ?></p></td>
      <td valign="top"><p><b><?php echo "$Input" ?>:</b><br /><?php echo $row_logsbasic['inputter']; ?></p></td>
      <td valign="top"><p><b><?php echo "$Status" ?>:</b><br /><?php echo $row_logsbasic['status']; ?></p></td>
      </tr>
    <tr>
      <td colspan="4" valign="top">
        <p>{Incident Code and Code Details}</p></td>
      </tr>
    <tr>
      <td colspan="4" valign="top"><p><b><?php echo "$Sum" ?>:</b><br /><?php echo $row_logsbasic['summary']; ?></p></td>
      </tr>
    <tr>
      <td colspan="4" valign="top"><p><a href="log_detailed.php?id=<?php echo $row_logsbasic['id']; ?>"><?php echo "$View" ?></a> <?php echo "$VDetails" ?></p></td>
      </tr>
    
    <br />
    <br />
  </table>
  <?php } // Show if recordset not empty ?>
<?php } while ($row_logsbasic = mysql_fetch_assoc($logsbasic)); ?>
 <p>
   <?php if ($totalRows_logsbasic > 0) { // Show if recordset not empty ?>
  <a href="<?php printf("%s?pageNum_logsbasic=%d%s", $currentPage, min($totalPages_logsbasic, $pageNum_logsbasic + 1), $queryString_logsbasic); ?>"><?php echo "$nPage" ?></a> | <a href="<?php printf("%s?pageNum_logsbasic=%d%s", $currentPage, max(0, $pageNum_logsbasic - 1), $queryString_logsbasic); ?>"><?php echo "$pPage" ?></a><br />
     <?php echo "$Reports" ?> <?php echo ($startRow_logsbasic + 1) ?> <?php echo "$to" ?> <?php echo min($startRow_logsbasic + $maxRows_logsbasic, $totalRows_logsbasic) ?> <?php echo "$of" ?> <?php echo $totalRows_logsbasic ?>
  <?php } // Show if recordset not empty ?>
. <br />
<?php
include("inc/footer.php");
?>
</body>
</html>
<?php
mysql_free_result($logsbasic);
?>
Return current item: Railway Incident Reporting System