9 Commits

13 changed files with 155 additions and 103 deletions

View File

@@ -280,4 +280,5 @@
is enabled.
- Validate all date and time fields to prevent user entered invalid date
formats from crashing php.
- Fixed profile page to automatically refresh page to show the results
when a user changes their color preferences.

32
INSTALL
View File

@@ -4,32 +4,30 @@
SPDX-License-Identifier: GPL-2.0
Installation of OpenLog is straightforward.
1. Gather the required information.
You'll need to know how to configure your web server. This means where
you want to put the files to be served and any configuration required to
allow clients to reach them. You'll also need to know the username and
password of the MySQL administrator.
You'll need to know how to configure your web server. This means where
you want to put the files to be served and any configuration required to
allow clients to reach them. You'll also need to know the username and
password of the MySQL administrator.
2. Unpack
Unpack the distribution in a convenient place (such as /tmp or My Documents).
A directory will be created called OpenLog-x.x.x.
Unpack the distribution in a convenient place (such as /tmp or My Documents).
A directory will be created called OpenLog-x.x.x.
3. Review License
Change to the openlog-x.x.x directory and review the LICENSE file.
Change to the openlog-x.x.x directory and review the LICENSE file.
4. Run the install script
If installing on a Linux or Unix based system, type ./install.sh at a
command prompt. If installing on a Windows based system, double click
install.bat. Follow the prompts.
If installing on a Linux or Unix based system, type ./install.sh at a
command prompt. If installing on a Windows based system, double click
install.bat. Follow the prompts.
5. Check and set Configuration
Click on the Administration menu option on the main page to adjust the initial
settings. You will need to log in as OpenLogAdmin. The initial default password
is "OpenLog-1". From the Administration page, you can click on the links at the
top to add techs, subjects, shifts, etc.
7. Start using OpenLog.
Click on the Administration menu option on the main page to adjust the initial
settings. You will need to log in as OpenLogAdmin. The initial default password
is "OpenLog-1". From the Administration page, you can click on the links at the
top to add techs, subjects, shifts, etc.
6. Start using OpenLog.

View File

@@ -14,10 +14,10 @@
** DO NOT EDIT **
************************************************************************
*/
$appname="APPNAME";
$dbname="DBNAME";
$username="DBUSER";
$dbpass="DBPASS";
$appname = "APPNAME";
$dbname = "DBNAME";
$username = "DBUSER";
$dbpass = "DBPASS";
function dberrmsg($dbname) {
echo "
@@ -34,7 +34,7 @@ function dberrmsg($dbname) {
exit();
}
$db=@mysqli_connect("localhost",$username,$dbpass,$dbname);
$db = @mysqli_connect("localhost",$username,$dbpass,$dbname);
if (mysqli_errno($db)) {
dberrmsg($dbname);
}

View File

@@ -280,4 +280,7 @@
is enabled.
- Validate all date and time fields to prevent user entered invalid date
formats from crashing php.
- Fixed profile page to automatically refresh page to show the results
when a user changes their color preferences.

View File

@@ -764,17 +764,25 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id"));
$name = $currentvalues["techname"];
$pass = $passconf = "password_is_unchanged";
$shift = $currentvalues["shift"];
if ($currentvalues["admin"] == 1) {
$admintag = "<input type=\"checkbox\" name=\"admin\" checked>";
if (!empty($currentvalues)) {
$name = $currentvalues["techname"];
$pass = $passconf = "password_is_unchanged";
$shift = $currentvalues["shift"];
if ($currentvalues["admin"] == 1) {
$admintag = "<input type=\"checkbox\" name=\"admin\" checked>";
} else {
$admintag = "<input type=\"checkbox\" name=\"admin\">";
}
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$pass = NULL;
$shift = NULL;
$admintag = "<input type=\"checkbox\" name=\"admin\">";
}
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
@@ -878,10 +886,15 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id"));
$name = $currentvalues["shiftname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
if (!empty($currentvalues)) {
$name = $currentvalues["shiftname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
@@ -952,10 +965,15 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id"));
$name = $currentvalues["subjectname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
if (!empty($currentvalues)) {
$name = $currentvalues["subjectname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = "";
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
@@ -1026,12 +1044,19 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id"));
$name = $currentvalues["displaytxt"];
$priority = $currentvalues["linkpriority"];
$url = $currentvalues["urltxt"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
if (!empty($currentvalues)) {
$name = $currentvalues["displaytxt"];
$priority = $currentvalues["linkpriority"];
$url = $currentvalues["urltxt"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$priority = NULL;
$url = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
// determine where we are in the priority stack
@@ -1145,10 +1170,22 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id"));
$name = $currentvalues["flagname"];
$flagsym = $currentvalues["flagsym"];
$flagcolor = $currentvalues["flagcolor"];
$flagcoloropts = "";
if (!empty($currentvalues)) {
$name = $currentvalues["flagname"];
$flagsym = $currentvalues["flagsym"];
$flagcolor = $currentvalues["flagcolor"];
$flagcoloropts = "";
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$flagsym = NULL;
$flagcolor = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
foreach ($basic_colors as $cname => $chex) {
if ($chex == $flagcolor) {
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\" selected>$cname</option>";
@@ -1156,11 +1193,6 @@ switch ($table) {
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\">$cname</option>";
}
}
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
// set form options for add
$sectiontitle = "<b>Add New Flag</b><br><br>";
@@ -1246,10 +1278,15 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id"));
$name = $currentvalues["lpactionname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
if (!empty($currentvalues)) {
$name = $currentvalues["lpactionname"];
if ($currentvalues["status"] == 1) {
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
} else {
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
$name = NULL;
$activetag = "<input type=\"checkbox\" name=\"active\">";
}
} else {
@@ -1320,9 +1357,15 @@ switch ($table) {
";
// pull current values from database
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id"));
$name = $currentvalues["bannername"];
$bnrcolor = $currentvalues["bannercolor"];
$bnrtextcolor = $currentvalues["textcolor"];
if (!empty($currentvalues)) {
$name = $currentvalues["bannername"];
$bnrcolor = $currentvalues["bannercolor"];
$bnrtextcolor = $currentvalues["textcolor"];
} else {
$name = NULL;
$bnrcolor = NULL;
$bnrtextcolor = NULL;
}
$bnrcoloropts = "";
foreach ($basic_colors as $cname => $chex) {
if ($chex == $bnrcolor) {

View File

@@ -968,15 +968,15 @@ function templateselect($techid, $operation)
<td>
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
if ($isadmin && $operation!=NULL) {
if ($isadmin && $operation != NULL) {
$templaterow = mysqli_query($db, "select * from notetemplates where tech!=\"0\" order by tech asc, templatename asc");
} else {
$templaterow = mysqli_query($db, "select * from notetemplates where tech=\"$techid\" order by templatename asc");
}
printf("<option value=\"%s\" selected>%s</option>", "0", "Select user template");
while ($templateitem = mysqli_fetch_assoc($templaterow)) {
if ($isadmin && $operation!=NULL) {
$techname=dblookup($db, "techs", "techid", "techname", $templateitem["tech"]);
if ($isadmin && $operation != NULL) {
$techname = dblookup($db, "techs", "techid", "techname", $templateitem["tech"]);
printf("<option value=\"%s\">%s(%s)</option>", $templateitem["templateid"], $templateitem["templatename"], $techname);
} else {
printf("<option value=\"%s\">%s</option>", $templateitem["templateid"], $templateitem["templatename"]);
@@ -1020,7 +1020,7 @@ function fix_date($datestring)
if (!$datestring) $datestring = $today;
$datepatt = '/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/';
if (!preg_match($datepatt,$datestring)) $datestring = $today;
if (!preg_match($datepatt, $datestring)) $datestring = $today;
$datestring = mysqli_real_escape_string($db, $datestring);
return $datestring;
}
@@ -1034,7 +1034,7 @@ function fix_time($timestring)
if (!$timestring) $timestring = $now;
$timepatt = '/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/';
if (!preg_match($timepatt,$timestring)) $timestring = $now;
if (!preg_match($timepatt, $timestring)) $timestring = $now;
$timestring = mysqli_real_escape_string($db, $timestring);
return $timestring;
}

View File

@@ -9,7 +9,7 @@
include("functions.php");
if (!array_key_exists("login",$_SESSION) && !array_key_exists("partview",$_REQUEST)) {
if (!array_key_exists("login", $_SESSION) && !array_key_exists("partview", $_REQUEST)) {
header("Location: login.php");
}
@@ -40,7 +40,7 @@ $uids = $_POST['uids'] ?? [];
$partnums = $_POST['partnums'] ?? [];
$sernums = $_POST['sernums'] ?? [];
$actions = $_POST['actions'] ?? [];
$mfreqs = $_POST['mfreqs'] ?? [];
$mfreqs = $_POST['mfreqs'] ?? ["off"];
$schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL;
$partview = $_REQUEST['partview'] ?? NULL;
@@ -98,7 +98,7 @@ if ($add) {
// sanitize and fix blank date and time
$date = fix_date($date);
$time = fix_time($time);
// determine whether supplied date is future or past
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$date\",CURRENT_DATE)"));
// if future, set time to 00:00:01, if past, set to 23:59:59
@@ -199,7 +199,7 @@ if ($add) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
}
@@ -217,7 +217,7 @@ if ($add) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
}
@@ -235,7 +235,7 @@ if ($add) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
}
} else {
@@ -265,7 +265,7 @@ if ($edit) {
// sanitize and fix blank date and time
$date = fix_date($date);
$time = fix_time($time);
// remove cruft from note text
$note = strip_tags($note, "<a>");
$note = mysqli_real_escape_string($db, $note);
@@ -364,7 +364,7 @@ if ($edit) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
}
@@ -382,7 +382,7 @@ if ($edit) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
}
@@ -400,7 +400,7 @@ if ($edit) {
// add it to logparts table
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
// create a maintenance form if required
if ($mfreqs[$plidx] == "on") {
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
}
} else {
@@ -500,7 +500,7 @@ if ($delete) {
format_message(0, "<strong>Note deleted.</strong> <a href=\"lognotes.php\">Return to main page.</a>");
}
if (array_key_exists('login',$_SESSION)) {
if (array_key_exists('login', $_SESSION)) {
// show the template selection line
templateselect($techid, NULL);
}
@@ -619,7 +619,6 @@ $flagcount = 1;
// display checkboxes for all the flags, selecting the ones that are set for this note/template
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
if (in_array($flagcheckbox["flagid"], $theseflags)) {
printf(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
@@ -648,9 +647,15 @@ while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
$flagcount = 1;
}
}
echo "
<br><input type=\"checkbox\" name=\"syncflags\" value=\"1\"><font title=\"Set the selected flags on the other notes in the reference chain\">Set flags on reference chain</font>
";
if (mysqli_num_rows($flagslist)) {
echo "
<br><input type=\"checkbox\" name=\"syncflags\" value=\"1\"><font title=\"Set the selected flags on the other notes in the reference chain\">Set flags on reference chain</font>
";
} else {
echo "
<input type=\"hidden\" name=\"syncflags\" value=\"0\">
";
}
if ($add && $refto) $refstring = $refto;
echo "
@@ -678,16 +683,12 @@ if ($add) {
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
<td align=\"center\"><select name=\"actions[$partline]\">
<option value=\"select\">Select Action</option>
<option value=\"$defaultaction\" selected>Select Action</option>
";
$actrow = mysqli_query($db, "select * from logpartactions");
while ($actitem = mysqli_fetch_assoc($actrow)) {
if ($actitem["status"] == 1) {
if ($actitem["lpactionid"] == $defaultaction) {
printf("<option value=\"%s\" selected>%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
} else {
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
}
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
}
}
echo "
@@ -739,19 +740,28 @@ if ($edit) {
<td align=\"center\">$epsn</td>
<td align=\"center\">
";
$actrow = mysqli_query($db, "select * from logpartactions");
while ($actitem = mysqli_fetch_assoc($actrow)) {
if ($actitem["lpactionid"] == $defaultaction) {
echo "$actitem[lpactionname]";
}
if ($defaultaction) {
// an action was selected previously, so just display it
$actname = dblookup($db, "logpartactions", "lpactionid", "lpactionname", $defaultaction);
echo "$actname";
}
echo "
</td>
";
// find maint form for this line and show link
$mflinknum = mysqli_fetch_assoc(mysqli_query($db, "select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\""))["maintformid"];
echo "
<td align=\"center\"><a href=\"maintformentry.php?mfedit=1&maintformid=$mflinknum\" title=\"Click to view/edit this maintenance form\">$mflinknum</a></td>
<td align=\"center\">
";
$mflinkqry = mysqli_query($db, "select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\"");
if (mysqli_num_rows($mflinkqry)) {
$mflinkdata = mysqli_fetch_assoc($mflinkqry);
$mflinknum = $mflinkdata["maintformid"];
echo "
<a href=\"maintformentry.php?mfedit=1&maintformid=$mflinknum\" title=\"Click to view/edit this maintenance form\">$mflinknum</a>
";
}
echo "
</td>
</tr>
";
}
@@ -764,16 +774,12 @@ if ($edit) {
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
<td align=\"center\"><select name=\"actions[$partline]\">
<option value=\"select\">Select Action</option>
<option value=\"$defaultaction\" selected>Select Action</option>
";
$actrow = mysqli_query($db, "select * from logpartactions");
while ($actitem = mysqli_fetch_assoc($actrow)) {
if ($actitem["status"] == 1) {
if ($actitem["lpactionid"] == $defaultaction) {
printf("<option value=\"%s\" selected>%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
} else {
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
}
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
}
}
echo "

View File

@@ -178,7 +178,7 @@ if ($mfadd) {
// add the record to maintforms
if (! $pdatamismatch) {
$lognoteid = ($lognoteid==NULL) ? 0 : $lognoteid;
$lognoteid = ($lognoteid == NULL) ? 0 : $lognoteid;
mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
$newmaintformid = mysqli_insert_id($db);

View File

@@ -116,6 +116,8 @@ if (!$print) {
// color settings
$hexcolor = "#" . ltrim($hexcolor);
putsetting($modcolor, $hexcolor, $techid);
$currentpage = $_SERVER['PHP_SELF'];
header("Refresh: .1; url=$currentpage");
}
if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\"");

View File

@@ -130,7 +130,6 @@ if ($add) {
}
// run through the memberlist and modify the table
foreach ($memberlist as $memberdev) {
$addqry = ("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag)
values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")");
mysqli_query($db, $addqry);

View File

@@ -35,7 +35,7 @@ $srchploc = $_REQUEST['srchploc'] ?? NULL;
$srchnha = $_REQUEST['srchnha'] ?? NULL;
$srchrepord = $_REQUEST['srchrepord'] ?? NULL;
$srchflags = $_POST['srchflags'] ?? [];
$target = $_REQUEST['target'] ?? ["log","maintform","part"];
$target = $_REQUEST['target'] ?? ["log", "maintform", "part"];
$doparts = PARTS_FUNCTIONS;
$logname = LOG_NAME;

View File

@@ -163,9 +163,9 @@ if ($usertemplateid) {
}
// determine original owner of template
$orig_owner=dblookup($db, "notetemplates","templateid","tech",$templateid);
$orig_owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid);
if ($efftechid != NULL && $efftechid != $orig_owner) {
$operation="add";
$operation = "add";
}
if ($operation == "add") {

View File

@@ -202,7 +202,7 @@ then
else
# proceed with upgrade
# put app in maintenance mode
echo "Putting the applocation in maintenance mode..."
echo "Putting the application in maintenance mode..."
# make sure mod_rewrite is enabled
if [[ ! -e "$APACHE_CONF_DIR/../mods-enabled/rewrite.load" ]]
then