Initial commit as release 1.1.0

This commit is contained in:
2026-02-14 11:07:25 -05:00
parent 6b49566e58
commit a6331f7fed
141 changed files with 50383 additions and 0 deletions

480
distfiles/config.php Normal file
View File

@@ -0,0 +1,480 @@
<?php
/*
config.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2018 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
// 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'];
$role=dblookup($drs_db,"users","id","role",$userid);
// redirect to index.php if not an admin
if ($role != ADMIN) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
exit();
}
// import incoming arrays
$print=$_REQUEST['print'];
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);
}
// load variables from incoming array
$update_display=$incoming['update_display'];
$display_appname=$incoming['display_appname'];
$display_banner=$incoming['display_banner'];
$display_footer=$incoming['display_footer'];
$display_pereffhlp=$incoming['display_pereffhlp'];
$update_colors=$incoming['update_colors'];
$reset_colors=$incoming['reset_colors'];
$newbgc=$incoming['newbgc'];
$newmbgc=$incoming['newmbgc'];
$newtc=$incoming['newtc'];
$newlc=$incoming['newlc'];
$newvlc=$incoming['newvlc'];
$newhc=$incoming['newhc'];
$edit_banner=$incoming['edit_banner'];
$add_banner=$incoming['add_banner'];
$update_banner=$incoming['update_banner'];
$delete_banner=$incoming['delete_banner'];
$bnrid=$incoming['bnrid'];
$bnrname=$incoming['bnrname'];
$bnrcolor=$incoming['bnrcolor'];
$bnrtxtcolor=$incoming['bnrtxtcolor'];
$update_misc=$incoming['update_misc'];
$sessttl=$incoming['sessttl'];
$sessdir=$incoming['sessdir'];
$logoutall=$incoming['logoutall'];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
}
framework("begin","$appname","Configuration",$print);
//var_dump($_REQUEST);
//var_dump($incoming);
// ******** begin database manipulation ********
if ($update_display) {
// remove html tags from footer_message and sanitize
$display_footer=strip_tags($display_footer);
$clean_display_footer=mysqli_real_escape_string($drs_db,$display_footer);
// remove html tags from app name and sanitize
$display_appname=strip_tags($display_appname);
$clean_display_appname=mysqli_real_escape_string($drs_db,$display_appname);
// remove html tags from period effective help text and sanitize
$display_pereffhlp=strip_tags($display_pereffhlp);
$clean_display_pereffhlp=mysqli_real_escape_string($drs_db,$display_pereffhlp);
mysqli_query($drs_db,"update config set value=\"$clean_display_appname\" where name=\"app_name\"");
mysqli_query($drs_db,"update config set value=\"$display_banner\" where name=\"banner\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_footer\" where name=\"footer_message\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_pereffhlp\" where name=\"period_eff_help_txt\"");
echo "<meta http-equiv='refresh' content='0'>";
}
if ($update_colors) {
if ($newbgc) mysqli_query($drs_db,"update config set value=\"$newbgc\" where name=\"background_color\"");
if ($newmbgc) mysqli_query($drs_db,"update config set value=\"$newmbgc\" where name=\"menubg_color\"");
if ($newtc) mysqli_query($drs_db,"update config set value=\"$newtc\" where name=\"text_color\"");
if ($newlc) mysqli_query($drs_db,"update config set value=\"$newlc\" where name=\"link_color\"");
if ($newvlc) mysqli_query($drs_db,"update config set value=\"$newvlc\" where name=\"vlink_color\"");
if ($newhc) mysqli_query($drs_db,"update config set value=\"$newhc\" where name=\"heading_color\"");
echo "<meta http-equiv='refresh' content='0'>";
}
if ($reset_colors) {
mysqli_query($drs_db,"update config set value=defaultvalue where name like \"%_color\"");
echo "<meta http-equiv='refresh' content='0'>";
}
if ($add_banner) {
// do error checking
// remove html tags from banner name
$bnrname=strip_tags($bnrname);
// test for name supplied
if (strlen(trim($bnrname))) {
$namesuppld=true;
} else {
$namesuppld=false;
$namesuppld_err=true;
}
// test for name unique
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\""))) {
$nameunique=false;
$nameunique_err=true;
} else {
$nameunique=true;
}
if ($namesuppld && $nameunique) {
// sanitize banner name
$clean_bnrname=mysqli_real_escape_string($drs_db,$bnrname);
// modify the table
mysqli_query($drs_db,"insert into banners(bannername,bannercolor,textcolor) values(\"$clean_bnrname\",\"$bnrcolor\",\"$bnrtxtcolor\")");
}
}
if ($edit_banner) {
if ($delete_banner) {
mysqli_query($drs_db,"delete from banners where bannerid=\"$bnrid\"");
unset($edit_banner);
}
if ($update_banner) {
// do error checking
// remove html tags from banner name
$bnrname=strip_tags($bnrname);
// test for name supplied
if (strlen(trim($bnrname))) {
$namesuppld=true;
} else {
$namesuppld=false;
$namesuppld_err=true;
}
// test for name unique
if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$bnrname\" and bannerid!=\"$bnrid\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\""))) {
$nameunique=false;
$nameunique_err=true;
} else {
$nameunique=true;
}
} else {
$nameunique=true;
}
if ($namesuppld && $nameunique) {
// sanitize banner name
$clean_bnrname=mysqli_real_escape_string($drs_db,$bnrname);
// modify the table
mysqli_query($drs_db,"update banners set bannername=\"$bnrname\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$bnrid\"");
}
}
}
if ($update_misc) {
if ($logoutall) {
if ($ostype == 'WIN') {
$sessfileloc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
} else {
$sessfileloc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
}
foreach (glob($sessfileloc."/*") as $sessfile) {
unlink($sessfile);
}
}
// test for sessttl supplied
if (strlen(trim($sessttl))) {
$ttlsuppld=true;
} else {
$ttlsuppld=false;
$ttlsuppld_err=true;
}
// test for sessdir supplied
if (strlen(trim($sessdir))) {
$dirsuppld=true;
} else {
$dirsuppld=false;
$dirsuppld_err=true;
}
if ($ttlsuppld && $dirsuppld) {
mysqli_query($drs_db,"update config set value=\"$sessttl\" where name=\"session_ttl_days\"");
if ($ostype == 'WIN') {
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"win_server_session_dir\"");
} else {
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"unix_server_session_dir\"");
}
}
}
// ******** end database manipulation ********
pagetable("begin");
if (!$print) {
pageblock("left","begin");
sidemenu();
pageblock("left","end");
}
pageblock("right","begin");
banner($print);
echo "<br>";
echo "
<div id=\"configtabs\">
<ul>
<li><a href=\"#display_options\">Display Options</a></li>
<li><a href=\"#page_colors\">Page Colors</a></li>
<li><a href=\"#banners\">Banners</a></li>
<li><a href=\"#miscellaneous\">Miscellaneous Options</a></li>
</ul>
<div id=\"display_options\">
<form method=\"post\" action=\"config.php\">
";
$curapn=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"app_name\""))[0];
$curbnr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"banner\""))[0];
$curftr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"footer_message\""))[0];
$curpereffhlp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"period_eff_help_txt\""))[0];
echo "
<font size=\"+1\"><b>Display Configuration Parameters</b></font><br><br><br><br>
";
echo "
Application Name (will appear at the top of every page):<br>
<input type=\"text\" name=\"display_appname\" size=\"80\" value=\"$curapn\">
<br><br><br>
";
echo "
Banner (will appear at the top and bottom of pages): &nbsp;<select name=\"display_banner\" id=\"sel-banner\">
";
$bannerqry=mysqli_query($drs_db,"select * from banners");
while ($bannerrow=mysqli_fetch_assoc($bannerqry)) {
if ($bannerrow["bannerid"]==$curbnr) {
printf("<option value=\"%s\" selected>%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
} else {
printf("<option value=\"%s\">%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
}
}
echo "
</select><br><br><br>
Footer Message (will appear at the bottom of pages):<br>
<input type=\"text\" name=\"display_footer\" size=\"80\" value=\"$curftr\"><br><br><br>
Period Effective Help Text :<br>
<textarea rows=\"4\" cols=\"80\" name=\"display_pereffhlp\" wrap=\"soft\">$curpereffhlp</textarea><br><br><br><br>
<input type=\"submit\" name=\"update_display\" value=\"Update Options\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br><br><br>
</form>
";
echo "
</div>
<div id=\"page_colors\">
";
$curbgc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"background_color\""))[0];
$curmbgc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"menubg_color\""))[0];
$curtc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"text_color\""))[0];
$curlc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"link_color\""))[0];
$curvlc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"vlink_color\""))[0];
$curhc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"heading_color\""))[0];
echo "
<font size=\"+1\"><b>Color Configuration Parameters</b></font><br><br>
<table border=\"0\"><tr>
<td>
<form method=\"post\" action=\"config.php#page_colors\">
<b>Select the color you'd like to change then use the color picker to select a new color</b><br><br>
<table border=\"0\" cellpadding=\"10\">
<tr><td>Page background color</td><td>#<input type=\"text\" name=\"newbgc\" value=\"$curbgc\" id=\"bgcfield\" onFocus=\"ddcolorposter.echocolor(this, 'bgcbox')\"> <span id=\"bgcbox\" class=\"colorbox\">____</span></td></tr>
<tr><td>Menu background color</td><td>#<input type=\"text\" name=\"newmbgc\" value=\"$curmbgc\" id=\"mbgcfield\" onFocus=\"ddcolorposter.echocolor(this, 'mbgcbox')\"> <span id=\"mbgcbox\" class=\"colorbox\">____</span></td></tr>
<tr><td>Normal text color</td><td>#<input type=\"text\" name=\"newtc\" value=\"$curtc\" id=\"tcfield\" onFocus=\"ddcolorposter.echocolor(this, 'tcbox')\"> <span id=\"tcbox\" class=\"colorbox\">____</span></td></tr>
<tr><td>Link color</td><td>#<input type=\"text\" name=\"newlc\" value=\"$curlc\" id=\"lcfield\" onFocus=\"ddcolorposter.echocolor(this, 'lcbox')\"> <span id=\"lcbox\" class=\"colorbox\">____</span></td></tr>
<tr><td>Visited link color</td><td>#<input type=\"text\" name=\"newvlc\" value=\"$curvlc\" id=\"vlcfield\" onFocus=\"ddcolorposter.echocolor(this, 'vlcbox')\"> <span id=\"vlcbox\" class=\"colorbox\">____</span></td></tr>
<tr><td>Heading color</td><td>#<input type=\"text\" name=\"newhc\" value=\"$curhc\" id=\"hcfield\" onFocus=\"ddcolorposter.echocolor(this, 'hcbox')\"> <span id=\"hcbox\" class=\"colorbox\">____</span></td></tr>
</table>
<br><br>
<input type=\"submit\" name=\"update_colors\" value=\"Update Colors\">&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset_colors\" value=\"Reset Colors to Defaults\">
</td>
<td>
<div id=\"pickerPanel\" class=\"dragPanel\">
<h4 id=\"pickerHandle\">&nbsp;</h4>
<div id=\"pickerDiv\">
<img id=\"pickerbg\" src=\"colorpicker/img/pickerbg.png\" alt=\"\">
<div id=\"selector\"><img src=\"colorpicker/img/select.gif\"></div>
</div>
<div id=\"hueBg\">
<div id=\"hueThumb\"><img src=\"colorpicker/img/hline.png\"></div>
</div>
<div id=\"pickervaldiv\">
<form name=\"pickerform\" onsubmit=\"return pickerUpdate()\">
<font size=\"-3\">
<br />
R <input name=\"pickerrval\" id=\"pickerrval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
H <input name=\"pickerhval\" id=\"pickerhval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
<br />
G <input name=\"pickergval\" id=\"pickergval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
S <input name=\"pickergsal\" id=\"pickersval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
<br />
B <input name=\"pickerbval\" id=\"pickerbval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
V <input name=\"pickervval\" id=\"pickervval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
<br />
<br />
# <input name=\"pickerhexval\" id=\"pickerhexval\" type=\"text\" value=\"0\" size=\"6\" maxlength=\"6\" />
<br />
</font>
</form>
</div>
<div id=\"pickerSwatch\">&nbsp;</div>
</div>
</td>
</tr></table>
";
echo "
</form>
</div>
<div id=\"banners\">
";
if ($nameunique_err) format_message(1,"Banner name already exists. Please try another.");
if ($namesuppld_err) format_message(1,"Banner name cannot be blank.");
if ($edit_banner) {
// set form options for editing
$sectiontitle="<font size=\"+1\"><b>Modify Banner</b></font><br><br>";
$formtag="<form method=\"post\" action=\"config.php?edit_banner=1#banners\">";
$buttontags="
<input type=\"hidden\" name=\"bnrid\" value=\"$bnrid\">
<input type=\"submit\" name=\"update_banner\" value=\"Update Banner\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"delete_banner\" value=\"Delete Banner\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
";
// pull current values from database
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from banners where bannerid=$bnrid"));
$bnrname=$currentvalues["bannername"];
$bnrcolor=$currentvalues["bannercolor"];
$bnrtextcolor=$currentvalues["textcolor"];
$bnrcoloropts="";
foreach($basic_colors as $cname => $chex) {
if ($chex==$bnrcolor) {
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\" selected>$cname</option>";
} else {
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\">$cname</option>";
}
}
$bnrtextcoloropts="";
foreach($basic_colors as $cname => $chex) {
if ($chex==$bnrtextcolor) {
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\" selected>$cname</option>";
} else {
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\">$cname</option>";
}
}
} else {
// set form options for add
$sectiontitle="<font size=\"+1\"><b>Add New Banner</b></font><br><br>";
$formtag="<form method=\"post\" action=\"config.php#banners\">";
$bnrname="";
$buttontags="
<input type=\"submit\" name=\"add_banner\" value=\"Add Banner\">
";
// set default values
$bnrcolor="#000000";
$bnrtextcolor="#FFFFFF";
$bnrcoloropts="";
foreach($basic_colors as $cname => $chex) {
if ($chex==$bnrcolor) {
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\" selected>$cname</option>";
} else {
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\">$cname</option>";
}
}
$bnrtextcoloropts="";
foreach($basic_colors as $cname => $chex) {
if ($chex==$bnrtextcolor) {
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\" selected>$cname</option>";
} else {
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\">$cname</option>";
}
}
}
echo "
$sectiontitle
$formtag
<table border=\"0\">
<tr><td>
Banner Name (text displayed in the banner): &nbsp;<input type=\"text\" name=\"bnrname\" size=\"40\" value=\"$bnrname\"><br><br>
Banner Color (background color of the banner): &nbsp;
<select name=\"bnrcolor\">
$bnrcoloropts
</select><br><br>
Banner Text Color (text color of the banner, different than banner color): &nbsp;
<select name=\"bnrtxtcolor\">
$bnrtextcoloropts
</select><br><br>
</td></tr>
</table>
$buttontags
</form>
<br><hr>
";
// show the table of entities
$existingdata=mysqli_query($drs_db,"select * from banners where bannerid!=1 order by bannerid asc");
echo "
<b>Existing Banners</b>&nbsp;&nbsp;&nbsp;<font size=\"-1\">Click on the Banner ID to edit.</font><br><br>
<table border=\"1\">
<tr><th>Banner ID</th><th>Banner</th></tr>
";
while ($tablerow=mysqli_fetch_assoc($existingdata)) {
printf("
<tr>
<td><a href=\"config.php?edit_banner=1&bnrid=%s#banners\">%s</a></td>
<td align=\"center\" bgcolor=\"%s\"><font color=\"%s\">%s</font></td>
</tr>",
$tablerow["bannerid"],$tablerow["bannerid"],
$tablerow["bannercolor"],$tablerow["textcolor"],$tablerow["bannername"]);
}
echo "</table>";
echo "
</div>
<div id=\"miscellaneous\">
<form method=\"post\" action=\"config.php#miscellaneous\">
";
if ($ttlsuppld_err) format_message(1,"Session expiration time cannot be blank.");
if ($dirsuppld_err) format_message(1,"Server session file directory cannot be blank.");
$curttl=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"session_ttl_days\""))[0];
if ($ostype == 'WIN') {
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
} else {
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
}
echo "
<font size=\"+1\"><b>Miscellaneous Configuration Parameters</b></font><br><br><br><br>
Session expiration time (users will have to log in again after this long) : &nbsp;<input type=\"text\" name=\"sessttl\" size=\"3\" value=\"$curttl\"> days<br><br>
Server session file directory (must be writable by the web server process) : <br><input type=\"text\" name=\"sessdir\" size=\"40\" value=\"$curssdir\"><br><br>
Force logout of all users &nbsp;<input type=\"checkbox\" name=\"logoutall\"><br><br><br><br>
<input type=\"submit\" name=\"update_misc\" value=\"Update Options\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
</div>
</div>
";
echo "<br>";
banner($print);
pageblock("right","end");
pagetable("end");
framework("end","","",$print);
?>