Files
OpenDRS/boilerplate.php

109 lines
2.2 KiB
PHP

<?php
/*
boilerplate.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2024 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to login page if access_mode is untrusted and user is
// not logged in
if ($access_mode == "untrusted" && ! isset($_SESSION['userid'])) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:login.php");
exit();
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
exit();
}
// import session variables
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
// copy $_REQUEST[] to $incoming[]
$incoming=arrayCopy($_REQUEST);
}
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
*
*/
// assign variables from constants
$appname=APP_NAME;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($drs_db,"users","id","role",$userid);
// define local functions
framework("begin","$appname","Boilerplate Page",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
// ******** end database manipulation ********
pagetable("begin");
if (!$print) {
pageblock("left","begin");
sidemenu();
pageblock("left","end");
}
pageblock("right","begin");
banner($print);
echo "<br>";
echo "<center><b><font size=\"+1\">This is the standard template used for all pages in the application.</font></b></center>";
echo "<br>";
banner($print);
pageblock("right","end");
pagetable("end");
framework("end","","",$print);
?>