From c11ef1ad8c2f5ac6e293e3e381f758afb9c86ec8 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 10 Feb 2026 22:18:42 -0500 Subject: [PATCH 01/50] Updated various files where the version number exists. Continued work on templates.php. --- CHANGELOG | 6 +- INSTALL | 2 +- VERSION.txt | 2 +- database-initial.sql | 54 ++- database-update.sh | 4 + database-update.sql | 5 + db.php.template | 2 +- distfiles/CHANGELOG | 7 +- distfiles/INSTALL | 2 +- distfiles/about.php | 2 +- distfiles/admin.php | 2 +- distfiles/functions.php | 101 +++--- distfiles/gpl.php | 2 +- distfiles/logentry.php | 366 +++++++++++---------- distfiles/login.php | 2 +- distfiles/lognotes.php | 65 ++-- distfiles/maintform.php | 2 +- distfiles/maintformentry.php | 2 +- distfiles/partentry.php | 2 +- distfiles/parts.php | 2 +- distfiles/profile.php | 2 +- distfiles/refchain.php | 26 +- distfiles/schedmaint.php | 2 +- distfiles/search.php | 2 +- distfiles/settings.php | 2 +- distfiles/templates.php | 616 +++++++++++++++++++++++++++++++++++ files-update.sh | 5 - install.sh | 2 +- 28 files changed, 983 insertions(+), 306 deletions(-) create mode 100644 distfiles/templates.php diff --git a/CHANGELOG b/CHANGELOG index 28ba9c0..ed31190 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 @@ -240,7 +240,3 @@ treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. - -5.2.5 - 2026-02-10 - This is just a version number bump to get on a major-minor-patch - scheme. There are no code changes for this release. diff --git a/INSTALL b/INSTALL index c7ced63..68e2883 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,6 @@ INSTALL OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 diff --git a/VERSION.txt b/VERSION.txt index 462faf7..03f488b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.5 +5.3.0 diff --git a/database-initial.sql b/database-initial.sql index 951c5cf..c1b89c9 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -69,7 +69,7 @@ CREATE TABLE `configs` ( LOCK TABLES `configs` WRITE; /*!40000 ALTER TABLE `configs` DISABLE KEYS */; INSERT INTO `configs` VALUES -(1,'ol_version','5.2.5'), +(1,'ol_version','5.2.4'), (2,'log_name','OpenLog'), (3,'banner','1'), (4,'background_color','#003333'), @@ -232,6 +232,32 @@ LOCK TABLES `flags` WRITE; /*!40000 ALTER TABLE `flags` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `flagmap` +-- + +DROP TABLE IF EXISTS `flagmap`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `flagmap` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `flagmap` +-- + +LOCK TABLES `flagmap` WRITE; +/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */; +/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `links` -- @@ -273,7 +299,6 @@ CREATE TABLE `lognotes` ( `tech` int(11) NOT NULL, `subject` int(11) NOT NULL, `lognote` text DEFAULT NULL, - `refs` tinytext DEFAULT NULL, PRIMARY KEY (`lognoteid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -287,6 +312,31 @@ LOCK TABLES `lognotes` WRITE; /*!40000 ALTER TABLE `lognotes` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `reflinks` +-- + +DROP TABLE IF EXISTS `reflinks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `reflinks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `reflinks` +-- + +LOCK TABLES `reflinks` WRITE; +/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */; +/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `logpartactions` -- diff --git a/database-update.sh b/database-update.sh index cc37f86..f166b4c 100755 --- a/database-update.sh +++ b/database-update.sh @@ -37,3 +37,7 @@ margs="--defaults-extra-file=$mysql_opt_file" # ---------- version 5.2.5 ------------ # Nothing to do # ------------------------------------- + +# ---------- version 5.3.0 ------------ +# Nothing to do +# ------------------------------------- diff --git a/database-update.sql b/database-update.sql index 20326fb..ef76257 100644 --- a/database-update.sql +++ b/database-update.sql @@ -55,3 +55,8 @@ UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version"; -- Update version number UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version"; -- -------------------------------------- + +-- ---------- version 5.3.0 ------------- +-- Update version number +UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version"; +-- -------------------------------------- diff --git a/db.php.template b/db.php.template index 084f062..81521ef 100644 --- a/db.php.template +++ b/db.php.template @@ -3,7 +3,7 @@ /* db.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/CHANGELOG b/distfiles/CHANGELOG index dbadc6b..a1ebe30 100644 --- a/distfiles/CHANGELOG +++ b/distfiles/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 @@ -240,8 +240,3 @@ treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. - -5.2.5 - 2026-02-10 - This is just a version number bump to get on a major-minor-patch - scheme. There are no code changes for this release. - diff --git a/distfiles/INSTALL b/distfiles/INSTALL index c7ced63..68e2883 100644 --- a/distfiles/INSTALL +++ b/distfiles/INSTALL @@ -1,6 +1,6 @@ INSTALL OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 diff --git a/distfiles/about.php b/distfiles/about.php index af3b950..ccdb1d7 100644 --- a/distfiles/about.php +++ b/distfiles/about.php @@ -2,7 +2,7 @@ /* about.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/admin.php b/distfiles/admin.php index daa09a2..25c8747 100644 --- a/distfiles/admin.php +++ b/distfiles/admin.php @@ -2,7 +2,7 @@ /* admin.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/functions.php b/distfiles/functions.php index baafb08..24f2f7d 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -2,7 +2,7 @@ /* functions.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ @@ -181,17 +181,28 @@ function framework($option,$htmltitle,$pagetitle,$print) { } }).datepicker(\"setDate\", defdate); - function insertUrlAtCaret(outputAreaId, inputAreaId) { - var rawlinktext=document.getElementById(inputAreaId).value; - var url='' + rawlinktext + ''; + function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) { + var linktext=document.getElementById(inputTextAreaId).value; + var rawurltext=document.getElementById(inputUrlAreaId).value; + if (rawurltext=='') return; + var lastslashindex=rawurltext.lastIndexOf('/'); + if (lastslashindex==rawurltext.length-1) { + rawurltext=rawurltext.slice(0, -1); + } + if (linktext=='' && rawurltext!= '') { + lastslashindex=rawurltext.lastIndexOf('/'); + var lastpartofurl=rawurltext.substring(lastslashindex+1); + linktext=lastpartofurl; + } + var link='' + linktext + ''; var txtarea = document.getElementById(outputAreaId); var scrollPos = txtarea.scrollTop; var caretPos = txtarea.selectionStart; var front = (txtarea.value).substring(0, caretPos); var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length); - txtarea.value = front + url + back; - caretPos = caretPos + url.length; + txtarea.value = front + link + back; + caretPos = caretPos + link.length; txtarea.selectionStart = caretPos; txtarea.selectionEnd = caretPos; txtarea.focus(); @@ -311,6 +322,7 @@ function sidemenu($noprint=false) { +
Administration
My Profile
Manage Templates
"; if (!isset($_SESSION['login'])) { @@ -375,8 +387,13 @@ function banner($print) { function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) { // look up a single field in a database given a value for a single field - $out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"")); - return($out_data[0]); + $dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""); + if (mysqli_num_rows($dbqry)) { + $out_data=mysqli_fetch_row($dbqry)[0]; + } else { + $out_data=NULL; + } + return($out_data); } function calendar($year,$month,$day,$link_url) { @@ -625,63 +642,53 @@ function islink($il_note) { // determines if the argument is a link in a reference chain // returns 1 if note is a link, 0 if not global $db; - $il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\"")); - if ($il_pq[0]=="") { - $il_hasprev=0; - } else { - $il_hasprev=1; - } - $il_sq=mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where refs like \"%$il_note%\"")); - if ($il_sq) { - $il_hassubs=1; - } else { - $il_hassubs=0; - } - if($il_hassubs || $il_hasprev) { + $refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')"); + if (mysqli_num_rows($refqry)) { return 1; } else { return 0; } } + function generate_chain($chainlink) { // generate a reference chain // takes a single parameter, a noteid // finds all notes that are members of a chain containing the supplied noteid - // returns a sorted array of all notes in chain + // returns a sorted array (chainarray) of all notes in chain global $db; - $refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\""); - $nanote=array(); - $narefs=array(); - while ($allrefs=mysqli_fetch_row($refsqry)) { - $spltrefs=explode(",",$allrefs[1]); - $iptr=0; - while ($iptr"); $note=mysqli_real_escape_string($db,$note); - // remove cruft from references and sanitize - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - $refs=mysqli_real_escape_string($db,$refs); + if (strlen($refstring)) { + // remove everything except numbers and spaces from references and sanitize + $refstring=preg_replace("#[^\d ]{1,}#"," ",$refstring); + $refstring=mysqli_real_escape_string($db,$refstring); + $refstring=trim($refstring); + } if ($doparts==1) { // inspect part data @@ -137,19 +154,29 @@ if ($add) { } if ($authorized) { // add the record to lognotes - mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote,refs) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\",\"$refs\")"); + mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); $newnoteid=mysqli_insert_id($db); - // add this noteid to the appropriate flag_tables + // add references to the reflinks table + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(noteid,target) values($newnoteid,$target)"); + } + } $chainmembers=generate_chain($newnoteid); - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; + + // update the flagmap table + foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$newnoteid\")"); + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); if ($syncflags) { //set flag for reference chain notes foreach ($chainmembers as $refdnote) { - mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$refdnote\")"); + if ($refdnote != $newnoteid) { + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + } } } } @@ -220,98 +247,17 @@ if ($add) { } } } - } elseif ($loadtemplate) { - if ($templateid) { - $templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); - $defaultshift=$templatevalues["shift"]; - $defaultsubject=$templatevalues["subject"]; - $note=$templatevalues["lognote"]; - $refto=$templatevalues["refs"]; - $techid=$templatevalues["tech"]; + } else { + if ($loadtemplate) { + $templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); + $defaultshift=$templatevalues["shift"]; + $defaultsubject=$templatevalues["subject"]; + $note=$templatevalues["lognote"]; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($thistgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$thistgt[0]; } - } elseif ($savetemplate) { - if ($note) { - // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - - // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - if ($authorized) { - if ($templateid) { - // update the existing template - mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where templateid=\"$templateid\""); - - // update the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $thisflag_tbl="flag_".$thisflagid[0]; - if ($flags[0]=="") $flags=[]; - if (in_array($thisflagid[0],$flags)) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) { - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"notetemplates\",\"$templateid\")"); - } - } else { - if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) { - mysqli_query($db,"delete from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""); - } - } - } - } else { - // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) { - // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")"); - $newtemplateid=mysqli_insert_id($db); - - // add this templateid to the appropriate flag_tables - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; - mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")"); - } - $templateid=$newtemplateid; - } else { - $save_nameexists=TRUE; - } - } - } } - } elseif ($copytemplate) { - if ($note) { - // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - - // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - if ($authorized) { - // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) { - // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")"); - $newtemplateid=mysqli_insert_id($db); - - // add this templateid to the appropriate flag_tables - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; - mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")"); - } - $templateid=$newtemplateid; - } else { - $copy_nameexists=TRUE; - } - } - } - } elseif ($deltemplate) { - // delete from notetemplates table - mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); - // delete occurances from the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $delflag_tbl="flag_".$thisflagid[0]; - mysqli_query($db,"delete from $delflag_tbl where target=\"notetemplates\" and id=\"$templateid\""); - } - unset($templateid); } } if ($edit) { @@ -323,7 +269,10 @@ if ($edit) { $note=mysqli_real_escape_string($db,$note); // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refstring=preg_replace("#[a-zA-Z]{1,}#","",$refstring); + } if ($doparts==1) { // inspect part data @@ -359,31 +308,37 @@ if ($edit) { if ($authorized) { // update lognotes table - mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where lognoteid=\"$noteid\""); + mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where lognoteid=\"$noteid\""); - // update the flag_tables - $flagids=mysqli_query($db,"select flagid from flags"); + // update the reflinks table + mysqli_query($db,"delete from reflinks where noteid=\"$noteid\""); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach($refarray as $thisref) { + mysqli_query($db,"insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")"); + } + } $chainmembers=generate_chain($noteid); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $thisflag_tbl="flag_".$thisflagid[0]; - if ($flags[0]=="") $flags=[]; - if (in_array($thisflagid[0],$flags)) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { - // set flag for this noteid - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$noteid\")"); - // set flag for reference chain notes - if ($syncflags) { - foreach($chainmembers as $refdnote) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$refdnote\""))) { - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$refdnote\")"); - } - } - } + + // update the flagmap table + mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + if ($syncflags) { + foreach ($chainmembers as $refdnote) { + if ($refdnote != $noteid) { + mysqli_query($db,"delete from flagmap where lognoteid=\"$refdnote\""); } - } else { - if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { - // clear flag for this note - mysqli_query($db,"delete from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""); + } + } + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")"); + if ($syncflags) { + //set flag for reference chain notes + foreach ($chainmembers as $refdnote) { + if ($refdnote != $noteid) { + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + } } } } @@ -449,25 +404,48 @@ if ($edit) { } else { // no part info was entered + ; } } } } } } - // refresh the note in question from the database - $getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\""); + if ($loadtemplate) { + // get the note in question from the selected template + $getnote=mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""); + } else { + // refresh the note in question from the database + $getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\""); + } $notetoedit=mysqli_fetch_assoc($getnote); } if ($delete) { + // find notes having this note as a target + $drefnoteqry=mysqli_query($db,"select noteid from reflinks where target=\"$noteid\""); + while ($drefnoterow=mysqli_fetch_assoc($drefnoteqry)) { + $drefnotes[]=$drefnoterow["noteid"]; + } + // find targets for this note + $dreftgtqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); + while ($dreftgtrow=mysqli_fetch_assoc($dreftgtqry)) { + $dreftgts[]=$dreftgtrow["target"]; + } + // for every note having this one as a target, add this note's targets + foreach ($drefnotes as $drefnote) { + foreach ($dreftgts as $dreftgt) { + mysqli_query($db,"insert into reflinks(noteid,target) values(\"$drefnote\",\"$dreftgt\")"); + } + } + // delete this note from reflinks + mysqli_query($db,"delete from reflinks where noteid is not null and (noteid=\"$noteid\" or target=\"$noteid\")"); + // delete from lognotes table mysqli_query($db,"delete from lognotes where lognoteid=\"$noteid\""); - // delete occurances from the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $delflag_tbl="flag_".$thisflagid[0]; - mysqli_query($db,"delete from $delflag_tbl where target=\"lognotes\" and id=\"$noteid\""); - } + + // delete occurances from the flagmap table + mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + // delete occurances from the logparts table mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\""); } @@ -488,17 +466,23 @@ if ($add) { $notetime=$now; } if ($edit || $delete) { - $notedate=$notetoedit["date"]; - $notetime=$notetoedit["time"]; + $notedate=$notetoedit["date"] ?? $today; + $notetime=$notetoedit["time"] ?? $now; $defaultshift=$notetoedit["shift"]; $defaultsubject=$notetoedit["subject"]; + $note=$notetoedit["lognote"]; - $refto=$notetoedit["refs"]; + // generate reference string for this note + if ($submit) { + $refstring=NULL; + } + $refstringqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); + while ($thistgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$thistgt[0]; + } $techid=$notetoedit["tech"]; } $techname=dblookup($db,"techs","techid","techname",$techid); -$copy_nameexists=$copy_nameexists ?? NULL; -$save_nameexists=$save_nameexists ?? NULL; if ($submit) { if ($note) { if ($add) { @@ -514,54 +498,64 @@ if ($submit) { if ($delete) { format_message(0,"Note deleted. Return to main page."); } -if ($copy_nameexists) { - format_message(1,"Template copy failed because the name you supplied already exists."); -} -if ($save_nameexists) { - format_message(1,"Template save failed because the name you supplied already exists."); -} echo "
"; if ($_SESSION['login']) { // generate template line echo " -
- "; - if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$templateid); + // list user templates + echo " + +  or  "; - - if ($loadtemplate) { - echo " - - - "; - } - + // list global templates echo " +    + "; + // show load button + echo " + + +
+    - -   - - - - - + Manage templates +

"; @@ -641,28 +635,32 @@ echo "
-Note: 
+Note: 

- Insert Link
+  +  +Insert Link
"; -// get an array of flagids set for this noteid + +// create an array called theseflags of flagids set for this noteid $allflags=mysqli_query($db,"select flagid from flags"); unset($theseflags); $theseflags=[]; while ($thisflag=mysqli_fetch_row($allflags)) { - $thisflagtbl="flag_".$thisflag[0]; if ($templateid) { - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"notetemplates\" and id=\"$templateid\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { $theseflags[]=$thisflag[0]; } } else { - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"lognotes\" and id=\"$noteid\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and lognoteid=\"$noteid\""))) { $theseflags[]=$thisflag[0]; } } } + +// if adding a note/template, only show active flags, otherwise, show all flags if ($add) { $flagslist=mysqli_query($db,"select * from flags where status=1"); } else { @@ -670,6 +668,8 @@ if ($add) { } $flagsperline=8; $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)) { @@ -692,8 +692,12 @@ while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { } echo "
Set flags on reference chain +"; + +if ($add && $refto) $refstring=$refto; +echo "

References:   -         +                               "; if ($add) { diff --git a/distfiles/login.php b/distfiles/login.php index bef3ff6..ba8f9a8 100644 --- a/distfiles/login.php +++ b/distfiles/login.php @@ -2,7 +2,7 @@ /* login.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/lognotes.php b/distfiles/lognotes.php index 1854e05..13365ca 100644 --- a/distfiles/lognotes.php +++ b/distfiles/lognotes.php @@ -2,7 +2,7 @@ /* lognotes.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ @@ -42,14 +42,14 @@ function shifttable_classic($shift, $tgt_date, $db) { if ($dshdr) { // print the shift header printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "
\n"; echo "\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $reftonote=$tablerow["lognoteid"]; - $refs="    \"Add"; - if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $thisnote=$tablerow["lognoteid"]; + $refs="    \"Add"; + if (islink($thisnote)) { + $refs=$refs."      \"View"; } // convert tech number to name $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); @@ -59,27 +59,24 @@ function shifttable_classic($shift, $tgt_date, $db) { $fmtnote=convertweblinks($tablerow["lognote"]); // generate the flags string $flagstring=""; - $allflagqry=mysqli_query($db,"select flagid from flags"); - while ($allflagids=mysqli_fetch_row($allflagqry)) { - $flagid=$allflagids[0]; - $flag_tbl="flag_".$flagid; - if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagname=$flagparam["flagname"]; - $flagstring=$flagstring."$flagsym  "; - } + $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; } if ($flagstring) { $fmtnote=$fmtnote."
".$flagstring."     "; } else { $fmtnote=$fmtnote."
"; } + if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote=$fmtnote."PARTS"; } } // now print the line in the table @@ -134,14 +131,14 @@ function shifttable_clean($shift, $tgt_date, $db) { if ($dshdr) { // print the shift header printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "

"; echo "
Note IDTechSubjectNoteReferences
diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index 62a983a..db5e130 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -2,7 +2,7 @@ /* blankpage.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/search.php b/distfiles/search.php index 04d774b..0b9e9cb 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -2,7 +2,7 @@ /* search.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/settings.php b/distfiles/settings.php index a538c53..cebd1a0 100644 --- a/distfiles/settings.php +++ b/distfiles/settings.php @@ -2,7 +2,7 @@ /* settings.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/templates.php b/distfiles/templates.php new file mode 100644 index 0000000..b8fb6d8 --- /dev/null +++ b/distfiles/templates.php @@ -0,0 +1,616 @@ +"; + if ($hastemplates) { + // print the user header + if ($user=="0") { + echo "Global Templates"; + if ($isadmin) { + echo "    Create or copy a global template
"; + } + } else { + if ($user==$techid) { + echo "My templates"; + echo "    Create or copy a template
"; + } else { + echo "Templates for $tblusername"; + } + } + // print the table + echo "
\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $reftonote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote=$tablerow["lognoteid"]; + $refs="    \"Add"; if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $refs=$refs."      \"View"; } // convert tech number to name $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); @@ -151,17 +148,13 @@ function shifttable_clean($shift, $tgt_date, $db) { $fmtnote=convertweblinks($tablerow["lognote"]); // generate the flags string $flagstring=""; - $allflagqry=mysqli_query($db,"select flagid from flags"); - while ($allflagids=mysqli_fetch_row($allflagqry)) { - $flagid=$allflagids[0]; - $flag_tbl="flag_".$flagid; - if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagname=$flagparam["flagname"]; - $flagstring=$flagstring."$flagsym  "; - } + $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; } if ($flagstring) { $fmtnote=$fmtnote."
".$flagstring."     "; @@ -170,8 +163,8 @@ function shifttable_clean($shift, $tgt_date, $db) { } if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote=$fmtnote."PARTS"; } } // now print the line in the table diff --git a/distfiles/maintform.php b/distfiles/maintform.php index 933db51..ca15206 100644 --- a/distfiles/maintform.php +++ b/distfiles/maintform.php @@ -2,7 +2,7 @@ /* maintform.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 46a4e26..a714180 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -2,7 +2,7 @@ /* maintformentry.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/partentry.php b/distfiles/partentry.php index fdd1b94..08a5490 100644 --- a/distfiles/partentry.php +++ b/distfiles/partentry.php @@ -2,7 +2,7 @@ /* partentry.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/parts.php b/distfiles/parts.php index 5dbcc08..9d6b6d1 100644 --- a/distfiles/parts.php +++ b/distfiles/parts.php @@ -2,7 +2,7 @@ /* parts.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/profile.php b/distfiles/profile.php index c299f66..15af5cb 100644 --- a/distfiles/profile.php +++ b/distfiles/profile.php @@ -2,7 +2,7 @@ /* profile.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/refchain.php b/distfiles/refchain.php index db77d8c..d871b7e 100644 --- a/distfiles/refchain.php +++ b/distfiles/refchain.php @@ -2,14 +2,14 @@ /* refchain.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ include("functions.php"); -$print=$_REQUEST['print']; +$print=$_REQUEST['print'] ?? ""; $chainnote=$_REQUEST['chainnote']; $logname=LOG_NAME; @@ -59,17 +59,29 @@ while($mptr$flagsym  "; } } + + //$allflagqry=mysqli_query($db,"select flagid from flags"); + //while ($allflagids=mysqli_fetch_row($allflagqry)) { + //$flagid=$allflagids[0]; + //$flag_tbl="flag_".$flagid; + //if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { + //$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); + //$flagcolor=$flagparam["flagcolor"]; + //$flagsym=$flagparam["flagsym"]; + //$flagstring=$flagstring."$flagsym  "; + //} + //} + if ($flagstring) $fmtnote=$fmtnote."
".$flagstring; printf("
"; + echo ""; + while ($tablerow = mysqli_fetch_assoc($templatequery)) { + $templateid=$tablerow["templateid"]; + $templatename=$tablerow["templatename"]; + // convert shift number to name + $shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + // convert subject number to name + $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + // create links of urls in note + $fmtnote=convertweblinks($tablerow["lognote"]); + // generate the flags string + $flagstring=""; + $flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; + } + if ($flagstring) { + $fmtnote=$fmtnote."
".$flagstring."     "; + } else { + $fmtnote=$fmtnote."
"; + } + // generate a reference string + $refstring=NULL; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($tgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$tgt[0]; + } + // now print the line in the table + if (!$isadmin && $user=="0") { + $nameblock="$templatename"; + } else { + $nameblock="$templatename"; + } + printf( + " + + + + + + \n", + $nameblock, + $shiftname, + $subjname, + $fmtnote, + $refstring + ); + }; + echo "
Template NameShiftSubjectNoteReferences
%s %s%s%s%s



"; + } else { + if ($user=="0") { + echo "There are no global templates"; + if ($isadmin) { + echo "    Add a new global template"; + } + } else { + if ($user==$techid) { + echo "You have no templates"; + } else { + echo "$tblusername has no templates"; + } + if (($user==$techid) || $isadmin) { + echo "    Add a new template
"; + } + } + echo "

"; + } + echo "
"; +} + +function templateselect($db,$techid) { + echo " + + "; + // generate template selection line + echo " + + "; + // list user templates + echo " + + +
+  or  + "; + // list global templates + echo " +    + "; + // show load button + echo " + + + Manage templates +
+
+
+ "; +} + +// ******** begin database manipulation ******** + +if ($usertemplateid) { + $templateid=$usertemplateid; +} else if ($globaltemplateid) { + $templateid=$globaltemplateid; +} else { + $loadtemplate=NULL; +} + +if ($add) { + if ($submit) { + if ($note) { + // remove cruft from note text + $note=strip_tags($note,""); + $note=mysqli_real_escape_string($db,$note); + + if ($add_auth) { + // check if name supplied + if ($templatename) { + $namesupplied=TRUE; + // check if supplied name already exists + if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { + // add the record to notetemplates + mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); + $newtemplateid=mysqli_insert_id($db); + + // update the flagmap table + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); + } + + // add references to the reflinks table + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)"); + } + } + $templateid=$newtemplateid; + } else { + $nameexists=TRUE; + } + } else { + $namesupplied=FALSE; + } + } + } + } +} +if ($edit) { + if ($submit) { + if ($note) { + // remove cruft from note text + $note=strip_tags($note,""); + $note=mysqli_real_escape_string($db,$note); + + if ($edit_auth) { + // check if name was supplied + if ($templatename) { + $namesupplied=TRUE; + // update notetemplates + mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); + + // update the flagmap table + mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); + } + + // update the reflinks table + mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)"); + } + } + } else { + $namesupplied=FALSE; + } + } + } + } + if ($delete) { + if ($del_auth) { + // update notetemplates + mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); + // update the flagmap table + mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + // update the reflinks table + mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + $templateid=NULL; + $note=NULL; + } + } +} + +// ******** end database manipulation ******** + +pagetable("begin"); +if (!$print) { + pageblock("left","begin"); + sidemenu(); + pageblock("left","end"); +} +pageblock("right","begin"); +banner($print); + + +if ($submit || $delete) { + // show success/failure messages + $nameexists=$nameexists ?? NULL; + $namesupplied=$namesupplied ?? NULL; + if ($delete) { + format_message(0,"Template deleted."); + } else { + $addfail=FALSE; + if ($add) { + if ($nameexists) { + format_message(1,"Template save failed because the name you supplied already exists. Please try again."); + $addfail=TRUE; + } + if (!$namesupplied) { + format_message(1,"Template save failed because you didn't supply a name. Please try again."); + $addfail=TRUE; + } + if (!$note) { + format_message(1,"Template save failed because you didn't enter any note text. Please try again."); + $addfail=TRUE; + } + if (!$addfail) format_message(0,"Template added."); + } + $editfail=FALSE; + if ($edit) { + if (!$namesupplied) { + format_message(1,"Template save failed because you didn't supply a name. Please try again."); + $editfail=TRUE; + } + if (!$note) { + format_message(1,"Template save failed because you didn't enter any note text. Please try again."); + $editfail=TRUE; + } + if (!$editfail) format_message(0,"Template modified."); + } + } +} + +if ($delete) { + // just show the link back to the templates page + echo " +
Manage templates



+ "; +} else if ($add || $edit) { + // Display the input form + if ($loadtemplate) { + // make templateid the selected template + if ($usertemplateid) { + $templateid=$usertemplateid; + } else if ($globaltemplateid) { + $templateid=$globaltemplateid; + } else { + $templateid=NULL; + } + } + if ($edit || $loadtemplate) { + // use values from the templateid supplied with a defined tech id + $loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); + $filltemplatename=$loadeddata["templatename"]; + if ($tech) { + $filltech=$tech; + } else if ($efftechid) { + $filltech=$efftechid; + } else { + $filltech=$techid; + } + $fillshift=$loadeddata["shift"]; + $fillsubject=$loadeddata["subject"]; + $fillnote=$loadeddata["lognote"]; + } else { + // use empty values with a defined tech id + $filltemplatename=NULL; + if ($tech) { + $filltech=$tech; + } else if ($efftechid) { + $filltech=$efftechid; + } else { + $filltech=$techid; + } + $fillshift=$defaultshift; + $fillsubject=NULL; + $fillnote=NULL; + } + + if ($add) $optext="Adding new"; + if ($edit) $optext="Editing"; + if ($isadmin && $filltech==0) { + echo " +
$optext global template

+ "; + } else { + echo " +
$optext user template

+ "; + } + + // show the template selection line + templateselect($db,$techid); + + // start template entry section + echo " +
+ + + "; + if ($isadmin) { + if ($filltech!="0") { + // allow tech selection + echo " + + "; + } else { + // don't show tech line, just force value to 0 + echo " + + "; + } + } else { + $add_auth=TRUE; + $edit_auth=TRUE; + echo " + + "; + } + echo " + + + +
Template Name:   +
Tech:   +
Shift:   + Subject:   +
+ + Note: 
+
+   +   + Insert Link
+ "; + + // create an array called theseflags and optionally load it with flagids set for this template + unset($theseflags); + $theseflags=[]; + if ($templateid) { + $allflags=mysqli_query($db,"select flagid from flags"); + while ($thisflag=mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { + $theseflags[]=$thisflag[0]; + } + } + } + + $flagslist=mysqli_query($db,"select * from flags where status=1"); + $flagsperline=8; + $flagcount=1; + + // display checkboxes for all the flags, selecting the ones that are set for this template + while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + if ($edit && in_array($flagcheckbox["flagid"],$theseflags)) { + printf("%s", + $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + } else { + $flagid=$flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf("%s", + $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + } + } + if ($flagcount<$flagsperline) { + echo "   "; + $flagcount++; + } else { + echo "
"; + $flagcount=1; + } + } + + if ($edit || $loadtemplate) { + // generate a reference string + $refstring=NULL; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($tgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$tgt[0]; + } + } + echo " +

References:   +          +                       + "; + + if ($add && $add_auth) { + echo " + + + "; + } + if ($edit && $edit_auth) { + echo " + + + + "; + if ($del_auth) { + echo" +      

+ Deleted templates are irretrievable! + "; + } + } + + echo " +
+
+ "; +} else { + echo "
"; + // Show my user template table + templatetable($db,$techid,$techid); + + // Show global template table + templatetable($db,$techid,"0"); + + if ($isadmin) { + // Show template tables for other users + $techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0"); + while ($techtblrow=(mysqli_fetch_row($techqry))) { + templatetable($db,$techid,$techtblrow[0]); + } + } +} + + +banner($print); +pageblock("right","end"); +pagetable("end"); + +framework("end","","",$print); + +?> diff --git a/files-update.sh b/files-update.sh index de5086f..962ad47 100755 --- a/files-update.sh +++ b/files-update.sh @@ -41,8 +41,3 @@ fi # ---------- version 5.2.4.4 ----------- # No changes # -------------------------------------- - -# ---------- version 5.2.5 ------------- -# No changes -# -------------------------------------- - diff --git a/install.sh b/install.sh index 46fe055..c26db53 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ APP_NAME="OpenLog" DEFAULT_DB_NAME="openlog" -APP_VERSION="5.2.5" +APP_VERSION="5.3.0" DOC_ROOT="/var/www" INSTALL_LOC="openlog" APACHE_CONF_DIR="/etc/apache2/conf-available" From 78ee18f03b1533f425ab2040c525858c0c94c09a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 11 Feb 2026 15:48:46 -0500 Subject: [PATCH 02/50] Created a useful README.md file --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index e69de29..e8bfa0d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,44 @@ +# OpenLog # + +OpenLog is an online logbook application. It allows anyone with a web browser to read, enter, and search for notes on any subject. The available shifts, employees, and subjects are easily configured. Notes can be referred to other notes and the entire chain of referenced notes can be displayed in a single page. This makes it convenient to track ongoing projects or actions on a particular piece of equipment over a long period of time. Version 5.0 adds parts tracking functionality. Notes can have parts change information associated with them and maintenance/repair forms can be generated for parts. Parts related functions can be disabled to reduce clutter if they are not needed. Version 5.1 adds scheduled maintenance functionality, which can also be disabled if not needed. Notes, parts, and maintenance forms can be searched for based on a number of criteria. The look and feel of the OpenLog pages are easily changed. Settings that affect all users can be changed in the Administration menu. Each user can personalize his or her own settings in the My Profile menu. No browser specific HTML is used in OpenLog, so it should be useable in any browser, and it has been tested using Google Chrome, Mozilla Firefox and Microsoft Internet Explorer. + +## Prerequisites ## + +Linux - The installer is written to automate installation on Debian based Linux servers, but OpenLog itself should run on any current Linux distribution, albeit installation will need to be accomplished manually. +Apache2 - Current development is using version 2.4.65 +MySQL or MariaDB - Current development is using MariaDB version 11.8.3 +php - Current development is using version 8.4.11 + + +## Installation ## + +### Linux Instructions ### + +> [!NOTE] +> These instructions are used to either install a new instance of OpenLog or upgrade an existing one. + +1. Unzip the OpenLog-x.x.x.tar.gz file you've downloaded into a convenient place. +2. `cd OpenLog-x.x.x` +3. `sudo ./install.sh` + +The installer will check for installation of the required packages and prompt for their installation if not found. +You'll then be prompted for the webserver's install location. The default should work for standard installations. +You'll then be prompted for the installation location of this instance of OpenLog. You should come up with a unique name. +If this directory already exists and contains an instance of OpenLog, you will be prompted to cancel the process or upgrade this instance. If you choose to upgrade, your OpenLog instance will be upgraded and you're done. +If this directory does not exist, it will be created and a new instance will be installed. You can have multiple instances of OpenLog running under different names in different directories. For example, if you wanted to create an Operations Log, you could enter `opslog`. +If installing a new instance, for example, the Operations Log referred to above, you could enter `OpsLog` or `Operations Log`. +For a new instance, you'll br prompted for the name of the database to be created. You should choose something appropriate, like `opslog` for the example given. +Next, you'll be prompted to enable the apache2 configuration for this instance. +The new instance will now be installed and accessible. You will be given some important information. +> [!IMPORTANT] +> The default login credentials for the initial admin user are: +> login: `OpenLogAdmin` +> password: `OpenLog-1` +> Make note of these credentials, otherwise you will not be able to login and configure your new installation. +> +> It is highly recommended that you change the OpenLogAdmin user password and/or create your own admin user (with a secure password) and disable this default account after logging in for the first time. + + +## History ## + +OpenLog was written to replace a creaky old inefficient error prone Access database which had in turn replaced stacks of paper logbooks. Now, with some improvements and over 15 years and 44000 notes later in a production environment, it's still going strong. From a79f73a8ca6162ae71c88042ac150eab75267986 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 11 Feb 2026 22:28:02 -0500 Subject: [PATCH 03/50] Continued work on templates.php --- README.md | 56 ++++++---- distfiles/templates.php | 237 +++++++++++++++++++--------------------- 2 files changed, 145 insertions(+), 148 deletions(-) diff --git a/README.md b/README.md index e8bfa0d..cec85a9 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,26 @@ # OpenLog # -OpenLog is an online logbook application. It allows anyone with a web browser to read, enter, and search for notes on any subject. The available shifts, employees, and subjects are easily configured. Notes can be referred to other notes and the entire chain of referenced notes can be displayed in a single page. This makes it convenient to track ongoing projects or actions on a particular piece of equipment over a long period of time. Version 5.0 adds parts tracking functionality. Notes can have parts change information associated with them and maintenance/repair forms can be generated for parts. Parts related functions can be disabled to reduce clutter if they are not needed. Version 5.1 adds scheduled maintenance functionality, which can also be disabled if not needed. Notes, parts, and maintenance forms can be searched for based on a number of criteria. The look and feel of the OpenLog pages are easily changed. Settings that affect all users can be changed in the Administration menu. Each user can personalize his or her own settings in the My Profile menu. No browser specific HTML is used in OpenLog, so it should be useable in any browser, and it has been tested using Google Chrome, Mozilla Firefox and Microsoft Internet Explorer. +OpenLog is an online logbook application. It allows anyone with a web browser to read, enter, and search for notes on any subject. + +The available shifts, employees, and subjects are easily configured. Notes can be referred to other notes and the entire chain of referenced notes can be displayed in a single page. This makes it convenient to track ongoing projects or actions on a particular piece of equipment over a long period of time. + +Version 5.0 adds parts tracking functionality. Notes can have parts change information associated with them and maintenance/repair forms can be generated for parts. Parts related functions can be disabled to reduce clutter if they are not needed. + +Version 5.1 adds scheduled maintenance functionality, which can also be disabled if not needed. Notes, parts, and maintenance forms can be searched for based on a number of criteria. + +The look and feel of the OpenLog pages are easily changed. Settings that affect all users can be changed in the Administration menu. Each user can personalize his or her own settings in the My Profile menu. + +No browser specific HTML is used in OpenLog, so it should be useable in any browser, and it has been tested using Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, and Edge. ## Prerequisites ## -Linux - The installer is written to automate installation on Debian based Linux servers, but OpenLog itself should run on any current Linux distribution, albeit installation will need to be accomplished manually. -Apache2 - Current development is using version 2.4.65 -MySQL or MariaDB - Current development is using MariaDB version 11.8.3 -php - Current development is using version 8.4.11 - +- Linux - The installer is written to automate installation on Debian based Linux servers, but OpenLog itself should run on any current Linux distribution, albeit installation will need to be accomplished manually. +- Apache2 - Current development is using version 2.4.65 +- MySQL or MariaDB - Current development is using MariaDB version 11.8.3 +- php - Current development is using version 8.4.11 ## Installation ## -### Linux Instructions ### - > [!NOTE] > These instructions are used to either install a new instance of OpenLog or upgrade an existing one. @@ -21,22 +28,23 @@ php - Current development is using version 8.4.11 2. `cd OpenLog-x.x.x` 3. `sudo ./install.sh` -The installer will check for installation of the required packages and prompt for their installation if not found. -You'll then be prompted for the webserver's install location. The default should work for standard installations. -You'll then be prompted for the installation location of this instance of OpenLog. You should come up with a unique name. -If this directory already exists and contains an instance of OpenLog, you will be prompted to cancel the process or upgrade this instance. If you choose to upgrade, your OpenLog instance will be upgraded and you're done. -If this directory does not exist, it will be created and a new instance will be installed. You can have multiple instances of OpenLog running under different names in different directories. For example, if you wanted to create an Operations Log, you could enter `opslog`. -If installing a new instance, for example, the Operations Log referred to above, you could enter `OpsLog` or `Operations Log`. -For a new instance, you'll br prompted for the name of the database to be created. You should choose something appropriate, like `opslog` for the example given. -Next, you'll be prompted to enable the apache2 configuration for this instance. -The new instance will now be installed and accessible. You will be given some important information. -> [!IMPORTANT] -> The default login credentials for the initial admin user are: -> login: `OpenLogAdmin` -> password: `OpenLog-1` -> Make note of these credentials, otherwise you will not be able to login and configure your new installation. -> -> It is highly recommended that you change the OpenLogAdmin user password and/or create your own admin user (with a secure password) and disable this default account after logging in for the first time. +* The installer will check for installation of the required packages and prompt for their installation if not found. +* You'll then be prompted for the webserver's install location. The default should work for standard installations. +* You'll then be prompted for the installation location of this instance of OpenLog. You should come up with a unique name. +* If this directory already exists and contains an instance of OpenLog, you will be prompted to cancel the process or upgrade this instance. + * If you choose to upgrade, your OpenLog instance will be upgraded and you're done. +* If this directory does not exist, it will be created and a new instance will be installed. You can have multiple instances of OpenLog running under different names in different directories. For example, if you wanted to create an Operations Log, you could enter `opslog`. + * In the Operations Log example referred to above, you could enter `OpsLog` or `Operations Log`. + * You'll br prompted for the name of the database to be created. You should choose something appropriate, like `opslog` for the example given. + * Next, you'll be prompted to enable the apache2 configuration for this instance. + *The new instance will now be installed and accessible. You will be given some important information. + > [!IMPORTANT] + > The default login credentials for the initial admin user are: + > login: `OpenLogAdmin` + > password: `OpenLog-1` + > Make note of these credentials, otherwise you will not be able to login and configure your new installation. + > + > It is highly recommended that you change the OpenLogAdmin user password and/or create your own admin user (with a secure password) and disable this default account after logging in for the first time. ## History ## diff --git a/distfiles/templates.php b/distfiles/templates.php index b8fb6d8..192aee8 100644 --- a/distfiles/templates.php +++ b/distfiles/templates.php @@ -16,7 +16,6 @@ if (!$_SESSION['login'] && !$_REQUEST['partview']) { $techid=$_SESSION['login'] ?? NULL; $isadmin=dblookup($db,"techs","techid","admin",$techid); $print=$_REQUEST['print'] ?? NULL; -$tech=$_REQUEST['tech'] ?? NULL; $efftechid=$_REQUEST['efftechid'] ?? NULL; $shift=$_REQUEST['shift'] ?? NULL; $subject=$_REQUEST['subject'] ?? NULL; @@ -24,9 +23,10 @@ $note=$_REQUEST['note'] ?? NULL; $flags=$_POST['flags'] ?? []; $refstring=$_REQUEST['refstring'] ?? NULL; $submit=$_REQUEST['submit'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; +$operation=$_REQUEST['operation'] ?? NULL; +//$add=$_REQUEST['add'] ?? NULL; +//$edit=$_REQUEST['edit'] ?? NULL; +//$delete=$_REQUEST['delete'] ?? NULL; $templateid=$_REQUEST['templateid'] ?? NULL; $templatename=$_REQUEST['templatename'] ?? NULL; $usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; @@ -49,22 +49,14 @@ if ($print=="Printer Friendly") { } framework("begin","$logname","Note Templates",$print); + +// make basic determination about authorization if ($isadmin) { - $add_auth=TRUE; - $edit_auth=TRUE; - $del_auth=TRUE; + $authorized=TRUE; } else if ($efftechid==$techid) { - $add_auth=TRUE; - $edit_auth=TRUE; - $del_auth=TRUE; -} else if ($tech==$techid) { - $add_auth=TRUE; - $edit_auth=TRUE; - $del_auth=TRUE; + $authorized=TRUE; } else { - $add_auth=FALSE; - $edit_auth=FALSE; - $del_auth=FALSE; + $authorized=FALSE; } var_dump($_REQUEST); @@ -85,13 +77,9 @@ function templatetable($db,$techid,$user) { // print the user header if ($user=="0") { echo "Global Templates"; - if ($isadmin) { - echo "    Create or copy a global template
"; - } } else { if ($user==$techid) { echo "My templates"; - echo "    Create or copy a template
"; } else { echo "Templates for $tblusername"; } @@ -133,7 +121,7 @@ function templatetable($db,$techid,$user) { if (!$isadmin && $user=="0") { $nameblock="$templatename"; } else { - $nameblock="$templatename"; + $nameblock="$templatename"; } printf( " @@ -154,25 +142,19 @@ function templatetable($db,$techid,$user) { } else { if ($user=="0") { echo "There are no global templates"; - if ($isadmin) { - echo "    Add a new global template"; - } } else { if ($user==$techid) { echo "You have no templates"; } else { echo "$tblusername has no templates"; } - if (($user==$techid) || $isadmin) { - echo "    Add a new template
"; - } } echo "

"; } echo "
"; } -function templateselect($db,$techid) { +function templateselect($db,$techid,$operation) { echo "
"; @@ -207,6 +189,7 @@ function templateselect($db,$techid) { "; // show load button echo " + @@ -228,14 +211,14 @@ if ($usertemplateid) { $loadtemplate=NULL; } -if ($add) { +if ($operation=="add") { if ($submit) { if ($note) { // remove cruft from note text $note=strip_tags($note,""); $note=mysqli_real_escape_string($db,$note); - if ($add_auth) { + if ($authorized) { // check if name supplied if ($templatename) { $namesupplied=TRUE; @@ -270,17 +253,26 @@ if ($add) { } } } -if ($edit) { +if ($operation=="edit" || $operation=="delete") { + // test to see if this templateid is owned by techid to prevent hijacking + $owner=dblookup($db,"notetemplates","templateid","tech",$templateid); + if (!$isadmin && ($owner!=$techid)) $authorized=FALSE; + if ($submit) { if ($note) { // remove cruft from note text $note=strip_tags($note,""); $note=mysqli_real_escape_string($db,$note); - if ($edit_auth) { + if ($templatename) { + $namesupplied=TRUE; + } else { + $namesupplied=FALSE; + } + + if ($authorized) { // check if name was supplied if ($templatename) { - $namesupplied=TRUE; // update notetemplates mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); @@ -300,14 +292,12 @@ if ($edit) { mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)"); } } - } else { - $namesupplied=FALSE; } } } } - if ($delete) { - if ($del_auth) { + if ($operation=="delete") { + if ($authorized) { // update notetemplates mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); // update the flagmap table @@ -332,50 +322,63 @@ pageblock("right","begin"); banner($print); -if ($submit || $delete) { +if ($submit || $operation=="delete") { // show success/failure messages $nameexists=$nameexists ?? NULL; $namesupplied=$namesupplied ?? NULL; - if ($delete) { - format_message(0,"Template deleted."); - } else { + + if ($operation=="add") { $addfail=FALSE; - if ($add) { - if ($nameexists) { - format_message(1,"Template save failed because the name you supplied already exists. Please try again."); - $addfail=TRUE; - } - if (!$namesupplied) { - format_message(1,"Template save failed because you didn't supply a name. Please try again."); - $addfail=TRUE; - } - if (!$note) { - format_message(1,"Template save failed because you didn't enter any note text. Please try again."); - $addfail=TRUE; - } - if (!$addfail) format_message(0,"Template added."); + if ($nameexists) { + format_message(1,"Template creation failed because the name you supplied already exists. Please try again."); + $addfail=TRUE; } + if (!$namesupplied) { + format_message(1,"Template creation failed because you didn't supply a name. Please try again."); + $addfail=TRUE; + } + if (!$note) { + format_message(1,"Template creation failed because you didn't enter any note text. Please try again."); + $addfail=TRUE; + } + if (!$authorized) { + format_message(1,"Template creation failed because you are not authorized to do so."); + $addfail=TRUE; + } + if (!$addfail) format_message(0,"Template created."); + } + if ($operation=="edit") { $editfail=FALSE; - if ($edit) { - if (!$namesupplied) { - format_message(1,"Template save failed because you didn't supply a name. Please try again."); - $editfail=TRUE; - } - if (!$note) { - format_message(1,"Template save failed because you didn't enter any note text. Please try again."); - $editfail=TRUE; - } - if (!$editfail) format_message(0,"Template modified."); + if (!$namesupplied) { + format_message(1,"Template save failed because you didn't supply a name. Please try again."); + $editfail=TRUE; } + if (!$note) { + format_message(1,"Template save failed because you didn't enter any note text. Please try again."); + $editfail=TRUE; + } + if (!$authorized) { + format_message(1,"Template save failed because you are not authorized to do so."); + $editfail=TRUE; + } + if (!$editfail) format_message(0,"Template modified."); + } + if ($operation=="delete") { + $deletefail=FALSE; + if (!$authorized) { + format_message(1,"Template delete failed because you are not authorized to do so."); + $deletefail=TRUE; + } + if (!$deletefail) format_message(0,"Template deleted."); } } -if ($delete) { +if ($operation=="delete") { // just show the link back to the templates page echo "
Manage templates



"; -} else if ($add || $edit) { +} else if ($operation=="add" || $operation=="edit") { // Display the input form if ($loadtemplate) { // make templateid the selected template @@ -387,14 +390,14 @@ if ($delete) { $templateid=NULL; } } - if ($edit || $loadtemplate) { + if ($operation=="edit" || $loadtemplate) { // use values from the templateid supplied with a defined tech id $loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); $filltemplatename=$loadeddata["templatename"]; - if ($tech) { - $filltech=$tech; - } else if ($efftechid) { + if ($efftechid) { $filltech=$efftechid; + } else if ($isadmin && $loadeddata["tech"]=="0") { + $filltech="0"; } else { $filltech=$techid; } @@ -404,9 +407,7 @@ if ($delete) { } else { // use empty values with a defined tech id $filltemplatename=NULL; - if ($tech) { - $filltech=$tech; - } else if ($efftechid) { + if ($efftechid) { $filltech=$efftechid; } else { $filltech=$techid; @@ -416,20 +417,15 @@ if ($delete) { $fillnote=NULL; } - if ($add) $optext="Adding new"; - if ($edit) $optext="Editing"; - if ($isadmin && $filltech==0) { - echo " -
$optext global template

- "; - } else { - echo " -
$optext user template

- "; - } + if ($operation=="add") $optext="Creating new"; + if ($operation=="edit") $optext="Editing"; + echo " +
$optext template

+ "; + // show the template selection line - templateselect($db,$techid); + templateselect($db,$techid,$operation); // start template entry section echo " @@ -439,33 +435,29 @@ if ($delete) { "; if ($isadmin) { - if ($filltech!="0") { - // allow tech selection - echo " - Tech:   - - "; + echo " + Tech:   + - "; + echo ""; } + if ($techalpha) $torder="techname"; else $torder="techid"; + $techrow=mysqli_query($db,"select * from techs order by $torder asc"); + while ($techitem=mysqli_fetch_assoc($techrow)) { + if ($techitem["techid"]==$filltech) { + printf("",$techitem["techid"],$techitem["techname"]); + } else { + printf("",$techitem["techid"],$techitem["techname"]); + } + } + echo " + + "; } else { - $add_auth=TRUE; - $edit_auth=TRUE; + $authorized=TRUE; echo " "; @@ -532,7 +524,7 @@ if ($delete) { // display checkboxes for all the flags, selecting the ones that are set for this template while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($edit && in_array($flagcheckbox["flagid"],$theseflags)) { + if ($operation=="edit" && in_array($flagcheckbox["flagid"],$theseflags)) { printf("%s", $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); } else { @@ -551,7 +543,7 @@ if ($delete) { } } - if ($edit || $loadtemplate) { + if ($operation=="edit" || $loadtemplate) { // generate a reference string $refstring=NULL; $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); @@ -565,24 +557,20 @@ if ($delete) {                       "; - if ($add && $add_auth) { + if ($operation=="add" && $authorized) { echo " - + "; } - if ($edit && $edit_auth) { + if ($operation=="edit" && $authorized) { echo " - + +      

+ Deleted templates are irretrievable! "; - if ($del_auth) { - echo" -      

- Deleted templates are irretrievable! - "; - } } echo " @@ -590,7 +578,8 @@ if ($delete) {
"; } else { - echo "
"; + echo "
Create or copy a template

"; + // Show my user template table templatetable($db,$techid,$techid); From 0547e97479af7c4a9217677649544d72f0d9d62d Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 12 Feb 2026 19:42:36 -0500 Subject: [PATCH 04/50] Moved templateselect function from templates.php to functions.php for use in other pages. --- distfiles/functions.php | 50 ++++++++++++++++++++++++++++++++++++ distfiles/templates.php | 57 +++-------------------------------------- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/distfiles/functions.php b/distfiles/functions.php index 24f2f7d..d737cc4 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -931,4 +931,54 @@ function format_message($msgtype,$msgtxt) { "; } +function templateselect($techid,$operation) { + // Displays a line enabling selection of a user or global template + // $techid is the id number of the current tech + // $operation is one of "add" "edit" "delete" + global $db; + echo " + + "; + // generate template selection line + echo " + + "; + // list user templates + echo " + + +
+  or  + "; + // list global templates + echo " +    + "; + // show load button + echo " + + + + Manage templates +
+
+ + "; +} ?> diff --git a/distfiles/templates.php b/distfiles/templates.php index 192aee8..74a691c 100644 --- a/distfiles/templates.php +++ b/distfiles/templates.php @@ -24,9 +24,6 @@ $flags=$_POST['flags'] ?? []; $refstring=$_REQUEST['refstring'] ?? NULL; $submit=$_REQUEST['submit'] ?? NULL; $operation=$_REQUEST['operation'] ?? NULL; -//$add=$_REQUEST['add'] ?? NULL; -//$edit=$_REQUEST['edit'] ?? NULL; -//$delete=$_REQUEST['delete'] ?? NULL; $templateid=$_REQUEST['templateid'] ?? NULL; $templatename=$_REQUEST['templatename'] ?? NULL; $usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; @@ -59,7 +56,7 @@ if ($isadmin) { $authorized=FALSE; } -var_dump($_REQUEST); +// var_dump($_REQUEST); function templatetable($db,$techid,$user) { // Show template table @@ -154,53 +151,6 @@ function templatetable($db,$techid,$user) { echo "
"; } -function templateselect($db,$techid,$operation) { - echo " -
- "; - // generate template selection line - echo " - - "; - // list user templates - echo " - - -
-  or  - "; - // list global templates - echo " -    - "; - // show load button - echo " - - - - Manage templates -
-
-
- "; -} - // ******** begin database manipulation ******** if ($usertemplateid) { @@ -422,10 +372,9 @@ if ($operation=="delete") { echo "
$optext template

"; - - + // show the template selection line - templateselect($db,$techid,$operation); + templateselect($techid,$operation); // start template entry section echo " From 07a6d352b0f212f60c99a7b378f8e6ed7a7d83f0 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 12 Feb 2026 20:38:40 -0500 Subject: [PATCH 05/50] changed path of backup directory inside the package directory to avoid cluttering up package directory. --- install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index c26db53..1fdde6a 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,6 @@ APP_VERSION="5.3.0" DOC_ROOT="/var/www" INSTALL_LOC="openlog" APACHE_CONF_DIR="/etc/apache2/conf-available" -BACKUP_DIR="openlog-previous-installation" LANDING_PAGE="lognotes.php" CONFIG_TABLE="configs" CONFIG_NAME_COLUMN="confname" @@ -202,7 +201,9 @@ then abort_exit else # proceed with upgrade - mkdir -p backups + datestamp=$(date +%Y-%m-%d_%H:%M:%S) + backupdir=backups/$datestamp + mkdir -p $backupdir operation="upgraded" curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2) @@ -216,14 +217,14 @@ then echo "database = $curr_dbname" >> $mysql_opt_file echo "batch" >> $mysql_opt_file echo "disable-column-names" >> $mysql_opt_file - + # back up existing database echo "Backing up the current database to the package directory." - mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql + mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > $backupdir/$curr_dbname-$datestamp-backup.sql # back up existing installation echo "Backing up current installation to the package directory." - cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup + cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup # delete all existing installation files except db.php find $install_path/ -mindepth 1 -not -name 'db.php' -delete @@ -267,6 +268,8 @@ then echo "" echo "Setting file ownership . . ." chown -R $httpd_user_group $install_path + echo "Backups of the previous openlog files and the previous database were made" + echo "and are located in the $backupdir directory." fi else # This was a mistake. Exit now to avoid clobbering another app. From d2cb1851d0fb82e06e3e9b6e06ab0d265ae7f2a7 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 12 Feb 2026 20:40:05 -0500 Subject: [PATCH 06/50] restored the flag table and reference chain modifiactions that somehow got deleted --- database-update.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/database-update.sh b/database-update.sh index f166b4c..269a666 100755 --- a/database-update.sh +++ b/database-update.sh @@ -39,5 +39,80 @@ margs="--defaults-extra-file=$mysql_opt_file" # ------------------------------------- # ---------- version 5.3.0 ------------ -# Nothing to do +# +echo "Started database updates for OpenLog version 5.3.0..." + +# Import old flag data from old scheme to new flagmap table +if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]] +then + echo "Importing flag data from old scheme to new flagmap table..." + for flagnumber in $(mysql $margs -e "select flagid from flags") + do + flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'") + if [[ -n "$flag_x" ]] + then + for tgtid in $(mysql $margs -e "select id from flag_$flagnumber") + do + target=$(mysql $margs -e "select target from flag_$flagnumber where id=$tgtid") + if [[ $target == "lognotes" ]] + then + mysql $margs -e "insert into flagmap(flagid,lognoteid) values($flagnumber,$tgtid)" + elif [[ $target == "maintforms" ]] + then + mysql $margs -e "insert into flagmap(flagid,maintformid) values($flagnumber,$tgtid)" + elif [[ $target == "notetemplates" ]] + then + mysql $margs -e "insert into flagmap(flagid,notetemplateid) values($flagnumber,$tgtid)" + fi + + done + mysql $margs -e "drop table flag_$flagnumber" + fi + done + echo "...done." +fi + +# Import reference chain data into new reflinks table +if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]] +then + echo "Importing lognote reference chain data into new reflinks table..." + for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''") + do + refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note") + oldifs=$IFS + IFS=', ' + for target in $refstring + do + target=$(echo "$target" | xargs) + mysql $margs -e "insert into reflinks(noteid,target) values($note,$target)" + done + IFS=$oldifs + done + echo "...done." + echo "Importing template reference chain data into new reflinks table..." + for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''") + do + refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template") + oldifs=$IFS + IFS=', ' + for target in $refstring + do + target=$(echo "$target" | xargs) + mysql $margs -e "insert into reflinks(templateid,target) values($template,$target)" + done + IFS=$oldifs + done + echo "...done." + mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1 + mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1 +fi + +# Convert database to utf8mb4/utf8mb4_unicode_ci +echo "Converting database to utf8mb4 encoding..." +mysql $margs -e "ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci" +for table in $(mysql $margs -e "show tables") +do + mysql $margs -e "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" +done +echo "...done." # ------------------------------------- From 9e392faa4d02e77cb468744661f1b85c2e558064 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 12 Feb 2026 20:40:56 -0500 Subject: [PATCH 07/50] restored the flagmap and reflinks table creations that somehow got deleted --- database-update.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/database-update.sql b/database-update.sql index ef76257..c96da54 100644 --- a/database-update.sql +++ b/database-update.sql @@ -59,4 +59,24 @@ UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version"; -- ---------- version 5.3.0 ------------- -- Update version number UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version"; + +-- Create the flagmap table +CREATE TABLE IF NOT EXISTS `flagmap` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- Create the reflinks table +CREATE TABLE IF NOT EXISTS `reflinks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -------------------------------------- From f74385d8f3279316872605874f9170da8ae1e04f Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 12 Feb 2026 21:56:45 -0500 Subject: [PATCH 08/50] flag fixes in work --- distfiles/search.php | 80 ++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/distfiles/search.php b/distfiles/search.php index 0b9e9cb..d179cbe 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -34,7 +34,7 @@ $srchpname=$_REQUEST['srchpname'] ?? NULL; $srchploc=$_REQUEST['srchploc'] ?? NULL; $srchnha=$_REQUEST['srchnha'] ?? NULL; $srchrepord=$_REQUEST['srchrepord'] ?? NULL; -$srchflags=$_REQUEST['srchflags'] ?? NULL; +$srchflags=$_POST['srchflags'] ?? []; $target=$_REQUEST['target'] ?? NULL; $doparts=PARTS_FUNCTIONS; @@ -57,6 +57,15 @@ framework("begin","$logname Search","Search",$print); //var_dump($_REQUEST); // ******** begin database manipulation ******** + +// define the arrays +$logfromtables=[]; +$mffromtables=[]; +$pfromtables=[]; +$logconstraints=[]; +$mfconstraints=[]; +$pconstraints=[]; + // get the date range of lognotes $logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes"); $logdateresults=mysqli_fetch_row($logdateqry); @@ -75,8 +84,6 @@ if ($mfmaxdate == "") $mfmaxdate = $today; $mindate=min($logmindate, $mfmindate); $maxdate=max($logmaxdate, $mfmaxdate); - - if ($search) { // strip whitespace from beginning and end of text fields $srchtext=trim($srchtext); @@ -122,8 +129,9 @@ if ($search) { $logfromtables[]="lognotes"; $logconstraints[]="lognotes.lognote like \"%$srchtext%\""; } + // fixme // flags - if ($srchflags != NULL) { + if (!empty($srchflags)) { foreach ($srchflags as $flagtblnum) { $flagtblname="flag_{$flagtblnum}"; $logfromtables[]="lognotes"; @@ -231,6 +239,7 @@ if ($search) { $mffromtables[]="maintactions"; $mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; } + // fixme // flags foreach ($srchflags as $flagtblnum) { $flagtblname="flag_{$flagtblnum}"; @@ -463,27 +472,37 @@ if (!$print) {

Flags: "; - $flagslist=mysqli_query($db,"select * from flags"); - $flagsperline=8; - $flagcount=1; - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($srchflags[0]=="") $srchflags=[]; - if (in_array($flagcheckbox["flagid"],$srchflags)) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + $flagslist = mysqli_query($db, "select * from flags"); + $flagsperline = 8; + $flagcount = 1; + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { + if ($srchflags[0] == "") $srchflags = []; + if (in_array($flagcheckbox["flagid"], $srchflags)) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } else { - $flagid=$flagcheckbox["flagid"]; - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + $flagid = $flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo " @@ -656,20 +675,23 @@ if ($search) { $logsubjname=dblookup($db,"subjects","subjectid","subjectname",$logtablerow['subject']); // create links of urls in note $logfmtnote=convertweblinks($logtablerow['lognote']); + // generate the flags string $flagstring=""; - $allflagqry=mysqli_query($db,"select flagid from flags"); - while ($allflagids=mysqli_fetch_row($allflagqry)) { - $flagid=$allflagids[0]; - $flag_tbl="flag_".$flagid; - if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$logtablerow[lognoteid]\""))) { - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagstring=$flagstring."$flagsym  "; - } + $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$logtablerow[lognoteid]"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; } - if ($flagstring) $logfmtnote=$logfmtnote."
".$flagstring; + if ($flagstring) { + $logfmtnote=$logfmtnote."
".$flagstring."     "; + } else { + $logfmtnote=$logfmtnote."
"; + } + printf(" %s %s / %s From 71f60d353f2feeeb05fa32fe3dc2fc98cc9d330b Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Fri, 13 Feb 2026 21:15:52 -0500 Subject: [PATCH 09/50] got lognote multi flag search working --- distfiles/search.php | 55 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/distfiles/search.php b/distfiles/search.php index d179cbe..3e0ad9f 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -129,15 +129,22 @@ if ($search) { $logfromtables[]="lognotes"; $logconstraints[]="lognotes.lognote like \"%$srchtext%\""; } - // fixme // flags if (!empty($srchflags)) { - foreach ($srchflags as $flagtblnum) { - $flagtblname="flag_{$flagtblnum}"; - $logfromtables[]="lognotes"; - $logfromtables[]=$flagtblname; - $logconstraints[]="lognotes.lognoteid={$flagtblname}.id and {$flagtblname}.target=\"lognotes\""; + unset($flagconstraints); + $flagcount=count($srchflags); + $logfromtables[]="lognotes"; + $logfromtables[]="flagmap"; + $flagconstraints[]="flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; + foreach ($srchflags as $flagid) { + $flagconstraints[]="\"$flagid\""; + $flagconstraints[]=","; } + // remove final comma + array_splice($flagconstraints, -1, 1); + $flagconstraints[]=") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; + // make flagconstraints a single string so that the final implode doesn't split it + $logconstraints[]=join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { @@ -192,9 +199,24 @@ if ($search) { $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query + echo "logfromtables: "; + foreach ($logfromtables as $lft) { + echo "$lft "; + } + echo "

"; + + echo "logconstraints: "; + foreach ($logconstraints as $lc) { + echo "$lc "; + } + echo "

"; + $logfromclause=implode(",",array_unique($logfromtables)); + echo "logfromclause: $logfromclause

"; $logwhereclause=implode(" and ",$logconstraints); + echo "logwhereclause: $logwhereclause

"; $logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); + echo "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"; } if ($target[0]=="") $target=[]; if (in_array("maintform",$target)) { @@ -239,13 +261,22 @@ if ($search) { $mffromtables[]="maintactions"; $mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; } - // fixme // flags - foreach ($srchflags as $flagtblnum) { - $flagtblname="flag_{$flagtblnum}"; + if (!empty($srchflags)) { + unset($flagconstraints); + $flagcount=count($srchflags); $mffromtables[]="maintforms"; - $mffromtables[]=$flagtblname; - $mfconstraints[]="maintforms.maintformid={$flagtblname}.id and {$flagtblname}.target=\"maintforms\""; + $mffromtables[]="flagmap"; + $flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; + foreach ($srchflags as $flagid) { + $flagconstraints[]="\"$flagid\""; + $flagconstraints[]=","; + } + // remove final comma + array_splice($flagconstraints, -1, 1); + $flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; + // make flagconstraints a single string so that the final implode doesn't split it + $logconstraints[]=join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { @@ -476,7 +507,7 @@ if (!$print) { $flagsperline = 8; $flagcount = 1; while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { - if ($srchflags[0] == "") $srchflags = []; + //if ($srchflags[0] == "") $srchflags = []; if (in_array($flagcheckbox["flagid"], $srchflags)) { printf( "%s", From 35173f6faa66192a6b451baf1b0ca8c556e385b7 Mon Sep 17 00:00:00 2001 From: "rod.wright" Date: Sat, 14 Feb 2026 10:57:37 -0500 Subject: [PATCH 10/50] Update LICENSE Added license info for the Fugue icon set --- LICENSE | 323 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 322 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index d5a25a2..0ef45ee 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ The following license applies to all OpenLog code -Copyright (C) 2016 by Rod Wright : +Copyright (C) 2026 by Rod Wright : GNU GENERAL PUBLIC LICENSE Version 2, June 1991 @@ -382,3 +382,324 @@ The following license applies to jquery code : CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +The following license applies to the Fugue icon set : + Creative Commons Legal Code + + Attribution 3.0 Unported + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR + DAMAGES RESULTING FROM ITS USE. + + License + + THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE + COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY + COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS + AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + + BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE + TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY + BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS + CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND + CONDITIONS. + + 1. Definitions + + a. "Adaptation" means a work based upon the Work, or upon the Work and + other pre-existing works, such as a translation, adaptation, + derivative work, arrangement of music or other alterations of a + literary or artistic work, or phonogram or performance and includes + cinematographic adaptations or any other form in which the Work may be + recast, transformed, or adapted including in any form recognizably + derived from the original, except that a work that constitutes a + Collection will not be considered an Adaptation for the purpose of + this License. For the avoidance of doubt, where the Work is a musical + work, performance or phonogram, the synchronization of the Work in + timed-relation with a moving image ("synching") will be considered an + Adaptation for the purpose of this License. + b. "Collection" means a collection of literary or artistic works, such as + encyclopedias and anthologies, or performances, phonograms or + broadcasts, or other works or subject matter other than works listed + in Section 1(f) below, which, by reason of the selection and + arrangement of their contents, constitute intellectual creations, in + which the Work is included in its entirety in unmodified form along + with one or more other contributions, each constituting separate and + independent works in themselves, which together are assembled into a + collective whole. A work that constitutes a Collection will not be + considered an Adaptation (as defined above) for the purposes of this + License. + c. "Distribute" means to make available to the public the original and + copies of the Work or Adaptation, as appropriate, through sale or + other transfer of ownership. + d. "Licensor" means the individual, individuals, entity or entities that + offer(s) the Work under the terms of this License. + e. "Original Author" means, in the case of a literary or artistic work, + the individual, individuals, entity or entities who created the Work + or if no individual or entity can be identified, the publisher; and in + addition (i) in the case of a performance the actors, singers, + musicians, dancers, and other persons who act, sing, deliver, declaim, + play in, interpret or otherwise perform literary or artistic works or + expressions of folklore; (ii) in the case of a phonogram the producer + being the person or legal entity who first fixes the sounds of a + performance or other sounds; and, (iii) in the case of broadcasts, the + organization that transmits the broadcast. + f. "Work" means the literary and/or artistic work offered under the terms + of this License including without limitation any production in the + literary, scientific and artistic domain, whatever may be the mode or + form of its expression including digital form, such as a book, + pamphlet and other writing; a lecture, address, sermon or other work + of the same nature; a dramatic or dramatico-musical work; a + choreographic work or entertainment in dumb show; a musical + composition with or without words; a cinematographic work to which are + assimilated works expressed by a process analogous to cinematography; + a work of drawing, painting, architecture, sculpture, engraving or + lithography; a photographic work to which are assimilated works + expressed by a process analogous to photography; a work of applied + art; an illustration, map, plan, sketch or three-dimensional work + relative to geography, topography, architecture or science; a + performance; a broadcast; a phonogram; a compilation of data to the + extent it is protected as a copyrightable work; or a work performed by + a variety or circus performer to the extent it is not otherwise + considered a literary or artistic work. + g. "You" means an individual or entity exercising rights under this + License who has not previously violated the terms of this License with + respect to the Work, or who has received express permission from the + Licensor to exercise rights under this License despite a previous + violation. + h. "Publicly Perform" means to perform public recitations of the Work and + to communicate to the public those public recitations, by any means or + process, including by wire or wireless means or public digital + performances; to make available to the public Works in such a way that + members of the public may access these Works from a place and at a + place individually chosen by them; to perform the Work to the public + by any means or process and the communication to the public of the + performances of the Work, including by public digital performance; to + broadcast and rebroadcast the Work by any means including signs, + sounds or images. + i. "Reproduce" means to make copies of the Work by any means including + without limitation by sound or visual recordings and the right of + fixation and reproducing fixations of the Work, including storage of a + protected performance or phonogram in digital form or other electronic + medium. + + 2. Fair Dealing Rights. Nothing in this License is intended to reduce, + limit, or restrict any uses free from copyright or rights arising from + limitations or exceptions that are provided for in connection with the + copyright protection under copyright law or other applicable laws. + + 3. License Grant. Subject to the terms and conditions of this License, + Licensor hereby grants You a worldwide, royalty-free, non-exclusive, + perpetual (for the duration of the applicable copyright) license to + exercise the rights in the Work as stated below: + + a. to Reproduce the Work, to incorporate the Work into one or more + Collections, and to Reproduce the Work as incorporated in the + Collections; + b. to create and Reproduce Adaptations provided that any such Adaptation, + including any translation in any medium, takes reasonable steps to + clearly label, demarcate or otherwise identify that changes were made + to the original Work. For example, a translation could be marked "The + original work was translated from English to Spanish," or a + modification could indicate "The original work has been modified."; + c. to Distribute and Publicly Perform the Work including as incorporated + in Collections; and, + d. to Distribute and Publicly Perform Adaptations. + e. For the avoidance of doubt: + + i. Non-waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme cannot be waived, the Licensor + reserves the exclusive right to collect such royalties for any + exercise by You of the rights granted under this License; + ii. Waivable Compulsory License Schemes. In those jurisdictions in + which the right to collect royalties through any statutory or + compulsory licensing scheme can be waived, the Licensor waives the + exclusive right to collect such royalties for any exercise by You + of the rights granted under this License; and, + iii. Voluntary License Schemes. The Licensor waives the right to + collect royalties, whether individually or, in the event that the + Licensor is a member of a collecting society that administers + voluntary licensing schemes, via that society, from any exercise + by You of the rights granted under this License. + + The above rights may be exercised in all media and formats whether now + known or hereafter devised. The above rights include the right to make + such modifications as are technically necessary to exercise the rights in + other media and formats. Subject to Section 8(f), all rights not expressly + granted by Licensor are hereby reserved. + + 4. Restrictions. The license granted in Section 3 above is expressly made + subject to and limited by the following restrictions: + + a. You may Distribute or Publicly Perform the Work only under the terms + of this License. You must include a copy of, or the Uniform Resource + Identifier (URI) for, this License with every copy of the Work You + Distribute or Publicly Perform. You may not offer or impose any terms + on the Work that restrict the terms of this License or the ability of + the recipient of the Work to exercise the rights granted to that + recipient under the terms of the License. You may not sublicense the + Work. You must keep intact all notices that refer to this License and + to the disclaimer of warranties with every copy of the Work You + Distribute or Publicly Perform. When You Distribute or Publicly + Perform the Work, You may not impose any effective technological + measures on the Work that restrict the ability of a recipient of the + Work from You to exercise the rights granted to that recipient under + the terms of the License. This Section 4(a) applies to the Work as + incorporated in a Collection, but this does not require the Collection + apart from the Work itself to be made subject to the terms of this + License. If You create a Collection, upon notice from any Licensor You + must, to the extent practicable, remove from the Collection any credit + as required by Section 4(b), as requested. If You create an + Adaptation, upon notice from any Licensor You must, to the extent + practicable, remove from the Adaptation any credit as required by + Section 4(b), as requested. + b. If You Distribute, or Publicly Perform the Work or any Adaptations or + Collections, You must, unless a request has been made pursuant to + Section 4(a), keep intact all copyright notices for the Work and + provide, reasonable to the medium or means You are utilizing: (i) the + name of the Original Author (or pseudonym, if applicable) if supplied, + and/or if the Original Author and/or Licensor designate another party + or parties (e.g., a sponsor institute, publishing entity, journal) for + attribution ("Attribution Parties") in Licensor's copyright notice, + terms of service or by other reasonable means, the name of such party + or parties; (ii) the title of the Work if supplied; (iii) to the + extent reasonably practicable, the URI, if any, that Licensor + specifies to be associated with the Work, unless such URI does not + refer to the copyright notice or licensing information for the Work; + and (iv) , consistent with Section 3(b), in the case of an Adaptation, + a credit identifying the use of the Work in the Adaptation (e.g., + "French translation of the Work by Original Author," or "Screenplay + based on original Work by Original Author"). The credit required by + this Section 4 (b) may be implemented in any reasonable manner; + provided, however, that in the case of a Adaptation or Collection, at + a minimum such credit will appear, if a credit for all contributing + authors of the Adaptation or Collection appears, then as part of these + credits and in a manner at least as prominent as the credits for the + other contributing authors. For the avoidance of doubt, You may only + use the credit required by this Section for the purpose of attribution + in the manner set out above and, by exercising Your rights under this + License, You may not implicitly or explicitly assert or imply any + connection with, sponsorship or endorsement by the Original Author, + Licensor and/or Attribution Parties, as appropriate, of You or Your + use of the Work, without the separate, express prior written + permission of the Original Author, Licensor and/or Attribution + Parties. + c. Except as otherwise agreed in writing by the Licensor or as may be + otherwise permitted by applicable law, if You Reproduce, Distribute or + Publicly Perform the Work either by itself or as part of any + Adaptations or Collections, You must not distort, mutilate, modify or + take other derogatory action in relation to the Work which would be + prejudicial to the Original Author's honor or reputation. Licensor + agrees that in those jurisdictions (e.g. Japan), in which any exercise + of the right granted in Section 3(b) of this License (the right to + make Adaptations) would be deemed to be a distortion, mutilation, + modification or other derogatory action prejudicial to the Original + Author's honor and reputation, the Licensor will waive or not assert, + as appropriate, this Section, to the fullest extent permitted by the + applicable national law, to enable You to reasonably exercise Your + right under Section 3(b) of this License (right to make Adaptations) + but not otherwise. + + 5. Representations, Warranties and Disclaimer + + UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR + OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY + KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, + INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, + FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF + LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, + WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION + OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + + 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE + LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR + ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES + ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS + BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + 7. Termination + + a. This License and the rights granted hereunder will terminate + automatically upon any breach by You of the terms of this License. + Individuals or entities who have received Adaptations or Collections + from You under this License, however, will not have their licenses + terminated provided such individuals or entities remain in full + compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will + survive any termination of this License. + b. Subject to the above terms and conditions, the license granted here is + perpetual (for the duration of the applicable copyright in the Work). + Notwithstanding the above, Licensor reserves the right to release the + Work under different license terms or to stop distributing the Work at + any time; provided, however that any such election will not serve to + withdraw this License (or any other license that has been, or is + required to be, granted under the terms of this License), and this + License will continue in full force and effect unless terminated as + stated above. + + 8. Miscellaneous + + a. Each time You Distribute or Publicly Perform the Work or a Collection, + the Licensor offers to the recipient a license to the Work on the same + terms and conditions as the license granted to You under this License. + b. Each time You Distribute or Publicly Perform an Adaptation, Licensor + offers to the recipient a license to the original Work on the same + terms and conditions as the license granted to You under this License. + c. If any provision of this License is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this License, and without further action + by the parties to this agreement, such provision shall be reformed to + the minimum extent necessary to make such provision valid and + enforceable. + d. No term or provision of this License shall be deemed waived and no + breach consented to unless such waiver or consent shall be in writing + and signed by the party to be charged with such waiver or consent. + e. This License constitutes the entire agreement between the parties with + respect to the Work licensed here. There are no understandings, + agreements or representations with respect to the Work not specified + here. Licensor shall not be bound by any additional provisions that + may appear in any communication from You. This License may not be + modified without the mutual written agreement of the Licensor and You. + f. The rights granted under, and the subject matter referenced, in this + License were drafted utilizing the terminology of the Berne Convention + for the Protection of Literary and Artistic Works (as amended on + September 28, 1979), the Rome Convention of 1961, the WIPO Copyright + Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 + and the Universal Copyright Convention (as revised on July 24, 1971). + These rights and subject matter take effect in the relevant + jurisdiction in which the License terms are sought to be enforced + according to the corresponding provisions of the implementation of + those treaty provisions in the applicable national law. If the + standard suite of rights granted under applicable copyright law + includes additional rights not granted under this License, such + additional rights are deemed to be included in the License; this + License is not intended to restrict the license of any rights under + applicable law. + + + Creative Commons Notice + + Creative Commons is not a party to this License, and makes no warranty + whatsoever in connection with the Work. Creative Commons will not be + liable to You or any party on any legal theory for any damages + whatsoever, including without limitation any general, special, + incidental or consequential damages arising in connection to this + license. Notwithstanding the foregoing two (2) sentences, if Creative + Commons has expressly identified itself as the Licensor hereunder, it + shall have all rights and obligations of Licensor. + + Except for the limited purpose of indicating to the public that the + Work is licensed under the CCPL, Creative Commons does not authorize + the use by either party of the trademark "Creative Commons" or any + related trademark or logo of Creative Commons without the prior + written consent of Creative Commons. Any permitted use will be in + compliance with Creative Commons' then-current trademark usage + guidelines, as may be published on its website or otherwise made + available upon request from time to time. For the avoidance of doubt, + this trademark restriction does not form part of this License. + + Creative Commons may be contacted at https://creativecommons.org/. From 63bb7a3445c1705ca7ba8ecc2756990c5c1a209a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 17 Feb 2026 14:43:46 -0500 Subject: [PATCH 11/50] More work on flags --- distfiles/maintformentry.php | 79 ++++++++++++++++++------------------ distfiles/refchain.php | 12 ------ distfiles/search.php | 40 +++++++----------- 3 files changed, 54 insertions(+), 77 deletions(-) diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index a714180..2c9b902 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -176,10 +176,10 @@ if ($mfadd) { $newmaintformid=mysqli_insert_id($db); $mfidtoprint=$newmaintformid; - // add this maintformid to the appropriate flag_tables - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; - mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$newmaintformid\")"); + // update the flagmap table + foreach ($flags as $thisflag) { + // set flag for this maintenance form + mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); } } } @@ -209,20 +209,12 @@ if ($mfedit) { if (! $pdatamismatch) { mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\", mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\""); - // update the appropriate flag_tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $thisflag_tbl="flag_".$thisflagid[0]; - if ($flags[0]=="") $flags=[]; - if (in_array($thisflagid[0],$flags)) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) { - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")"); - } - } else { - if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) { - mysqli_query($db,"delete from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""); - } - } + + // update the flagmap table + mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); + foreach ($flags as $thisflag) { + // set flag for this maintenance form + mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$maintformid\")"); } } } @@ -233,12 +225,8 @@ if ($mfedit) { if ($mfdelete && $mfauthorized) { // delete from maintforms table mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\""); - // delete occurances from the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $delflag_tbl="flag_".$thisflagid[0]; - mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\""); - } + // delete occurances from the flagmap table + mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); } if ($actionadd) { @@ -384,22 +372,33 @@ if ($printfmt) { Flags
"; - // get an array of flagids set for this maintformid - $allflags=mysqli_query($db,"select flagid from flags"); - unset($theseflags); - while ($thisflag=mysqli_fetch_row($allflags)) { - $thisflagtbl="flag_".$thisflag[0]; - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) { - $theseflags[]=$thisflag[0]; - } - } - $flagslist=mysqli_query($db,"select * from flags"); - while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { - if ($theseflags[0]=="") $theseflags=[]; - if (in_array($flagsymbol["flagid"],$theseflags)) { - echo $flagsymbol['flagsym']."  "; - } - } + + + + + + + + + + + + // // get an array of flagids set for this maintformid + // $allflags=mysqli_query($db,"select flagid from flags"); + // unset($theseflags); + // while ($thisflag=mysqli_fetch_row($allflags)) { + // $thisflagtbl="flag_".$thisflag[0]; + // if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) { + // $theseflags[]=$thisflag[0]; + // } + // } + // $flagslist=mysqli_query($db,"select * from flags"); + // while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { + // if ($theseflags[0]=="") $theseflags=[]; + // if (in_array($flagsymbol["flagid"],$theseflags)) { + // echo $flagsymbol['flagsym']."  "; + // } + // } echo "

Maintenance Actions
diff --git a/distfiles/refchain.php b/distfiles/refchain.php index d871b7e..f13f231 100644 --- a/distfiles/refchain.php +++ b/distfiles/refchain.php @@ -70,18 +70,6 @@ while($mptr$flagsym  "; - //} - //} - if ($flagstring) $fmtnote=$fmtnote."
".$flagstring; printf(" diff --git a/distfiles/search.php b/distfiles/search.php index 3e0ad9f..e3c67a9 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -54,7 +54,9 @@ if ($print) { framework("begin","$logname Search","Search",$print); -//var_dump($_REQUEST); +// echo "REQUEST variables:
"; +// var_dump($_REQUEST); + // ******** begin database manipulation ******** @@ -199,24 +201,9 @@ if ($search) { $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - echo "logfromtables: "; - foreach ($logfromtables as $lft) { - echo "$lft "; - } - echo "

"; - - echo "logconstraints: "; - foreach ($logconstraints as $lc) { - echo "$lc "; - } - echo "

"; - $logfromclause=implode(",",array_unique($logfromtables)); - echo "logfromclause: $logfromclause

"; $logwhereclause=implode(" and ",$logconstraints); - echo "logwhereclause: $logwhereclause

"; $logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); - echo "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"; } if ($target[0]=="") $target=[]; if (in_array("maintform",$target)) { @@ -268,15 +255,15 @@ if ($search) { $mffromtables[]="maintforms"; $mffromtables[]="flagmap"; $flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; - foreach ($srchflags as $flagid) { - $flagconstraints[]="\"$flagid\""; + foreach ($srchflags as $thisflagid) { + $flagconstraints[]="\"$thisflagid\""; $flagconstraints[]=","; } // remove final comma array_splice($flagconstraints, -1, 1); $flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; // make flagconstraints a single string so that the final implode doesn't split it - $logconstraints[]=join('', $flagconstraints); + $mfconstraints[]=join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { @@ -687,9 +674,10 @@ if ($search) { if ($target[0]=="") $target=[]; if (in_array("log",$target)) { // run lognotes query and show results - if(mysqli_num_rows($logrowqry)) { + $log_num_results=mysqli_num_rows($logrowqry); + if($log_num_results) { echo " - Results from Logbook

+ Results from Logbook: $log_num_results

"; @@ -748,9 +736,10 @@ if ($search) { if ($target[0]=="") $target=[]; if (in_array("maintform",$target)) { // run maintforms query and show results - if(mysqli_num_rows($mfrowqry)) { + $mf_num_results=mysqli_num_rows($mfrowqry); + if($mf_num_results) { echo " - Results from Maintenance Forms

+ Results from Maintenance Forms: $mf_num_results


Note IDDate/TimeShiftTechSubjectNoteReferences
@@ -811,9 +800,10 @@ if ($search) { if ($target[0]=="") $target=[]; if (in_array("part",$target)) { // run parts query and show results - if(mysqli_num_rows($prowqry)) { + $p_num_results=mysqli_num_rows($prowqry); + if($p_num_results) { echo " - Results from Parts

+ Results from Parts: $p_num_results

ID
From cc2b638a6adf1cf51a8af63a4fbcb4577ccd16e9 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:29:58 -0500 Subject: [PATCH 12/50] Removed useless hyperlinks from headers of parts results table. --- distfiles/search.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distfiles/search.php b/distfiles/search.php index e3c67a9..dbae96d 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -807,10 +807,10 @@ if ($search) {
Action
- - - - + + + + "; while ($partrow=mysqli_fetch_assoc($prowqry)) { From 557af4db0486edfa0f336b7b5363b856407f1020 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:31:44 -0500 Subject: [PATCH 13/50] Set REQUEST variables to default to NULL if not passed to avoid php warnings --- distfiles/parts.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distfiles/parts.php b/distfiles/parts.php index 9d6b6d1..7893f93 100644 --- a/distfiles/parts.php +++ b/distfiles/parts.php @@ -15,10 +15,10 @@ if (isset($_SESSION['login'])) { unset($loggedin); } -$print=$_REQUEST['print']; -$add=$_REQUEST['add']; -$sort=$_REQUEST['sort']; -$order=$_REQUEST['order']; +$print=$_REQUEST['print'] ?? NULL; +$add=$_REQUEST['add'] ?? NULL; +$sort=$_REQUEST['sort'] ?? NULL; +$order=$_REQUEST['order'] ?? NULL; $logname=LOG_NAME; $uidtext=UID_TEXT; From 5396f3367b6f1808efb80f773ab6a2d8fecc67fb Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:33:25 -0500 Subject: [PATCH 14/50] Various cleanups to avoid php undefined variable warnings --- distfiles/partentry.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/distfiles/partentry.php b/distfiles/partentry.php index 08a5490..ed7ba64 100644 --- a/distfiles/partentry.php +++ b/distfiles/partentry.php @@ -17,17 +17,17 @@ if (!isset($_SESSION['login'])) { $loggedinas=$_SESSION['login']; $isadmin=dblookup($db,"techs","techid","admin",$loggedinas); -$print=$_REQUEST['print']; -$add=$_REQUEST['add']; -$edit=$_REQUEST['edit']; -$delete=$_REQUEST['delete']; +$print=$_REQUEST['print'] ?? NULL; +$add=$_REQUEST['add'] ?? NULL; +$edit=$_REQUEST['edit'] ?? NULL; +$delete=$_REQUEST['delete'] ?? NULL; -$partid=$_REQUEST['partid']; -$uid=$_REQUEST['uid']; -$partnum=$_REQUEST['partnum']; -$sernum=$_REQUEST['sernum']; -$partname=$_REQUEST['partname']; -$submit=$_REQUEST['submit']; +$partid=$_REQUEST['partid'] ?? NULL; +$uid=$_REQUEST['uid'] ?? NULL; +$partnum=$_REQUEST['partnum'] ?? NULL; +$sernum=$_REQUEST['sernum'] ?? NULL; +$partname=$_REQUEST['partname'] ?? NULL; +$submit=$_REQUEST['submit'] ?? NULL; $logname=LOG_NAME; $uidtext=UID_TEXT; @@ -96,13 +96,13 @@ $partdatainput=array(); $partdatainput['partid']=$partid; $partinfo=get_part_data($partdatainput); if ($partinfo['result']==2) { - $pdatamismatch=1; + $pdatamismatch=TRUE; } else { - unset($pdatamismatch); - if ($partinfo['uid']) $uid=$partinfo['uid']; - if ($partinfo['partnum']) $partnum=$partinfo['partnum']; - if ($partinfo['sernum']) $sernum=$partinfo['sernum']; - if ($partinfo['partname']) $partname=$partinfo['partname']; + $pdatamismatch=FALSE; + $uid = (array_key_exists('uid',$partinfo)) ? $partinfo['uid'] : NULL; + $partnum = (array_key_exists('partnum',$partinfo)) ? $partinfo['partnum'] : NULL; + $sernum = (array_key_exists('sernum',$partinfo)) ? $partinfo['sernum'] : NULL; + $partname = (array_key_exists('partname',$partinfo)) ? $partinfo['partname'] : NULL; } if ($delete) { if ($inmaintforms) { From 1a4c9a9c2a6d772c1b09d2f6631585519322dc7d Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:37:45 -0500 Subject: [PATCH 15/50] Fixed bug where the shifts weren't being shown in the existing techs table. --- distfiles/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distfiles/admin.php b/distfiles/admin.php index 25c8747..dd5959c 100644 --- a/distfiles/admin.php +++ b/distfiles/admin.php @@ -794,7 +794,7 @@ switch($table) { $shiftrow=mysqli_query($db,"select * from shifts"); while ($shiftitem=mysqli_fetch_assoc($shiftrow)) { if ($shiftitem["status"] == 1) { - if ($shiftitem["shiftid"]==$customshiftnum) { + if ($shiftitem["shiftid"]==$shift) { printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); } else { printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); @@ -830,7 +830,7 @@ switch($table) { } else { $statdef="\"inactive\""; } - $shiftname=dblookup($db,"shifts","shiftname","shiftid",$shift); + $shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); printf(" From ff71083b49429f652e0746822ad7af2e9e45deca Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:40:40 -0500 Subject: [PATCH 16/50] fixes to get_part_data to prevent php undefined variable warnings --- distfiles/functions.php | 45 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/distfiles/functions.php b/distfiles/functions.php index d737cc4..3944c6e 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -757,43 +757,45 @@ function get_part_data($partinputdata) { // partid, uid, partnum, sernum, partname, result // where result=0 for success, 1 for no data found, 2 for mismatch global $db; + $checkmm = FALSE; + $result = 0; // pull input data from input array - if ($partinputdata['partid'] && $partinputdata['partid'] != "") $partid= $partinputdata['partid']; - if ($partinputdata['uid'] && $partinputdata['uid'] != "") $uid= $partinputdata['uid']; - if ($partinputdata['partnum'] && $partinputdata['partnum'] != "") $partnum= $partinputdata['partnum']; - if ($partinputdata['sernum'] && $partinputdata['sernum'] != "") $sernum= $partinputdata['sernum']; + $partid = (array_key_exists('partid', $partinputdata) && $partinputdata['partid'] != "") ? $partinputdata['partid'] : NULL; + $uid = (array_key_exists('uid', $partinputdata) && $partinputdata['uid'] != "") ? $partinputdata['uid'] : NULL; + $partnum = (array_key_exists('partnum', $partinputdata) && $partinputdata['partnum'] != "") ? $partinputdata['partnum'] : NULL; + $sernum = (array_key_exists('sernum', $partinputdata) && $partinputdata['sernum'] != "") ? $partinputdata['sernum'] : NULL; // for part data supplied, see what info is available // if a partid is supplied, pull other info from parts if ($partid) { // if partid supplied - $partqry=mysqli_query($db,"select * from parts where partid=\"$partid\""); + $partqry = mysqli_query($db, "select * from parts where partid=\"$partid\""); } else if ($uid && (!$partnum && !$sernum)) { // if uid only supplied - $partqry=mysqli_query($db,"select * from parts where uid like \"$uid\""); + $partqry = mysqli_query($db, "select * from parts where uid like \"$uid\""); } else if (($partnum && $sernum) && !$uid) { // if pn/sn only supplied - $partqry=mysqli_query($db,"select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\""); - } else if ($uid && $partnum && $sernum ) { //if uid and pn/sn supplied - $partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\""); - $checkmm=1; - $mismatchqry=mysqli_query($db,"select * from parts where + $partqry = mysqli_query($db, "select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\""); + } else if ($uid && $partnum && $sernum) { //if uid and pn/sn supplied + $partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\""); + $checkmm = TRUE; + $mismatchqry = mysqli_query($db, "select * from parts where (uid like \"$uid\" and ((partnum !=\"$partnum\" and partnum !=\"\")or (sernum !=\"$sernum\" and sernum !=\"\"))) or ((uid not like \"$uid\" and uid not like \"\") and (partnum =\"$partnum\" and sernum =\"$sernum\")) "); - } else if ($uid && $partnum && ! $sernum ) { //if uid and pn only supplied - $partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and partnum=\"$partnum\""); - $checkmm=1; - $mismatchqry=mysqli_query($db,"select partid from parts where + } else if ($uid && $partnum && ! $sernum) { //if uid and pn only supplied + $partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\""); + $checkmm = TRUE; + $mismatchqry = mysqli_query($db, "select partid from parts where (uid like \"$uid\" and partnum !=\"$partnum\") or (uid not like \"$uid\" and partnum =\"$partnum\") "); - } else if ($uid && ! $partnum && $sernum ) { //if uid and sn only supplied - $partqry=mysqli_query($db,"select * from parts where uid like \"$uid\" and sernum=\"$sernum\""); - $checkmm=1; - $mismatchqry=mysqli_query($db,"select partid from parts where + } else if ($uid && ! $partnum && $sernum) { //if uid and sn only supplied + $partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and sernum=\"$sernum\""); + $checkmm = TRUE; + $mismatchqry = mysqli_query($db, "select partid from parts where (uid like \"$uid\" and sernum !=\"$sernum\") or (uid not like \"$uid\" and sernum =\"$sernum\") "); } else { // not enough input data supplied, so return result of 1 - $result=1; + $result = 1; } if (! $result) { if (mysqli_num_rows($partqry)) { @@ -807,9 +809,6 @@ function get_part_data($partinputdata) { if ($checkmm) { if (mysqli_num_rows($mismatchqry)) { $result=2; - //while ($mmdata=mysqli_fetch_assoc($mismatchqry)) { - //var_dump($mmdata); - //} } } From 262bd6dcdc8397650fbae68ffea64e4b8560f2dd Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:42:03 -0500 Subject: [PATCH 17/50] Minor cleanups to prevent php undefined variables warnings. --- distfiles/maintform.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/distfiles/maintform.php b/distfiles/maintform.php index ca15206..2263e21 100644 --- a/distfiles/maintform.php +++ b/distfiles/maintform.php @@ -11,8 +11,9 @@ include("functions.php"); if (isset($_SESSION['login'])) $techid=$_SESSION['login']; -$histdays=$_REQUEST['histdays']; -$submit=$_REQUEST['submit']; +$print=$_REQUEST['print'] ?? NULL; +$histdays=$_REQUEST['histdays'] ?? NULL; +$submit=$_REQUEST['submit'] ?? NULL; $logname=LOG_NAME; $uidtext=UID_TEXT; From 5e1856f1dc99706b800b356ce29bef6ce36e859c Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:48:29 -0500 Subject: [PATCH 18/50] Cleanups to avoid php undefined variable warnings. Changed boolean variables from 1/0 to TRUE/FALSE. Converted flag handling code to the new scheme. --- distfiles/maintformentry.php | 142 +++++++++++++++++------------------ 1 file changed, 67 insertions(+), 75 deletions(-) diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 2c9b902..45e3601 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -31,38 +31,38 @@ function getactiondata($maintactionid) { return $actiondata; } -$print=$_REQUEST['print']; +$print=$_REQUEST['print'] ?? NULL; -$maintformid=$_REQUEST['maintformid']; -$lognoteid=$_REQUEST['lognoteid']; -$mfdate=$_REQUEST['date']; -$mftime=$_REQUEST['time']; -$mfsubmit=$_REQUEST['mfsubmit']; -$mfadd=$_REQUEST['mfadd']; -$mfedit=$_REQUEST['mfedit']; -$mfdelete=$_REQUEST['mfdelete']; -$mfpartloc=$_REQUEST['mfpartloc']; -$mfmalfunction=$_REQUEST['mfmalfunction']; -$nha=$_REQUEST['nha']; -$repord=$_REQUEST['repord']; -$mfpart=$_REQUEST['mfpart']; -$uid=$_REQUEST['uid']; -$partnum=$_REQUEST['partnum']; -$sernum=$_REQUEST['sernum']; -$partname=$_REQUEST['partname']; -$actionadd=$_REQUEST['actionadd']; -$actionedit=$_REQUEST['actionedit']; -$actiondelete=$_REQUEST['actiondelete']; -$maintactionid=$_REQUEST['maintactionid']; -$actiondate=$_REQUEST['actiondate']; -$actiontime=$_REQUEST['actiontime']; -$actiontech=$_REQUEST['actiontech']; -$action=$_REQUEST['action']; -$actionaddsubmit=$_REQUEST['actionaddsubmit']; -$actioneditsubmit=$_REQUEST['actioneditsubmit']; -$printfmt=$_REQUEST['printfmt']; -if ($printfmt) $print=1; -$flags=$_POST['flags']; +$maintformid=$_REQUEST['maintformid'] ?? NULL; +$lognoteid=$_REQUEST['lognoteid'] ?? NULL; +$mfdate=$_REQUEST['date'] ?? NULL; +$mftime=$_REQUEST['time'] ?? NULL; +$mfsubmit=$_REQUEST['mfsubmit'] ?? NULL; +$mfadd=$_REQUEST['mfadd'] ?? NULL; +$mfedit=$_REQUEST['mfedit'] ?? NULL; +$mfdelete=$_REQUEST['mfdelete'] ?? NULL; +$mfpartloc=$_REQUEST['mfpartloc'] ?? NULL; +$mfmalfunction=$_REQUEST['mfmalfunction'] ?? NULL; +$nha=$_REQUEST['nha'] ?? NULL; +$repord=$_REQUEST['repord'] ?? NULL; +$mfpart=$_REQUEST['mfpart'] ?? NULL; +$uid=$_REQUEST['uid'] ?? NULL; +$partnum=$_REQUEST['partnum'] ?? NULL; +$sernum=$_REQUEST['sernum'] ?? NULL; +$partname=$_REQUEST['partname'] ?? NULL; +$actionadd=$_REQUEST['actionadd'] ?? NULL; +$actionedit=$_REQUEST['actionedit'] ?? NULL; +$actiondelete=$_REQUEST['actiondelete'] ?? NULL; +$maintactionid=$_REQUEST['maintactionid'] ?? NULL; +$actiondate=$_REQUEST['actiondate'] ?? NULL; +$actiontime=$_REQUEST['actiontime'] ?? NULL; +$actiontech=$_REQUEST['actiontech'] ?? NULL; +$action=$_REQUEST['action'] ?? NULL; +$actionaddsubmit=$_REQUEST['actionaddsubmit'] ?? NULL; +$actioneditsubmit=$_REQUEST['actioneditsubmit'] ?? NULL; +$printfmt=$_REQUEST['printfmt'] ?? NULL; +if ($printfmt) $print=TRUE; +$flags=$_POST['flags'] ?? []; $logname=LOG_NAME; $uidtext=UID_TEXT; @@ -78,48 +78,49 @@ if ($printfmt) { framework("begin","","",$print); } else if ($mfedit) { framework("begin","$logname","Maintenance Form Edit",$print); - if ($loggedinas) $mfauthorized=1; + if ($loggedinas) $mfauthorized=TRUE; } else if ($mfdelete) { framework("begin","$logname","Maintenance Form Edit",$print); $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); - if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=1; + if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE; } else if ($actionadd) { framework("begin","$logname","Maintenance Action Entry",$print); $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); if ($loggedinas) { - $mfauthorized=1; - $actionauthorized=1; + $mfauthorized=TRUE; + $actionauthorized=TRUE; } } else if ($actionedit || $actiondelete) { framework("begin","$logname","Maintenance Action Edit",$print); $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); - if ($loggedinas) $mfauthorized=1; + if ($loggedinas) $mfauthorized=TRUE; $actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid); - if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1; + if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE; } else { - $mfadd=1; + $mfadd=TRUE; framework("begin","$logname","Maintenance Form Entry",$print); $mftech=$loggedinas; - $mfauthorized=1; + $mfauthorized=TRUE; } // ******** begin database manipulation ******** //var_dump($_REQUEST); +$pdatamismatch=NULL; if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) { // pull mf data from database $mftoedit=getmfdata($maintformid); - $partdatainput=array(); + $partdatainput=[]; if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart']; if ($uid) $partdatainput['uid']=$uid; if ($partnum) $partdatainput['partnum']=$partnum; if ($sernum) $partdatainput['sernum']=$sernum; $partinfo=get_part_data($partdatainput); if ($partinfo['result']==2) { - $pdatamismatch=1; + $pdatamismatch=TRUE; } else { - unset($pdatamismatch); + $pdatamismatch=FALSE; if ($partinfo['partid']) $mfpart=$partinfo['partid']; if ($partinfo['uid']) $uid=$partinfo['uid']; if ($partinfo['partnum']) $partnum=$partinfo['partnum']; @@ -157,9 +158,10 @@ if ($mfadd) { mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); $mfpart=mysqli_insert_id($db); } else if ($partinfo['result']==2) { - $pdatamismatch=1; + $pdatamismatch=TRUE; } else { // if it is in parts table, get partid for this record + $pdatamismatch=FALSE; $mfpart=$partinfo['partid']; } if ($uid =="" || $partnum == "" || $sernum == "") { @@ -214,7 +216,7 @@ if ($mfedit) { mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$maintformid\")"); + mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")"); } } } @@ -312,7 +314,7 @@ if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit | $sernum=$partinfo['sernum']; $partname=$partinfo['partname']; $pluresult=$partinfo['result']; - if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch); + if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE; } $techname=dblookup($db,"techs","techid","techname",$mftech); @@ -373,32 +375,23 @@ if ($printfmt) {
Action$uidtextPart NumberSerial NumberPart Name$uidtextPart NumberSerial NumberPart Name
%s
"; - - - - - - - - - - - // // get an array of flagids set for this maintformid - // $allflags=mysqli_query($db,"select flagid from flags"); - // unset($theseflags); - // while ($thisflag=mysqli_fetch_row($allflags)) { - // $thisflagtbl="flag_".$thisflag[0]; - // if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) { - // $theseflags[]=$thisflag[0]; - // } - // } - // $flagslist=mysqli_query($db,"select * from flags"); - // while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { - // if ($theseflags[0]=="") $theseflags=[]; - // if (in_array($flagsymbol["flagid"],$theseflags)) { - // echo $flagsymbol['flagsym']."  "; - // } - // } + // create an array called theseflags of flagids set for this maintformid + $allflags=mysqli_query($db,"select flagid from flags"); + unset($theseflags); + $theseflags=[]; + while ($thisflag=mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { + $theseflags[]=$thisflag[0]; + } + } + // display flag symbols for set flags + $flagslist=mysqli_query($db,"select * from flags"); + while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { + if ($theseflags[0]=="") $theseflags=[]; + if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) { + echo $flagsymbol['flagsym']."  "; + } + } echo "

Maintenance Actions
@@ -469,13 +462,12 @@ if ($printfmt) { "; - // get an array of flagids set for this maintformid + // create an array called theseflags of flagids set for this maintformid $allflags=mysqli_query($db,"select flagid from flags"); unset($theseflags); $theseflags=[]; while ($thisflag=mysqli_fetch_row($allflags)) { - $thisflagtbl="flag_".$thisflag[0]; - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { $theseflags[]=$thisflag[0]; } } @@ -487,7 +479,7 @@ if ($printfmt) { $flagsperline=8; $flagcount=1; while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($theseflags[0]=="") $theseflags=[]; + //if ($theseflags[0]=="") $theseflags=[]; if (in_array($flagcheckbox["flagid"],$theseflags)) { printf("%s", $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); From c4d2d4334eaf923b129be2626b1b694cebaf286f Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 12:56:49 -0500 Subject: [PATCH 19/50] Cleanup to avoid php undefined array key warning --- distfiles/gpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distfiles/gpl.php b/distfiles/gpl.php index c8a40d6..3991153 100644 --- a/distfiles/gpl.php +++ b/distfiles/gpl.php @@ -10,7 +10,7 @@ include("functions.php"); -$print=$_REQUEST['print']; +$print=$_REQUEST['print'] ?? NULL; if ($print) { $sbcolor=P_SIDEBAR_COLOR; From 0145f5849f38940a942a76fbb66abd8744991662 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 13:00:04 -0500 Subject: [PATCH 20/50] Minor cleanups and removed references to installing on Windows since we don't try to support that any more. --- distfiles/INSTALL | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/distfiles/INSTALL b/distfiles/INSTALL index 68e2883..d808a4f 100644 --- a/distfiles/INSTALL +++ b/distfiles/INSTALL @@ -14,16 +14,14 @@ 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). +Unpack the distribution in a convenient place. 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. +Type ./install.sh at a command prompt. Follow the prompts. 5. Check and set Configuration Click on the Administration menu option on the main page to adjust the initial From 86f1512cc0a31a59dac07154afe608899afefd9a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 14:10:33 -0500 Subject: [PATCH 21/50] Removed hardcoded form action to templates.php in the templateselect function. --- distfiles/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distfiles/functions.php b/distfiles/functions.php index 3944c6e..4ef401f 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -936,7 +936,7 @@ function templateselect($techid,$operation) { // $operation is one of "add" "edit" "delete" global $db; echo " -
+ "; // generate template selection line echo " From 9122040863bda88b7ec6f95254791ead2ff2b6c4 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Wed, 18 Feb 2026 14:11:52 -0500 Subject: [PATCH 22/50] Replaced template line loading code with the templateselect function. --- distfiles/logentry.php | 65 ++++-------------------------------------- 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/distfiles/logentry.php b/distfiles/logentry.php index b1d3cb3..3b11a3b 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -498,70 +498,15 @@ if ($submit) { if ($delete) { format_message(0,"Note deleted. Return to main page."); } -echo " - -"; + if ($_SESSION['login']) { - // generate template line - echo " - - "; - // list user templates - echo " - - -
-  or  - "; - // list global templates - echo " -    - "; - // show load button - echo " - - - Manage templates -
-
- "; + // show the template selection line + templateselect($techid,NULL); } + // start note entry section echo " +
Date:   From 01fd47814bab3782337309479b8c30ede049800a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 14:08:40 -0500 Subject: [PATCH 23/50] Various reformats. Changed boolean variables from 1/0 to TRUE/FALSE in multiple files. --- BUGS | 3 +- TODO.txt | 8 +- database-initial.sql | 893 ++++++++++++++++---------- database-update.sql | 62 +- distfiles/about.php | 30 +- distfiles/admin.php | 1160 ++++++++++++++++++---------------- distfiles/functions.php | 509 ++++++++------- distfiles/gpl.php | 30 +- distfiles/logentry.php | 638 ++++++++++--------- distfiles/login.php | 64 +- distfiles/lognotes.php | 217 +++---- distfiles/maintform.php | 180 +++--- distfiles/maintformentry.php | 481 +++++++------- distfiles/partentry.php | 92 ++- distfiles/parts.php | 81 +-- distfiles/profile.php | 185 +++--- distfiles/refchain.php | 98 +-- distfiles/schedmaint.php | 688 ++++++++++---------- distfiles/search.php | 698 ++++++++++---------- distfiles/settings.php | 40 +- distfiles/templates.php | 493 ++++++++------- install.sh | 2 +- 22 files changed, 3502 insertions(+), 3150 deletions(-) diff --git a/BUGS b/BUGS index 39f47d2..26132e5 100644 --- a/BUGS +++ b/BUGS @@ -1,4 +1,5 @@ BUGS 1. Adding a reference to a note using the magnifying glass icon is possible even if not logged in. This results in a blank tech and shift. -SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There needs to be a specific view only state.) +SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There +needs to be a specific view only state.) diff --git a/TODO.txt b/TODO.txt index 3d54569..f5e5795 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,15 @@ TODO.txt 1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE -2. Allow admins to create global templates. +2. Allow admins to create global templates. DONE 3. Create a way to restore the global page colors. (db change reqd) 4. Pick a logbook subject to associate with a scheduled task to populate for the logbook entry. (db change reqd) 5. Add info messages to scheduled task page edits. 6. Allow scheduled tasks to be completed as a group instead of having to complete each member. 7. Implement popup calendars for date entry fields. DONE -8. Improve template management interface. It can be confusing. It needs its own page. -9. Remove refs from templates. (db change reqd) -10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) +8. Improve template management interface. It can be confusing. It needs its own page. DONE +9. Remove refs from templates. (db change reqd) DONE +10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) DONE 11. allow partids to be autogenerated if user doesn't supply one (db change reqd) 12. If there are no flags, don't offer to set them on reference chain 13. make some flags immutable so they won't be synced on reference chain. diff --git a/database-initial.sql b/database-initial.sql index c1b89c9..8ec8ada 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -4,46 +4,87 @@ -- ------------------------------------------------------ -- Server version 10.6.18-MariaDB-0ubuntu0.22.04.1 -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */ +; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */ +; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */ +; +/*!40101 SET NAMES utf8mb4 */ +; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */ +; +/*!40103 SET TIME_ZONE='+00:00' */ +; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */ +; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */ +; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */ +; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */ +; -- -- Table structure for table `banners` -- DROP TABLE IF EXISTS `banners`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `banners` ( - `bannerid` int(11) NOT NULL AUTO_INCREMENT, - `bannername` tinytext DEFAULT NULL, - `bannercolor` tinytext DEFAULT NULL, - `textcolor` tinytext DEFAULT NULL, - PRIMARY KEY (`bannerid`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `bannerid` int(11) NOT NULL AUTO_INCREMENT, + `bannername` tinytext DEFAULT NULL, + `bannercolor` tinytext DEFAULT NULL, + `textcolor` tinytext DEFAULT NULL, + PRIMARY KEY (`bannerid`) +) ENGINE = InnoDB AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `banners` -- LOCK TABLES `banners` WRITE; -/*!40000 ALTER TABLE `banners` DISABLE KEYS */; -INSERT INTO `banners` VALUES -(1,'no banner','#000000','#000000'), -(2,'UNCLASSIFIED','#009900','#FFFFFF'), -(3,'CONFIDENTIAL','#000099','#FFFFFF'), -(4,'SECRET','#990000','#FFFFFF'), -(5,'TOP SECRET','#FF6600','#FFFFFF'); -/*!40000 ALTER TABLE `banners` ENABLE KEYS */; +/*!40000 ALTER TABLE `banners` DISABLE KEYS */ +; +INSERT INTO + `banners` +VALUES ( + 1, + 'no banner', + '#000000', + '#000000' + ), + ( + 2, + 'UNCLASSIFIED', + '#009900', + '#FFFFFF' + ), + ( + 3, + 'CONFIDENTIAL', + '#000099', + '#FFFFFF' + ), + ( + 4, + 'SECRET', + '#990000', + '#FFFFFF' + ), + ( + 5, + 'TOP SECRET', + '#FF6600', + '#FFFFFF' + ); +/*!40000 ALTER TABLE `banners` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -51,55 +92,109 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `configs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `configs` ( - `confid` int(11) NOT NULL AUTO_INCREMENT, - `confname` text DEFAULT NULL, - `confvalue` text DEFAULT NULL, - PRIMARY KEY (`confid`), - UNIQUE (`confname`) -) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `confid` int(11) NOT NULL AUTO_INCREMENT, + `confname` text DEFAULT NULL, + `confvalue` text DEFAULT NULL, + PRIMARY KEY (`confid`), + UNIQUE (`confname`) +) ENGINE = InnoDB AUTO_INCREMENT = 33 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `configs` -- LOCK TABLES `configs` WRITE; -/*!40000 ALTER TABLE `configs` DISABLE KEYS */; -INSERT INTO `configs` VALUES -(1,'ol_version','5.2.4'), -(2,'log_name','OpenLog'), -(3,'banner','1'), -(4,'background_color','#003333'), -(5,'p_background_color','#FFFFFF'), -(6,'sidebar_color','#336666'), -(7,'p_sidebar_color','#FFFFFF'), -(8,'menubg_color','#000000'), -(9,'p_menubg_color','#FFFFFF'), -(10,'text_color','#FFFFFF'), -(11,'p_text_color','#000000'), -(12,'link_color','#00FF00'), -(13,'p_link_color','#000000'), -(14,'vlink_color','#00FF00'), -(15,'p_vlink_color','#000000'), -(16,'heading_color','#00FFFF'), -(17,'p_heading_color','#000000'), -(18,'footer_message','Please report bugs to software@thermionic.net.'), -(19,'show_ts','1'), -(20,'url_chunk_size','70'), -(21,'tech_alpha','1'), -(22,'subj_alpha','1'), -(23,'unix_server_session_dir','/tmp/openlog/openlog/sessions'), -(24,'win_server_session_dir','c:\\Windows\\Temp\\openlog\\\\openlog\\sessions'), -(25,'session_ttl_days','30'), -(26,'log_style','1'), -(27,'uid_text','Part ID Number'), -(28,'parts_functions','1'), -(29,'schedmaint_functions','1'), -(30,'log_errors','0'); -/*!40000 ALTER TABLE `configs` ENABLE KEYS */; +/*!40000 ALTER TABLE `configs` DISABLE KEYS */ +; +INSERT INTO + `configs` +VALUES (1, 'ol_version', '5.2.4'), + (2, 'log_name', 'OpenLog'), + (3, 'banner', '1'), + ( + 4, + 'background_color', + '#003333' + ), + ( + 5, + 'p_background_color', + '#FFFFFF' + ), + (6, 'sidebar_color', '#336666'), + ( + 7, + 'p_sidebar_color', + '#FFFFFF' + ), + (8, 'menubg_color', '#000000'), + ( + 9, + 'p_menubg_color', + '#FFFFFF' + ), + (10, 'text_color', '#FFFFFF'), + (11, 'p_text_color', '#000000'), + (12, 'link_color', '#00FF00'), + (13, 'p_link_color', '#000000'), + (14, 'vlink_color', '#00FF00'), + ( + 15, + 'p_vlink_color', + '#000000' + ), + ( + 16, + 'heading_color', + '#00FFFF' + ), + ( + 17, + 'p_heading_color', + '#000000' + ), + ( + 18, + 'footer_message', + 'Please report bugs to software@thermionic.net.' + ), + (19, 'show_ts', '1'), + (20, 'url_chunk_size', '70'), + (21, 'tech_alpha', '1'), + (22, 'subj_alpha', '1'), + ( + 23, + 'unix_server_session_dir', + '/tmp/openlog/openlog/sessions' + ), + ( + 24, + 'win_server_session_dir', + 'c:\\Windows\\Temp\\openlog\\\\openlog\\sessions' + ), + (25, 'session_ttl_days', '30'), + (26, 'log_style', '1'), + ( + 27, + 'uid_text', + 'Part ID Number' + ), + (28, 'parts_functions', '1'), + ( + 29, + 'schedmaint_functions', + '1' + ), + (30, 'log_errors', '0'); +/*!40000 ALTER TABLE `configs` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -107,24 +202,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `customs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `customs` ( - `customid` int(11) NOT NULL AUTO_INCREMENT, - `customtech` int(11) DEFAULT NULL, - `customconfnum` int(11) DEFAULT NULL, - `customconfvalue` text DEFAULT NULL, - PRIMARY KEY (`customid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `customid` int(11) NOT NULL AUTO_INCREMENT, + `customtech` int(11) DEFAULT NULL, + `customconfnum` int(11) DEFAULT NULL, + `customconfvalue` text DEFAULT NULL, + PRIMARY KEY (`customid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `customs` -- LOCK TABLES `customs` WRITE; -/*!40000 ALTER TABLE `customs` DISABLE KEYS */; -/*!40000 ALTER TABLE `customs` ENABLE KEYS */; +/*!40000 ALTER TABLE `customs` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `customs` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -132,23 +232,28 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `devicegroups`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `devicegroups` ( - `groupid` int(11) NOT NULL AUTO_INCREMENT, - `groupdevice` int(11) DEFAULT NULL, - `memberdevice` int(11) DEFAULT NULL, - PRIMARY KEY (`groupid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `groupid` int(11) NOT NULL AUTO_INCREMENT, + `groupdevice` int(11) DEFAULT NULL, + `memberdevice` int(11) DEFAULT NULL, + PRIMARY KEY (`groupid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `devicegroups` -- LOCK TABLES `devicegroups` WRITE; -/*!40000 ALTER TABLE `devicegroups` DISABLE KEYS */; -/*!40000 ALTER TABLE `devicegroups` ENABLE KEYS */; +/*!40000 ALTER TABLE `devicegroups` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `devicegroups` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -156,25 +261,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `devices`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `devices` ( - `deviceid` int(11) NOT NULL AUTO_INCREMENT, - `devicename` tinytext DEFAULT NULL, - `devicedesc` text DEFAULT NULL, - `group_flag` int(11) DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`deviceid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `deviceid` int(11) NOT NULL AUTO_INCREMENT, + `devicename` tinytext DEFAULT NULL, + `devicedesc` text DEFAULT NULL, + `group_flag` int(11) DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`deviceid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `devices` -- LOCK TABLES `devices` WRITE; -/*!40000 ALTER TABLE `devices` DISABLE KEYS */; -/*!40000 ALTER TABLE `devices` ENABLE KEYS */; +/*!40000 ALTER TABLE `devices` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `devices` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -182,28 +292,33 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `events`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `events` ( - `eventid` int(11) NOT NULL AUTO_INCREMENT, - `task` int(11) DEFAULT NULL, - `device` int(11) DEFAULT NULL, - `start_date` date DEFAULT NULL, - `last_date` date DEFAULT NULL, - `deferred_flag` int(11) DEFAULT NULL, - `deferred_date` date DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`eventid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `eventid` int(11) NOT NULL AUTO_INCREMENT, + `task` int(11) DEFAULT NULL, + `device` int(11) DEFAULT NULL, + `start_date` date DEFAULT NULL, + `last_date` date DEFAULT NULL, + `deferred_flag` int(11) DEFAULT NULL, + `deferred_date` date DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`eventid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `events` -- LOCK TABLES `events` WRITE; -/*!40000 ALTER TABLE `events` DISABLE KEYS */; -/*!40000 ALTER TABLE `events` ENABLE KEYS */; +/*!40000 ALTER TABLE `events` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `events` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -211,25 +326,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `flags`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `flags` ( - `flagid` int(11) NOT NULL AUTO_INCREMENT, - `flagname` tinytext DEFAULT NULL, - `flagsym` tinytext DEFAULT NULL, - `flagcolor` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`flagid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `flagid` int(11) NOT NULL AUTO_INCREMENT, + `flagname` tinytext DEFAULT NULL, + `flagsym` tinytext DEFAULT NULL, + `flagcolor` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`flagid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `flags` -- LOCK TABLES `flags` WRITE; -/*!40000 ALTER TABLE `flags` DISABLE KEYS */; -/*!40000 ALTER TABLE `flags` ENABLE KEYS */; +/*!40000 ALTER TABLE `flags` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `flags` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -237,25 +357,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `flagmap`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `flagmap` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `flagid` int(11) NOT NULL, - `lognoteid` int(11) DEFAULT NULL, - `maintformid` int(11) DEFAULT NULL, - `notetemplateid` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `flagmap` -- LOCK TABLES `flagmap` WRITE; -/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */; -/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */; +/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -263,25 +388,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `links`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `links` ( - `linkid` int(11) NOT NULL AUTO_INCREMENT, - `linkpriority` int(11) NOT NULL, - `displaytxt` text DEFAULT NULL, - `urltxt` text DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`linkid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `linkid` int(11) NOT NULL AUTO_INCREMENT, + `linkpriority` int(11) NOT NULL, + `displaytxt` text DEFAULT NULL, + `urltxt` text DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`linkid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `links` -- LOCK TABLES `links` WRITE; -/*!40000 ALTER TABLE `links` DISABLE KEYS */; -/*!40000 ALTER TABLE `links` ENABLE KEYS */; +/*!40000 ALTER TABLE `links` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `links` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -289,27 +419,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `lognotes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `lognotes` ( - `lognoteid` int(11) NOT NULL AUTO_INCREMENT, - `date` date DEFAULT NULL, - `time` time DEFAULT NULL, - `shift` int(11) NOT NULL, - `tech` int(11) NOT NULL, - `subject` int(11) NOT NULL, - `lognote` text DEFAULT NULL, - PRIMARY KEY (`lognoteid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `lognoteid` int(11) NOT NULL AUTO_INCREMENT, + `date` date DEFAULT NULL, + `time` time DEFAULT NULL, + `shift` int(11) NOT NULL, + `tech` int(11) NOT NULL, + `subject` int(11) NOT NULL, + `lognote` text DEFAULT NULL, + PRIMARY KEY (`lognoteid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `lognotes` -- LOCK TABLES `lognotes` WRITE; -/*!40000 ALTER TABLE `lognotes` DISABLE KEYS */; -/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */; +/*!40000 ALTER TABLE `lognotes` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -317,24 +452,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `reflinks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `reflinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `noteid` int(11) DEFAULT NULL, - `templateid` int(11) DEFAULT NULL, - `target` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `reflinks` -- LOCK TABLES `reflinks` WRITE; -/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */; -/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */; +/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -342,30 +482,36 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `logpartactions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `logpartactions` ( - `lpactionid` int(11) NOT NULL AUTO_INCREMENT, - `lpactionname` tinytext DEFAULT NULL, - `status` int(11) DEFAULT NULL, - PRIMARY KEY (`lpactionid`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `lpactionid` int(11) NOT NULL AUTO_INCREMENT, + `lpactionname` tinytext DEFAULT NULL, + `status` int(11) DEFAULT NULL, + PRIMARY KEY (`lpactionid`) +) ENGINE = InnoDB AUTO_INCREMENT = 7 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `logpartactions` -- LOCK TABLES `logpartactions` WRITE; -/*!40000 ALTER TABLE `logpartactions` DISABLE KEYS */; -INSERT INTO `logpartactions` VALUES -(1,'removed',1), -(2,'installed',1), -(3,'repaired',1), -(4,'replaced',1), -(5,'incoming',1), -(6,'outgoing',1); -/*!40000 ALTER TABLE `logpartactions` ENABLE KEYS */; +/*!40000 ALTER TABLE `logpartactions` DISABLE KEYS */ +; +INSERT INTO + `logpartactions` +VALUES (1, 'removed', 1), + (2, 'installed', 1), + (3, 'repaired', 1), + (4, 'replaced', 1), + (5, 'incoming', 1), + (6, 'outgoing', 1); +/*!40000 ALTER TABLE `logpartactions` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -373,24 +519,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `logparts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `logparts` ( - `logpartid` int(11) NOT NULL AUTO_INCREMENT, - `lognoteid` int(11) DEFAULT NULL, - `partid` int(11) DEFAULT NULL, - `action` int(11) DEFAULT NULL, - PRIMARY KEY (`logpartid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `logpartid` int(11) NOT NULL AUTO_INCREMENT, + `lognoteid` int(11) DEFAULT NULL, + `partid` int(11) DEFAULT NULL, + `action` int(11) DEFAULT NULL, + PRIMARY KEY (`logpartid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `logparts` -- LOCK TABLES `logparts` WRITE; -/*!40000 ALTER TABLE `logparts` DISABLE KEYS */; -/*!40000 ALTER TABLE `logparts` ENABLE KEYS */; +/*!40000 ALTER TABLE `logparts` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `logparts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -398,26 +549,31 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `maintactions`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `maintactions` ( - `maintactionid` int(11) NOT NULL AUTO_INCREMENT, - `actiondate` date DEFAULT NULL, - `actiontime` time DEFAULT NULL, - `maintformnum` int(11) NOT NULL, - `actiontech` int(11) NOT NULL, - `action` text DEFAULT NULL, - PRIMARY KEY (`maintactionid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `maintactionid` int(11) NOT NULL AUTO_INCREMENT, + `actiondate` date DEFAULT NULL, + `actiontime` time DEFAULT NULL, + `maintformnum` int(11) NOT NULL, + `actiontech` int(11) NOT NULL, + `action` text DEFAULT NULL, + PRIMARY KEY (`maintactionid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `maintactions` -- LOCK TABLES `maintactions` WRITE; -/*!40000 ALTER TABLE `maintactions` DISABLE KEYS */; -/*!40000 ALTER TABLE `maintactions` ENABLE KEYS */; +/*!40000 ALTER TABLE `maintactions` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `maintactions` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -425,31 +581,36 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `maintforms`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `maintforms` ( - `maintformid` int(11) NOT NULL AUTO_INCREMENT, - `mfdate` date DEFAULT NULL, - `mftime` time DEFAULT NULL, - `mftech` int(11) DEFAULT NULL, - `mfpart` int(11) NOT NULL, - `mfpartloc` text DEFAULT NULL, - `mfmalfunction` text DEFAULT NULL, - `nha` tinytext DEFAULT NULL, - `repord` tinytext DEFAULT NULL, - `lognoteid` int(11) DEFAULT NULL, - `pending` int(11) DEFAULT NULL, - PRIMARY KEY (`maintformid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `maintformid` int(11) NOT NULL AUTO_INCREMENT, + `mfdate` date DEFAULT NULL, + `mftime` time DEFAULT NULL, + `mftech` int(11) DEFAULT NULL, + `mfpart` int(11) NOT NULL, + `mfpartloc` text DEFAULT NULL, + `mfmalfunction` text DEFAULT NULL, + `nha` tinytext DEFAULT NULL, + `repord` tinytext DEFAULT NULL, + `lognoteid` int(11) DEFAULT NULL, + `pending` int(11) DEFAULT NULL, + PRIMARY KEY (`maintformid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `maintforms` -- LOCK TABLES `maintforms` WRITE; -/*!40000 ALTER TABLE `maintforms` DISABLE KEYS */; -/*!40000 ALTER TABLE `maintforms` ENABLE KEYS */; +/*!40000 ALTER TABLE `maintforms` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `maintforms` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -457,27 +618,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `notetemplates`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `notetemplates` ( - `templateid` int(11) NOT NULL AUTO_INCREMENT, - `templatename` tinytext DEFAULT NULL, - `shift` int(11) NOT NULL, - `tech` int(11) NOT NULL, - `subject` int(11) NOT NULL, - `lognote` text DEFAULT NULL, - `refs` tinytext DEFAULT NULL, - PRIMARY KEY (`templateid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `templateid` int(11) NOT NULL AUTO_INCREMENT, + `templatename` tinytext DEFAULT NULL, + `shift` int(11) NOT NULL, + `tech` int(11) NOT NULL, + `subject` int(11) NOT NULL, + `lognote` text DEFAULT NULL, + `refs` tinytext DEFAULT NULL, + PRIMARY KEY (`templateid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `notetemplates` -- LOCK TABLES `notetemplates` WRITE; -/*!40000 ALTER TABLE `notetemplates` DISABLE KEYS */; -/*!40000 ALTER TABLE `notetemplates` ENABLE KEYS */; +/*!40000 ALTER TABLE `notetemplates` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `notetemplates` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -485,25 +651,30 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `parts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `parts` ( - `partid` int(11) NOT NULL AUTO_INCREMENT, - `uid` tinytext DEFAULT NULL, - `partnum` tinytext DEFAULT NULL, - `sernum` tinytext DEFAULT NULL, - `partname` tinytext DEFAULT NULL, - PRIMARY KEY (`partid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `partid` int(11) NOT NULL AUTO_INCREMENT, + `uid` tinytext DEFAULT NULL, + `partnum` tinytext DEFAULT NULL, + `sernum` tinytext DEFAULT NULL, + `partname` tinytext DEFAULT NULL, + PRIMARY KEY (`partid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `parts` -- LOCK TABLES `parts` WRITE; -/*!40000 ALTER TABLE `parts` DISABLE KEYS */; -/*!40000 ALTER TABLE `parts` ENABLE KEYS */; +/*!40000 ALTER TABLE `parts` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `parts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -511,25 +682,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `shifts`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `shifts` ( - `shiftid` int(11) NOT NULL AUTO_INCREMENT, - `shiftname` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`shiftid`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `shiftid` int(11) NOT NULL AUTO_INCREMENT, + `shiftname` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`shiftid`) +) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `shifts` -- LOCK TABLES `shifts` WRITE; -/*!40000 ALTER TABLE `shifts` DISABLE KEYS */; -INSERT INTO `shifts` VALUES -(1,'First Shift',1); -/*!40000 ALTER TABLE `shifts` ENABLE KEYS */; +/*!40000 ALTER TABLE `shifts` DISABLE KEYS */ +; +INSERT INTO `shifts` VALUES (1, 'First Shift', 1); +/*!40000 ALTER TABLE `shifts` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -537,26 +712,32 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `styles`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `styles` ( - `styleid` int(11) NOT NULL AUTO_INCREMENT, - `styletype` tinytext DEFAULT NULL, - `stylename` tinytext DEFAULT NULL, - PRIMARY KEY (`styleid`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `styleid` int(11) NOT NULL AUTO_INCREMENT, + `styletype` tinytext DEFAULT NULL, + `stylename` tinytext DEFAULT NULL, + PRIMARY KEY (`styleid`) +) ENGINE = InnoDB AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `styles` -- LOCK TABLES `styles` WRITE; -/*!40000 ALTER TABLE `styles` DISABLE KEYS */; -INSERT INTO `styles` VALUES -(1,'logdisplay','classic'), -(2,'logdisplay','clean'); -/*!40000 ALTER TABLE `styles` ENABLE KEYS */; +/*!40000 ALTER TABLE `styles` DISABLE KEYS */ +; +INSERT INTO + `styles` +VALUES (1, 'logdisplay', 'classic'), + (2, 'logdisplay', 'clean'); +/*!40000 ALTER TABLE `styles` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -564,25 +745,29 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `subjects`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `subjects` ( - `subjectid` int(11) NOT NULL AUTO_INCREMENT, - `subjectname` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`subjectid`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `subjectid` int(11) NOT NULL AUTO_INCREMENT, + `subjectname` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`subjectid`) +) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `subjects` -- LOCK TABLES `subjects` WRITE; -/*!40000 ALTER TABLE `subjects` DISABLE KEYS */; -INSERT INTO `subjects` VALUES -(1,'Miscellaneous',1); -/*!40000 ALTER TABLE `subjects` ENABLE KEYS */; +/*!40000 ALTER TABLE `subjects` DISABLE KEYS */ +; +INSERT INTO `subjects` VALUES (1, 'Miscellaneous', 1); +/*!40000 ALTER TABLE `subjects` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -590,30 +775,35 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `tasks`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `tasks` ( - `taskid` int(11) NOT NULL AUTO_INCREMENT, - `taskname` tinytext DEFAULT NULL, - `taskdesc` text DEFAULT NULL, - `frequency` int(11) DEFAULT NULL, - `period` tinytext DEFAULT NULL, - `weekdays_only` int(11) DEFAULT NULL, - `nextdue_relative` int(11) DEFAULT NULL, - `refdoc_name` tinytext DEFAULT NULL, - `refdoc_url` tinytext DEFAULT NULL, - `active_flag` int(11) DEFAULT NULL, - PRIMARY KEY (`taskid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `taskid` int(11) NOT NULL AUTO_INCREMENT, + `taskname` tinytext DEFAULT NULL, + `taskdesc` text DEFAULT NULL, + `frequency` int(11) DEFAULT NULL, + `period` tinytext DEFAULT NULL, + `weekdays_only` int(11) DEFAULT NULL, + `nextdue_relative` int(11) DEFAULT NULL, + `refdoc_name` tinytext DEFAULT NULL, + `refdoc_url` tinytext DEFAULT NULL, + `active_flag` int(11) DEFAULT NULL, + PRIMARY KEY (`taskid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `tasks` -- LOCK TABLES `tasks` WRITE; -/*!40000 ALTER TABLE `tasks` DISABLE KEYS */; -/*!40000 ALTER TABLE `tasks` ENABLE KEYS */; +/*!40000 ALTER TABLE `tasks` DISABLE KEYS */ +; +/*!40000 ALTER TABLE `tasks` ENABLE KEYS */ +; UNLOCK TABLES; -- @@ -621,37 +811,58 @@ UNLOCK TABLES; -- DROP TABLE IF EXISTS `techs`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8 */ +; CREATE TABLE `techs` ( - `techid` int(11) NOT NULL AUTO_INCREMENT, - `techname` tinytext DEFAULT NULL, - `admin` int(11) DEFAULT NULL, - `shift` int(11) DEFAULT NULL, - `techpass` text DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`techid`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + `techid` int(11) NOT NULL AUTO_INCREMENT, + `techname` tinytext DEFAULT NULL, + `admin` int(11) DEFAULT NULL, + `shift` int(11) DEFAULT NULL, + `techpass` text DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`techid`) +) ENGINE = InnoDB AUTO_INCREMENT = 3 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; -- -- Dumping data for table `techs` -- LOCK TABLES `techs` WRITE; -/*!40000 ALTER TABLE `techs` DISABLE KEYS */; -INSERT INTO `techs` VALUES -(1,'OpenLogAdmin',1,1,'$2y$10$6eCxUFNzoAkycMJpZ.zvaOfoByYhqi0YicQbut3XGc/TRxyxiUwcm',1); -/*!40000 ALTER TABLE `techs` ENABLE KEYS */; +/*!40000 ALTER TABLE `techs` DISABLE KEYS */ +; +INSERT INTO + `techs` +VALUES ( + 1, + 'OpenLogAdmin', + 1, + 1, + '$2y$10$6eCxUFNzoAkycMJpZ.zvaOfoByYhqi0YicQbut3XGc/TRxyxiUwcm', + 1 + ); +/*!40000 ALTER TABLE `techs` ENABLE KEYS */ +; UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */ +; -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */ +; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */ +; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */ +; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */ +; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */ +; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */ +; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */ +; --- Dump completed on 2024-07-09 14:36:00 +-- Dump completed on 2024-07-09 14:36:00 \ No newline at end of file diff --git a/database-update.sql b/database-update.sql index c96da54..a5d096e 100644 --- a/database-update.sql +++ b/database-update.sql @@ -2,81 +2,85 @@ -- ---------- version 5.2.1 ------------- -- Make confname a unique column -ALTER TABLE configs ADD UNIQUE(confname); +ALTER TABLE configs ADD UNIQUE (confname); -- Delete db name, user, and password configs -DELETE FROM configs where confname="ol_dbname"; -DELETE FROM configs where confname="ol_dbuser"; -DELETE FROM configs where confname="ol_dbpass"; +DELETE FROM configs where confname = "ol_dbname"; + +DELETE FROM configs where confname = "ol_dbuser"; + +DELETE FROM configs where confname = "ol_dbpass"; -- Add config option for server side error logging -INSERT IGNORE INTO configs(confname,confvalue) values('log_errors','0') +INSERT IGNORE INTO + configs (confname, confvalue) +values ('log_errors', '0') -- Update version number -UPDATE configs SET confvalue="5.2.1" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.2 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.2" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.2" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.3 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.3" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.4" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.1 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.1" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.1" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.2 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.2" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.2" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.3 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.3" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.3" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.4.4 ----------- -- Update version number -UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.4.4" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.2.5 ------------- -- Update version number -UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.2.5" WHERE confname = "ol_version"; -- -------------------------------------- -- ---------- version 5.3.0 ------------- -- Update version number -UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version"; +UPDATE configs SET confvalue = "5.3.0" WHERE confname = "ol_version"; -- Create the flagmap table CREATE TABLE IF NOT EXISTS `flagmap` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `flagid` int(11) NOT NULL, - `lognoteid` int(11) DEFAULT NULL, - `maintformid` int(11) DEFAULT NULL, - `notetemplateid` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; -- Create the reflinks table CREATE TABLE IF NOT EXISTS `reflinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `noteid` int(11) DEFAULT NULL, - `templateid` int(11) DEFAULT NULL, - `target` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci; --- -------------------------------------- +-- -------------------------------------- \ No newline at end of file diff --git a/distfiles/about.php b/distfiles/about.php index ccdb1d7..9ebfa31 100644 --- a/distfiles/about.php +++ b/distfiles/about.php @@ -8,27 +8,27 @@ */ include("functions.php"); -$version=OL_VERSION; +$version = OL_VERSION; -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","About OpenLog","About OpenLog",$print); +framework("begin", "About OpenLog", "About OpenLog", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); echo "

OpenLog $version @@ -87,10 +87,8 @@ border=0>

Fugue
Icons
The icons used in OpenLog ar

-"; -pageblock("right","end"); +"; +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/admin.php b/distfiles/admin.php index dd5959c..8d89dbe 100644 --- a/distfiles/admin.php +++ b/distfiles/admin.php @@ -10,710 +10,723 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } // get user's admin status -$loginid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$loginid); -$print=$_REQUEST['print'] ?? NULL; -$table=$_REQUEST['table'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$update=$_REQUEST['update'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; -$id=$_REQUEST['id'] ?? NULL; -$name=$_REQUEST['name'] ?? NULL; -$admin=$_REQUEST['admin'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$pass=$_REQUEST['pass'] ?? NULL; -$passconf=$_REQUEST['passconf'] ?? NULL; -$belowlink=$_REQUEST['belowlink'] ?? NULL; -$url=$_REQUEST['url'] ?? NULL; -$flagsym=$_REQUEST['flagsym'] ?? NULL; -$flagcolor=$_REQUEST['flagcolor'] ?? NULL; -$bnrcolor=$_REQUEST['bnrcolor'] ?? NULL; -$bnrtxtcolor=$_REQUEST['bnrtxtcolor'] ?? NULL; -$active=$_REQUEST['active'] ?? NULL; -$type=$_REQUEST['type'] ?? NULL; -$display_logname=$_REQUEST['display_logname'] ?? NULL; -$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL; -$display_banner=$_REQUEST['display_banner'] ?? NULL; -$display_footer=$_REQUEST['display_footer'] ?? NULL; -$display_showts=$_REQUEST['display_showts'] ?? NULL; -$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL; -$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL; -$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL; -$display_uidtext=$_REQUEST['display_uidtext'] ?? NULL; -$modcolor=$_REQUEST['modcolor'] ?? NULL; -$hexcolor=$_REQUEST['hexcolor'] ?? NULL; -$db_dbname=$_REQUEST['db_dbname'] ?? NULL; -$misc_sessttl=$_REQUEST['misc_sessttl'] ?? NULL; -$misc_sessdir=$_REQUEST['misc_sessdir'] ?? NULL; -$misc_logoutall=$_REQUEST['misc_logoutall'] ?? NULL; -$misc_partfuncs=$_REQUEST['misc_partfuncs'] ?? NULL; -$misc_schedmaintfuncs=$_REQUEST['misc_schedmaintfuncs'] ?? NULL; +$loginid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $loginid); +$print = $_REQUEST['print'] ?? NULL; +$table = $_REQUEST['table'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$update = $_REQUEST['update'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; +$id = $_REQUEST['id'] ?? NULL; +$name = $_REQUEST['name'] ?? NULL; +$admin = $_REQUEST['admin'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$pass = $_REQUEST['pass'] ?? NULL; +$passconf = $_REQUEST['passconf'] ?? NULL; +$belowlink = $_REQUEST['belowlink'] ?? NULL; +$url = $_REQUEST['url'] ?? NULL; +$flagsym = $_REQUEST['flagsym'] ?? NULL; +$flagcolor = $_REQUEST['flagcolor'] ?? NULL; +$bnrcolor = $_REQUEST['bnrcolor'] ?? NULL; +$bnrtxtcolor = $_REQUEST['bnrtxtcolor'] ?? NULL; +$active = $_REQUEST['active'] ?? NULL; +$type = $_REQUEST['type'] ?? NULL; +$display_logname = $_REQUEST['display_logname'] ?? NULL; +$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL; +$display_banner = $_REQUEST['display_banner'] ?? NULL; +$display_footer = $_REQUEST['display_footer'] ?? NULL; +$display_showts = $_REQUEST['display_showts'] ?? NULL; +$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL; +$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL; +$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL; +$display_uidtext = $_REQUEST['display_uidtext'] ?? NULL; +$modcolor = $_REQUEST['modcolor'] ?? NULL; +$hexcolor = $_REQUEST['hexcolor'] ?? NULL; +$db_dbname = $_REQUEST['db_dbname'] ?? NULL; +$misc_sessttl = $_REQUEST['misc_sessttl'] ?? NULL; +$misc_sessdir = $_REQUEST['misc_sessdir'] ?? NULL; +$misc_logoutall = $_REQUEST['misc_logoutall'] ?? NULL; +$misc_partfuncs = $_REQUEST['misc_partfuncs'] ?? NULL; +$misc_schedmaintfuncs = $_REQUEST['misc_schedmaintfuncs'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Administration",$print); +framework("begin", "$logname", "Administration", $print); //var_dump($_REQUEST); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); if ($isadmin) { // ******** begin database manipulation ******** if ($add) { - switch($table) { + switch ($table) { case "techs": - if ($admin) $admin=1; else $admin=0; - if ($active) $active=1; else $active=0; + if ($admin) $admin = 1; + else $admin = 0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } if ($namesuppld && $nameunique && $passmatch) { // modify the table - $addqry=("insert into techs(techname,admin,shift,techpass,status) values(\"$name\",\"$admin\",\"$shift\",\"$passhash\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into techs(techname,admin,shift,techpass,status) values(\"$name\",\"$admin\",\"$shift\",\"$passhash\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "shifts": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Shift name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) { + $nameunique = FALSE; echo " Shift name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into shifts(shiftname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into shifts(shiftname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "subjects": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Subject name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) { + $nameunique = FALSE; echo " Subject name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into subjects(subjectname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into subjects(subjectname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "links": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Display text cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) { + $nameunique = FALSE; echo " Display text already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for urltxt supplied if (strlen(trim($url))) { - $urlsuppld=1; + $urlsuppld = TRUE; } else { - $urlsuppld=0; + $urlsuppld = FALSE; echo " URL text cannot be blank.
"; } if ($namesuppld && $nameunique && $urlsuppld) { // bump entries with linkpriority higher than belowlink up by one if necessary - $mypriority=$belowlink+1; - if (mysqli_num_rows(mysqli_query($db,"select linkpriority from links where linkpriority=\"$mypriority\""))) { - mysqli_query($db,"update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); + $mypriority = $belowlink + 1; + if (mysqli_num_rows(mysqli_query($db, "select linkpriority from links where linkpriority=\"$mypriority\""))) { + mysqli_query($db, "update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); } // insert the link - mysqli_query($db,"insert into links(linkpriority,displaytxt,urltxt,status) values(\"$mypriority\",\"$name\",\"$url\",\"$active\")"); + mysqli_query($db, "insert into links(linkpriority,displaytxt,urltxt,status) values(\"$mypriority\",\"$name\",\"$url\",\"$active\")"); } break; case "flags": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Flag name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) { + $nameunique = FALSE; echo " Flag name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } // test for symbol supplied if (strlen(trim($flagsym))) { - $symsuppld=1; + $symsuppld = TRUE; } else { - $symsuppld=0; + $symsuppld = FALSE; echo " Flag symbol cannot be blank.
"; } // test for symbol unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\""))) { - $symunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) { + $symunique = FALSE; echo " Flag symbol already exists.
"; } else { - $symunique=1; + $symunique = TRUE; } if ($namesuppld && $nameunique && $symsuppld && $symunique) { - // insert record in links table - mysqli_query($db,"insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")"); - // create sub tables for this link - $lastflagid=mysqli_insert_id($db); - mysqli_query($db,"create table flag_$lastflagid(target tinytext,id int not null)"); + // insert record in flags table + mysqli_query($db, "insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")"); } break; case "logpartactions": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Part Action name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) { + $nameunique = FALSE; echo " Part Action name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into logpartactions(lpactionname,status) values(\"$name\",\"$active\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into logpartactions(lpactionname,status) values(\"$name\",\"$active\")"); + mysqli_query($db, $addqry); } break; case "banners": // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Banner name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) { + $nameunique = FALSE; echo " Banner name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into banners(bannername,bannercolor,textcolor) values(\"$name\",\"$bnrcolor\",\"$bnrtxtcolor\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into banners(bannername,bannercolor,textcolor) values(\"$name\",\"$bnrcolor\",\"$bnrtxtcolor\")"); + mysqli_query($db, $addqry); } break; - default : - framework("begin","$logname Administration","Error",$print); - echo "unknown table"; - framework("end","","",$print); - exit(); + default: + framework("begin", "$logname Administration", "Error", $print); + echo "unknown table"; + framework("end", "", "", $print); + exit(); } } if ($edit) { - switch($table) { + switch ($table) { case "techs": - if ($admin) $admin=1; else $admin=0; - if ($active) $active=1; else $active=0; + if ($admin) $admin = 1; + else $admin = 0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes by this tech - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where tech=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where tech=\"$id\""))) { + $hasnotes = TRUE; echo " Tech has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } // check for maintenance forms by this tech - if (mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$id\""))) { - $hasmfs=1; + if (mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$id\""))) { + $hasmfs = TRUE; echo " Tech has maintenance forms and cannot be deleted.
"; } else { - $hasmfs=0; + $hasmfs = FALSE; } // check for maintenance actions by this tech - if (mysqli_num_rows(mysqli_query($db,"select maintactionid from maintactions where actiontech=\"$id\""))) { - $hasmas=1; + if (mysqli_num_rows(mysqli_query($db, "select maintactionid from maintactions where actiontech=\"$id\""))) { + $hasmas = TRUE; echo " Tech has maintenance actions and cannot be deleted.
"; } else { - $hasmas=0; + $hasmas = FALSE; } if (!$hasnotes && !$hasmfs && !$hasmas) { // delete entity - mysqli_query($db,"delete from techs where techid=\"$id\""); + mysqli_query($db, "delete from techs where techid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass!="password_is_unchanged") { - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); - $updqry=("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\""); + if ($pass != "password_is_unchanged") { + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); + $updqry = ("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\""); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } } else { - $passmatch=1; - $updqry="update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\""; + $passmatch = TRUE; + $updqry = "update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\""; } if ($namesuppld && $nameunique && $passmatch) { // modify the table - mysqli_query($db,$updqry); + mysqli_query($db, $updqry); } } break; case "shifts": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes with this shift - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where shift=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where shift=\"$id\""))) { + $hasnotes = TRUE; echo " Shift has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } if (!$hasnotes) { // delete entity - mysqli_query($db,"delete from shifts where shiftid=\"$id\""); + mysqli_query($db, "delete from shifts where shiftid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Shift name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select shiftid from shifts where shiftname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) { + $nameunique = FALSE; echo " Shift name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update shifts set shiftname=\"$name\",status=\"$active\" where shiftid=\"$id\""); + mysqli_query($db, "update shifts set shiftname=\"$name\",status=\"$active\" where shiftid=\"$id\""); } } break; case "subjects": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for log notes with this subject - if (mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where subject=\"$id\""))) { - $hasnotes=1; + if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where subject=\"$id\""))) { + $hasnotes = TRUE; echo " Subject has notes in logbook and cannot be deleted.
"; } else { - $hasnotes=0; + $hasnotes = FALSE; } if (!$hasnotes) { // delete entity - mysqli_query($db,"delete from subjects where subjectid=\"$id\""); + mysqli_query($db, "delete from subjects where subjectid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Subject name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select subjectid from subjects where subjectname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) { + $nameunique = FALSE; echo " Subject name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update subjects set subjectname=\"$name\",status=\"$active\" where subjectid=\"$id\""); + mysqli_query($db, "update subjects set subjectname=\"$name\",status=\"$active\" where subjectid=\"$id\""); } } break; case "links": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { - mysqli_query($db,"delete from links where linkid=\"$id\""); + mysqli_query($db, "delete from links where linkid=\"$id\""); } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Display text cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select linkid from links where displaytxt=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) { + $nameunique = FALSE; echo " Display text already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for urltxt supplied if (strlen(trim($url))) { - $urlsuppld=1; + $urlsuppld = TRUE; } else { - $urlsuppld=0; + $urlsuppld = FALSE; echo " URL text cannot be blank.
"; } if ($namesuppld && $nameunique && $urlsuppld) { // bump entries with linkpriority higher than belowlink up by one if necessary - $mypriority=$belowlink+1; - if (mysqli_num_rows(mysqli_query($db,"select linkpriority from links where linkpriority=\"$mypriority\""))) { - mysqli_query($db,"update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); + $mypriority = $belowlink + 1; + if (mysqli_num_rows(mysqli_query($db, "select linkpriority from links where linkpriority=\"$mypriority\""))) { + mysqli_query($db, "update links set linkpriority=linkpriority+1 where linkpriority>\"$belowlink\""); } // update the link - mysqli_query($db,"update links set linkpriority=\"$mypriority\",displaytxt=\"$name\",urltxt=\"$url\",status=\"$active\" where linkid=\"$id\""); + mysqli_query($db, "update links set linkpriority=\"$mypriority\",displaytxt=\"$name\",urltxt=\"$url\",status=\"$active\" where linkid=\"$id\""); } } break; case "flags": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for things using this flag - if (mysqli_num_rows(mysqli_query($db,"select * from flag_$id"))) { - $used=1; + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$id\""))) { + $used = TRUE; echo " Flag is used by other tables and cannot be deleted.
"; } else { - $used=0; + $used = FALSE; } if (!$used) { // delete entity - mysqli_query($db,"delete from flags where flagid=\"$id\""); - mysqli_query($db,"drop table flag_$id"); + mysqli_query($db, "delete from flags where flagid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Flag name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) { + $nameunique = FALSE; echo " Flag name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for symbol supplied if (strlen(trim($flagsym))) { - $symsuppld=1; + $symsuppld = TRUE; } else { - $symsuppld=0; + $symsuppld = FALSE; echo " Flag symbol cannot be blank.
"; } // test for symbol unique - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagsym=\"$flagsym\""))) { - $symunique=0; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) { + $symunique = FALSE; echo " Flag symbol already exists.
"; } else { - $symunique=1; + $symunique = TRUE; } } else { - $symunique=1; + $symunique = TRUE; } if ($namesuppld && $nameunique && $symsuppld && $symunique) { // modify the table - mysqli_query($db,"update flags set flagname=\"$name\",flagsym=\"$flagsym\",flagcolor=\"$flagcolor\",status=\"$active\" where flagid=\"$id\""); + mysqli_query($db, "update flags set flagname=\"$name\",flagsym=\"$flagsym\",flagcolor=\"$flagcolor\",status=\"$active\" where flagid=\"$id\""); } } break; case "logpartactions": - if ($active) $active=1; else $active=0; + if ($active) $active = 1; + else $active = 0; if ($delete) { // check for logparts with this part action - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where action=\"$id\""))) { - $hasparts=1; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where action=\"$id\""))) { + $hasparts = TRUE; echo " Action is assigned to parts in logbook notes and cannot be deleted.
"; } else { - $hasparts=0; + $hasparts = FALSE; } if (!$hasparts) { // delete entity - mysqli_query($db,"delete from logpartactions where lpactionid=\"$id\""); + mysqli_query($db, "delete from logpartactions where lpactionid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Part Action name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select lpactionid from logpartactions where lpactionname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) { + $nameunique = FALSE; echo " Part Action name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update logpartactions set lpactionname=\"$name\",status=\"$active\" where lpactionid=\"$id\""); + mysqli_query($db, "update logpartactions set lpactionname=\"$name\",status=\"$active\" where lpactionid=\"$id\""); } } break; case "banners": if ($delete) { // delete entity - mysqli_query($db,"delete from banners where bannerid=\"$id\""); + mysqli_query($db, "delete from banners where bannerid=\"$id\""); } if ($update) { // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Banner name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) { + $nameunique = FALSE; echo " Banner name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } if ($namesuppld && $nameunique) { // modify the table - mysqli_query($db,"update banners set bannername=\"$name\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$id\""); + mysqli_query($db, "update banners set bannername=\"$name\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$id\""); } } break; - case "configs" : - switch($type) { - case "display" : - if ($display_showts) $display_showts=1; else $display_showts=0; - if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0; - if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0; + case "configs": + switch ($type) { + case "display": + if ($display_showts) $display_showts = 1; + else $display_showts = 0; + if ($display_techalpha == "a") $display_techalpha = 1; + else $display_techalpha = 0; + if ($display_subjalpha == "a") $display_subjalpha = 1; + else $display_subjalpha = 0; // test for logname supplied if (strlen(trim($display_logname))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Log name cannot be blank.
"; } // test for urlchunk supplied if (strlen(trim($display_urlchunk))) { - $chunksuppld=1; + $chunksuppld = TRUE; } else { - $chunksuppld=0; + $chunksuppld = FALSE; echo " URL chunk size cannot be blank.
"; } if ($namesuppld && $chunksuppld) { - mysqli_query($db,"update configs set confvalue=\"$display_logname\" where confname=\"log_name\""); - mysqli_query($db,"update configs set confvalue=\"$display_urlchunk\" where confname=\"url_chunk_size\""); - mysqli_query($db,"update configs set confvalue=\"$display_banner\" where confname=\"banner\""); - mysqli_query($db,"update configs set confvalue=\"$display_footer\" where confname=\"footer_message\""); - mysqli_query($db,"update configs set confvalue=\"$display_showts\" where confname=\"show_ts\""); - mysqli_query($db,"update configs set confvalue=\"$display_techalpha\" where confname=\"tech_alpha\""); - mysqli_query($db,"update configs set confvalue=\"$display_subjalpha\" where confname=\"subj_alpha\""); - mysqli_query($db,"update configs set confvalue=\"$display_logstyle\" where confname=\"log_style\""); - mysqli_query($db,"update configs set confvalue=\"$display_uidtext\" where confname=\"uid_text\""); - } + mysqli_query($db, "update configs set confvalue=\"$display_logname\" where confname=\"log_name\""); + mysqli_query($db, "update configs set confvalue=\"$display_urlchunk\" where confname=\"url_chunk_size\""); + mysqli_query($db, "update configs set confvalue=\"$display_banner\" where confname=\"banner\""); + mysqli_query($db, "update configs set confvalue=\"$display_footer\" where confname=\"footer_message\""); + mysqli_query($db, "update configs set confvalue=\"$display_showts\" where confname=\"show_ts\""); + mysqli_query($db, "update configs set confvalue=\"$display_techalpha\" where confname=\"tech_alpha\""); + mysqli_query($db, "update configs set confvalue=\"$display_subjalpha\" where confname=\"subj_alpha\""); + mysqli_query($db, "update configs set confvalue=\"$display_logstyle\" where confname=\"log_style\""); + mysqli_query($db, "update configs set confvalue=\"$display_uidtext\" where confname=\"uid_text\""); + } break; - case "color" : - $hexcolor="#".ltrim($hexcolor); - mysqli_query($db,"update configs set confvalue=\"$hexcolor\" where confname=\"$modcolor\""); + case "color": + $hexcolor = "#" . ltrim($hexcolor); + mysqli_query($db, "update configs set confvalue=\"$hexcolor\" where confname=\"$modcolor\""); break; case "misc": if ($misc_partfuncs) { - mysqli_query($db,"update configs set confvalue=\"1\" where confname=\"parts_functions\""); + mysqli_query($db, "update configs set confvalue=\"1\" where confname=\"parts_functions\""); } else { - mysqli_query($db,"update configs set confvalue=\"0\" where confname=\"parts_functions\""); + mysqli_query($db, "update configs set confvalue=\"0\" where confname=\"parts_functions\""); } if ($misc_logoutall) { if ($ostype == 'WIN') { - $sessfileloc=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0]; + $sessfileloc = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0]; } else { - $sessfileloc=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; + $sessfileloc = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; } - foreach (glob($sessfileloc."/*") as $sessfile) { + foreach (glob($sessfileloc . "/*") as $sessfile) { unlink($sessfile); } } if ($misc_schedmaintfuncs) { - mysqli_query($db,"update configs set confvalue=\"1\" where confname=\"schedmaint_functions\""); + mysqli_query($db, "update configs set confvalue=\"1\" where confname=\"schedmaint_functions\""); } else { - mysqli_query($db,"update configs set confvalue=\"0\" where confname=\"schedmaint_functions\""); + mysqli_query($db, "update configs set confvalue=\"0\" where confname=\"schedmaint_functions\""); } // test for sessttl supplied if (strlen(trim($misc_sessttl))) { - $ttlsuppld=1; + $ttlsuppld = TRUE; } else { - $ttlsuppld=0; + $ttlsuppld = FALSE; echo " Session expiration time cannot be blank.
"; } // test for sessdir supplied if (strlen(trim($misc_sessdir))) { - $dirsuppld=1; + $dirsuppld = TRUE; } else { - $dirsuppld=0; + $dirsuppld = FALSE; echo " Server session file directory cannot be blank.
"; } if ($ttlsuppld && $dirsuppld) { - mysqli_query($db,"update configs set confvalue=\"$misc_sessttl\" where confname=\"session_ttl_days\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessttl\" where confname=\"session_ttl_days\""); if ($ostype == 'WIN') { - mysqli_query($db,"update configs set confvalue=\"$misc_sessdir\" where confname=\"win_server_session_dir\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessdir\" where confname=\"win_server_session_dir\""); } else { - mysqli_query($db,"update configs set confvalue=\"$misc_sessdir\" where confname=\"unix_server_session_dir\""); + mysqli_query($db, "update configs set confvalue=\"$misc_sessdir\" where confname=\"unix_server_session_dir\""); } } break; - default : + default: echo "Unknown config type!"; break; } break; - default : - framework("begin","$logname Administration","Error",$print); + default: + framework("begin", "$logname Administration", "Error", $print); echo "unknown table"; - framework("end","","",$print); + framework("end", "", "", $print); exit(); } } // ******** end database manipulation ******** } - + // show help echo "
Changes made here are global and affect all users. You must have admin privileges to make changes to these settings. To set your personal preferences, you should use the My Profile page. "; - + sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); // show the menu of tables echo " @@ -735,47 +748,47 @@ echo "

"; -switch($table) { - case "techs" : - if ($isadmin) { +switch ($table) { + case "techs": + if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Tech

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Tech

"; + $formtag = ""; + $buttontags = "          
"; // 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=""; + $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 = ""; } else { - $admintag=""; + $admintag = ""; } - if ($currentvalues["status"]==1) { - $activetag=""; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Tech

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Tech

"; + $formtag = ""; + $buttontags = " "; // set default values - $admintag=""; - $activetag=""; + $admintag = ""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -786,18 +799,18 @@ switch($table) { Repeat Password:  

Need a random password?   "; - $rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); + $rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12); echo "  $rpw

Shift:            
"; // 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=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id")); + $name = $currentvalues["shiftname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Shift

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Shift

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -894,62 +910,65 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select shiftid,shiftname,status from shifts order by shiftid asc"); + $existingdata = mysqli_query($db, "select shiftid,shiftname,status from shifts order by shiftid asc"); echo " Existing Shifts   Click on the Shift ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["shiftid"],$tablerow["shiftid"], - $tablerow["shiftname"], - $statdef); + $tablerow["shiftid"], + $tablerow["shiftid"], + $tablerow["shiftname"], + $statdef + ); } echo "
Shift IDShift NameActive
%s %s %s
"; break; - case "subjects" : + case "subjects": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Subject

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Subject

"; + $formtag = ""; + $buttontags = "          
"; // 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=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id")); + $name = $currentvalues["subjectname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Subject

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Subject

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -965,100 +984,103 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select subjectid,subjectname,status from subjects order by subjectid asc"); + $existingdata = mysqli_query($db, "select subjectid,subjectname,status from subjects order by subjectid asc"); echo " Existing Subjects   Click on the Subject ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["subjectid"],$tablerow["subjectid"], - $tablerow["subjectname"], - $statdef); + $tablerow["subjectid"], + $tablerow["subjectid"], + $tablerow["subjectname"], + $statdef + ); } echo "
Subject IDSubject NameActive
%s %s %s
"; break; - case "links" : + case "links": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Link

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Link

"; + $formtag = ""; + $buttontags = "          
"; // 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=""; + $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 = ""; } else { - $activetag=""; + $activetag = ""; } // determine where we are in the priority stack - $prow=mysqli_fetch_assoc(mysqli_query($db,"select min(linkpriority) as highest from links")); - if ($prow["highest"]==$priority) { - $belowselection=0; + $prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links")); + if ($prow["highest"] == $priority) { + $belowselection = 0; } else { - $abovelink=mysqli_fetch_row(mysqli_query($db,"select max(linkpriority) from links where linkpriority<\"$priority\"")); - $belowselection=$abovelink[0]; + $abovelink = mysqli_fetch_row(mysqli_query($db, "select max(linkpriority) from links where linkpriority<\"$priority\"")); + $belowselection = $abovelink[0]; } - $priorselect=""; + if ($belowselection == 0) { + $priorselect = $priorselect . ""; } else { - $priorselect=$priorselect . ""; + $priorselect = $priorselect . ""; } - $linkrow=mysqli_query($db,"select linkpriority,displaytxt from links order by linkpriority asc"); - while ($linkitem=mysqli_fetch_assoc($linkrow)) { - if ($belowselection==$linkitem["linkpriority"]) { - $priorselect=$priorselect . "\n"; + $linkrow = mysqli_query($db, "select linkpriority,displaytxt from links order by linkpriority asc"); + while ($linkitem = mysqli_fetch_assoc($linkrow)) { + if ($belowselection == $linkitem["linkpriority"]) { + $priorselect = $priorselect . "\n"; } else { - $priorselect=$priorselect . "\n"; + $priorselect = $priorselect . "\n"; } } - $priorselect=$priorselect . ""; + $priorselect = $priorselect . ""; } else { // set form options for add - $sectiontitle="Add New Link

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Link

"; + $formtag = ""; + $buttontags = " "; // set default values - $abovelink=mysqli_fetch_row(mysqli_query($db,"select max(linkpriority) from links")); - $belowselection=$abovelink[0]; - $priorselect=""; + $priorselect = $priorselect . ""; + $linkrow = mysqli_query($db, "select linkpriority,displaytxt from links order by linkpriority asc"); + while ($linkitem = mysqli_fetch_assoc($linkrow)) { + if ($belowselection == $linkitem["linkpriority"]) { + $priorselect = $priorselect . "\n"; } else { - $priorselect=$priorselect . "\n"; + $priorselect = $priorselect . "\n"; } } - $priorselect=$priorselect . ""; - $activetag=""; + $priorselect = $priorselect . ""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1078,83 +1100,87 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select linkid,displaytxt,urltxt,status from links order by linkpriority asc"); + $existingdata = mysqli_query($db, "select linkid,displaytxt,urltxt,status from links order by linkpriority asc"); echo " Existing Links   Click on the Link ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["linkid"],$tablerow["linkid"], - $tablerow["displaytxt"], - $tablerow["urltxt"],$tablerow["urltxt"], - $statdef); + $tablerow["linkid"], + $tablerow["linkid"], + $tablerow["displaytxt"], + $tablerow["urltxt"], + $tablerow["urltxt"], + $statdef + ); } echo "
Link IDDisplay TextURLActive
%s %s %s %s
"; break; - case "flags" : + case "flags": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Flag

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Flag

"; + $formtag = ""; + $buttontags = "          
"; // 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=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$flagcolor) { - $flagcoloropts=$flagcoloropts . ""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id")); + $name = $currentvalues["flagname"]; + $flagsym = $currentvalues["flagsym"]; + $flagcolor = $currentvalues["flagcolor"]; + $flagcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $flagcolor) { + $flagcoloropts = $flagcoloropts . ""; } else { - $flagcoloropts=$flagcoloropts . ""; + $flagcoloropts = $flagcoloropts . ""; } } - if ($currentvalues["status"]==1) { - $activetag=""; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Flag

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Flag

"; + $formtag = ""; + $buttontags = " "; // set default values - $flagcolor="#FFFFFF"; - $flagcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$flagcolor) { - $flagcoloropts=$flagcoloropts . ""; + $flagcolor = "#FFFFFF"; + $flagcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $flagcolor) { + $flagcoloropts = $flagcoloropts . ""; } else { - $flagcoloropts=$flagcoloropts . ""; + $flagcoloropts = $flagcoloropts . ""; } } - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1175,64 +1201,68 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from flags order by flagid asc"); + $existingdata = mysqli_query($db, "select * from flags order by flagid asc"); echo " Existing Flags   Click on the Flag ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["flagid"],$tablerow["flagid"], - $tablerow["flagname"], - $tablerow["flagcolor"],$tablerow["flagsym"], - $statdef); + $tablerow["flagid"], + $tablerow["flagid"], + $tablerow["flagname"], + $tablerow["flagcolor"], + $tablerow["flagsym"], + $statdef + ); } echo "
Flag IDFlag NameFlag SymbolActive
%s %s %s %s
"; break; - case "logpartactions" : + case "logpartactions": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Part Action

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Part Action

"; + $formtag = ""; + $buttontags = "          
"; // 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=""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id")); + $name = $currentvalues["lpactionname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Part Action

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Part Action

"; + $formtag = ""; + $buttontags = " "; // set default values - $activetag=""; + $activetag = ""; } - + echo " $sectiontitle $formtag @@ -1248,92 +1278,95 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from logpartactions order by lpactionid asc"); + $existingdata = mysqli_query($db, "select * from logpartactions order by lpactionid asc"); echo " Existing Part Actions   Click on the Action ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { if ($tablerow["status"]) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " ", - $tablerow["lpactionid"],$tablerow["lpactionid"], - $tablerow["lpactionname"], - $statdef); + $tablerow["lpactionid"], + $tablerow["lpactionid"], + $tablerow["lpactionname"], + $statdef + ); } echo "
Part Action IDPart Action NameActive
%s %s %s
"; break; - case "banners" : + case "banners": if ($isadmin) { // show the form if ($edit) { // set form options for editing - $sectiontitle="Modify Banner

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Banner

"; + $formtag = ""; + $buttontags = "          
"; // 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"]; - $bnrcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrcolor) { - $bnrcoloropts=$bnrcoloropts . ""; + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id")); + $name = $currentvalues["bannername"]; + $bnrcolor = $currentvalues["bannercolor"]; + $bnrtextcolor = $currentvalues["textcolor"]; + $bnrcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrcolor) { + $bnrcoloropts = $bnrcoloropts . ""; } else { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcoloropts = $bnrcoloropts . ""; } } - $bnrtextcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrtextcolor) { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrtextcolor) { + $bnrtextcoloropts = $bnrtextcoloropts . ""; } else { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = $bnrtextcoloropts . ""; } } } else { // set form options for add - $sectiontitle="Add New Banner

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add New Banner

"; + $formtag = ""; + $buttontags = " "; // set default values - $bnrcolor="#000000"; - $bnrtextcolor="#FFFFFF"; - $bnrcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrcolor) { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcolor = "#000000"; + $bnrtextcolor = "#FFFFFF"; + $bnrcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrcolor) { + $bnrcoloropts = $bnrcoloropts . ""; } else { - $bnrcoloropts=$bnrcoloropts . ""; + $bnrcoloropts = $bnrcoloropts . ""; } } - $bnrtextcoloropts=""; - foreach($basic_colors as $cname => $chex) { - if ($chex==$bnrtextcolor) { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = ""; + foreach ($basic_colors as $cname => $chex) { + if ($chex == $bnrtextcolor) { + $bnrtextcoloropts = $bnrtextcoloropts . ""; } else { - $bnrtextcoloropts=$bnrtextcoloropts . ""; + $bnrtextcoloropts = $bnrtextcoloropts . ""; } } } - + echo " $sectiontitle $formtag @@ -1356,47 +1389,52 @@ switch($table) { "; } // show the table of entities - $existingdata=mysqli_query($db,"select * from banners where bannerid!=1 order by bannerid asc"); + $existingdata = mysqli_query($db, "select * from banners where bannerid!=1 order by bannerid asc"); echo " Existing Banners   Click on the Banner ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { - printf(" + while ($tablerow = mysqli_fetch_assoc($existingdata)) { + printf( + " ", - $tablerow["bannerid"],$tablerow["bannerid"], - $tablerow["bannercolor"],$tablerow["textcolor"],$tablerow["bannername"]); + $tablerow["bannerid"], + $tablerow["bannerid"], + $tablerow["bannercolor"], + $tablerow["textcolor"], + $tablerow["bannername"] + ); } echo "
Banner IDBanner
%s %s
"; break; - case "configs" : - switch($type) { - case "display" : - $curlname=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"log_name\""))[0]; - $curlchunk=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"url_chunk_size\""))[0]; - $curbnr=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"banner\""))[0]; - $curftr=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"footer_message\""))[0]; - $curts=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"show_ts\""))[0]; - $curtdo=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"tech_alpha\""))[0]; - $cursdo=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"subj_alpha\""))[0]; - $curlogstyle=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"log_style\""))[0]; - $curuidtxt=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"uid_text\""))[0]; + case "configs": + switch ($type) { + case "display": + $curlname = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"log_name\""))[0]; + $curlchunk = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"url_chunk_size\""))[0]; + $curbnr = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"banner\""))[0]; + $curftr = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"footer_message\""))[0]; + $curts = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"show_ts\""))[0]; + $curtdo = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"tech_alpha\""))[0]; + $cursdo = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"subj_alpha\""))[0]; + $curlogstyle = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"log_style\""))[0]; + $curuidtxt = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"uid_text\""))[0]; echo "
Display Configuration Parameters


Log Name (will appear at the top of pages and in the titlebar):  

Banner (will appear at the top and bottom of pages):  

Log style (the look of the log notes display):    "; - $templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc"); - printf("","0","Select user template"); - while ($templateitem=mysqli_fetch_assoc($templaterow)) { - printf("",$templateitem["templateid"],$templateitem["templatename"]); + $templaterow = mysqli_query($db, "select * from notetemplates where tech=\"$techid\" order by templatename asc"); + printf("", "0", "Select user template"); + while ($templateitem = mysqli_fetch_assoc($templaterow)) { + printf("", $templateitem["templateid"], $templateitem["templatename"]); } echo "  or  @@ -959,10 +979,10 @@ function templateselect($techid,$operation) { echo "    @@ -980,4 +1000,3 @@ function templateselect($techid,$operation) { "; } -?> diff --git a/distfiles/gpl.php b/distfiles/gpl.php index 3991153..aa66594 100644 --- a/distfiles/gpl.php +++ b/distfiles/gpl.php @@ -10,25 +10,25 @@ include("functions.php"); -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","OpenLog License","OpenLog License",$print); +framework("begin", "OpenLog License", "OpenLog License", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); - sidemenu(); - pageblock("left","end"); +if (!$print) { + pageblock("left", "begin"); + sidemenu(); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); echo "
             GNU GENERAL PUBLIC LICENSE
@@ -375,10 +375,8 @@ Public License instead of this License.
 
 
"; - -pageblock("right","end"); + +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/logentry.php b/distfiles/logentry.php index 3b11a3b..babe693 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -10,72 +10,72 @@ include("functions.php"); if (!$_SESSION['login'] && !$_REQUEST['partview']) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); -$efftechid=$_REQUEST['efftechid'] ?? NULL; -$noteid=$_REQUEST['noteid'] ?? NULL; -$print=$_REQUEST['print'] ?? NULL; -$date=$_REQUEST['date'] ?? NULL; -$time=$_REQUEST['time'] ?? NULL; -$note=$_REQUEST['note'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$subject=$_REQUEST['subject'] ?? NULL; -$refstring=$_REQUEST['refstring'] ?? NULL; -$refto=$_REQUEST['refto'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; -$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; -$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL; -$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL; -$templatename=$_REQUEST['templatename'] ?? NULL; -$removepart=$_REQUEST['removepart'] ?? NULL; -$syncflags=$_REQUEST['syncflags'] ?? NULL; -$flags=$_POST['flags'] ?? []; -$uids=$_POST['uids'] ?? []; -$partnums=$_POST['partnums'] ?? []; -$sernums=$_POST['sernums'] ?? []; -$actions=$_POST['actions'] ?? []; -$mfreqs=$_POST['mfreqs'] ?? []; -$schedmaintcomplete=$_REQUEST['schedmaintcomplete'] ?? NULL; -$partview=$_REQUEST['partview'] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); +$efftechid = $_REQUEST['efftechid'] ?? NULL; +$noteid = $_REQUEST['noteid'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$date = $_REQUEST['date'] ?? NULL; +$time = $_REQUEST['time'] ?? NULL; +$note = $_REQUEST['note'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$subject = $_REQUEST['subject'] ?? NULL; +$refstring = $_REQUEST['refstring'] ?? NULL; +$refto = $_REQUEST['refto'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; +$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL; +$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL; +$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL; +$templatename = $_REQUEST['templatename'] ?? NULL; +$removepart = $_REQUEST['removepart'] ?? NULL; +$syncflags = $_REQUEST['syncflags'] ?? NULL; +$flags = $_POST['flags'] ?? []; +$uids = $_POST['uids'] ?? []; +$partnums = $_POST['partnums'] ?? []; +$sernums = $_POST['sernums'] ?? []; +$actions = $_POST['actions'] ?? []; +$mfreqs = $_POST['mfreqs'] ?? []; +$schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL; +$partview = $_REQUEST['partview'] ?? NULL; -$doparts=PARTS_FUNCTIONS; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; -$uidtext=UID_TEXT; +$doparts = PARTS_FUNCTIONS; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; +$uidtext = UID_TEXT; -$defaultshift=dblookup($db,"techs","techid","shift",$techid); +$defaultshift = dblookup($db, "techs", "techid", "shift", $techid); -if ($print=="Printer Friendly") { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; +if ($print == "Printer Friendly") { + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -if ($partview) $edit=1; -if (!$add && !$edit && !$delete && !$submit) $add=1; +if ($partview) $edit = 1; +if (!$add && !$edit && !$delete && !$submit) $add = 1; if ($isadmin) { - $authorized=TRUE; + $authorized = TRUE; } else { - $authorized=FALSE; + $authorized = FALSE; } if ($add) { - framework("begin","$logname","Note Entry",$print); - $authorized=TRUE; + framework("begin", "$logname", "Note Entry", $print); + $authorized = TRUE; } if ($edit || $delete) { - framework("begin","$logname","Note Edit",$print); - $owner=dblookup($db,"lognotes","lognoteid","tech",$noteid); - if ($techid==$owner) $authorized=TRUE; + framework("begin", "$logname", "Note Edit", $print); + $owner = dblookup($db, "lognotes", "lognoteid", "tech", $noteid); + if ($techid == $owner) $authorized = TRUE; } // var_dump($_REQUEST); @@ -83,163 +83,162 @@ if ($edit || $delete) { // ******** begin database manipulation ******** if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $templateid=NULL; - $loadtemplate=NULL; + $templateid = NULL; + $loadtemplate = NULL; } -if ($add) { - if ($submit) { +if ($add) { + if ($submit) { // add the entry if submit is pressed if ($note) { // sanitize and fix blank date and time - $date=mysqli_real_escape_string($db,$date); - $time=mysqli_real_escape_string($db,$time); - if (!$date) $date=$today; - if (!$time) $time=$now; + $date = mysqli_real_escape_string($db, $date); + $time = mysqli_real_escape_string($db, $time); + if (!$date) $date = $today; + if (!$time) $time = $now; // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$date\",CURRENT_DATE)")); + $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 - if ($datediff[0]<0) { - $time="23:59:59"; + if ($datediff[0] < 0) { + $time = "23:59:59"; } - if ($datediff[0]>0) { - $time="00:00:01"; + if ($datediff[0] > 0) { + $time = "00:00:01"; } - + // remove html tags from note text and sanitize - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + if (strlen($refstring)) { // remove everything except numbers and spaces from references and sanitize - $refstring=preg_replace("#[^\d ]{1,}#"," ",$refstring); - $refstring=mysqli_real_escape_string($db,$refstring); - $refstring=trim($refstring); + $refstring = preg_replace("#[^\d ]{1,}#", " ", $refstring); + $refstring = mysqli_real_escape_string($db, $refstring); + $refstring = trim($refstring); } - - if ($doparts==1) { + + if ($doparts == 1) { // inspect part data - $maxplidx=max( - max(array_keys($uids)), - max(array_keys($partnums)), - max(array_keys($sernums)) + $maxplidx = max( + max(array_keys($uids)), + max(array_keys($partnums)), + max(array_keys($sernums)) ); - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // for each part line, see what info is available // if uid or pn/sn supplied, pull other info from parts if ($uids[$plidx] != "") { // see if this uid is in parts table. - $uidqry=mysqli_query($db,"select * from parts where uid=\"$uids[$plidx]\""); + $uidqry = mysqli_query($db, "select * from parts where uid=\"$uids[$plidx]\""); if (mysqli_num_rows($uidqry)) { // if so, populate pn/sn - $uiddata=mysqli_fetch_assoc($uidqry); - $partnums[$plidx]=$uiddata['partnum']; - $sernums[$plidx]=$uiddata['sernum']; + $uiddata = mysqli_fetch_assoc($uidqry); + $partnums[$plidx] = $uiddata['partnum']; + $sernums[$plidx] = $uiddata['sernum']; } } if ($partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in parts table. - $pnsnqry=mysqli_query($db,"select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); + $pnsnqry = mysqli_query($db, "select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); if (mysqli_num_rows($pnsnqry)) { // if so, populate uid - $pnsndata=mysqli_fetch_assoc($pnsnqry); - $uids[$plidx]=$pnsndata['uid']; + $pnsndata = mysqli_fetch_assoc($pnsnqry); + $uids[$plidx] = $pnsndata['uid']; } } } } if ($authorized) { // add the record to lognotes - mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); - $newnoteid=mysqli_insert_id($db); - + mysqli_query($db, "insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); + $newnoteid = mysqli_insert_id($db); + // add references to the reflinks table if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(noteid,target) values($newnoteid,$target)"); + mysqli_query($db, "insert into reflinks(noteid,target) values($newnoteid,$target)"); } } - $chainmembers=generate_chain($newnoteid); - + $chainmembers = generate_chain($newnoteid); + // update the flagmap table foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); if ($syncflags) { //set flag for reference chain notes foreach ($chainmembers as $refdnote) { if ($refdnote != $newnoteid) { - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); } } } } - - if ($doparts==1) { + + if ($doparts == 1) { // now run through the part lines - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // update the parts table - + // if this line includes a uid and a pn/sn if ($uids[$plidx] != "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if it's in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - - // if this line includes a uid only + + // if this line includes a uid only } else if ($uids[$plidx] != "" && $partnums[$plidx] == "" && $sernums[$plidx] == "") { // see if this uid is in parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid) values(\"$uids[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid) values(\"$uids[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - - // if this line includes a pn/sn only + + // if this line includes a pn/sn only } else if ($uids[$plidx] == "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")"); } - } else { // no part info was entered } @@ -249,58 +248,58 @@ if ($add) { } } else { if ($loadtemplate) { - $templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); - $defaultshift=$templatevalues["shift"]; - $defaultsubject=$templatevalues["subject"]; - $note=$templatevalues["lognote"]; - $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); - while ($thistgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$thistgt[0]; - } + $templatevalues = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\"")); + $defaultshift = $templatevalues["shift"]; + $defaultsubject = $templatevalues["subject"]; + $note = $templatevalues["lognote"]; + $refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\""); + while ($thistgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $thistgt[0]; + } } } } if ($edit) { - if ($removepart && $authorized) mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\""); + if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\""); if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + // remove cruft from references if (strlen($refstring)) { - $refstring=trim($refstring); - $refstring=preg_replace("#[a-zA-Z]{1,}#","",$refstring); + $refstring = trim($refstring); + $refstring = preg_replace("#[a-zA-Z]{1,}#", "", $refstring); } - - if ($doparts==1) { + + if ($doparts == 1) { // inspect part data - $maxplidx=max( - max(array_keys($uids)), - max(array_keys($partnums)), - max(array_keys($sernums)) + $maxplidx = max( + max(array_keys($uids)), + max(array_keys($partnums)), + max(array_keys($sernums)) ); - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // for each part line, see what info is available // if uid or pn/sn supplied, pull other info from parts if ($uids[$plidx] != "") { // see if this uid is in parts table. - $uidqry=mysqli_query($db,"select * from parts where uid=\"$uids[$plidx]\""); + $uidqry = mysqli_query($db, "select * from parts where uid=\"$uids[$plidx]\""); if (mysqli_num_rows($uidqry)) { // if so, populate pn/sn - $uiddata=mysqli_fetch_assoc($uidqry); - $partnums[$plidx]=$uiddata['partnum']; - $sernums[$plidx]=$uiddata['sernum']; + $uiddata = mysqli_fetch_assoc($uidqry); + $partnums[$plidx] = $uiddata['partnum']; + $sernums[$plidx] = $uiddata['sernum']; } } if ($partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in parts table. - $pnsnqry=mysqli_query($db,"select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); + $pnsnqry = mysqli_query($db, "select * from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""); if (mysqli_num_rows($pnsnqry)) { // if so, populate uid - $pnsndata=mysqli_fetch_assoc($pnsnqry); - $uids[$plidx]=$pnsndata['uid']; + $pnsndata = mysqli_fetch_assoc($pnsnqry); + $uids[$plidx] = $pnsndata['uid']; } } } @@ -308,102 +307,101 @@ if ($edit) { if ($authorized) { // update lognotes table - mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where lognoteid=\"$noteid\""); - + mysqli_query($db, "update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where lognoteid=\"$noteid\""); + // update the reflinks table - mysqli_query($db,"delete from reflinks where noteid=\"$noteid\""); + mysqli_query($db, "delete from reflinks where noteid=\"$noteid\""); if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); - foreach($refarray as $thisref) { - mysqli_query($db,"insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")"); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); + foreach ($refarray as $thisref) { + mysqli_query($db, "insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")"); } } - $chainmembers=generate_chain($noteid); - + $chainmembers = generate_chain($noteid); + // update the flagmap table - mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + mysqli_query($db, "delete from flagmap where lognoteid=\"$noteid\""); if ($syncflags) { foreach ($chainmembers as $refdnote) { if ($refdnote != $noteid) { - mysqli_query($db,"delete from flagmap where lognoteid=\"$refdnote\""); + mysqli_query($db, "delete from flagmap where lognoteid=\"$refdnote\""); } } } foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")"); if ($syncflags) { //set flag for reference chain notes foreach ($chainmembers as $refdnote) { if ($refdnote != $noteid) { - mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + mysqli_query($db, "insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); } } } } - - if ($doparts==1) { + + if ($doparts == 1) { // run through the new part lines - for ($plidx=0;$plidx<=$maxplidx;$plidx++) { + for ($plidx = 0; $plidx <= $maxplidx; $plidx++) { // update the parts table - + // if this line includes a uid and a pn/sn if ($uids[$plidx] != "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if it's in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum) values(\"$uids[$plidx]\",\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - - // if this line includes a uid only + + // if this line includes a uid only } else if ($uids[$plidx] != "" && $partnums[$plidx] == "" && $sernums[$plidx] == "") { // see if this uid is in parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\" and partnum is NULL and sernum is NULL"))) { // if not, add it to parts - mysqli_query($db,"insert into parts(uid) values(\"$uids[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid) values(\"$uids[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where uid=\"$uids[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where uid=\"$uids[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - - // if this line includes a pn/sn only + + // if this line includes a pn/sn only } else if ($uids[$plidx] == "" && $partnums[$plidx] != "" && $sernums[$plidx] != "") { // see if this pn/sn is in the parts table - if (! mysqli_num_rows(mysqli_query($db,"select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select partid from parts where uid is NULL and partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))) { // if not, add it to parts - mysqli_query($db,"insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); - $lpid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(partnum,sernum) values(\"$partnums[$plidx]\",\"$sernums[$plidx]\")"); + $lpid = mysqli_insert_id($db); } else { // if so get the partid for the logparts table - $lpid=mysqli_fetch_row(mysqli_query($db,"select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; + $lpid = mysqli_fetch_row(mysqli_query($db, "select partid from parts where partnum=\"$partnums[$plidx]\" and sernum=\"$sernums[$plidx]\""))[0]; } // add it to logparts table - mysqli_query($db,"insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); + mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")"); // create a maintenance form if required - if ($mfreqs[$plidx]=="on") { - mysqli_query($db,"insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); + if ($mfreqs[$plidx] == "on") { + mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")"); } - } else { - // no part info was entered + // no part info was entered ; } } @@ -413,95 +411,95 @@ if ($edit) { } if ($loadtemplate) { // get the note in question from the selected template - $getnote=mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""); + $getnote = mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""); } else { // refresh the note in question from the database - $getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\""); + $getnote = mysqli_query($db, "select * from lognotes where lognoteid=\"$noteid\""); } - $notetoedit=mysqli_fetch_assoc($getnote); + $notetoedit = mysqli_fetch_assoc($getnote); } if ($delete) { // find notes having this note as a target - $drefnoteqry=mysqli_query($db,"select noteid from reflinks where target=\"$noteid\""); - while ($drefnoterow=mysqli_fetch_assoc($drefnoteqry)) { - $drefnotes[]=$drefnoterow["noteid"]; + $drefnoteqry = mysqli_query($db, "select noteid from reflinks where target=\"$noteid\""); + while ($drefnoterow = mysqli_fetch_assoc($drefnoteqry)) { + $drefnotes[] = $drefnoterow["noteid"]; } // find targets for this note - $dreftgtqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); - while ($dreftgtrow=mysqli_fetch_assoc($dreftgtqry)) { - $dreftgts[]=$dreftgtrow["target"]; + $dreftgtqry = mysqli_query($db, "select target from reflinks where noteid=\"$noteid\""); + while ($dreftgtrow = mysqli_fetch_assoc($dreftgtqry)) { + $dreftgts[] = $dreftgtrow["target"]; } // for every note having this one as a target, add this note's targets foreach ($drefnotes as $drefnote) { foreach ($dreftgts as $dreftgt) { - mysqli_query($db,"insert into reflinks(noteid,target) values(\"$drefnote\",\"$dreftgt\")"); + mysqli_query($db, "insert into reflinks(noteid,target) values(\"$drefnote\",\"$dreftgt\")"); } } // delete this note from reflinks - mysqli_query($db,"delete from reflinks where noteid is not null and (noteid=\"$noteid\" or target=\"$noteid\")"); - + mysqli_query($db, "delete from reflinks where noteid is not null and (noteid=\"$noteid\" or target=\"$noteid\")"); + // delete from lognotes table - mysqli_query($db,"delete from lognotes where lognoteid=\"$noteid\""); - + mysqli_query($db, "delete from lognotes where lognoteid=\"$noteid\""); + // delete occurances from the flagmap table - mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); - + mysqli_query($db, "delete from flagmap where lognoteid=\"$noteid\""); + // delete occurances from the logparts table - mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\""); + mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\""); } // ******** end database manipulation ******** pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form if ($add) { - $notedate=$today; - $notetime=$now; + $notedate = $today; + $notetime = $now; } if ($edit || $delete) { - $notedate=$notetoedit["date"] ?? $today; - $notetime=$notetoedit["time"] ?? $now; - $defaultshift=$notetoedit["shift"]; - $defaultsubject=$notetoedit["subject"]; - - $note=$notetoedit["lognote"]; + $notedate = $notetoedit["date"] ?? $today; + $notetime = $notetoedit["time"] ?? $now; + $defaultshift = $notetoedit["shift"]; + $defaultsubject = $notetoedit["subject"]; + + $note = $notetoedit["lognote"]; // generate reference string for this note if ($submit) { - $refstring=NULL; + $refstring = NULL; } - $refstringqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); - while ($thistgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$thistgt[0]; + $refstringqry = mysqli_query($db, "select target from reflinks where noteid=\"$noteid\""); + while ($thistgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $thistgt[0]; } - $techid=$notetoedit["tech"]; + $techid = $notetoedit["tech"]; } -$techname=dblookup($db,"techs","techid","techname",$techid); +$techname = dblookup($db, "techs", "techid", "techname", $techid); if ($submit) { if ($note) { if ($add) { - format_message(0,"Note added. You may enter another note or return to main page."); + format_message(0, "Note added. You may enter another note or return to main page."); } if ($edit) { - format_message(0,"Note changed. Return to main page."); + format_message(0, "Note changed. Return to main page."); } } else { - format_message(1,"You didn't enter any note text. Please try again."); + format_message(1, "You didn't enter any note text. Please try again."); } } if ($delete) { - format_message(0,"Note deleted. Return to main page."); + format_message(0, "Note deleted. Return to main page."); } if ($_SESSION['login']) { // show the template selection line - templateselect($techid,NULL); + templateselect($techid, NULL); } // start note entry section @@ -520,14 +518,15 @@ if ($isadmin) { Tech:   "; -$shiftrow=mysqli_query($db,"select * from shifts"); -while ($shiftitem=mysqli_fetch_assoc($shiftrow)) { +$shiftrow = mysqli_query($db, "select * from shifts"); +while ($shiftitem = mysqli_fetch_assoc($shiftrow)) { if ($shiftitem["status"] == 1) { - if ($shiftitem["shiftid"]==$defaultshift) { - printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); + if ($shiftitem["shiftid"] == $defaultshift) { + printf("", $shiftitem["shiftid"], $shiftitem["shiftname"]); } else { - printf("",$shiftitem["shiftid"],$shiftitem["shiftname"]); + printf("", $shiftitem["shiftid"], $shiftitem["shiftname"]); } } } @@ -563,15 +562,16 @@ echo " Subject:   %s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); +while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { + + if (in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } else { - $flagid=$flagcheckbox["flagid"]; - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + $flagid = $flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo "
Set flags on reference chain "; -if ($add && $refto) $refstring=$refto; +if ($add && $refto) $refstring = $refto; echo "

References:            @@ -652,13 +662,13 @@ if ($add) { "; } if ($doparts) { - $defaultaction=0; + $defaultaction = 0; echo "

"; - for ($partline=0;$partline <=5;$partline++) { + for ($partline = 0; $partline <= 5; $partline++) { echo " @@ -667,13 +677,13 @@ if ($add) { "; // populate the existing part lines - $linekey=0; - $elineqry=mysqli_query($db,"select logpartid, partid, action from logparts where lognoteid=\"$noteid\""); - while ($eline=mysqli_fetch_assoc($elineqry)) { - $iconpartid=$eline['logpartid']; - $lpidvar=$eline['partid']; - $eparts=mysqli_fetch_assoc(mysqli_query($db,"select uid,partnum,sernum from parts where partid=\"$lpidvar\"")); - $epuid=$eparts['uid']; - $eppn=$eparts['partnum']; - $epsn=$eparts['sernum']; - $defaultaction=$eline['action']; - + $linekey = 0; + $elineqry = mysqli_query($db, "select logpartid, partid, action from logparts where lognoteid=\"$noteid\""); + while ($eline = mysqli_fetch_assoc($elineqry)) { + $iconpartid = $eline['logpartid']; + $lpidvar = $eline['partid']; + $eparts = mysqli_fetch_assoc(mysqli_query($db, "select uid,partnum,sernum from parts where partid=\"$lpidvar\"")); + $epuid = $eparts['uid']; + $eppn = $eparts['partnum']; + $epsn = $eparts['sernum']; + $defaultaction = $eline['action']; + echo " "; // 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"]; + $mflinknum = mysqli_fetch_assoc(mysqli_query($db, "select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\""))["maintformid"]; echo " "; } // add six empty part lines - $defaultaction=0; - for ($partline=$linekey;$partline <=$linekey+5;$partline++) { + $defaultaction = 0; + for ($partline = $linekey; $partline <= $linekey + 5; $partline++) { echo " @@ -753,13 +763,13 @@ if ($edit) { "; } else { - $authorized=TRUE; + $authorized = TRUE; echo " "; @@ -416,13 +418,13 @@ if ($operation=="delete") {
$uidtextPart NumberSerial NumberActionMaint Form
$uidtextPart NumberSerial NumberActionMaint Form
@@ -726,9 +736,9 @@ if ($edit) { $epsn "; - $actrow=mysqli_query($db,"select * from logpartactions"); - while ($actitem=mysqli_fetch_assoc($actrow)) { - if ($actitem["lpactionid"]==$defaultaction) { + $actrow = mysqli_query($db, "select * from logpartactions"); + while ($actitem = mysqli_fetch_assoc($actrow)) { + if ($actitem["lpactionid"] == $defaultaction) { echo "$actitem[lpactionname]"; } } @@ -736,15 +746,15 @@ if ($edit) { $mflinknum
"; - if ($techalpha) $torder="techname"; else $torder="techid"; - $techrow=mysqli_query($db,"select * from techs order by $torder asc"); - while ($techitem=mysqli_fetch_assoc($techrow)) { - if ($techitem["status"]==1) { - printf("",$techitem["techid"],$techitem["techname"]); + if ($techalpha) $torder = "techname"; + else $torder = "techid"; + $techrow = mysqli_query($db, "select * from techs order by $torder asc"); + while ($techitem = mysqli_fetch_assoc($techrow)) { + if ($techitem["status"] == 1) { + printf("", $techitem["techid"], $techitem["techname"]); } } echo "

@@ -87,16 +87,14 @@ if ($login) {

"; } else { - $loginid=$_SESSION['login']; - $loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0]; + $loginid = $_SESSION['login']; + $loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0]; echo " You are already logged in as $loggedinas. Please select a menu option at the left to continue.

"; } } -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/lognotes.php b/distfiles/lognotes.php index 13365ca..d1d80d6 100644 --- a/distfiles/lognotes.php +++ b/distfiles/lognotes.php @@ -12,103 +12,107 @@ include("functions.php"); //$tgt_year=$_REQUEST['y']; //$tgt_month=$_REQUEST['m']; //$tgt_day=$_REQUEST['d']; -$tgt_date=$_REQUEST['tgt_date'] ?? ""; -$print=$_REQUEST['print'] ?? ""; -if (isset($_SESSION['login'])) $techid=$_SESSION['login']; +$tgt_date = $_REQUEST['tgt_date'] ?? ""; +$print = $_REQUEST['print'] ?? ""; +if (isset($_SESSION['login'])) $techid = $_SESSION['login']; -$logname=LOG_NAME; -$tablestyle=LOG_STYLE; +$logname = LOG_NAME; +$tablestyle = LOG_STYLE; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // use default date values if not supplied -if ($tgt_date=="") $tgt_date=$today; +if ($tgt_date == "") $tgt_date = $today; // define shifttable_classic function -function shifttable_classic($shift, $tgt_date, $db) { +function shifttable_classic($shift, $tgt_date, $db) +{ // convert the shift number to a name for display - $doparts=PARTS_FUNCTIONS; - $showtime=SHOW_TS; - $shname=dblookup($db,"shifts","shiftid","shiftname",$shift); - $dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); - $dshdr=mysqli_fetch_row($dshdrdata); + $doparts = PARTS_FUNCTIONS; + $showtime = SHOW_TS; + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift); + $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); + $dshdr = mysqli_fetch_row($dshdrdata); if ($dshdr) { // print the shift header - printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + printf("%s\n", $shname); + $note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "
\n"; echo "\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $thisnote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote = $tablerow["lognoteid"]; + $refs = "    \"Add"; if (islink($thisnote)) { - $refs=$refs."      \"View"; + $refs = $refs . "      \"View"; } // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } - + if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote = $fmtnote . "PARTS"; } } // now print the line in the table if ($showtime) { printf( - " + "\n", - $tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"], - $tname, - $subjname, - $fmtnote, - $refs + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["time"], + $tname, + $subjname, + $fmtnote, + $refs ); } else { printf( - " + "\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tname, - $subjname, - $fmtnote, - $refs + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tname, + $subjname, + $fmtnote, + $refs ); } } @@ -121,82 +125,85 @@ function shifttable_classic($shift, $tgt_date, $db) { } // define the shifttable_clean function -function shifttable_clean($shift, $tgt_date, $db) { +function shifttable_clean($shift, $tgt_date, $db) +{ // convert the shift number to a name for display - $doparts=PARTS_FUNCTIONS; - $showtime=SHOW_TS; - $shname=dblookup($db,"shifts","shiftid","shiftname",$shift); - $dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); - $dshdr=mysqli_fetch_row($dshdrdata); + $doparts = PARTS_FUNCTIONS; + $showtime = SHOW_TS; + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift); + $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); + $dshdr = mysqli_fetch_row($dshdrdata); if ($dshdr) { // print the shift header - printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + printf("%s\n", $shname); + $note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "

"; echo "
Note IDTechSubjectNoteReferences
%s  %s %s %s %s %s
%s %s %s %s %s
", - $def_eventid,$def_deferred_date, - $devicedata_devicedesc,$devicedata_devicename, - $taskdata_taskdesc,$taskdata_taskname, - $lastdatestrg + $def_eventid, + $def_deferred_date, + $devicedata_devicedesc, + $devicedata_devicename, + $taskdata_taskdesc, + $taskdata_taskname, + $lastdatestrg ); } echo " @@ -886,9 +908,7 @@ if ($action) { banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/search.php b/distfiles/search.php index dbae96d..2c63907 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -9,50 +9,50 @@ include("functions.php"); -$noprint=1; +$noprint = TRUE; if (isset($_SESSION['login'])) { - $loggedin=1; + $loggedin = TRUE; } else { - unset($loggedin); + $loggedin = FALSE; } -$print=$_REQUEST['print'] ?? NULL; -$search=$_REQUEST['search'] ?? NULL; -$srchnoteid=$_REQUEST['srchnoteid'] ?? NULL; -$srchmfid=$_REQUEST['srchmfid'] ?? NULL; -$srchbdate=$_REQUEST['srchbdate'] ?? NULL; -$srchedate=$_REQUEST['srchedate'] ?? NULL; -$srchshift=$_REQUEST['srchshift'] ?? NULL; -$srchtech=$_REQUEST['srchtech'] ?? NULL; -$srchsubj=$_REQUEST['srchsubj'] ?? NULL; -$srchtext=$_REQUEST['srchtext'] ?? NULL; -$srchuid=$_REQUEST['srchuid'] ?? NULL; -$srchpn=$_REQUEST['srchpn'] ?? NULL; -$srchsn=$_REQUEST['srchsn'] ?? NULL; -$srchpname=$_REQUEST['srchpname'] ?? NULL; -$srchploc=$_REQUEST['srchploc'] ?? NULL; -$srchnha=$_REQUEST['srchnha'] ?? NULL; -$srchrepord=$_REQUEST['srchrepord'] ?? NULL; -$srchflags=$_POST['srchflags'] ?? []; -$target=$_REQUEST['target'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$search = $_REQUEST['search'] ?? NULL; +$srchnoteid = $_REQUEST['srchnoteid'] ?? NULL; +$srchmfid = $_REQUEST['srchmfid'] ?? NULL; +$srchbdate = $_REQUEST['srchbdate'] ?? NULL; +$srchedate = $_REQUEST['srchedate'] ?? NULL; +$srchshift = $_REQUEST['srchshift'] ?? NULL; +$srchtech = $_REQUEST['srchtech'] ?? NULL; +$srchsubj = $_REQUEST['srchsubj'] ?? NULL; +$srchtext = $_REQUEST['srchtext'] ?? NULL; +$srchuid = $_REQUEST['srchuid'] ?? NULL; +$srchpn = $_REQUEST['srchpn'] ?? NULL; +$srchsn = $_REQUEST['srchsn'] ?? NULL; +$srchpname = $_REQUEST['srchpname'] ?? NULL; +$srchploc = $_REQUEST['srchploc'] ?? NULL; +$srchnha = $_REQUEST['srchnha'] ?? NULL; +$srchrepord = $_REQUEST['srchrepord'] ?? NULL; +$srchflags = $_POST['srchflags'] ?? []; +$target = $_REQUEST['target'] ?? NULL; -$doparts=PARTS_FUNCTIONS; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; -$uidtext=UID_TEXT; +$doparts = PARTS_FUNCTIONS; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname Search","Search",$print); +framework("begin", "$logname Search", "Search", $print); // echo "REQUEST variables:
"; // var_dump($_REQUEST); @@ -61,273 +61,273 @@ framework("begin","$logname Search","Search",$print); // ******** begin database manipulation ******** // define the arrays -$logfromtables=[]; -$mffromtables=[]; -$pfromtables=[]; -$logconstraints=[]; -$mfconstraints=[]; -$pconstraints=[]; +$logfromtables = []; +$mffromtables = []; +$pfromtables = []; +$logconstraints = []; +$mfconstraints = []; +$pconstraints = []; // get the date range of lognotes -$logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes"); -$logdateresults=mysqli_fetch_row($logdateqry); -$logmindate=$logdateresults[0]; +$logdateqry = mysqli_query($db, "select min(date), max(date) from lognotes"); +$logdateresults = mysqli_fetch_row($logdateqry); +$logmindate = $logdateresults[0]; if ($logmindate == "") $logmindate = $today; -$logmaxdate=$logdateresults[1]; +$logmaxdate = $logdateresults[1]; if ($logmaxdate == "") $logmaxdate = $today; // get the date range of maintenance forms -$mfdateqry=mysqli_query($db,"select min(mfdate), max(mfdate) from maintforms"); -$mfdateresults=mysqli_fetch_row($mfdateqry); -$mfmindate=$mfdateresults[0]; +$mfdateqry = mysqli_query($db, "select min(mfdate), max(mfdate) from maintforms"); +$mfdateresults = mysqli_fetch_row($mfdateqry); +$mfmindate = $mfdateresults[0]; if ($mfmindate == "") $mfmindate = $today; -$mfmaxdate=$mfdateresults[1]; +$mfmaxdate = $mfdateresults[1]; if ($mfmaxdate == "") $mfmaxdate = $today; // determine entire date range -$mindate=min($logmindate, $mfmindate); -$maxdate=max($logmaxdate, $mfmaxdate); +$mindate = min($logmindate, $mfmindate); +$maxdate = max($logmaxdate, $mfmaxdate); if ($search) { // strip whitespace from beginning and end of text fields - $srchtext=trim($srchtext); - $srchpname=trim($srchpname); - $srchploc=trim($srchploc); - $srchnha=trim($srchnha); - if ($target[0]=="") $target=[]; - if (in_array("log",$target)) { + $srchtext = trim($srchtext); + $srchpname = trim($srchpname); + $srchploc = trim($srchploc); + $srchnha = trim($srchnha); + if ($target[0] == "") $target = []; + if (in_array("log", $target)) { // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.lognoteid=\"$srchnoteid\""; + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=maintforms.lognoteid and maintforms.maintformid=\"$srchmfid\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=maintforms.lognoteid and maintforms.maintformid=\"$srchmfid\""; } // date range if ($srchbdate != "" && $srchedate != "") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.date between \"$srchbdate\" and \"$srchedate\""; + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.date between \"$srchbdate\" and \"$srchedate\""; } // shift - if ($srchshift !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.shift=\"$srchshift\""; + if ($srchshift != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.shift=\"$srchshift\""; } // tech - if ($srchtech !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.tech=\"$srchtech\""; + if ($srchtech != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.tech=\"$srchtech\""; } // subject - if ($srchsubj !="0") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.subject=\"$srchsubj\""; + if ($srchsubj != "0") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.subject=\"$srchsubj\""; } // search text - if ($srchtext !="") { - $logfromtables[]="lognotes"; - $logconstraints[]="lognotes.lognote like \"%$srchtext%\""; + if ($srchtext != "") { + $logfromtables[] = "lognotes"; + $logconstraints[] = "lognotes.lognote like \"%$srchtext%\""; } // flags if (!empty($srchflags)) { unset($flagconstraints); - $flagcount=count($srchflags); - $logfromtables[]="lognotes"; - $logfromtables[]="flagmap"; - $flagconstraints[]="flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; + $flagcount = count($srchflags); + $logfromtables[] = "lognotes"; + $logfromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; foreach ($srchflags as $flagid) { - $flagconstraints[]="\"$flagid\""; - $flagconstraints[]=","; + $flagconstraints[] = "\"$flagid\""; + $flagconstraints[] = ","; } // remove final comma array_splice($flagconstraints, -1, 1); - $flagconstraints[]=") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; + $flagconstraints[] = ") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; // make flagconstraints a single string so that the final implode doesn't split it - $logconstraints[]=join('', $flagconstraints); + $logconstraints[] = join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.uid=\"{$srchuid}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partnum=\"{$srchpn}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.sernum=\"{$srchsn}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partname like \"%{$srchpname}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $logfromtables[]="lognotes"; - $logfromtables[]="logparts"; - $logfromtables[]="parts"; - $logfromtables[]="maintforms"; - $logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $logfromtables[] = "lognotes"; + $logfromtables[] = "logparts"; + $logfromtables[] = "parts"; + $logfromtables[] = "maintforms"; + $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $logfromclause=implode(",",array_unique($logfromtables)); - $logwhereclause=implode(" and ",$logconstraints); - $logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); + $logfromclause = implode(",", array_unique($logfromtables)); + $logwhereclause = implode(" and ", $logconstraints); + $logrowqry = mysqli_query($db, "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); } - if ($target[0]=="") $target=[]; - if (in_array("maintform",$target)) { + if ($target[0] == "") $target = []; + if (in_array("maintform", $target)) { // maintforms search // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.maintformid=\"$srchmfid\""; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.maintformid=\"$srchmfid\""; } // date range if ($srchbdate != "" && $srchedate != "") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfdate between \"$srchbdate\" and \"$srchedate\""; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfdate between \"$srchbdate\" and \"$srchedate\""; } // shift - if ($srchshift !="0") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.shift=\"$srchshift\""; + if ($srchshift != "0") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.shift=\"$srchshift\""; } // tech - if ($srchtech !="0") { - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mftech=\"$srchtech\""; + if ($srchtech != "0") { + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mftech=\"$srchtech\""; } // subject - if ($srchsubj !="0") { - $mffromtables[]="maintforms"; - $mffromtables[]="lognotes"; - $mfconstraints[]="maintforms.lognoteid=lognotes.lognoteid and lognotes.subject=\"$srchsubj\""; + if ($srchsubj != "0") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "lognotes"; + $mfconstraints[] = "maintforms.lognoteid=lognotes.lognoteid and lognotes.subject=\"$srchsubj\""; } // search text - if ($srchtext !="") { - $mffromtables[]="maintforms"; - $mffromtables[]="maintactions"; - $mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; + if ($srchtext != "") { + $mffromtables[] = "maintforms"; + $mffromtables[] = "maintactions"; + $mfconstraints[] = "maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; } // flags if (!empty($srchflags)) { unset($flagconstraints); - $flagcount=count($srchflags); - $mffromtables[]="maintforms"; - $mffromtables[]="flagmap"; - $flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; + $flagcount = count($srchflags); + $mffromtables[] = "maintforms"; + $mffromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; foreach ($srchflags as $thisflagid) { - $flagconstraints[]="\"$thisflagid\""; - $flagconstraints[]=","; + $flagconstraints[] = "\"$thisflagid\""; + $flagconstraints[] = ","; } // remove final comma array_splice($flagconstraints, -1, 1); - $flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; + $flagconstraints[] = ") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; // make flagconstraints a single string so that the final implode doesn't split it - $mfconstraints[]=join('', $flagconstraints); + $mfconstraints[] = join('', $flagconstraints); } // uid if ($srchuid != "any" && $srchuid != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.uid=\"{$srchuid}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.partnum=\"{$srchpn}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.sernum=\"{$srchsn}\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $mffromtables[]="maintforms"; - $mffromtables[]="parts"; - $mfconstraints[]="maintforms.mfpart=parts.partid and parts.partname like \"%{$srchpname}%\""; + $mffromtables[] = "maintforms"; + $mffromtables[] = "parts"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $mffromtables[]="parts"; - $mffromtables[]="maintforms"; - $mfconstraints[]="maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $mffromtables[] = "parts"; + $mffromtables[] = "maintforms"; + $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $mffromclause=implode(",",array_unique($mffromtables)); - $mfwhereclause=implode(" and ",$mfconstraints); - $mfrowqry=mysqli_query($db,"select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); + $mffromclause = implode(",", array_unique($mffromtables)); + $mfwhereclause = implode(" and ", $mfconstraints); + $mfrowqry = mysqli_query($db, "select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); } - if ($target[0]=="") $target=[]; - if (in_array("part",$target)) { + if ($target[0] == "") $target = []; + if (in_array("part", $target)) { // parts search // define the query constraints // log note id if ($srchnoteid != "any" && $srchnoteid != "") { - $pfromtables[]="parts"; - $pfromtables[]="logparts"; - $pfromtables[]="lognotes"; - $pconstraints[]="parts.partid=logparts.partid and logparts.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; + $pfromtables[] = "parts"; + $pfromtables[] = "logparts"; + $pfromtables[] = "lognotes"; + $pconstraints[] = "parts.partid=logparts.partid and logparts.lognoteid=lognotes.lognoteid and lognotes.lognoteid=\"$srchnoteid\""; } // maint form id if ($srchmfid != "any" && $srchmfid != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="parts.partid=maintforms.mfpart and maintforms.maintformid=\"$srchmfid\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "parts.partid=maintforms.mfpart and maintforms.maintformid=\"$srchmfid\""; } // date range doesn't apply to parts // shift doesn't apply to parts @@ -337,74 +337,89 @@ if ($search) { // flags doesn't apply to parts // uid if ($srchuid != "any" && $srchuid != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.uid=\"{$srchuid}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.uid=\"{$srchuid}\""; } // part number if ($srchpn != "any" && $srchpn != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.partnum=\"{$srchpn}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.partnum=\"{$srchpn}\""; } // serial number if ($srchsn != "any" && $srchsn != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.sernum=\"{$srchsn}\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.sernum=\"{$srchsn}\""; } // part name if ($srchpname != "any" && $srchpname != "") { - $pfromtables[]="parts"; - $pconstraints[]="parts.partname like \"%{$srchpname}%\""; + $pfromtables[] = "parts"; + $pconstraints[] = "parts.partname like \"%{$srchpname}%\""; } // part location if ($srchploc != "any" && $srchploc != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.mfpartloc like \"%{$srchploc}%\""; } // next higher assembly if ($srchnha != "any" && $srchnha != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.nha like \"%{$srchnha}%\""; } // repair order if ($srchrepord != "any" && $srchrepord != "") { - $pfromtables[]="parts"; - $pfromtables[]="maintforms"; - $pconstraints[]="maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; + $pfromtables[] = "parts"; + $pfromtables[] = "maintforms"; + $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } // build the clauses and run the query - $pfromclause=implode(",",array_unique($pfromtables)); - $pwhereclause=implode(" and ",$pconstraints); - $prowqry=mysqli_query($db,"select parts.* from $pfromclause where $pwhereclause order by parts.uid asc"); + $pfromclause = implode(",", array_unique($pfromtables)); + $pwhereclause = implode(" and ", $pconstraints); + $prowqry = mysqli_query($db, "select parts.* from $pfromclause where $pwhereclause order by parts.uid asc"); } } // ******** end database manipulation ******** pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form -if ($srchnoteid) $noteidval=$srchnoteid; else $noteidval="any"; -if ($srchmfid) $mfidval=$srchmfid; else $mfidval="any"; -if ($srchbdate) $bdateval=$srchbdate; else $bdateval=$mindate; -if ($srchedate) $edateval=$srchedate; else $edateval=$maxdate; -if ($srchshift) $shiftval=$srchshift; else $shiftval=0; -if ($srchtech) $techval=$srchtech; else $techval=0; -if ($srchsubj) $subjval=$srchsubj; else $subjval=0; -if ($srchtext) $textval=$srchtext; else $textval=""; -if ($srchuid) $uidval=$srchuid; else $uidval="any"; -if ($srchpn) $pnval=$srchpn; else $pnval="any"; -if ($srchsn) $snval=$srchsn; else $snval="any"; -if ($srchpname) $pnameval=$srchpname; else $pnameval="any"; -if ($srchploc) $plocval=$srchploc; else $plocval="any"; -if ($srchnha) $nhaval=$srchnha; else $nhaval="any"; -if ($srchrepord) $repordval=$srchrepord; else $repordval="any"; +if ($srchnoteid) $noteidval = $srchnoteid; +else $noteidval = "any"; +if ($srchmfid) $mfidval = $srchmfid; +else $mfidval = "any"; +if ($srchbdate) $bdateval = $srchbdate; +else $bdateval = $mindate; +if ($srchedate) $edateval = $srchedate; +else $edateval = $maxdate; +if ($srchshift) $shiftval = $srchshift; +else $shiftval = 0; +if ($srchtech) $techval = $srchtech; +else $techval = 0; +if ($srchsubj) $subjval = $srchsubj; +else $subjval = 0; +if ($srchtext) $textval = $srchtext; +else $textval = ""; +if ($srchuid) $uidval = $srchuid; +else $uidval = "any"; +if ($srchpn) $pnval = $srchpn; +else $pnval = "any"; +if ($srchsn) $snval = $srchsn; +else $snval = "any"; +if ($srchpname) $pnameval = $srchpname; +else $pnameval = "any"; +if ($srchploc) $plocval = $srchploc; +else $plocval = "any"; +if ($srchnha) $nhaval = $srchnha; +else $nhaval = "any"; +if ($srchrepord) $repordval = $srchrepord; +else $repordval = "any"; if (!$print) { echo " @@ -417,53 +432,55 @@ if (!$print) {

Shift:         Tech:         Subject:  Logbook  "; } else { @@ -556,7 +573,7 @@ if (!$print) { "; if ($search) { - $allvars=http_build_query($_REQUEST); + $allvars = http_build_query($_REQUEST); echo "       Print Search Results "; @@ -575,30 +592,30 @@ if (!$print) {

Shift:   "; - if ($shiftval==0) { + if ($shiftval == 0) { echo "any"; } else { - $shiftname=dblookup($db,"shifts","shiftid","shiftname",$shiftval); + $shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $shiftval); echo "$shiftname"; } echo "        Tech:   "; - if ($techval==0) { + if ($techval == 0) { echo "any"; } else { - $techname=dblookup($db,"techs","techid","techname",$techval); + $techname = dblookup($db, "techs", "techid", "techname", $techval); echo "$techname"; } echo "        Subject:   "; - if ($subjval==0) { + if ($subjval == 0) { echo "any"; } else { - $subjname=dblookup($db,"subjects","subjectid","subjectname",$subjval); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $subjval); echo "$subjname"; } echo " @@ -625,30 +642,33 @@ if (!$print) {

Flags: "; - $flagslist=mysqli_query($db,"select * from flags"); - $flagsperline=8; - $flagcount=1; - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + $flagslist = mysqli_query($db, "select * from flags"); + $flagsperline = 8; + $flagcount = 1; + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { if ($srchflags) { - if ($srchflags[0]=="") $srchflags=[]; - if (in_array($flagcheckbox["flagid"],$srchflags)) { - printf("%s", - $flagcheckbox["flagcolor"],$flagcheckbox["flagsym"]); + if ($srchflags[0] == "") $srchflags = []; + if (in_array($flagcheckbox["flagid"], $srchflags)) { + printf( + "%s", + $flagcheckbox["flagcolor"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo "

"; if ($doparts) { - if ($target[0]=="") $target=[]; + if ($target[0] == "") $target = []; echo " Search in:   "; @@ -671,47 +691,48 @@ if (!$print) { } if ($search) { - if ($target[0]=="") $target=[]; - if (in_array("log",$target)) { + if ($target[0] == "") $target = []; + if (in_array("log", $target)) { // run lognotes query and show results - $log_num_results=mysqli_num_rows($logrowqry); - if($log_num_results) { + $log_num_results = mysqli_num_rows($logrowqry); + if ($log_num_results) { echo " Results from Logbook: $log_num_results

\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $thisnote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote = $tablerow["lognoteid"]; + $refs = "    \"Add"; if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $refs = $refs . "      \"View"; } // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote = $fmtnote . "PARTS"; } } // now print the line in the table if ($showtime) { printf( - "%s   + "%s   %s      %s      %s      %s
%s

\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tablerow["time"], - $tname, - $subjname, - $refs, - $fmtnote + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["time"], + $tname, + $subjname, + $refs, + $fmtnote ); } else { printf( - "%s   + "%s   %s      %s      %s
%s

\n", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tname, - $subjname, - $refs, - $fmtnote + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tname, + $subjname, + $refs, + $fmtnote ); } } @@ -208,11 +215,11 @@ function shifttable_clean($shift, $tgt_date, $db) { echo "

\n"; } -framework("begin","$logname","Online Logbook",$print); +framework("begin", "$logname", "Online Logbook", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); //calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php"); echo "
"; echo htmlspecialchars($tgt_date); @@ -225,29 +232,27 @@ if(!$print) { sidemenu(); echo "

"; showlinklist($print); - pageblock("left","end"); + pageblock("left", "end"); } else { echo "
$tgt_year-$tgt_month-$tgt_day

"; } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); if (isset($techid)) nag($techid); //$date=date("Y-m-d",mktime(0,0,0,$tgt_month,$tgt_day,$tgt_year)); -$qry=mysqli_query($db,"select shiftid from shifts where status=1 order by shiftid asc"); -while ($shnum=mysqli_fetch_row($qry)) { - if ($tablestyle==1) { - shifttable_classic($shnum[0],$tgt_date,$db); - } else if ($tablestyle==2) { - shifttable_clean($shnum[0],$tgt_date,$db); +$qry = mysqli_query($db, "select shiftid from shifts where status=1 order by shiftid asc"); +while ($shnum = mysqli_fetch_row($qry)) { + if ($tablestyle == 1) { + shifttable_classic($shnum[0], $tgt_date, $db); + } else if ($tablestyle == 2) { + shifttable_clean($shnum[0], $tgt_date, $db); } } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/maintform.php b/distfiles/maintform.php index 2263e21..44dcde0 100644 --- a/distfiles/maintform.php +++ b/distfiles/maintform.php @@ -9,39 +9,40 @@ include("functions.php"); -if (isset($_SESSION['login'])) $techid=$_SESSION['login']; +if (isset($_SESSION['login'])) $techid = $_SESSION['login']; -$print=$_REQUEST['print'] ?? NULL; -$histdays=$_REQUEST['histdays'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$histdays = $_REQUEST['histdays'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; -if ($histdays=="") $histdays=30; +if ($histdays == "") $histdays = 30; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // define pendtable function -function pendtable($tech_id, $db) { - $uidtext=UID_TEXT; +function pendtable($tech_id, $db) +{ + $uidtext = UID_TEXT; // print section header if ($tech_id) { echo " Your Pending Maintenance Forms
"; - $pmf=mysqli_query($db,"select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc"); + $pmf = mysqli_query($db, "select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc"); } else { echo " All Pending Maintenance Forms
"; - $pmf=mysqli_query($db,"select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc"); + $pmf = mysqli_query($db, "select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc"); } echo "
@@ -60,26 +61,26 @@ function pendtable($tech_id, $db) { "; while ($pendrow = mysqli_fetch_assoc($pmf)) { // look up part data - $uid=dblookup($db,"parts","partid","uid",$pendrow["mfpart"]); - if ($uid=="") $uid=" "; - $partno=dblookup($db,"parts","partid","partnum",$pendrow["mfpart"]); - if ($partno=="") $partno=" "; - $serno=dblookup($db,"parts","partid","sernum",$pendrow["mfpart"]); - if ($serno=="") $serno=" "; - $partname=dblookup($db,"parts","partid","partname",$pendrow["mfpart"]); - if ($partname=="") $partname=" "; + $uid = dblookup($db, "parts", "partid", "uid", $pendrow["mfpart"]); + if ($uid == "") $uid = " "; + $partno = dblookup($db, "parts", "partid", "partnum", $pendrow["mfpart"]); + if ($partno == "") $partno = " "; + $serno = dblookup($db, "parts", "partid", "sernum", $pendrow["mfpart"]); + if ($serno == "") $serno = " "; + $partname = dblookup($db, "parts", "partid", "partname", $pendrow["mfpart"]); + if ($partname == "") $partname = " "; // look up tech name - $tname=dblookup($db,"techs","techid","techname",$pendrow["mftech"]); - if ($pendrow["lognoteid"]==0) { - $noteidval=" "; - $notetag="%s%s"; + $tname = dblookup($db, "techs", "techid", "techname", $pendrow["mftech"]); + if ($pendrow["lognoteid"] == 0) { + $noteidval = " "; + $notetag = "%s%s"; } else { - $noteidval=$pendrow["lognoteid"]; - $notetag="%s"; + $noteidval = $pendrow["lognoteid"]; + $notetag = "%s"; } if (!$tech_id) { printf( - " + " @@ -89,18 +90,20 @@ function pendtable($tech_id, $db) { ", - $pendrow["maintformid"],$pendrow["maintformid"], - $pendrow["mfdate"], - $tname, - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $pendrow["maintformid"], + $pendrow["maintformid"], + $pendrow["mfdate"], + $tname, + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } else { printf( - " + " @@ -109,13 +112,15 @@ function pendtable($tech_id, $db) { ", - $pendrow["maintformid"],$pendrow["maintformid"], - $pendrow["mfdate"], - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $pendrow["maintformid"], + $pendrow["maintformid"], + $pendrow["mfdate"], + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } } @@ -125,9 +130,10 @@ function pendtable($tech_id, $db) { } // define histtable function -function histtable($hist_days,$db) { - $uidtext=UID_TEXT; - $dayopts=array(30,90,180,365); +function histtable($hist_days, $db) +{ + $uidtext = UID_TEXT; + $dayopts = array(30, 90, 180, 365); // print section header echo " @@ -135,13 +141,13 @@ function histtable($hist_days,$db) { Days      @@ -160,24 +166,24 @@ function histtable($hist_days,$db) { "; while ($histrow = mysqli_fetch_assoc($histqry)) { // look up part data - $uid=dblookup($db,"parts","partid","uid",$histrow["mfpart"]); - $partno=dblookup($db,"parts","partid","partnum",$histrow["mfpart"]); - if ($partno=="") $partno=" "; - $serno=dblookup($db,"parts","partid","sernum",$histrow["mfpart"]); - if ($serno=="") $serno=" "; - $partname=dblookup($db,"parts","partid","partname",$histrow["mfpart"]); - if ($partname=="") $partname=" "; + $uid = dblookup($db, "parts", "partid", "uid", $histrow["mfpart"]); + $partno = dblookup($db, "parts", "partid", "partnum", $histrow["mfpart"]); + if ($partno == "") $partno = " "; + $serno = dblookup($db, "parts", "partid", "sernum", $histrow["mfpart"]); + if ($serno == "") $serno = " "; + $partname = dblookup($db, "parts", "partid", "partname", $histrow["mfpart"]); + if ($partname == "") $partname = " "; // look up tech name - $tname=dblookup($db,"techs","techid","techname",$histrow["mftech"]); - if ($histrow["lognoteid"]==0) { - $noteidval=" "; - $notetag="%s%s"; + $tname = dblookup($db, "techs", "techid", "techname", $histrow["mftech"]); + if ($histrow["lognoteid"] == 0) { + $noteidval = " "; + $notetag = "%s%s"; } else { - $noteidval=$histrow["lognoteid"]; - $notetag="%s"; + $noteidval = $histrow["lognoteid"]; + $notetag = "%s"; } printf( - " + " @@ -187,14 +193,16 @@ function histtable($hist_days,$db) { ", - $histrow["maintformid"],$histrow["maintformid"], - $histrow["mfdate"], - $tname, - $uid, - $partno, - $serno, - $partname, - $noteidval,$noteidval + $histrow["maintformid"], + $histrow["maintformid"], + $histrow["mfdate"], + $tname, + $uid, + $partno, + $serno, + $partname, + $noteidval, + $noteidval ); } echo " @@ -202,30 +210,28 @@ function histtable($hist_days,$db) { "; } -framework("begin","$logname","Maintenance Forms",$print); +framework("begin", "$logname", "Maintenance Forms", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); -banner($print); +pageblock("right", "begin"); +banner($print); echo "
"; -$haspending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\"")); +$haspending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\"")); if ($haspending) { - pendtable($techid,$db); + pendtable($techid, $db); echo "


"; } -pendtable(0,$db); +pendtable(0, $db); echo "


"; -histtable($histdays,$db); +histtable($histdays, $db); echo "

"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 45e3601..fdd2ff8 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -11,121 +11,123 @@ include("functions.php"); if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$loggedinas=$_SESSION['login']; -$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); +$loggedinas = $_SESSION['login']; +$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas); -function getmfdata($maintformid) { +function getmfdata($maintformid) +{ // pull maintenance form data from maintforms table global $db; - $mfdata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintforms where maintformid=\"$maintformid\"")); + $mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\"")); return $mfdata; } -function getactiondata($maintactionid) { +function getactiondata($maintactionid) +{ // pull maintenance action data from maintactions table global $db; - $actiondata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintactions where maintactionid=\"$maintactionid\"")); + $actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\"")); return $actiondata; } -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; -$maintformid=$_REQUEST['maintformid'] ?? NULL; -$lognoteid=$_REQUEST['lognoteid'] ?? NULL; -$mfdate=$_REQUEST['date'] ?? NULL; -$mftime=$_REQUEST['time'] ?? NULL; -$mfsubmit=$_REQUEST['mfsubmit'] ?? NULL; -$mfadd=$_REQUEST['mfadd'] ?? NULL; -$mfedit=$_REQUEST['mfedit'] ?? NULL; -$mfdelete=$_REQUEST['mfdelete'] ?? NULL; -$mfpartloc=$_REQUEST['mfpartloc'] ?? NULL; -$mfmalfunction=$_REQUEST['mfmalfunction'] ?? NULL; -$nha=$_REQUEST['nha'] ?? NULL; -$repord=$_REQUEST['repord'] ?? NULL; -$mfpart=$_REQUEST['mfpart'] ?? NULL; -$uid=$_REQUEST['uid'] ?? NULL; -$partnum=$_REQUEST['partnum'] ?? NULL; -$sernum=$_REQUEST['sernum'] ?? NULL; -$partname=$_REQUEST['partname'] ?? NULL; -$actionadd=$_REQUEST['actionadd'] ?? NULL; -$actionedit=$_REQUEST['actionedit'] ?? NULL; -$actiondelete=$_REQUEST['actiondelete'] ?? NULL; -$maintactionid=$_REQUEST['maintactionid'] ?? NULL; -$actiondate=$_REQUEST['actiondate'] ?? NULL; -$actiontime=$_REQUEST['actiontime'] ?? NULL; -$actiontech=$_REQUEST['actiontech'] ?? NULL; -$action=$_REQUEST['action'] ?? NULL; -$actionaddsubmit=$_REQUEST['actionaddsubmit'] ?? NULL; -$actioneditsubmit=$_REQUEST['actioneditsubmit'] ?? NULL; -$printfmt=$_REQUEST['printfmt'] ?? NULL; -if ($printfmt) $print=TRUE; -$flags=$_POST['flags'] ?? []; +$maintformid = $_REQUEST['maintformid'] ?? NULL; +$lognoteid = $_REQUEST['lognoteid'] ?? NULL; +$mfdate = $_REQUEST['date'] ?? NULL; +$mftime = $_REQUEST['time'] ?? NULL; +$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL; +$mfadd = $_REQUEST['mfadd'] ?? NULL; +$mfedit = $_REQUEST['mfedit'] ?? NULL; +$mfdelete = $_REQUEST['mfdelete'] ?? NULL; +$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL; +$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL; +$nha = $_REQUEST['nha'] ?? NULL; +$repord = $_REQUEST['repord'] ?? NULL; +$mfpart = $_REQUEST['mfpart'] ?? NULL; +$uid = $_REQUEST['uid'] ?? NULL; +$partnum = $_REQUEST['partnum'] ?? NULL; +$sernum = $_REQUEST['sernum'] ?? NULL; +$partname = $_REQUEST['partname'] ?? NULL; +$actionadd = $_REQUEST['actionadd'] ?? NULL; +$actionedit = $_REQUEST['actionedit'] ?? NULL; +$actiondelete = $_REQUEST['actiondelete'] ?? NULL; +$maintactionid = $_REQUEST['maintactionid'] ?? NULL; +$actiondate = $_REQUEST['actiondate'] ?? NULL; +$actiontime = $_REQUEST['actiontime'] ?? NULL; +$actiontech = $_REQUEST['actiontech'] ?? NULL; +$action = $_REQUEST['action'] ?? NULL; +$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL; +$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL; +$printfmt = $_REQUEST['printfmt'] ?? NULL; +if ($printfmt) $print = TRUE; +$flags = $_POST['flags'] ?? []; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } if ($printfmt) { - framework("begin","","",$print); + framework("begin", "", "", $print); } else if ($mfedit) { - framework("begin","$logname","Maintenance Form Edit",$print); - if ($loggedinas) $mfauthorized=TRUE; + framework("begin", "$logname", "Maintenance Form Edit", $print); + if ($loggedinas) $mfauthorized = TRUE; } else if ($mfdelete) { - framework("begin","$logname","Maintenance Form Edit",$print); - $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); - if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE; + framework("begin", "$logname", "Maintenance Form Edit", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); + if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE; } else if ($actionadd) { - framework("begin","$logname","Maintenance Action Entry",$print); - $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); + framework("begin", "$logname", "Maintenance Action Entry", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); if ($loggedinas) { - $mfauthorized=TRUE; - $actionauthorized=TRUE; + $mfauthorized = TRUE; + $actionauthorized = TRUE; } } else if ($actionedit || $actiondelete) { - framework("begin","$logname","Maintenance Action Edit",$print); - $mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); - if ($loggedinas) $mfauthorized=TRUE; - $actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid); - if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE; + framework("begin", "$logname", "Maintenance Action Edit", $print); + $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid); + if ($loggedinas) $mfauthorized = TRUE; + $actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid); + if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE; } else { - $mfadd=TRUE; - framework("begin","$logname","Maintenance Form Entry",$print); - $mftech=$loggedinas; - $mfauthorized=TRUE; + $mfadd = TRUE; + framework("begin", "$logname", "Maintenance Form Entry", $print); + $mftech = $loggedinas; + $mfauthorized = TRUE; } // ******** begin database manipulation ******** //var_dump($_REQUEST); -$pdatamismatch=NULL; +$pdatamismatch = NULL; if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) { // pull mf data from database - $mftoedit=getmfdata($maintformid); - $partdatainput=[]; - if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart']; - if ($uid) $partdatainput['uid']=$uid; - if ($partnum) $partdatainput['partnum']=$partnum; - if ($sernum) $partdatainput['sernum']=$sernum; - $partinfo=get_part_data($partdatainput); - if ($partinfo['result']==2) { - $pdatamismatch=TRUE; + $mftoedit = getmfdata($maintformid); + $partdatainput = []; + if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart']; + if ($uid) $partdatainput['uid'] = $uid; + if ($partnum) $partdatainput['partnum'] = $partnum; + if ($sernum) $partdatainput['sernum'] = $sernum; + $partinfo = get_part_data($partdatainput); + if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { - $pdatamismatch=FALSE; - if ($partinfo['partid']) $mfpart=$partinfo['partid']; - if ($partinfo['uid']) $uid=$partinfo['uid']; - if ($partinfo['partnum']) $partnum=$partinfo['partnum']; - if ($partinfo['sernum']) $sernum=$partinfo['sernum']; - if ($partinfo['partname']) $partname=$partinfo['partname']; + $pdatamismatch = FALSE; + if ($partinfo['partid']) $mfpart = $partinfo['partid']; + if ($partinfo['uid']) $uid = $partinfo['uid']; + if ($partinfo['partnum']) $partnum = $partinfo['partnum']; + if ($partinfo['sernum']) $sernum = $partinfo['sernum']; + if ($partinfo['partname']) $partname = $partinfo['partname']; } } @@ -134,54 +136,54 @@ if ($mfadd) { // add the entry if submit is pressed if ($mfmalfunction && ($uid || ($partnum && $sernum))) { // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$mfdate\",CURRENT_DATE)")); + $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 - if ($datediff[0]<0) { - $mftime="23:59:59:"; + if ($datediff[0] < 0) { + $mftime = "23:59:59:"; } - if ($datediff[0]>0) { - $mftime="00:00:01:"; + if ($datediff[0] > 0) { + $mftime = "00:00:01:"; } // remove cruft from malfunction text - $mfmalfunction=htmlentities($mfmalfunction); - $mfmalfunction=addslashes($mfmalfunction); - + $mfmalfunction = htmlentities($mfmalfunction); + $mfmalfunction = addslashes($mfmalfunction); + if ($mfauthorized) { - $partdatainput=array(); - if ($uid) $partdatainput['uid']=$uid; - if ($partnum) $partdatainput['partnum']=$partnum; - if ($sernum) $partdatainput['sernum']=$sernum; - $partinfo=get_part_data($partdatainput); + $partdatainput = array(); + if ($uid) $partdatainput['uid'] = $uid; + if ($partnum) $partdatainput['partnum'] = $partnum; + if ($sernum) $partdatainput['sernum'] = $sernum; + $partinfo = get_part_data($partdatainput); // add to parts table - if ($partinfo['result']==1) { + if ($partinfo['result'] == 1) { // if this part has not been seen before, add it to the parts table and get partid - mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); - $mfpart=mysqli_insert_id($db); - } else if ($partinfo['result']==2) { - $pdatamismatch=TRUE; + mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); + $mfpart = mysqli_insert_id($db); + } else if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { // if it is in parts table, get partid for this record - $pdatamismatch=FALSE; - $mfpart=$partinfo['partid']; + $pdatamismatch = FALSE; + $mfpart = $partinfo['partid']; } - if ($uid =="" || $partnum == "" || $sernum == "") { + if ($uid == "" || $partnum == "" || $sernum == "") { // have the maintenance form stay pending due to incomplete part data - $pending=1; + $pending = 1; } else { - $pending=0; + $pending = 0; } - + // add the record to maintforms if (! $pdatamismatch) { - mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending) + 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); - $mfidtoprint=$newmaintformid; + $newmaintformid = mysqli_insert_id($db); + $mfidtoprint = $newmaintformid; // update the flagmap table foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); + mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); } } } @@ -189,66 +191,66 @@ if ($mfadd) { } } if ($mfedit) { - $mfidtoprint=$maintformid; + $mfidtoprint = $maintformid; if ($mfsubmit && $mfauthorized) { if ($mfmalfunction && ($uid || ($partnum && $sernum))) { // remove cruft from malfunction text - $mfmalfunction=htmlentities($mfmalfunction); - $mfmalfunction=addslashes($mfmalfunction); - + $mfmalfunction = htmlentities($mfmalfunction); + $mfmalfunction = addslashes($mfmalfunction); + // update parts table - if ($uid =="" || $partnum == "" || $sernum == "") { + if ($uid == "" || $partnum == "" || $sernum == "") { // have the maintenance form stay pending due to incomplete part data - $pending=1; + $pending = 1; } else { - $pending=0; + $pending = 0; } if (! $pdatamismatch) { - mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\""); + mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\""); } - + // update the record in maintforms if (! $pdatamismatch) { - mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\", + mysqli_query($db, "update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\", mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\""); - + // update the flagmap table - mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\""); foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")"); + mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")"); } } } } // refresh the maintenance form in question from the database - $mftoedit=getmfdata($maintformid); + $mftoedit = getmfdata($maintformid); } if ($mfdelete && $mfauthorized) { // delete from maintforms table - mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\""); // delete occurances from the flagmap table - mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\""); + mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\""); } if ($actionadd) { if ($actionaddsubmit) { if ($action) { // determine whether supplied date is future or past - $datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$actiondate\",CURRENT_DATE)")); + $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 - if ($datediff[0]<0) { - $actiontime="23:59:59:"; + if ($datediff[0] < 0) { + $actiontime = "23:59:59:"; } - if ($datediff[0]>0) { - $actiontime="00:00:01:"; + if ($datediff[0] > 0) { + $actiontime = "00:00:01:"; } // remove cruft from action text - $action=htmlentities($action); - $action=addslashes($action); - + $action = htmlentities($action); + $action = addslashes($action); + // add to maintactions table - mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action) + mysqli_query($db, "insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action) values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")"); echo mysqli_error($db); } @@ -259,19 +261,19 @@ if ($actionedit) { if ($actioneditsubmit && $actionauthorized) { // update the action // remove cruft from action text - $action=htmlentities($action); - $action=addslashes($action); - + $action = htmlentities($action); + $action = addslashes($action); + // update maintactions table - mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\""); + mysqli_query($db, "update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\""); } // refresh the action in question from the database - $actiontoedit=getactiondata($maintactionid); + $actiontoedit = getactiondata($maintactionid); } if ($actiondelete && $actionauthorized) { // delete the action - mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\""); + mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\""); } @@ -279,66 +281,67 @@ if ($actiondelete && $actionauthorized) { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form if ($mfadd || $actionadd) { - $mfdate=$today; - $mftime=$now; - $actiondate=$today; - $actiontime=$now; + $mfdate = $today; + $mftime = $now; + $actiondate = $today; + $actiontime = $now; } if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) { - $mfdate=$mftoedit["mfdate"]; - $mftime=$mftoedit["mftime"]; - $mfpart=$mftoedit["mfpart"]; - $mfpartloc=$mftoedit["mfpartloc"]; - $mfmalfunction=$mftoedit["mfmalfunction"]; - $nha=$mftoedit["nha"]; - $repord=$mftoedit["repord"]; - $lognoteid=$mftoedit["lognoteid"]; - if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"]; - if (! $mftime) $mftime=$now; + $mfdate = $mftoedit["mfdate"]; + $mftime = $mftoedit["mftime"]; + $mfpart = $mftoedit["mfpart"]; + $mfpartloc = $mftoedit["mfpartloc"]; + $mfmalfunction = $mftoedit["mfmalfunction"]; + $nha = $mftoedit["nha"]; + $repord = $mftoedit["repord"]; + $lognoteid = $mftoedit["lognoteid"]; + if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech = $mftoedit["mftech"]; + if (! $mftime) $mftime = $now; } if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) { - $partinfo=array(); - $partinfoinput['partid']=$mfpart; - $partinfo=get_part_data($partinfoinput); - $mfpart=$partinfo['partid']; - $uid=$partinfo['uid']; - $partnum=$partinfo['partnum']; - $sernum=$partinfo['sernum']; - $partname=$partinfo['partname']; - $pluresult=$partinfo['result']; - if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE; + $partinfo = array(); + $partinfoinput['partid'] = $mfpart; + $partinfo = get_part_data($partinfoinput); + $mfpart = $partinfo['partid']; + $uid = $partinfo['uid']; + $partnum = $partinfo['partnum']; + $sernum = $partinfo['sernum']; + $partname = $partinfo['partname']; + $pluresult = $partinfo['result']; + if ($pluresult == 2) $pdatamismatch = TRUE; + else $pdatamismatch = FALSE; } -$techname=dblookup($db,"techs","techid","techname",$mftech); +$techname = dblookup($db, "techs", "techid", "techname", $mftech); if ($mfsubmit) { if ($mfmalfunction) { if (($uid || ($partnum && $sernum)) || $mfpart) { if ($mfadd) { - format_message(0,"Maintenance Form added. You may enter another one or return to Maintenance Forms page."); + format_message(0, "Maintenance Form added. You may enter another one or return to Maintenance Forms page."); } if ($mfedit) { - format_message(0,"Maintenance Form changed. Return to Maintenance Forms page."); + format_message(0, "Maintenance Form changed. Return to Maintenance Forms page."); } } else { - format_message(1,"You didn't enter any part information. Please try again."); + format_message(1, "You didn't enter any part information. Please try again."); } } else { - format_message(1,"You didn't enter any malfunction description. Please try again."); + format_message(1, "You didn't enter any malfunction description. Please try again."); } } if ($mfdelete) { - format_message(0,"Maintenance Form Deleted. Return to Maintenance Forms page."); + format_message(0, "Maintenance Form Deleted. Return to Maintenance Forms page."); } if ($pdatamismatch) { - $advtxt=" + $advtxt = "   Warning: The $uidtext doesn't match the Part Number/Serial Number associated with it in our database. Please ensure the part information @@ -346,7 +349,7 @@ if ($pdatamismatch) { the Parts page to correct the database. "; } else { - $advtxt=" + $advtxt = " You can enter a $uidtext or Part Number/Serial Number or both. "; } @@ -374,34 +377,34 @@ if ($printfmt) { Flags
%s %s %s%s $notetag
%s %s %s%s $notetag
%s %s %s%s $notetag
"; - + // create an array called theseflags of flagids set for this maintformid - $allflags=mysqli_query($db,"select flagid from flags"); + $allflags = mysqli_query($db, "select flagid from flags"); unset($theseflags); - $theseflags=[]; - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { - $theseflags[]=$thisflag[0]; + $theseflags = []; + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { + $theseflags[] = $thisflag[0]; } } // display flag symbols for set flags - $flagslist=mysqli_query($db,"select * from flags"); - while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { - if ($theseflags[0]=="") $theseflags=[]; - if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) { - echo $flagsymbol['flagsym']."  "; + $flagslist = mysqli_query($db, "select * from flags"); + while ($flagsymbol = mysqli_fetch_assoc($flagslist)) { + if ($theseflags[0] == "") $theseflags = []; + if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) { + echo $flagsymbol['flagsym'] . "  "; } } echo "

Maintenance Actions
"; - $maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); - while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { - $actiondate=$actiontable["actiondate"]; - $actiontime=$actiontable["actiontime"]; - $tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); - $actiontext=convertweblinks($actiontable["action"]); + $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); + while ($actiontable = mysqli_fetch_assoc($maintactionqry)) { + $actiondate = $actiontable["actiondate"]; + $actiontime = $actiontable["actiontime"]; + $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]); + $actiontext = convertweblinks($actiontable["action"]); // print the actions echo " @@ -463,39 +466,49 @@ if ($printfmt) {
"; // create an array called theseflags of flagids set for this maintformid - $allflags=mysqli_query($db,"select flagid from flags"); + $allflags = mysqli_query($db, "select flagid from flags"); unset($theseflags); - $theseflags=[]; - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { - $theseflags[]=$thisflag[0]; + $theseflags = []; + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) { + $theseflags[] = $thisflag[0]; } } if ($mfadd) { - $flagslist=mysqli_query($db,"select * from flags where status=1"); + $flagslist = mysqli_query($db, "select * from flags where status=1"); } else { - $flagslist=mysqli_query($db,"select * from flags"); + $flagslist = mysqli_query($db, "select * from flags"); } - $flagsperline=8; - $flagcount=1; - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + $flagsperline = 8; + $flagcount = 1; + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { //if ($theseflags[0]=="") $theseflags=[]; - if (in_array($flagcheckbox["flagid"],$theseflags)) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + if (in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } else { - $flagid=$flagcheckbox["flagid"]; - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + $flagid = $flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } echo " @@ -542,7 +555,7 @@ if ($printfmt) {
"; } - + echo "
@@ -550,16 +563,16 @@ if ($printfmt) { if ($actionadd || $actionedit) { // show the action form if ($actionadd) { - $matime=$now; - $actiontext=""; - $actiontech=$loggedinas; + $matime = $now; + $actiontext = ""; + $actiontech = $loggedinas; } else if ($actionedit) { - $actiontext=$actiontoedit['action']; - $actiontech=$actiontoedit['actiontech']; - $actiondate=$actiontoedit['actiondate']; - $actiontime=$actiontoedit['actiontime']; + $actiontext = $actiontoedit['action']; + $actiontech = $actiontoedit['actiontech']; + $actiondate = $actiontoedit['actiondate']; + $actiontime = $actiontoedit['actiontime']; } - $tname=dblookup($db,"techs","techid","techname",$actiontech); + $tname = dblookup($db, "techs", "techid", "techname", $actiontech); echo " "; -$partqry=mysqli_query($db,"select * from parts order by $sort $order"); -while ($partline=mysqli_fetch_assoc($partqry)) { +$partqry = mysqli_query($db, "select * from parts order by $sort $order"); +while ($partline = mysqli_fetch_assoc($partqry)) { if (!$partline['uid']) { - $pluidtxt="none"; + $pluidtxt = "none"; } else { - $pluidtxt=$partline['uid']; + $pluidtxt = $partline['uid']; } if ($loggedin) { - printf(" + printf( + " ", - $partline['partid'],$pluidtxt, - $partline['partnum'], - $partline['sernum'], - $partline['partname'] + $partline['partid'], + $pluidtxt, + $partline['partnum'], + $partline['sernum'], + $partline['partname'] ); } else { - printf(" + printf( + " ", - $pluidtxt, - $partline['partnum'], - $partline['sernum'], - $partline['partname'] + $pluidtxt, + $partline['partnum'], + $partline['sernum'], + $partline['partname'] ); } echo " @@ -115,9 +118,7 @@ echo " echo "

"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/profile.php b/distfiles/profile.php index 15af5cb..48319d1 100644 --- a/distfiles/profile.php +++ b/distfiles/profile.php @@ -10,133 +10,136 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$print=$_REQUEST['print'] ?? NULL; -$table=$_REQUEST['table'] ?? NULL; -$updateinfo=$_REQUEST['updateinfo'] ?? NULL; -$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL; -$setcolor=$_REQUEST['setcolor'] ?? NULL; -$name=$_REQUEST['name'] ?? NULL; -$pass=$_REQUEST['pass'] ?? NULL; -$passconf=$_REQUEST['passconf'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL; -$display_showts=$_REQUEST['display_showts'] ?? NULL; -$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL; -$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL; -$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL; -$modcolor=$_REQUEST['modcolor'] ?? NULL; -$hexcolor=$_REQUEST['hexcolor'] ?? NULL; -$resetcustom=$_REQUEST["resetcustom"] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$table = $_REQUEST['table'] ?? NULL; +$updateinfo = $_REQUEST['updateinfo'] ?? NULL; +$updatedisplay = $_REQUEST['updatedisplay'] ?? NULL; +$setcolor = $_REQUEST['setcolor'] ?? NULL; +$name = $_REQUEST['name'] ?? NULL; +$pass = $_REQUEST['pass'] ?? NULL; +$passconf = $_REQUEST['passconf'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL; +$display_showts = $_REQUEST['display_showts'] ?? NULL; +$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL; +$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL; +$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL; +$modcolor = $_REQUEST['modcolor'] ?? NULL; +$hexcolor = $_REQUEST['hexcolor'] ?? NULL; +$resetcustom = $_REQUEST["resetcustom"] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","My Profile",$print); +framework("begin", "$logname", "My Profile", $print); pagetable("begin"); -if(!$print){ - pageblock("left","begin"); - +if (!$print) { + pageblock("left", "begin"); + // ******** begin database manipulation ******** if ($updateinfo) { // name shift password settings // do error checking // test for name supplied if (strlen(trim($name))) { - $namesuppld=1; + $namesuppld = TRUE; } else { - $namesuppld=0; + $namesuppld = FALSE; echo " Tech name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) { - if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { - $nameunique=0; + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) { + if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) { + $nameunique = FALSE; echo " Tech name already exists.
"; } else { - $nameunique=1; + $nameunique = TRUE; } } else { - $nameunique=1; + $nameunique = TRUE; } // test for matching passwords - if ($pass!="password_is_unchanged") { - if ($pass==$passconf) { - $passmatch=1; - $passhash=password_hash($pass,PASSWORD_DEFAULT); - $namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\""); + if ($pass != "password_is_unchanged") { + if ($pass == $passconf) { + $passmatch = TRUE; + $passhash = password_hash($pass, PASSWORD_DEFAULT); + $namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\""); } else { - $passmatch=0; + $passmatch = FALSE; echo " The passwords you supplied don't match.
"; } } else { - $passmatch=1; - $namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\""; + $passmatch = TRUE; + $namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\""; } if ($namesuppld && $nameunique && $passmatch) { - mysqli_query($db,$namepassupdqry); - mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\""); + mysqli_query($db, $namepassupdqry); + mysqli_query($db, "update techs set shift=\"$shift\" where techid=\"$techid\""); } } if ($updatedisplay) { // display settings - if ($display_showts) $display_showts=1; else $display_showts=0; - if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0; - if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0; + if ($display_showts) $display_showts = 1; + else $display_showts = 0; + if ($display_techalpha == "a") $display_techalpha = 1; + else $display_techalpha = 0; + if ($display_subjalpha == "a") $display_subjalpha = 1; + else $display_subjalpha = 0; // test for urlchunk supplied if (strlen(trim($display_urlchunk))) { - $chunksuppld=1; + $chunksuppld = TRUE; } else { - $chunksuppld=0; + $chunksuppld = FALSE; echo " URL chunk size cannot be blank.
"; } if ($chunksuppld) { - putsetting('url_chunk_size',$display_urlchunk,$techid); - putsetting('show_ts',$display_showts,$techid); - putsetting('tech_alpha',$display_techalpha,$techid); - putsetting('subj_alpha',$display_subjalpha,$techid); - putsetting('log_style',$display_logstyle,$techid); + putsetting('url_chunk_size', $display_urlchunk, $techid); + putsetting('show_ts', $display_showts, $techid); + putsetting('tech_alpha', $display_techalpha, $techid); + putsetting('subj_alpha', $display_subjalpha, $techid); + putsetting('log_style', $display_logstyle, $techid); } } if ($setcolor) { // color settings - $hexcolor="#".ltrim($hexcolor); - putsetting($modcolor,$hexcolor,$techid); + $hexcolor = "#" . ltrim($hexcolor); + putsetting($modcolor, $hexcolor, $techid); } - if ($resetcustom) mysqli_query($db,"delete from customs where customtech=\"$techid\""); - + if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\""); + sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); // pull my current data from tables -$curname=dblookup($db,"techs","techid","techname",$techid); -$curshift=dblookup($db,"techs","techid","shift",$techid); -$pass=$passconf="password_is_unchanged"; +$curname = dblookup($db, "techs", "techid", "techname", $techid); +$curshift = dblookup($db, "techs", "techid", "shift", $techid); +$pass = $passconf = "password_is_unchanged"; // other values from customs -$curlchunk=getsetting('url_chunk_size',$techid)["value"]; -$curts=getsetting('show_ts',$techid)["value"]; -$curtdo=getsetting('tech_alpha',$techid)["value"]; -$cursdo=getsetting('subj_alpha',$techid)["value"]; -$curbgc=getsetting('background_color',$techid)["value"]; -$cursbc=getsetting('sidebar_color',$techid)["value"]; -$curmbgc=getsetting('menubg_color',$techid)["value"]; -$curtc=getsetting('text_color',$techid)["value"]; -$curlc=getsetting('link_color',$techid)["value"]; -$curvlc=getsetting('vlink_color',$techid)["value"]; -$curhc=getsetting('heading_color',$techid)["value"]; -$curlogstyle=getsetting('log_style',$techid)["value"]; +$curlchunk = getsetting('url_chunk_size', $techid)["value"]; +$curts = getsetting('show_ts', $techid)["value"]; +$curtdo = getsetting('tech_alpha', $techid)["value"]; +$cursdo = getsetting('subj_alpha', $techid)["value"]; +$curbgc = getsetting('background_color', $techid)["value"]; +$cursbc = getsetting('sidebar_color', $techid)["value"]; +$curmbgc = getsetting('menubg_color', $techid)["value"]; +$curtc = getsetting('text_color', $techid)["value"]; +$curlc = getsetting('link_color', $techid)["value"]; +$curvlc = getsetting('vlink_color', $techid)["value"]; +$curhc = getsetting('heading_color', $techid)["value"]; +$curlogstyle = getsetting('log_style', $techid)["value"]; // show the form echo " @@ -149,19 +152,19 @@ Password:  

Need a random password?   "; -$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); +$rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12); echo "   $rpw

Shift:   "; -$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\""); -while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) { - if ($logstylerow["styleid"]==$curlogstyle) { - printf("",$logstylerow["styleid"],$logstylerow["stylename"]); +$logstyleqry = mysqli_query($db, "select styleid,stylename from styles where styletype=\"logdisplay\""); +while ($logstylerow = mysqli_fetch_assoc($logstyleqry)) { + if ($logstylerow["styleid"] == $curlogstyle) { + printf("", $logstylerow["styleid"], $logstylerow["stylename"]); } else { - printf("",$logstylerow["styleid"],$logstylerow["stylename"]); + printf("", $logstylerow["styleid"], $logstylerow["stylename"]); } } echo " @@ -236,7 +239,7 @@ echo "
My Color Preferences

"; -switch($modcolor) { +switch ($modcolor) { case "background_color": echo "
Tech:  $tname @@ -597,25 +610,25 @@ if ($printfmt) {

"; } - + echo "Maintenance Actions    "; if ($_SESSION['login'] && $maintformid) echo ""; echo "

"; - - - $maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); - while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { - $maintactionid=$actiontable["maintactionid"]; - $actiondate=$actiontable["actiondate"]; - $actiontime=$actiontable["actiontime"]; - $maintformnum=$actiontable["maintformnum"]; - $tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); - $actiontext=convertweblinks($actiontable["action"]); + + + $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); + while ($actiontable = mysqli_fetch_assoc($maintactionqry)) { + $maintactionid = $actiontable["maintactionid"]; + $actiondate = $actiontable["actiondate"]; + $actiontime = $actiontable["actiontime"]; + $maintformnum = $actiontable["maintformnum"]; + $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]); + $actiontext = convertweblinks($actiontable["action"]); // print the table echo "
"; - if (($loggedinas==$actiontable["actiontech"]) || $isadmin) { + if (($loggedinas == $actiontable["actiontech"]) || $isadmin) { echo " \"Edit   \"Delete @@ -638,16 +651,14 @@ if ($printfmt) {

"; } - + echo " "; } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/partentry.php b/distfiles/partentry.php index ed7ba64..5775dfd 100644 --- a/distfiles/partentry.php +++ b/distfiles/partentry.php @@ -11,39 +11,39 @@ include("functions.php"); if (!isset($_SESSION['login'])) { - header ("Location: login.php"); + header("Location: login.php"); } -$loggedinas=$_SESSION['login']; -$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); +$loggedinas = $_SESSION['login']; +$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas); -$print=$_REQUEST['print'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; -$partid=$_REQUEST['partid'] ?? NULL; -$uid=$_REQUEST['uid'] ?? NULL; -$partnum=$_REQUEST['partnum'] ?? NULL; -$sernum=$_REQUEST['sernum'] ?? NULL; -$partname=$_REQUEST['partname'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; +$partid = $_REQUEST['partid'] ?? NULL; +$uid = $_REQUEST['uid'] ?? NULL; +$partnum = $_REQUEST['partnum'] ?? NULL; +$sernum = $_REQUEST['sernum'] ?? NULL; +$partname = $_REQUEST['partname'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } if ($edit || $delete) { - framework("begin","$logname","Part Edit",$print); + framework("begin", "$logname", "Part Edit", $print); } else { - $add=1; - framework("begin","$logname","Part Entry",$print); + $add = 1; + framework("begin", "$logname", "Part Entry", $print); } // ******** begin database manipulation ******** @@ -53,11 +53,11 @@ if ($add) { if ($submit) { // add the entry if submit is pressed if ($uid || ($partnum && $sernum)) { - $partexists=mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")")); + $partexists = mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")")); if (! $partexists) { // add to parts table - mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); - $partid=mysqli_insert_id($db); + mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); + $partid = mysqli_insert_id($db); } } } @@ -66,18 +66,18 @@ if ($edit) { if ($submit) { if ($uid || ($partnum && $sernum)) { // update parts table - mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\""); + mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\""); } } } if ($delete) { // check for occurrence in logparts table - $inlogparts=mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where partid=\"$partid\"")); + $inlogparts = mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where partid=\"$partid\"")); // check for occurrence in maintforms table - $inmaintforms=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mfpart=\"$partid\"")); + $inmaintforms = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mfpart=\"$partid\"")); // delete from parts table - if(!$inlogparts && !$inmaintforms) { - mysqli_query($db,"delete from parts where partid=\"$partid\""); + if (!$inlogparts && !$inmaintforms) { + mysqli_query($db, "delete from parts where partid=\"$partid\""); } } @@ -85,24 +85,24 @@ if ($delete) { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the form -$partdatainput=array(); -$partdatainput['partid']=$partid; -$partinfo=get_part_data($partdatainput); -if ($partinfo['result']==2) { - $pdatamismatch=TRUE; +$partdatainput = array(); +$partdatainput['partid'] = $partid; +$partinfo = get_part_data($partdatainput); +if ($partinfo['result'] == 2) { + $pdatamismatch = TRUE; } else { - $pdatamismatch=FALSE; - $uid = (array_key_exists('uid',$partinfo)) ? $partinfo['uid'] : NULL; - $partnum = (array_key_exists('partnum',$partinfo)) ? $partinfo['partnum'] : NULL; - $sernum = (array_key_exists('sernum',$partinfo)) ? $partinfo['sernum'] : NULL; - $partname = (array_key_exists('partname',$partinfo)) ? $partinfo['partname'] : NULL; + $pdatamismatch = FALSE; + $uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL; + $partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL; + $sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL; + $partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL; } if ($delete) { if ($inmaintforms) { @@ -168,9 +168,7 @@ echo " "; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/parts.php b/distfiles/parts.php index 7893f93..606eac2 100644 --- a/distfiles/parts.php +++ b/distfiles/parts.php @@ -10,50 +10,50 @@ include("functions.php"); if (isset($_SESSION['login'])) { - $loggedin=1; + $loggedin = TRUE; } else { - unset($loggedin); + $loggedin = FALSE; } -$print=$_REQUEST['print'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$sort=$_REQUEST['sort'] ?? NULL; -$order=$_REQUEST['order'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$sort = $_REQUEST['sort'] ?? NULL; +$order = $_REQUEST['order'] ?? NULL; -$logname=LOG_NAME; -$uidtext=UID_TEXT; +$logname = LOG_NAME; +$uidtext = UID_TEXT; if ($add) { - header ("Location: partentry.php?add=1"); + header("Location: partentry.php?add=1"); } -if (! $sort) $sort="uid"; +if (! $sort) $sort = "uid"; if ($order == "asc") { - $order="desc"; + $order = "desc"; } else if ($order == "desc") { - $order="asc"; + $order = "asc"; } else { - $order="asc"; + $order = "asc"; } if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Parts",$print); +framework("begin", "$logname", "Parts", $print); pagetable("begin"); -if(!$print) { - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); if ($loggedin) { echo " @@ -71,15 +71,16 @@ echo "
Part Name
%s @@ -87,22 +88,24 @@ while ($partline=mysqli_fetch_assoc($partqry)) { %s %s %s
%s %s %s %s
", - $eventdata_eventid,$duedatestrg, - $devicedata_devicedesc,$devicedata_devicename, - $taskdata_taskdesc,$taskdata_taskname, - $lastdatestrg + $eventdata_eventid, + $duedatestrg, + $devicedata_devicedesc, + $devicedata_devicename, + $taskdata_taskdesc, + $taskdata_taskname, + $lastdatestrg ); } echo "
Page background color"; colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor="); @@ -290,9 +293,7 @@ echo " "; -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/refchain.php b/distfiles/refchain.php index f13f231..2826055 100644 --- a/distfiles/refchain.php +++ b/distfiles/refchain.php @@ -9,69 +9,70 @@ include("functions.php"); -$print=$_REQUEST['print'] ?? ""; -$chainnote=$_REQUEST['chainnote']; +$print = $_REQUEST['print'] ?? ""; +$chainnote = $_REQUEST['chainnote'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Reference Chain Display",$print); +framework("begin", "$logname", "Reference Chain Display", $print); // ******** begin database manipulation ******** -$master=generate_chain($chainnote); +$master = generate_chain($chainnote); // ******** end database manipulation ******** pagetable("begin"); -if(!$print){ - pageblock("left","begin"); +if (!$print) { + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); // display the chain -$mptr=0; +$mptr = 0; echo "

"; echo ""; -while($mptr\"Add    "; +while ($mptr < count($master)) { + if (mysqli_num_rows(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"))) { + $tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]")); + $noteid = $tablerow["lognoteid"]; + $urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"])); + $refs = "  \"Add    "; // convert the shift number to a name - $shname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + $shname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]); // convert tech number to name - $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); + $tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]); //convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagmapqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$noteid"); + $flagstring = ""; + $flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid"); if (mysqli_num_rows($flagmapqry)) { - while ($flagids=mysqli_fetch_row($flagmapqry)) { - $flagid=$flagids[0]; - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagstring=$flagstring."$flagsym  "; + while ($flagids = mysqli_fetch_row($flagmapqry)) { + $flagid = $flagids[0]; + $flagparam = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid\"")); + $flagcolor = $flagparam["flagcolor"]; + $flagsym = $flagparam["flagsym"]; + $flagstring = $flagstring . "$flagsym  "; } } - - if ($flagstring) $fmtnote=$fmtnote."
".$flagstring; - printf(" + + if ($flagstring) $fmtnote = $fmtnote . "
" . $flagstring; + printf( + "
@@ -81,23 +82,24 @@ while($mptr%s ", - $tablerow["lognoteid"],$tablerow["lognoteid"], - $tablerow["date"],$tablerow["time"], - $shname, - $tname, - $subjname, - $fmtnote, - $refs); + $tablerow["lognoteid"], + $tablerow["lognoteid"], + $tablerow["date"], + $tablerow["time"], + $shname, + $tname, + $subjname, + $fmtnote, + $refs + ); } else { - printf("\n",$master[$mptr]); + printf("\n", $master[$mptr]); } - $mptr=$mptr+1; + $mptr = $mptr + 1; } echo "
Note IDDate / TimeShiftTechSubjectNoteReferences
%s %s / %s%s
Note Id %s has been deleted and cannot be displayed.
Note Id %s has been deleted and cannot be displayed.


"; banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index db5e130..1dacf33 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -10,76 +10,76 @@ include("functions.php"); if (isset($_SESSION['login'])) { - $loggedin=true; + $loggedin = true; } else { - $loggedin=false; + $loggedin = false; } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); -$upcoming=$_REQUEST['upcoming'] ?? NULL; -$schedule=$_REQUEST['schedule'] ?? NULL; -$tasks=$_REQUEST['tasks'] ?? NULL; -$devices=$_REQUEST['devices'] ?? NULL; -$action=$_REQUEST['action'] ?? NULL; -$complete=$_REQUEST['complete'] ?? NULL; -$defer=$_REQUEST['defer'] ?? NULL; -$add=$_REQUEST['add'] ?? NULL; -$edit=$_REQUEST['edit'] ?? NULL; -$update=$_REQUEST['update'] ?? NULL; -$delete=$_REQUEST['delete'] ?? NULL; -$id=$_REQUEST['id'] ?? NULL; -$active_flag=$_REQUEST['active_flag'] ?? 0; +$upcoming = $_REQUEST['upcoming'] ?? NULL; +$schedule = $_REQUEST['schedule'] ?? NULL; +$tasks = $_REQUEST['tasks'] ?? NULL; +$devices = $_REQUEST['devices'] ?? NULL; +$action = $_REQUEST['action'] ?? NULL; +$complete = $_REQUEST['complete'] ?? NULL; +$defer = $_REQUEST['defer'] ?? NULL; +$add = $_REQUEST['add'] ?? NULL; +$edit = $_REQUEST['edit'] ?? NULL; +$update = $_REQUEST['update'] ?? NULL; +$delete = $_REQUEST['delete'] ?? NULL; +$id = $_REQUEST['id'] ?? NULL; +$active_flag = $_REQUEST['active_flag'] ?? 0; -$devicename=$_REQUEST['devicename'] ?? NULL; -$devicedesc=$_REQUEST['devicedesc'] ?? NULL; -$group_flag=$_REQUEST['group_flag'] ?? 0; -$members=$_REQUEST['members'] ?? []; +$devicename = $_REQUEST['devicename'] ?? NULL; +$devicedesc = $_REQUEST['devicedesc'] ?? NULL; +$group_flag = $_REQUEST['group_flag'] ?? 0; +$members = $_REQUEST['members'] ?? []; -$weekdays_only=$_REQUEST['weekdays_only'] ?? NULL; -$nextdue_relative=$_REQUEST['nextdue_relative'] ?? NULL; -$taskname=$_REQUEST['taskname'] ?? NULL; -$taskdesc=$_REQUEST['taskdesc'] ?? NULL; -$frequency=$_REQUEST['frequency'] ?? NULL; -$period=$_REQUEST['period'] ?? NULL; -$refdoc_name=$_REQUEST['refdoc_name'] ?? NULL; -$refdoc_url=$_REQUEST['refdoc_url'] ?? NULL; +$weekdays_only = $_REQUEST['weekdays_only'] ?? NULL; +$nextdue_relative = $_REQUEST['nextdue_relative'] ?? NULL; +$taskname = $_REQUEST['taskname'] ?? NULL; +$taskdesc = $_REQUEST['taskdesc'] ?? NULL; +$frequency = $_REQUEST['frequency'] ?? NULL; +$period = $_REQUEST['period'] ?? NULL; +$refdoc_name = $_REQUEST['refdoc_name'] ?? NULL; +$refdoc_url = $_REQUEST['refdoc_url'] ?? NULL; -$deferred_flag=$_REQUEST['deferred_flag'] ?? 0; -$deferred_date=$_REQUEST['deferred_date'] ?? NULL; -$start_date=$_REQUEST['start_date'] ?? NULL; -$last_date=$_REQUEST['last_date'] ?? NULL; -$task=$_REQUEST['task'] ?? NULL; -$device=$_REQUEST['device'] ?? NULL; -$deferuntil=$_REQUEST['deferuntil'] ?? NULL; -$completedate=$_REQUEST['completedate'] ?? NULL; -$addlognote=$_REQUEST['addlognote'] ?? NULL; +$deferred_flag = $_REQUEST['deferred_flag'] ?? 0; +$deferred_date = $_REQUEST['deferred_date'] ?? NULL; +$start_date = $_REQUEST['start_date'] ?? NULL; +$last_date = $_REQUEST['last_date'] ?? NULL; +$task = $_REQUEST['task'] ?? NULL; +$device = $_REQUEST['device'] ?? NULL; +$deferuntil = $_REQUEST['deferuntil'] ?? NULL; +$completedate = $_REQUEST['completedate'] ?? NULL; +$addlognote = $_REQUEST['addlognote'] ?? NULL; -$logname=LOG_NAME; +$logname = LOG_NAME; -$print=$_REQUEST['print'] ?? NULL; +$print = $_REQUEST['print'] ?? NULL; if ($print) { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } // **** BEGIN DATABASE OPERATIONS **** -$tomorrow=mysqli_fetch_row(mysqli_query($db,"select adddate((select current_date),1)"))[0]; -$errorstack=array(); +$tomorrow = mysqli_fetch_row(mysqli_query($db, "select adddate((select current_date),1)"))[0]; +$errorstack = array(); if ($action) { if ($complete) { // sanitize user input - $completedate=mysqli_real_escape_string($db,$completedate); + $completedate = mysqli_real_escape_string($db, $completedate); // update events - mysqli_query($db,"update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\""); + mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\""); if ($addlognote) { - $compltaskname=mysqli_fetch_row(mysqli_query($db,"select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0]; - $compldevicename=mysqli_fetch_row(mysqli_query($db,"select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0]; - $lognotestrg="Scheduled Maintenance task \"$compltaskname\" completed on device \"$compldevicename\"."; + $compltaskname = mysqli_fetch_row(mysqli_query($db, "select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0]; + $compldevicename = mysqli_fetch_row(mysqli_query($db, "select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0]; + $lognotestrg = "Scheduled Maintenance task \"$compltaskname\" completed on device \"$compldevicename\"."; // redirect to logentry header("Cache-Control:no-cache, must-revalidate"); header("Pragma:no-cache"); @@ -89,7 +89,7 @@ if ($action) { } if ($defer) { // update events - mysqli_query($db,"update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\""); + mysqli_query($db, "update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\""); } } if ($add) { @@ -97,41 +97,41 @@ if ($add) { // do error checking // check for task selected if ($task) { - $taskselected=true; + $taskselected = true; } else { - $taskselected=false; - $errorstack[]=" You didn't select a task.
"; + $taskselected = false; + $errorstack[] = " You didn't select a task.
"; } // check for device selected if ($device) { - $deviceselected=true; + $deviceselected = true; } else { - $deviceselected=false; - $errorstack[]=" You didn't select a device.
"; + $deviceselected = false; + $errorstack[] = " You didn't select a device.
"; } // sanitize text data - $start_date=mysqli_real_escape_string($db,$start_date); - $last_date=mysqli_real_escape_string($db,$last_date); - $deferred_date=mysqli_real_escape_string($db,$deferred_date); + $start_date = mysqli_real_escape_string($db, $start_date); + $last_date = mysqli_real_escape_string($db, $last_date); + $deferred_date = mysqli_real_escape_string($db, $deferred_date); if ($taskselected && $deviceselected) { // determine if device represents a group and break out individual devices - if (dblookup($db,"devices","deviceid","group_flag",$device)) { - $memberqry=mysqli_query($db,"select memberdevice from devicegroups where groupdevice=\"$device\""); - $memberlist=array(); - while ($memberrow=mysqli_fetch_row($memberqry)) { - $memberlist[]=$memberrow[0]; + if (dblookup($db, "devices", "deviceid", "group_flag", $device)) { + $memberqry = mysqli_query($db, "select memberdevice from devicegroups where groupdevice=\"$device\""); + $memberlist = array(); + while ($memberrow = mysqli_fetch_row($memberqry)) { + $memberlist[] = $memberrow[0]; } } else { - $memberlist=array($device); + $memberlist = array($device); } // run through the memberlist and modify the table foreach ($memberlist as $memberdev) { - if ($start_date==NULL) $start_date=$today; - if ($last_date==NULL) $last_date="0000-00-00"; - if ($deferred_date==NULL) $deferred_date="0000-00-00"; - $addqry=("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag) + if ($start_date == NULL) $start_date = $today; + if ($last_date == NULL) $last_date = "0000-00-00"; + if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + $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); + mysqli_query($db, $addqry); } } } @@ -139,54 +139,54 @@ if ($add) { // do error checking // test for name supplied if (strlen(trim($taskname))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Task name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Task name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\""))) { - $nameunique=false; - $errorstack[]=" Task name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\""))) { + $nameunique = false; + $errorstack[] = " Task name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } // sanitize text data - $taskname=mysqli_real_escape_string($db,$taskname); - $taskdesc=mysqli_real_escape_string($db,$taskdesc); - $refdoc_name=mysqli_real_escape_string($db,$refdoc_name); - $refdoc_url=mysqli_real_escape_string($db,$refdoc_url); - + $taskname = mysqli_real_escape_string($db, $taskname); + $taskdesc = mysqli_real_escape_string($db, $taskdesc); + $refdoc_name = mysqli_real_escape_string($db, $refdoc_name); + $refdoc_url = mysqli_real_escape_string($db, $refdoc_url); + if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into tasks(taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag) + $addqry = ("insert into tasks(taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag) values(\"$taskname\",\"$taskdesc\",\"$frequency\",\"$period\",\"$weekdays_only\",\"$nextdue_relative\",\"$refdoc_name\",\"$refdoc_url\",\"$active_flag\")"); - mysqli_query($db,$addqry); + mysqli_query($db, $addqry); } } if ($devices) { // do error checking // test for name supplied if (strlen(trim($devicename))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Device name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Device name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\""))) { - $nameunique=false; - $errorstack[]=" Device name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\""))) { + $nameunique = false; + $errorstack[] = " Device name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } // sanitize name and description - $devicename=mysqli_real_escape_string($db,$devicename); - $devicedesc=mysqli_real_escape_string($db,$devicedesc); + $devicename = mysqli_real_escape_string($db, $devicename); + $devicedesc = mysqli_real_escape_string($db, $devicedesc); if ($namesuppld && $nameunique) { // modify the table - $addqry=("insert into devices(devicename,devicedesc,group_flag,active_flag) values(\"$devicename\",\"$devicedesc\",\"$group_flag\",\"$active_flag\")"); - mysqli_query($db,$addqry); + $addqry = ("insert into devices(devicename,devicedesc,group_flag,active_flag) values(\"$devicename\",\"$devicedesc\",\"$group_flag\",\"$active_flag\")"); + mysqli_query($db, $addqry); } } } @@ -194,19 +194,19 @@ if ($edit) { if ($schedule) { if ($delete) { // delete entity - mysqli_query($db,"delete from events where eventid=\"$id\""); + mysqli_query($db, "delete from events where eventid=\"$id\""); } if ($update) { // do error checking // sanitize text data - $start_date=mysqli_real_escape_string($db,$start_date); - $last_date=mysqli_real_escape_string($db,$last_date); - $deferred_date=mysqli_real_escape_string($db,$deferred_date); + $start_date = mysqli_real_escape_string($db, $start_date); + $last_date = mysqli_real_escape_string($db, $last_date); + $deferred_date = mysqli_real_escape_string($db, $deferred_date); // update the tasks table - if ($start_date==NULL) $start_date=$today; - if ($last_date==NULL) $last_date="0000-00-00"; - if ($deferred_date==NULL) $deferred_date="0000-00-00"; - mysqli_query($db,"update events + if ($start_date == NULL) $start_date = $today; + if ($last_date == NULL) $last_date = "0000-00-00"; + if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + mysqli_query($db, "update events set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\", deferred_date=\"$deferred_date\",active_flag=\"$active_flag\" where eventid=\"$id\""); @@ -215,45 +215,45 @@ if ($edit) { if ($tasks) { if ($delete) { // check for scheduled maintenance for this entity - if (mysqli_num_rows(mysqli_query($db,"select eventid from events where task=\"$id\""))) { - $hasevents=true; - $errorstack[]=" Task has been scheduled maintenance and cannot be deleted.
"; + if (mysqli_num_rows(mysqli_query($db, "select eventid from events where task=\"$id\""))) { + $hasevents = true; + $errorstack[] = " Task has been scheduled maintenance and cannot be deleted.
"; } else { - $hasevents=false; + $hasevents = false; } if (!$hasevents) { // delete entity - mysqli_query($db,"delete from tasks where taskid=\"$id\""); + mysqli_query($db, "delete from tasks where taskid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($taskname))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Task name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Task name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\" and taskid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select taskid from tasks where taskname=\"$taskname\""))) { - $nameunique=false; - $errorstack[]=" Task name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\" and taskid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select taskid from tasks where taskname=\"$taskname\""))) { + $nameunique = false; + $errorstack[] = " Task name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } } else { - $nameunique=true; + $nameunique = true; } // sanitize text data - $taskname=mysqli_real_escape_string($db,$taskname); - $taskdesc=mysqli_real_escape_string($db,$taskdesc); - $refdoc_name=mysqli_real_escape_string($db,$refdoc_name); - $refdoc_url=mysqli_real_escape_string($db,$refdoc_url); + $taskname = mysqli_real_escape_string($db, $taskname); + $taskdesc = mysqli_real_escape_string($db, $taskdesc); + $refdoc_name = mysqli_real_escape_string($db, $refdoc_name); + $refdoc_url = mysqli_real_escape_string($db, $refdoc_url); if ($namesuppld && $nameunique) { // update the tasks table - mysqli_query($db,"update tasks + mysqli_query($db, "update tasks set taskname=\"$taskname\",taskdesc=\"$taskdesc\",frequency=\"$frequency\",period=\"$period\",weekdays_only=\"$weekdays_only\", nextdue_relative=\"$nextdue_relative\",refdoc_name=\"$refdoc_name\",refdoc_url=\"$refdoc_url\",active_flag=\"$active_flag\" where taskid=\"$id\""); @@ -263,48 +263,48 @@ if ($edit) { if ($devices) { if ($delete) { // check for scheduled maintenance for this device - if (mysqli_num_rows(mysqli_query($db,"select eventid from events where device=\"$id\""))) { - $hasevents=true; - $errorstack[]=" Device has scheduled maintenance and cannot be deleted.
"; + if (mysqli_num_rows(mysqli_query($db, "select eventid from events where device=\"$id\""))) { + $hasevents = true; + $errorstack[] = " Device has scheduled maintenance and cannot be deleted.
"; } else { - $hasevents=false; + $hasevents = false; } if (!$hasevents) { // delete entity - mysqli_query($db,"delete from devices where deviceid=\"$id\""); + mysqli_query($db, "delete from devices where deviceid=\"$id\""); } } if ($update) { // do error checking // test for name supplied if (strlen(trim($devicename))) { - $namesuppld=true; + $namesuppld = true; } else { - $namesuppld=false; - $errorstack[]=" Device name cannot be blank.
"; + $namesuppld = false; + $errorstack[] = " Device name cannot be blank.
"; } // test for name unique - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\" and deviceid!=\"$id\""))) { - if (mysqli_num_rows(mysqli_query($db,"select deviceid from devices where devicename=\"$devicename\""))) { - $nameunique=false; - $errorstack[]=" Device name already exists.
"; + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\" and deviceid!=\"$id\""))) { + if (mysqli_num_rows(mysqli_query($db, "select deviceid from devices where devicename=\"$devicename\""))) { + $nameunique = false; + $errorstack[] = " Device name already exists.
"; } else { - $nameunique=true; + $nameunique = true; } } else { - $nameunique=true; + $nameunique = true; } // sanitize name and description - $devicename=mysqli_real_escape_string($db,$devicename); - $devicedesc=mysqli_real_escape_string($db,$devicedesc); + $devicename = mysqli_real_escape_string($db, $devicename); + $devicedesc = mysqli_real_escape_string($db, $devicedesc); if ($namesuppld && $nameunique) { // update the devices table - mysqli_query($db,"update devices set devicename=\"$devicename\",devicedesc=\"$devicedesc\",group_flag=\"$group_flag\",active_flag=\"$active_flag\" where deviceid=\"$id\""); + mysqli_query($db, "update devices set devicename=\"$devicename\",devicedesc=\"$devicedesc\",group_flag=\"$group_flag\",active_flag=\"$active_flag\" where deviceid=\"$id\""); // update the devicegroups table - mysqli_query($db,"delete from devicegroups where groupdevice=\"$id\""); + mysqli_query($db, "delete from devicegroups where groupdevice=\"$id\""); if ($group_flag) { foreach ($members as $member) { - mysqli_query($db,"insert into devicegroups(groupdevice,memberdevice) values(\"$id\",\"$member\")"); + mysqli_query($db, "insert into devicegroups(groupdevice,memberdevice) values(\"$id\",\"$member\")"); } } } @@ -314,17 +314,17 @@ if ($edit) { // **** END DATABASE OPERATIONS **** -framework("begin","$logname","Scheduled Maintenance",$print); +framework("begin", "$logname", "Scheduled Maintenance", $print); //var_dump($_REQUEST); pagetable("begin"); -pageblock("left","begin"); +pageblock("left", "begin"); sidemenu(); -pageblock("left","end"); +pageblock("left", "end"); -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); if ($loggedin) { echo " @@ -340,17 +340,17 @@ if ($loggedin) { } // display any errors from database operations if (count($errorstack)) { - foreach($errorstack as $errorline) { + foreach ($errorstack as $errorline) { echo "$errorline
"; } } if ($action) { // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from events where eventid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from events where eventid=$id")); extract($currentvalues); - $taskname=dblookup($db,"tasks","taskid","taskname",$task); - $devicename=dblookup($db,"devices","deviceid","devicename",$device); + $taskname = dblookup($db, "tasks", "taskid", "taskname", $task); + $devicename = dblookup($db, "devices", "deviceid", "devicename", $device); // display form to complete or defer echo "
Task :   $taskname Device :   $devicename
@@ -383,46 +383,46 @@ if ($action) { // manage maintenance schedule if ($edit) { // set form options for editing - $sectiontitle="Modify Event

"; - $formtag="
"; - $buttontags=" + $sectiontitle = "Modify Event

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from events where eventid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from events where eventid=$id")); extract($currentvalues); if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } if ($deferred_flag) { - $deferredtag=""; + $deferredtag = ""; } else { - $deferredtag=""; + $deferredtag = ""; } - if ($start_date=="0000-00-00") $start_date=$today; - if ($last_date=="0000-00-00") $last_date=""; - if ($deferred_date=="0000-00-00") $deferred_date=$tomorrow; - $deferuntiltag=""; - $startdatetag=""; - $lastdatetag=""; + if ($start_date == "0000-00-00") $start_date = $today; + if ($last_date == "0000-00-00") $last_date = ""; + if ($deferred_date == "0000-00-00") $deferred_date = $tomorrow; + $deferuntiltag = ""; + $startdatetag = ""; + $lastdatetag = ""; } else { // set form options for add - $sectiontitle="Add Scheduled Maintenance

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Add Scheduled Maintenance

"; + $formtag = ""; + $buttontags = " "; // set default values - $deferredtag=""; - $deferuntiltag=""; - $activetag=""; - $startdatetag=""; - $lastdatetag=""; + $deferredtag = ""; + $deferuntiltag = ""; + $activetag = ""; + $startdatetag = ""; + $lastdatetag = ""; } // display form echo " @@ -434,13 +434,13 @@ if ($action) {
Task:  Device:   "; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); - if ($start_date=="0000-00-00") $start_date=$today; - if ($last_date=="0000-00-00") $last_date=""; - if ($deferred_date=="0000-00-00") $deferred_date=""; + if ($start_date == "0000-00-00") $start_date = $today; + if ($last_date == "0000-00-00") $last_date = ""; + if ($deferred_date == "0000-00-00") $deferred_date = ""; if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } if ($deferred_flag) { - $deferredflag="\"deferred\""; + $deferredflag = "\"deferred\""; } else { - $deferredflag="\"not"; + $deferredflag = "\"not"; } - $taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$task\"")); - extract($taskdata,EXTR_PREFIX_ALL,"taskdata"); - $devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$device\"")); - extract($devicedata,EXTR_PREFIX_ALL,"devicedata"); - if ($taskdata_period=="once") { - $tasktitle="One-time event"; + $taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$task\"")); + extract($taskdata, EXTR_PREFIX_ALL, "taskdata"); + $devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$device\"")); + extract($devicedata, EXTR_PREFIX_ALL, "devicedata"); + if ($taskdata_period == "once") { + $tasktitle = "One-time event"; } else { - $tasktitle="Repeat every $taskdata_frequency $taskdata_period"; + $tasktitle = "Repeat every $taskdata_frequency $taskdata_period"; } - printf(" + printf( + " @@ -520,60 +521,63 @@ if ($action) { ", - $eventid,$eventid, - $tasktitle,$taskdata_taskname, - $devicedata_devicename, - $start_date, - $last_date, - $deferredflag, - $deferred_date, - $statdef); + $eventid, + $eventid, + $tasktitle, + $taskdata_taskname, + $devicedata_devicename, + $start_date, + $last_date, + $deferredflag, + $deferred_date, + $statdef + ); } echo "
Event IDTaskDeviceStart DateLast
Completed
DeferredDeferred
Until
Active
%s %s%s %s
"; } else if ($tasks) { // manage tasks if ($edit) { // set form options for editing - $sectiontitle="Modify Task

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Task

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=$id")); extract($currentvalues); - $perioddef=$period; + $perioddef = $period; if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } if ($weekdays_only) { - $wdotag=""; + $wdotag = ""; } else { - $wdotag=""; + $wdotag = ""; } if ($nextdue_relative) { - $nextduetag="Absolute   Relative"; + $nextduetag = "Absolute   Relative"; } else { - $nextduetag="Absolute   Relative"; + $nextduetag = "Absolute   Relative"; } } else { // set form options for add - $sectiontitle="Add New Task

"; - $formtag=""; - $perioddef="once"; - $frequency=1; - $buttontags=" + $sectiontitle = "Add New Task

"; + $formtag = ""; + $perioddef = "once"; + $frequency = 1; + $buttontags = " "; // set default values - $wdotag=""; - $nextduetag="Absolute   Relative"; - $activetag=""; + $wdotag = ""; + $nextduetag = "Absolute   Relative"; + $activetag = ""; } // display form echo " @@ -590,10 +594,10 @@ if ($action) { Repeat every:     "; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - if ($period=="once") { - $rptstrg="one time only"; + if ($period == "once") { + $rptstrg = "one time only"; } else { - $rptstrg="$frequency $period"; + $rptstrg = "$frequency $period"; } - + if ($nextdue_relative) { - $duecalc="Relative"; + $duecalc = "Relative"; } else { - $duecalc="Absolute"; + $duecalc = "Absolute"; } if ($refdoc_name) { - $refstrg="$refdoc_name"; + $refstrg = "$refdoc_name"; if ($refdoc_url) { - $refstrg="$refdoc_name"; + $refstrg = "$refdoc_name"; } } else { - $refstrg=""; + $refstrg = ""; } if ($weekdays_only) { - $wdoflag="\"active\""; + $wdoflag = "\"active\""; } else { - $wdoflag="\"inactive\""; + $wdoflag = "\"inactive\""; } - printf(" + printf( + " @@ -660,54 +665,55 @@ if ($action) { ", - $taskid,$taskname, - $taskdesc, - $rptstrg, - $duecalc, - $wdoflag, - $refstrg, - $statdef); + $taskid, + $taskname, + $taskdesc, + $rptstrg, + $duecalc, + $wdoflag, + $refstrg, + $statdef + ); } echo "
Task NameTask DescriptionRepeat EveryDue Date
Calculation
Weekdays
Only
ReferenceActive
%s %s%s %s
"; - } else if ($devices) { // manage devices if ($edit) { // set form options for editing - $sectiontitle="Modify Device

"; - $formtag=""; - $buttontags=" + $sectiontitle = "Modify Device

"; + $formtag = ""; + $buttontags = "          
"; // pull current values from database - $currentvalues=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=$id")); + $currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=$id")); extract($currentvalues); if ($group_flag) { - $showgrouptable=true; - $grouptag=""; + $showgrouptable = true; + $grouptag = ""; } else { - $showgrouptable=false; - $grouptag=""; + $showgrouptable = false; + $grouptag = ""; } if ($active_flag) { - $activetag=""; + $activetag = ""; } else { - $activetag=""; + $activetag = ""; } } else { // set form options for add - $sectiontitle="Add New Device

"; - $formtag=""; - $showgrouptable=false; - $buttontags=" + $sectiontitle = "Add New Device

"; + $formtag = ""; + $showgrouptable = false; + $buttontags = " "; // set default values - $activetag=""; - $grouptag=""; + $activetag = ""; + $grouptag = ""; } // display form echo " @@ -722,28 +728,30 @@ if ($action) { Device represents a group of devices:  $grouptag

"; if ($showgrouptable) { - $existingdevs=mysqli_query($db,"select * from devices where deviceid!=$id and active_flag=\"1\""); + $existingdevs = mysqli_query($db, "select * from devices where deviceid!=$id and active_flag=\"1\""); echo " Existing members of this group

"; - while ($grouprow=mysqli_fetch_assoc($existingdevs)) { - extract($grouprow,EXTR_PREFIX_ALL,"gtbl"); - if (mysqli_num_rows(mysqli_query($db,"select groupid from devicegroups where memberdevice=$gtbl_deviceid and groupdevice=$id"))) { - $memberdef=""; + while ($grouprow = mysqli_fetch_assoc($existingdevs)) { + extract($grouprow, EXTR_PREFIX_ALL, "gtbl"); + if (mysqli_num_rows(mysqli_query($db, "select groupid from devicegroups where memberdevice=$gtbl_deviceid and groupdevice=$id"))) { + $memberdef = ""; } else { - $memberdef=""; + $memberdef = ""; } - printf(" + printf( + " ", - $gtbl_devicename, - $gtbl_devicedesc, - $memberdef); + $gtbl_devicename, + $gtbl_devicedesc, + $memberdef + ); } echo "
Device NameDevice DescriptionMember
%s %s %s

"; } @@ -756,25 +764,26 @@ if ($action) {

"; // show table of current devices - $existingdata=mysqli_query($db,"select * from devices"); + $existingdata = mysqli_query($db, "select * from devices"); echo " Existing Devices   Click on the Device ID to edit.

"; - while ($tablerow=mysqli_fetch_assoc($existingdata)) { + while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); if ($group_flag) { - $groupdef="\"This"; + $groupdef = "\"This"; } else { - $groupdef="\"This"; + $groupdef = "\"This"; } if ($active_flag) { - $statdef="\"active\""; + $statdef = "\"active\""; } else { - $statdef="\"inactive\""; + $statdef = "\"inactive\""; } - printf(" + printf( + " @@ -782,20 +791,25 @@ if ($action) { ", - $deviceid,$deviceid, - $devicename, - $devicedesc, - $groupdef, - $statdef); + $deviceid, + $deviceid, + $devicename, + $devicedesc, + $groupdef, + $statdef + ); } echo "
Device IDDevice NameDevice DescriptionGroupActive
%s %s%s %s
"; } else { - $ucevents=get_upcoming_events(); - + $ucevents = get_upcoming_events(); + // sort the upcoming events - function uc_cmp($a,$b) { return strcmp($a["duedate"], $b["duedate"]); } - uasort($ucevents,'uc_cmp'); - + function uc_cmp($a, $b) + { + return strcmp($a["duedate"], $b["duedate"]); + } + uasort($ucevents, 'uc_cmp'); + // show upcoming events table echo " Upcoming Scheduled Maintenance

@@ -806,55 +820,59 @@ if ($action) { "; foreach ($ucevents as $ucline) { extract($ucline); - printf(" + printf( + "
%s %s %s %s



"; - + // build array of deferred events - $defeventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and deferred_flag=\"1\" and deferred_date > \"$today\" order by deferred_date asc"); - $defevents=array(); - while ($defeventrow=mysqli_fetch_assoc($defeventsqry)) { + $defeventsqry = mysqli_query($db, "select * from events where active_flag=\"1\" and deferred_flag=\"1\" and deferred_date > \"$today\" order by deferred_date asc"); + $defevents = array(); + while ($defeventrow = mysqli_fetch_assoc($defeventsqry)) { // provide eventid,task,device,start_date,last_date,deferred_flag,deferred_date,active_flag - extract($defeventrow,EXTR_PREFIX_ALL,"def"); + extract($defeventrow, EXTR_PREFIX_ALL, "def"); // provide deviceid,devicename,devicedesc,group_flag,active_flag - $devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$def_device\"")); - extract($devicedata,EXTR_PREFIX_ALL,"devicedata"); + $devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$def_device\"")); + extract($devicedata, EXTR_PREFIX_ALL, "devicedata"); // provide taskid,taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag - $taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$def_task\"")); - extract($taskdata,EXTR_PREFIX_ALL,"taskdata"); - if ( ! ($taskdata_period == "once" && $def_last_date > $def_start_date)) { - if ($def_last_date=="0000-00-00") { - $lastdatestrg="never"; + $taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$def_task\"")); + extract($taskdata, EXTR_PREFIX_ALL, "taskdata"); + if (! ($taskdata_period == "once" && $def_last_date > $def_start_date)) { + if ($def_last_date == "0000-00-00") { + $lastdatestrg = "never"; } else { - $lastdatestrg="$def_last_date"; + $lastdatestrg = "$def_last_date"; } - $defeventline=array( - 'def_eventid'=>$def_eventid, - 'def_deferred_date'=>$def_deferred_date, - 'devicedata_devicedesc'=>$devicedata_devicedesc, - 'devicedata_devicename'=>$devicedata_devicename, - 'taskdata_taskdesc'=>$taskdata_taskdesc, - 'taskdata_taskname'=>$taskdata_taskname, - 'lastdatestrg'=>$lastdatestrg + $defeventline = array( + 'def_eventid' => $def_eventid, + 'def_deferred_date' => $def_deferred_date, + 'devicedata_devicedesc' => $devicedata_devicedesc, + 'devicedata_devicename' => $devicedata_devicename, + 'taskdata_taskdesc' => $taskdata_taskdesc, + 'taskdata_taskname' => $taskdata_taskname, + 'lastdatestrg' => $lastdatestrg ); - $defevents[]=$defeventline; + $defevents[] = $defeventline; } } - + // show deferred events table echo " Deferred Scheduled Maintenance

@@ -865,17 +883,21 @@ if ($action) { "; foreach ($defevents as $defline) { extract($defline); - printf(" + printf( + "
%s %s %s %s
"; while ($logtablerow = mysqli_fetch_assoc($logrowqry)) { - $logrefs="    \"Add"; + $logrefs = "    \"Add"; if (islink($logtablerow['lognoteid'])) { - $logrefs=$logrefs."      \"View"; + $logrefs = $logrefs . "      \"View"; } // convert the shift number to a name - $logshname=dblookup($db,"shifts","shiftid","shiftname",$logtablerow['shift']); + $logshname = dblookup($db, "shifts", "shiftid", "shiftname", $logtablerow['shift']); // convert tech number to name - $logtname=dblookup($db,"techs","techid","techname",$logtablerow['tech']); + $logtname = dblookup($db, "techs", "techid", "techname", $logtablerow['tech']); //convert subject number to name - $logsubjname=dblookup($db,"subjects","subjectid","subjectname",$logtablerow['subject']); + $logsubjname = dblookup($db, "subjects", "subjectid", "subjectname", $logtablerow['subject']); // create links of urls in note - $logfmtnote=convertweblinks($logtablerow['lognote']); - + $logfmtnote = convertweblinks($logtablerow['lognote']); + // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$logtablerow[lognoteid]"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$logtablerow[lognoteid]"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $logfmtnote=$logfmtnote."
".$flagstring."     "; - } else { - $logfmtnote=$logfmtnote."
"; + $logfmtnote = $logfmtnote . "
" . $flagstring . "     "; + } else { + $logfmtnote = $logfmtnote . "
"; } - - printf(" + + printf( + " @@ -720,24 +741,27 @@ if ($search) { ", - $logtablerow['lognoteid'],$logtablerow['lognoteid'], - $logtablerow['date'],$logtablerow['time'], - $logshname, - $logtname, - $logsubjname, - $logfmtnote, - $logrefs); + $logtablerow['lognoteid'], + $logtablerow['lognoteid'], + $logtablerow['date'], + $logtablerow['time'], + $logshname, + $logtname, + $logsubjname, + $logfmtnote, + $logrefs + ); } echo "
Note IDDate/TimeShiftTechSubjectNoteReferences
%s %s / %s %s%s %s


"; } else { echo "No Logbook notes match your search criteria.

"; } } - if ($target[0]=="") $target=[]; - if (in_array("maintform",$target)) { + if ($target[0] == "") $target = []; + if (in_array("maintform", $target)) { // run maintforms query and show results - $mf_num_results=mysqli_num_rows($mfrowqry); - if($mf_num_results) { + $mf_num_results = mysqli_num_rows($mfrowqry); + if ($mf_num_results) { echo " Results from Maintenance Forms: $mf_num_results


@@ -754,25 +778,25 @@ if ($search) { "; while ($mfrow = mysqli_fetch_assoc($mfrowqry)) { // look up part data - $mfuid=dblookup($db,"parts","partid","uid",$mfrow["mfpart"]); - if ($mfuid=="") $mfuid=" "; - $mfpartno=dblookup($db,"parts","partid","partnum",$mfrow["mfpart"]); - if ($mfpartno=="") $mfpartno=" "; - $mfserno=dblookup($db,"parts","partid","sernum",$mfrow["mfpart"]); - if ($mfserno=="") $mfserno=" "; - $mfpartname=dblookup($db,"parts","partid","partname",$mfrow["mfpart"]); - if ($mfpartname=="") $mfpartname=" "; + $mfuid = dblookup($db, "parts", "partid", "uid", $mfrow["mfpart"]); + if ($mfuid == "") $mfuid = " "; + $mfpartno = dblookup($db, "parts", "partid", "partnum", $mfrow["mfpart"]); + if ($mfpartno == "") $mfpartno = " "; + $mfserno = dblookup($db, "parts", "partid", "sernum", $mfrow["mfpart"]); + if ($mfserno == "") $mfserno = " "; + $mfpartname = dblookup($db, "parts", "partid", "partname", $mfrow["mfpart"]); + if ($mfpartname == "") $mfpartname = " "; // look up tech name - $mftname=dblookup($db,"techs","techid","techname",$mfrow["mftech"]); - if ($mfrow["lognoteid"]==0) { - $mfnoteidval=" "; - $mfnotetag="%s%s"; + $mftname = dblookup($db, "techs", "techid", "techname", $mfrow["mftech"]); + if ($mfrow["lognoteid"] == 0) { + $mfnoteidval = " "; + $mfnotetag = "%s%s"; } else { - $mfnoteidval=$mfrow["lognoteid"]; - $mfnotetag="%s"; + $mfnoteidval = $mfrow["lognoteid"]; + $mfnotetag = "%s"; } printf( - " + " @@ -782,14 +806,16 @@ if ($search) { ", - $mfrow["maintformid"],$mfrow["maintformid"], - $mfrow["mfdate"], - $mftname, - $mfuid, - $mfpartno, - $mfserno, - $mfpartname, - $mfnoteidval,$mfnoteidval + $mfrow["maintformid"], + $mfrow["maintformid"], + $mfrow["mfdate"], + $mftname, + $mfuid, + $mfpartno, + $mfserno, + $mfpartname, + $mfnoteidval, + $mfnoteidval ); } echo "
%s %s %s%s $mfnotetag


"; @@ -797,11 +823,11 @@ if ($search) { echo "No Maintenance Forms match your search criteria.

"; } } - if ($target[0]=="") $target=[]; - if (in_array("part",$target)) { + if ($target[0] == "") $target = []; + if (in_array("part", $target)) { // run parts query and show results - $p_num_results=mysqli_num_rows($prowqry); - if($p_num_results) { + $p_num_results = mysqli_num_rows($prowqry); + if ($p_num_results) { echo " Results from Parts: $p_num_results

@@ -813,9 +839,10 @@ if ($search) { "; - while ($partrow=mysqli_fetch_assoc($prowqry)) { + while ($partrow = mysqli_fetch_assoc($prowqry)) { if ($loggedin) { - printf(" + printf( + " ", - $partrow['partid'], - $partrow['uid'], - $partrow['partnum'], - $partrow['sernum'], - $partrow['partname'] + $partrow['partid'], + $partrow['uid'], + $partrow['partnum'], + $partrow['sernum'], + $partrow['partname'] ); } else { - printf(" + printf( + " ", - $partrow['uid'], - $partrow['partnum'], - $partrow['sernum'], - $partrow['partname'] + $partrow['uid'], + $partrow['partnum'], + $partrow['sernum'], + $partrow['partname'] ); } echo " @@ -860,9 +888,7 @@ if ($search) { } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/distfiles/settings.php b/distfiles/settings.php index cebd1a0..7a3b616 100644 --- a/distfiles/settings.php +++ b/distfiles/settings.php @@ -11,55 +11,53 @@ $today = date("Y-m-d"); $now = date("H:i:s"); -$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0]; -$ostype=strtoupper(substr(php_uname('s'), 0, 3)); +$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0]; +$ostype = strtoupper(substr(php_uname('s'), 0, 3)); if ($ostype == 'WIN') { - $sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0]; + $sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0]; } else { - $sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; + $sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0]; } -$lifetime=60 * 60 * 24 * $sttl; +$lifetime = 60 * 60 * 24 * $sttl; if (!is_dir($sdir)) mkdir($sdir, 0700, true); ini_set('session.cookie_lifetime', $lifetime); ini_set('session.gc_maxlifetime', $lifetime); ini_set('session.save_path', $sdir); -$ss=session_status(); -if ($ss==PHP_SESSION_NONE) session_start(); +$ss = session_status(); +if ($ss == PHP_SESSION_NONE) session_start(); // get config options from database and assign them to constants unset($techid); if (isset($_SESSION['login']) && $_SESSION['login'] != '') { - $techid=$_SESSION['login']; + $techid = $_SESSION['login']; } -$configqry=mysqli_query($db,"select confname,confvalue,confid from configs"); +$configqry = mysqli_query($db, "select confname,confvalue,confid from configs"); while ($configrow = mysqli_fetch_assoc($configqry)) { - $constname=strtoupper($configrow["confname"]); + $constname = strtoupper($configrow["confname"]); if (isset($techid)) { - $confid=$configrow["confid"]; - $custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\""); + $confid = $configrow["confid"]; + $custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\""); if (mysqli_num_rows($custqry)) { - $custrow=mysqli_fetch_row($custqry); - $custval=$custrow[0]; + $custrow = mysqli_fetch_row($custqry); + $custval = $custrow[0]; } else { unset($custval); } } if (isset($custval)) { - $constvalue=$custval; + $constvalue = $custval; } else { - $constvalue=$configrow["confvalue"]; + $constvalue = $configrow["confvalue"]; } - define("$constname","$constvalue"); + define("$constname", "$constvalue"); } // error reporting -$logerrors=LOG_ERRORS; -if ($logerrors==1) { +$logerrors = LOG_ERRORS; +if ($logerrors == 1) { error_reporting(E_ALL); } else { error_reporting(0); } - -?> diff --git a/distfiles/templates.php b/distfiles/templates.php index 74a691c..8282715 100644 --- a/distfiles/templates.php +++ b/distfiles/templates.php @@ -10,72 +10,73 @@ include("functions.php"); if (!$_SESSION['login'] && !$_REQUEST['partview']) { - header ("Location: login.php"); + header("Location: login.php"); } -$techid=$_SESSION['login'] ?? NULL; -$isadmin=dblookup($db,"techs","techid","admin",$techid); -$print=$_REQUEST['print'] ?? NULL; -$efftechid=$_REQUEST['efftechid'] ?? NULL; -$shift=$_REQUEST['shift'] ?? NULL; -$subject=$_REQUEST['subject'] ?? NULL; -$note=$_REQUEST['note'] ?? NULL; -$flags=$_POST['flags'] ?? []; -$refstring=$_REQUEST['refstring'] ?? NULL; -$submit=$_REQUEST['submit'] ?? NULL; -$operation=$_REQUEST['operation'] ?? NULL; -$templateid=$_REQUEST['templateid'] ?? NULL; -$templatename=$_REQUEST['templatename'] ?? NULL; -$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL; -$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL; -$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL; +$techid = $_SESSION['login'] ?? NULL; +$isadmin = dblookup($db, "techs", "techid", "admin", $techid); +$print = $_REQUEST['print'] ?? NULL; +$efftechid = $_REQUEST['efftechid'] ?? NULL; +$shift = $_REQUEST['shift'] ?? NULL; +$subject = $_REQUEST['subject'] ?? NULL; +$note = $_REQUEST['note'] ?? NULL; +$flags = $_POST['flags'] ?? []; +$refstring = $_REQUEST['refstring'] ?? NULL; +$submit = $_REQUEST['submit'] ?? NULL; +$operation = $_REQUEST['operation'] ?? NULL; +$templateid = $_REQUEST['templateid'] ?? NULL; +$templatename = $_REQUEST['templatename'] ?? NULL; +$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL; +$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL; +$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL; -$logname=LOG_NAME; -$techalpha=TECH_ALPHA; -$subjalpha=SUBJ_ALPHA; +$logname = LOG_NAME; +$techalpha = TECH_ALPHA; +$subjalpha = SUBJ_ALPHA; -$defaultshift=dblookup($db,"techs","techid","shift",$techid); +$defaultshift = dblookup($db, "techs", "techid", "shift", $techid); -if ($print=="Printer Friendly") { - $sbcolor=P_SIDEBAR_COLOR; - $mbgcolor=P_MENUBG_COLOR; +if ($print == "Printer Friendly") { + $sbcolor = P_SIDEBAR_COLOR; + $mbgcolor = P_MENUBG_COLOR; } else { - $sbcolor=SIDEBAR_COLOR; - $mbgcolor=MENUBG_COLOR; + $sbcolor = SIDEBAR_COLOR; + $mbgcolor = MENUBG_COLOR; } -framework("begin","$logname","Note Templates",$print); +framework("begin", "$logname", "Note Templates", $print); // make basic determination about authorization if ($isadmin) { - $authorized=TRUE; -} else if ($efftechid==$techid) { - $authorized=TRUE; + $authorized = TRUE; +} else if ($efftechid == $techid) { + $authorized = TRUE; } else { - $authorized=FALSE; + $authorized = FALSE; } // var_dump($_REQUEST); -function templatetable($db,$techid,$user) { +function templatetable($db, $techid, $user) +{ // Show template table - $isadmin=dblookup($db,"techs","techid","admin",$techid); - $templatequery=mysqli_query($db,"select * from notetemplates where tech=\"$user\" order by templatename asc"); - $tblusername=dblookup($db,"techs","techid","techname",$user); + $isadmin = dblookup($db, "techs", "techid", "admin", $techid); + $templatequery = mysqli_query($db, "select * from notetemplates where tech=\"$user\" order by templatename asc"); + $tblusername = dblookup($db, "techs", "techid", "techname", $user); if (mysqli_num_rows($templatequery)) { - $hastemplates=TRUE; + $hastemplates = TRUE; } else { - $hastemplates=FALSE; + $hastemplates = FALSE; } - + echo ""; if ($hastemplates) { // print the user header - if ($user=="0") { + if ($user == "0") { echo "Global Templates"; } else { - if ($user==$techid) { + if ($user == $techid) { echo "My templates"; } else { echo "Templates for $tblusername"; @@ -85,62 +86,62 @@ function templatetable($db,$techid,$user) { echo "
Part Name
\"Edit @@ -824,14 +851,15 @@ if ($search) { %s %s %s
\"You @@ -840,10 +868,10 @@ if ($search) { %s %s %s
"; echo ""; while ($tablerow = mysqli_fetch_assoc($templatequery)) { - $templateid=$tablerow["templateid"]; - $templatename=$tablerow["templatename"]; + $templateid = $tablerow["templateid"]; + $templatename = $tablerow["templatename"]; // convert shift number to name - $shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + $shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]); // convert subject number to name - $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + $subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]); // create links of urls in note - $fmtnote=convertweblinks($tablerow["lognote"]); + $fmtnote = convertweblinks($tablerow["lognote"]); // generate the flags string - $flagstring=""; - $flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid"); - while ($flagid=mysqli_fetch_row($flagqry)) { - $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); - $flagcolor=$flagparams["flagcolor"]; - $flagsym=$flagparams["flagsym"]; - $flagname=$flagparams["flagname"]; - $flagstring=$flagstring."$flagsym  "; + $flagstring = ""; + $flagqry = mysqli_query($db, "select flagid from flagmap where notetemplateid=$templateid"); + while ($flagid = mysqli_fetch_row($flagqry)) { + $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor = $flagparams["flagcolor"]; + $flagsym = $flagparams["flagsym"]; + $flagname = $flagparams["flagname"]; + $flagstring = $flagstring . "$flagsym  "; } if ($flagstring) { - $fmtnote=$fmtnote."
".$flagstring."     "; - } else { - $fmtnote=$fmtnote."
"; + $fmtnote = $fmtnote . "
" . $flagstring . "     "; + } else { + $fmtnote = $fmtnote . "
"; } // generate a reference string - $refstring=NULL; - $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); - while ($tgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$tgt[0]; + $refstring = NULL; + $refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\""); + while ($tgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $tgt[0]; } // now print the line in the table - if (!$isadmin && $user=="0") { - $nameblock="$templatename"; + if (!$isadmin && $user == "0") { + $nameblock = "$templatename"; } else { - $nameblock="$templatename"; + $nameblock = "$templatename"; } printf( - " + "\n", - $nameblock, - $shiftname, - $subjname, - $fmtnote, - $refstring + $nameblock, + $shiftname, + $subjname, + $fmtnote, + $refstring ); }; echo "
Template NameShiftSubjectNoteReferences
%s %s %s %s %s



"; } else { - if ($user=="0") { + if ($user == "0") { echo "There are no global templates"; } else { - if ($user==$techid) { + if ($user == $techid) { echo "You have no templates"; } else { echo "$tblusername has no templates"; @@ -154,108 +155,108 @@ function templatetable($db,$techid,$user) { // ******** begin database manipulation ******** if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $loadtemplate=NULL; + $loadtemplate = NULL; } -if ($operation=="add") { - if ($submit) { +if ($operation == "add") { + if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + if ($authorized) { // check if name supplied if ($templatename) { - $namesupplied=TRUE; + $namesupplied = TRUE; // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { + if (! mysqli_num_rows(mysqli_query($db, "select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); - $newtemplateid=mysqli_insert_id($db); - + mysqli_query($db, "insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); + $newtemplateid = mysqli_insert_id($db); + // update the flagmap table foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); + mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); } - + // add references to the reflinks table if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)"); + mysqli_query($db, "insert into reflinks(templateid,target) values($newtemplateid,$target)"); } } - $templateid=$newtemplateid; + $templateid = $newtemplateid; } else { - $nameexists=TRUE; + $nameexists = TRUE; } } else { - $namesupplied=FALSE; + $namesupplied = FALSE; } } } } } -if ($operation=="edit" || $operation=="delete") { +if ($operation == "edit" || $operation == "delete") { // test to see if this templateid is owned by techid to prevent hijacking - $owner=dblookup($db,"notetemplates","templateid","tech",$templateid); - if (!$isadmin && ($owner!=$techid)) $authorized=FALSE; - - if ($submit) { + $owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid); + if (!$isadmin && ($owner != $techid)) $authorized = FALSE; + + if ($submit) { if ($note) { // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - + $note = strip_tags($note, ""); + $note = mysqli_real_escape_string($db, $note); + if ($templatename) { - $namesupplied=TRUE; + $namesupplied = TRUE; } else { - $namesupplied=FALSE; + $namesupplied = FALSE; } - + if ($authorized) { // check if name was supplied if ($templatename) { // update notetemplates - mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); - + mysqli_query($db, "update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); + // update the flagmap table - mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\""); foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); + mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); } - + // update the reflinks table - mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + mysqli_query($db, "delete from reflinks where templateid=\"$templateid\""); if (strlen($refstring)) { - $refstring=trim($refstring); - $refarray=explode(" ",$refstring); + $refstring = trim($refstring); + $refarray = explode(" ", $refstring); foreach ($refarray as $target) { - mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)"); + mysqli_query($db, "insert into reflinks(templateid,target) values($templateid,$target)"); } } } } } } - if ($operation=="delete") { + if ($operation == "delete") { if ($authorized) { // update notetemplates - mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); + mysqli_query($db, "delete from notetemplates where templateid=\"$templateid\""); // update the flagmap table - mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\""); // update the reflinks table - mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); - $templateid=NULL; - $note=NULL; + mysqli_query($db, "delete from reflinks where templateid=\"$templateid\""); + $templateid = NULL; + $note = NULL; } } } @@ -264,118 +265,118 @@ if ($operation=="edit" || $operation=="delete") { pagetable("begin"); if (!$print) { - pageblock("left","begin"); + pageblock("left", "begin"); sidemenu(); - pageblock("left","end"); + pageblock("left", "end"); } -pageblock("right","begin"); +pageblock("right", "begin"); banner($print); -if ($submit || $operation=="delete") { +if ($submit || $operation == "delete") { // show success/failure messages - $nameexists=$nameexists ?? NULL; - $namesupplied=$namesupplied ?? NULL; - - if ($operation=="add") { - $addfail=FALSE; + $nameexists = $nameexists ?? NULL; + $namesupplied = $namesupplied ?? NULL; + + if ($operation == "add") { + $addfail = FALSE; if ($nameexists) { - format_message(1,"Template creation failed because the name you supplied already exists. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because the name you supplied already exists. Please try again."); + $addfail = TRUE; } if (!$namesupplied) { - format_message(1,"Template creation failed because you didn't supply a name. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because you didn't supply a name. Please try again."); + $addfail = TRUE; } if (!$note) { - format_message(1,"Template creation failed because you didn't enter any note text. Please try again."); - $addfail=TRUE; + format_message(1, "Template creation failed because you didn't enter any note text. Please try again."); + $addfail = TRUE; } if (!$authorized) { - format_message(1,"Template creation failed because you are not authorized to do so."); - $addfail=TRUE; + format_message(1, "Template creation failed because you are not authorized to do so."); + $addfail = TRUE; } - if (!$addfail) format_message(0,"Template created."); + if (!$addfail) format_message(0, "Template created."); } - if ($operation=="edit") { - $editfail=FALSE; + if ($operation == "edit") { + $editfail = FALSE; if (!$namesupplied) { - format_message(1,"Template save failed because you didn't supply a name. Please try again."); - $editfail=TRUE; + format_message(1, "Template save failed because you didn't supply a name. Please try again."); + $editfail = TRUE; } if (!$note) { - format_message(1,"Template save failed because you didn't enter any note text. Please try again."); - $editfail=TRUE; + format_message(1, "Template save failed because you didn't enter any note text. Please try again."); + $editfail = TRUE; } if (!$authorized) { - format_message(1,"Template save failed because you are not authorized to do so."); - $editfail=TRUE; + format_message(1, "Template save failed because you are not authorized to do so."); + $editfail = TRUE; } - if (!$editfail) format_message(0,"Template modified."); + if (!$editfail) format_message(0, "Template modified."); } - if ($operation=="delete") { - $deletefail=FALSE; + if ($operation == "delete") { + $deletefail = FALSE; if (!$authorized) { - format_message(1,"Template delete failed because you are not authorized to do so."); - $deletefail=TRUE; + format_message(1, "Template delete failed because you are not authorized to do so."); + $deletefail = TRUE; } - if (!$deletefail) format_message(0,"Template deleted."); + if (!$deletefail) format_message(0, "Template deleted."); } } -if ($operation=="delete") { +if ($operation == "delete") { // just show the link back to the templates page echo "
Manage templates



"; -} else if ($operation=="add" || $operation=="edit") { +} else if ($operation == "add" || $operation == "edit") { // Display the input form if ($loadtemplate) { // make templateid the selected template if ($usertemplateid) { - $templateid=$usertemplateid; + $templateid = $usertemplateid; } else if ($globaltemplateid) { - $templateid=$globaltemplateid; + $templateid = $globaltemplateid; } else { - $templateid=NULL; + $templateid = NULL; } } - if ($operation=="edit" || $loadtemplate) { + if ($operation == "edit" || $loadtemplate) { // use values from the templateid supplied with a defined tech id - $loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); - $filltemplatename=$loadeddata["templatename"]; + $loadeddata = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\"")); + $filltemplatename = $loadeddata["templatename"]; if ($efftechid) { - $filltech=$efftechid; - } else if ($isadmin && $loadeddata["tech"]=="0") { - $filltech="0"; + $filltech = $efftechid; + } else if ($isadmin && $loadeddata["tech"] == "0") { + $filltech = "0"; } else { - $filltech=$techid; + $filltech = $techid; } - $fillshift=$loadeddata["shift"]; - $fillsubject=$loadeddata["subject"]; - $fillnote=$loadeddata["lognote"]; + $fillshift = $loadeddata["shift"]; + $fillsubject = $loadeddata["subject"]; + $fillnote = $loadeddata["lognote"]; } else { // use empty values with a defined tech id - $filltemplatename=NULL; + $filltemplatename = NULL; if ($efftechid) { - $filltech=$efftechid; + $filltech = $efftechid; } else { - $filltech=$techid; + $filltech = $techid; } - $fillshift=$defaultshift; - $fillsubject=NULL; - $fillnote=NULL; + $fillshift = $defaultshift; + $fillsubject = NULL; + $fillnote = NULL; } - - if ($operation=="add") $optext="Creating new"; - if ($operation=="edit") $optext="Editing"; + + if ($operation == "add") $optext = "Creating new"; + if ($operation == "edit") $optext = "Editing"; echo "
$optext template

"; - + // show the template selection line - templateselect($techid,$operation); - + templateselect($techid, $operation); + // start template entry section echo " @@ -388,25 +389,26 @@ if ($operation=="delete") {
Tech:  
Shift:   Subject:  
@@ -454,50 +457,60 @@ if ($operation=="delete") {   Insert Link
"; - + // create an array called theseflags and optionally load it with flagids set for this template unset($theseflags); - $theseflags=[]; + $theseflags = []; if ($templateid) { - $allflags=mysqli_query($db,"select flagid from flags"); - while ($thisflag=mysqli_fetch_row($allflags)) { - if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { - $theseflags[]=$thisflag[0]; + $allflags = mysqli_query($db, "select flagid from flags"); + while ($thisflag = mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { + $theseflags[] = $thisflag[0]; } } } - - $flagslist=mysqli_query($db,"select * from flags where status=1"); - $flagsperline=8; - $flagcount=1; - + + $flagslist = mysqli_query($db, "select * from flags where status=1"); + $flagsperline = 8; + $flagcount = 1; + // display checkboxes for all the flags, selecting the ones that are set for this template - while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { - if ($operation=="edit" && in_array($flagcheckbox["flagid"],$theseflags)) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) { + if ($operation == "edit" && in_array($flagcheckbox["flagid"], $theseflags)) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } else { - $flagid=$flagcheckbox["flagid"]; - if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { - printf("%s", - $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + $flagid = $flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf( + "%s", + $flagcheckbox["flagid"], + $flagcheckbox["flagcolor"], + $flagcheckbox["flagname"], + $flagcheckbox["flagsym"] + ); } } - if ($flagcount<$flagsperline) { + if ($flagcount < $flagsperline) { echo "   "; $flagcount++; } else { echo "
"; - $flagcount=1; + $flagcount = 1; } } - - if ($operation=="edit" || $loadtemplate) { + + if ($operation == "edit" || $loadtemplate) { // generate a reference string - $refstring=NULL; - $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); - while ($tgt=mysqli_fetch_row($refstringqry)) { - $refstring=$refstring." ".$tgt[0]; + $refstring = NULL; + $refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\""); + while ($tgt = mysqli_fetch_row($refstringqry)) { + $refstring = $refstring . " " . $tgt[0]; } } echo " @@ -505,14 +518,14 @@ if ($operation=="delete") {                                "; - - if ($operation=="add" && $authorized) { + + if ($operation == "add" && $authorized) { echo " "; } - if ($operation=="edit" && $authorized) { + if ($operation == "edit" && $authorized) { echo " @@ -521,34 +534,32 @@ if ($operation=="delete") { Deleted templates are irretrievable! "; } - + echo "
"; } else { echo "
Create or copy a template

"; - + // Show my user template table - templatetable($db,$techid,$techid); - + templatetable($db, $techid, $techid); + // Show global template table - templatetable($db,$techid,"0"); - + templatetable($db, $techid, "0"); + if ($isadmin) { // Show template tables for other users - $techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0"); - while ($techtblrow=(mysqli_fetch_row($techqry))) { - templatetable($db,$techid,$techtblrow[0]); + $techqry = mysqli_query($db, "select techid from techs where techid != $techid and techid != 0"); + while ($techtblrow = (mysqli_fetch_row($techqry))) { + templatetable($db, $techid, $techtblrow[0]); } } } banner($print); -pageblock("right","end"); +pageblock("right", "end"); pagetable("end"); -framework("end","","",$print); - -?> +framework("end", "", "", $print); diff --git a/install.sh b/install.sh index 1fdde6a..afc16d3 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ # install.sh # OpenLog Online Logbook -# Copyright (C) 2025 Rod Wright +# Copyright (C) 2026 Rod Wright # SPDX-License-Identifier: GPL-2.0 From 41c5b4560b4833ab3c3a18fd91eabbf38f14a3cb Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 14:28:10 -0500 Subject: [PATCH 24/50] Updated to utf8mb4 encoding --- database-initial.sql | 246 ++++++++++++++++++++++++++++--------------- 1 file changed, 160 insertions(+), 86 deletions(-) diff --git a/database-initial.sql b/database-initial.sql index 8ec8ada..92a1c12 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -1,8 +1,9 @@ --- MariaDB dump 10.19 Distrib 10.6.18-MariaDB, for debian-linux-gnu (x86_64) +/*M!999999\- enable the sandbox mode */ +-- MariaDB dump 10.19-11.8.3-MariaDB, for debian-linux-gnu (x86_64) -- --- Host: localhost Database: ol521 +-- Host: localhost Database: openlog -- ------------------------------------------------------ --- Server version 10.6.18-MariaDB-0ubuntu0.22.04.1 +-- Server version 11.8.3-MariaDB-0+deb13u1 from Debian /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */ ; @@ -22,7 +23,7 @@ ; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */ ; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */ +/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */ ; -- @@ -32,7 +33,7 @@ DROP TABLE IF EXISTS `banners`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `banners` ( `bannerid` int(11) NOT NULL AUTO_INCREMENT, @@ -51,6 +52,8 @@ CREATE TABLE `banners` ( LOCK TABLES `banners` WRITE; /*!40000 ALTER TABLE `banners` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `banners` VALUES ( @@ -87,6 +90,8 @@ VALUES ( ; UNLOCK TABLES; +commit; + -- -- Table structure for table `configs` -- @@ -94,14 +99,14 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `configs`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `configs` ( `confid` int(11) NOT NULL AUTO_INCREMENT, `confname` text DEFAULT NULL, `confvalue` text DEFAULT NULL, PRIMARY KEY (`confid`), - UNIQUE (`confname`) + UNIQUE KEY `confname` (`confname`) USING HASH ) ENGINE = InnoDB AUTO_INCREMENT = 33 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */ ; @@ -113,6 +118,8 @@ CREATE TABLE `configs` ( LOCK TABLES `configs` WRITE; /*!40000 ALTER TABLE `configs` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `configs` VALUES (1, 'ol_version', '5.2.4'), @@ -197,6 +204,8 @@ VALUES (1, 'ol_version', '5.2.4'), ; UNLOCK TABLES; +commit; + -- -- Table structure for table `customs` -- @@ -204,7 +213,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `customs`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `customs` ( `customid` int(11) NOT NULL AUTO_INCREMENT, @@ -223,10 +232,13 @@ CREATE TABLE `customs` ( LOCK TABLES `customs` WRITE; /*!40000 ALTER TABLE `customs` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `customs` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `devicegroups` -- @@ -234,7 +246,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `devicegroups`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `devicegroups` ( `groupid` int(11) NOT NULL AUTO_INCREMENT, @@ -252,10 +264,13 @@ CREATE TABLE `devicegroups` ( LOCK TABLES `devicegroups` WRITE; /*!40000 ALTER TABLE `devicegroups` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `devicegroups` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `devices` -- @@ -263,7 +278,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `devices`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `devices` ( `deviceid` int(11) NOT NULL AUTO_INCREMENT, @@ -283,10 +298,13 @@ CREATE TABLE `devices` ( LOCK TABLES `devices` WRITE; /*!40000 ALTER TABLE `devices` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `devices` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `events` -- @@ -294,7 +312,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `events`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `events` ( `eventid` int(11) NOT NULL AUTO_INCREMENT, @@ -317,40 +335,12 @@ CREATE TABLE `events` ( LOCK TABLES `events` WRITE; /*!40000 ALTER TABLE `events` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `events` ENABLE KEYS */ ; UNLOCK TABLES; --- --- Table structure for table `flags` --- - -DROP TABLE IF EXISTS `flags`; -/*!40101 SET @saved_cs_client = @@character_set_client */ -; -/*!40101 SET character_set_client = utf8 */ -; -CREATE TABLE `flags` ( - `flagid` int(11) NOT NULL AUTO_INCREMENT, - `flagname` tinytext DEFAULT NULL, - `flagsym` tinytext DEFAULT NULL, - `flagcolor` tinytext DEFAULT NULL, - `status` int(11) NOT NULL, - PRIMARY KEY (`flagid`) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */ -; - --- --- Dumping data for table `flags` --- - -LOCK TABLES `flags` WRITE; -/*!40000 ALTER TABLE `flags` DISABLE KEYS */ -; -/*!40000 ALTER TABLE `flags` ENABLE KEYS */ -; -UNLOCK TABLES; +commit; -- -- Table structure for table `flagmap` @@ -359,7 +349,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `flagmap`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `flagmap` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -379,10 +369,47 @@ CREATE TABLE `flagmap` ( LOCK TABLES `flagmap` WRITE; /*!40000 ALTER TABLE `flagmap` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `flagmap` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + +-- +-- Table structure for table `flags` +-- + +DROP TABLE IF EXISTS `flags`; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8mb4 */ +; +CREATE TABLE `flags` ( + `flagid` int(11) NOT NULL AUTO_INCREMENT, + `flagname` tinytext DEFAULT NULL, + `flagsym` tinytext DEFAULT NULL, + `flagcolor` tinytext DEFAULT NULL, + `status` int(11) NOT NULL, + PRIMARY KEY (`flagid`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; + +-- +-- Dumping data for table `flags` +-- + +LOCK TABLES `flags` WRITE; +/*!40000 ALTER TABLE `flags` DISABLE KEYS */ +; +set autocommit = 0; +/*!40000 ALTER TABLE `flags` ENABLE KEYS */ +; +UNLOCK TABLES; + +commit; + -- -- Table structure for table `links` -- @@ -390,7 +417,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `links`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `links` ( `linkid` int(11) NOT NULL AUTO_INCREMENT, @@ -410,10 +437,13 @@ CREATE TABLE `links` ( LOCK TABLES `links` WRITE; /*!40000 ALTER TABLE `links` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `links` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `lognotes` -- @@ -421,7 +451,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `lognotes`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `lognotes` ( `lognoteid` int(11) NOT NULL AUTO_INCREMENT, @@ -443,39 +473,12 @@ CREATE TABLE `lognotes` ( LOCK TABLES `lognotes` WRITE; /*!40000 ALTER TABLE `lognotes` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `lognotes` ENABLE KEYS */ ; UNLOCK TABLES; --- --- Table structure for table `reflinks` --- - -DROP TABLE IF EXISTS `reflinks`; -/*!40101 SET @saved_cs_client = @@character_set_client */ -; -/*!40101 SET character_set_client = utf8 */ -; -CREATE TABLE `reflinks` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `noteid` int(11) DEFAULT NULL, - `templateid` int(11) DEFAULT NULL, - `target` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */ -; - --- --- Dumping data for table `reflinks` --- - -LOCK TABLES `reflinks` WRITE; -/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */ -; -/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */ -; -UNLOCK TABLES; +commit; -- -- Table structure for table `logpartactions` @@ -484,7 +487,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `logpartactions`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `logpartactions` ( `lpactionid` int(11) NOT NULL AUTO_INCREMENT, @@ -502,6 +505,8 @@ CREATE TABLE `logpartactions` ( LOCK TABLES `logpartactions` WRITE; /*!40000 ALTER TABLE `logpartactions` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `logpartactions` VALUES (1, 'removed', 1), @@ -514,6 +519,8 @@ VALUES (1, 'removed', 1), ; UNLOCK TABLES; +commit; + -- -- Table structure for table `logparts` -- @@ -521,7 +528,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `logparts`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `logparts` ( `logpartid` int(11) NOT NULL AUTO_INCREMENT, @@ -540,10 +547,13 @@ CREATE TABLE `logparts` ( LOCK TABLES `logparts` WRITE; /*!40000 ALTER TABLE `logparts` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `logparts` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `maintactions` -- @@ -551,7 +561,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `maintactions`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `maintactions` ( `maintactionid` int(11) NOT NULL AUTO_INCREMENT, @@ -572,10 +582,13 @@ CREATE TABLE `maintactions` ( LOCK TABLES `maintactions` WRITE; /*!40000 ALTER TABLE `maintactions` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `maintactions` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `maintforms` -- @@ -583,7 +596,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `maintforms`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `maintforms` ( `maintformid` int(11) NOT NULL AUTO_INCREMENT, @@ -609,10 +622,13 @@ CREATE TABLE `maintforms` ( LOCK TABLES `maintforms` WRITE; /*!40000 ALTER TABLE `maintforms` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `maintforms` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `notetemplates` -- @@ -620,7 +636,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `notetemplates`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `notetemplates` ( `templateid` int(11) NOT NULL AUTO_INCREMENT, @@ -642,10 +658,13 @@ CREATE TABLE `notetemplates` ( LOCK TABLES `notetemplates` WRITE; /*!40000 ALTER TABLE `notetemplates` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `notetemplates` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `parts` -- @@ -653,7 +672,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `parts`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `parts` ( `partid` int(11) NOT NULL AUTO_INCREMENT, @@ -673,10 +692,46 @@ CREATE TABLE `parts` ( LOCK TABLES `parts` WRITE; /*!40000 ALTER TABLE `parts` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `parts` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + +-- +-- Table structure for table `reflinks` +-- + +DROP TABLE IF EXISTS `reflinks`; +/*!40101 SET @saved_cs_client = @@character_set_client */ +; +/*!40101 SET character_set_client = utf8mb4 */ +; +CREATE TABLE `reflinks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */ +; + +-- +-- Dumping data for table `reflinks` +-- + +LOCK TABLES `reflinks` WRITE; +/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */ +; +set autocommit = 0; +/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */ +; +UNLOCK TABLES; + +commit; + -- -- Table structure for table `shifts` -- @@ -684,7 +739,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `shifts`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `shifts` ( `shiftid` int(11) NOT NULL AUTO_INCREMENT, @@ -702,11 +757,15 @@ CREATE TABLE `shifts` ( LOCK TABLES `shifts` WRITE; /*!40000 ALTER TABLE `shifts` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `shifts` VALUES (1, 'First Shift', 1); /*!40000 ALTER TABLE `shifts` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `styles` -- @@ -714,7 +773,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `styles`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `styles` ( `styleid` int(11) NOT NULL AUTO_INCREMENT, @@ -732,6 +791,8 @@ CREATE TABLE `styles` ( LOCK TABLES `styles` WRITE; /*!40000 ALTER TABLE `styles` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `styles` VALUES (1, 'logdisplay', 'classic'), @@ -740,6 +801,8 @@ VALUES (1, 'logdisplay', 'classic'), ; UNLOCK TABLES; +commit; + -- -- Table structure for table `subjects` -- @@ -747,7 +810,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `subjects`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `subjects` ( `subjectid` int(11) NOT NULL AUTO_INCREMENT, @@ -765,11 +828,15 @@ CREATE TABLE `subjects` ( LOCK TABLES `subjects` WRITE; /*!40000 ALTER TABLE `subjects` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `subjects` VALUES (1, 'Miscellaneous', 1); /*!40000 ALTER TABLE `subjects` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `tasks` -- @@ -777,7 +844,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `tasks`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `tasks` ( `taskid` int(11) NOT NULL AUTO_INCREMENT, @@ -802,10 +869,13 @@ CREATE TABLE `tasks` ( LOCK TABLES `tasks` WRITE; /*!40000 ALTER TABLE `tasks` DISABLE KEYS */ ; +set autocommit = 0; /*!40000 ALTER TABLE `tasks` ENABLE KEYS */ ; UNLOCK TABLES; +commit; + -- -- Table structure for table `techs` -- @@ -813,7 +883,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `techs`; /*!40101 SET @saved_cs_client = @@character_set_client */ ; -/*!40101 SET character_set_client = utf8 */ +/*!40101 SET character_set_client = utf8mb4 */ ; CREATE TABLE `techs` ( `techid` int(11) NOT NULL AUTO_INCREMENT, @@ -834,6 +904,8 @@ CREATE TABLE `techs` ( LOCK TABLES `techs` WRITE; /*!40000 ALTER TABLE `techs` DISABLE KEYS */ ; +set autocommit = 0; + INSERT INTO `techs` VALUES ( @@ -847,6 +919,8 @@ VALUES ( /*!40000 ALTER TABLE `techs` ENABLE KEYS */ ; UNLOCK TABLES; + +commit; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */ ; @@ -862,7 +936,7 @@ UNLOCK TABLES; ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */ ; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */ +/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */ ; --- Dump completed on 2024-07-09 14:36:00 \ No newline at end of file +-- Dump completed on 2026-02-19 14:18:01 \ No newline at end of file From dd86d2e5191b66d4b9d5a2424f354e2c55b230a9 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 16:03:10 -0500 Subject: [PATCH 25/50] Updated for new version. --- CHANGELOG | 38 ++++++++++++++++++++++++++++++++++++++ distfiles/CHANGELOG | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index ed31190..49a8129 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -240,3 +240,41 @@ treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. + +5.2.5 - 2026-02-10 + This is just a version number bump to get on a major-minor-patch + scheme. There are no code changes for this release. + +5.3.0 - 2026-02-20 + - Moved the template Create/Copy/Edit/Delete/Rename functionality to + its own page to make it less confusing and to fix some strange + behavior. + - Added global templates which can be used by anyone but can only be + created, modified, or deleted by administrators. This makes it + easier to employ standardized templates. + - Changed the character encoding of the database to utf8mb4 to enable + using emojis in text fields. + - Changed the insert link functionality. There are now two fields, link + text, and URL. The full URL string will now not be displayed in the + note, since it frequently was too long and deformed the table, + causing the user to have to scroll right to see the entire note. If + a URL is entered in the URL field and no link text is entered in the + link text field, the link will show up as just the last part of the + URL. For example, "http://somewhere.com/myfile.pdf" will show as + "myfile.pdf" in the note text. If text is entered in the link text + field, that is what will show as the clickable link in the note text. + NOTE: URLs in previously entered notes will not automatically be + converted. + - Changed the flag handling code to no longer dynamically create flag_ + tables in the database to track assignments. This is now done using + a flagmap table. + NOTE: The database will be modified to support this and the + importation of the previous data will take some time during + installation. + - References will no longer be stored in the lognotes table with the note. + There is now a reflinks table that stores the link information. + NOTE: The database will be modified to support this and the + importation of the previous data will take some time during + installation. + - Various code cleanups to prevent php warnings in the logs if logging + is enabled. diff --git a/distfiles/CHANGELOG b/distfiles/CHANGELOG index a1ebe30..797d929 100644 --- a/distfiles/CHANGELOG +++ b/distfiles/CHANGELOG @@ -233,10 +233,48 @@ installers. 5.2.4.4 - 2025-12-19 - -Fixed bugs that caused crashes on the Scheduled Maintenance page + - Fixed bugs that caused crashes on the Scheduled Maintenance page that were caused by more strict behavior of php regarding mysql queries. - Fixed bug where some functions defined in functions.php were not treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. + +5.2.5 - 2026-02-10 + This is just a version number bump to get on a major-minor-patch + scheme. There are no code changes for this release. + +5.3.0 - 2026-02-20 + - Moved the template Create/Copy/Edit/Delete/Rename functionality to + its own page to make it less confusing and to fix some strange + behavior. + - Added global templates which can be used by anyone but can only be + created, modified, or deleted by administrators. This makes it + easier to employ standardized templates. + - Changed the character encoding of the database to utf8mb4 to enable + using emojis in text fields. + - Changed the insert link functionality. There are now two fields, link + text, and URL. The full URL string will now not be displayed in the + note, since it frequently was too long and deformed the table, + causing the user to have to scroll right to see the entire note. If + a URL is entered in the URL field and no link text is entered in the + link text field, the link will show up as just the last part of the + URL. For example, "http://somewhere.com/myfile.pdf" will show as + "myfile.pdf" in the note text. If text is entered in the link text + field, that is what will show as the clickable link in the note text. + NOTE: URLs in previously entered notes will not automatically be + converted. + - Changed the flag handling code to no longer dynamically create flag_ + tables in the database to track assignments. This is now done using + a flagmap table. + NOTE: The database will be modified to support this and the + importation of the previous data will take some time during + installation. + - References will no longer be stored in the lognotes table with the note. + There is now a reflinks table that stores the link information. + NOTE: The database will be modified to support this and the + importation of the previous data will take some time during + installation. + - Various code cleanups to prevent php warnings in the logs if logging + is enabled. From b138f462d94eba24e0fa3270724b06cd3f03a9e1 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 18:33:19 -0500 Subject: [PATCH 26/50] Moved spinners for database upgrades from install.sh to database-update.sh --- database-update.sh | 34 +++++++++++++++++++++++++++++++--- install.sh | 8 ++------ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/database-update.sh b/database-update.sh index 269a666..45e45c2 100755 --- a/database-update.sh +++ b/database-update.sh @@ -6,6 +6,19 @@ # SPDX-License-Identifier: GPL-2.0 +function spinner() { + local pid="$1" + local delay="0.1" + local spinstr='|/-\\' + local i=0 + + while ps -p "$pid" > /dev/null; do + i=$(( (i+1) % 4 )) + printf "\r[%c]" "${spinstr:$i:1}" + sleep "$delay" + done + printf "\r \r" # Clear the spinner line +} if [[ $1 == "" ]] then @@ -45,7 +58,9 @@ echo "Started database updates for OpenLog version 5.3.0..." # Import old flag data from old scheme to new flagmap table if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]] then - echo "Importing flag data from old scheme to new flagmap table..." + echo "Importing flag data from old scheme to new flagmap table." + echo "This may take some time..." + ( for flagnumber in $(mysql $margs -e "select flagid from flags") do flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'") @@ -69,13 +84,18 @@ then mysql $margs -e "drop table flag_$flagnumber" fi done + ) & + task_pid=$! + spinner $task_pid echo "...done." fi # Import reference chain data into new reflinks table if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]] then - echo "Importing lognote reference chain data into new reflinks table..." + echo "Importing lognote reference chain data into new reflinks table." + echo "This may take some time..." + ( for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''") do refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note") @@ -88,8 +108,13 @@ then done IFS=$oldifs done + ) & + task_pid=$! + spinner $task_pid echo "...done." - echo "Importing template reference chain data into new reflinks table..." + echo "Importing template reference chain data into new reflinks table." + echo "This may take some time..." + ( for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''") do refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template") @@ -102,6 +127,9 @@ then done IFS=$oldifs done + ) & + task_pid=$! + spinner $task_pid echo "...done." mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1 mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1 diff --git a/install.sh b/install.sh index afc16d3..dbd897b 100755 --- a/install.sh +++ b/install.sh @@ -231,14 +231,10 @@ then echo "Performing database updates. This may take a while..." # apply database updates from sql file - (mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) & - task_pid=$! - spinner $task_pid + mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1 # apply database updates via script - (bash ./database-update.sh $mysql_opt_file) & - task_pid=$! - spinner $task_pid + bash ./database-update.sh $mysql_opt_file echo "... finished with database updates." rm -f $mysql_opt_file From 5a50400a561c463180334719dfde471388bbe76a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 18:48:26 -0500 Subject: [PATCH 27/50] changed an info message --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index dbd897b..1a3f6b2 100755 --- a/install.sh +++ b/install.sh @@ -229,7 +229,7 @@ then # delete all existing installation files except db.php find $install_path/ -mindepth 1 -not -name 'db.php' -delete - echo "Performing database updates. This may take a while..." + echo "Performing database updates..." # apply database updates from sql file mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1 From 33859546243e624ec362ef62e211661606d1ce9b Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 19:22:13 -0500 Subject: [PATCH 28/50] Convert single bracket ifs to double bracket. Disable access to app during upgrade. --- install.sh | 58 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index 1a3f6b2..f31f496 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ CONFIG_DEFAULT_COLUMN="" function privilege_check() { # test for superuser rights - if [[ $EUID -ne 0 ]]; then + if [[ "$EUID" != 0 ]]; then echo "This script must be run with superuser privileges. Try sudo $0" exit 1 fi @@ -36,11 +36,11 @@ function get_new_password() { echo "" read -p "Re-type new password: " -s -r rnewpw echo "" - if [ "$newpassword" = "" -o "$rnewpw" = "" ] + if [[ "$newpassword" == "" || "$rnewpw" == "" ]] then echo "Password cannot be blank. Please try again." echo "" - elif [ "$newpassword" != "$rnewpw" ] + elif [[ "$newpassword" != "$rnewpw" ]] then echo "Passwords do not match. Please try again." echo "" @@ -63,7 +63,7 @@ function install_required_packages() { gpattern="" for pkg_option in $(echo $prereq) do - if [ "$pkg_option" != "or" ] + if [[ "$pkg_option" != "or" ]] then gpattern+=" -e $pkg_option" preferred_pkg=$pkg_option @@ -76,7 +76,7 @@ function install_required_packages() { echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. " echo -n "Install $preferred_pkg now? [Y/n]: " read reqinstall - if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ] + if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]] then echo "$APP_NAME requires $prereq, but you have elected not to install it." echo "Installation cannot continue." @@ -172,20 +172,20 @@ echo "" echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :" read install_loc_in echo "" -if [ "$doc_root_in" = "" ] +if [[ "$doc_root_in" == "" ]] then doc_root_in=$DOC_ROOT fi -if [ "$install_loc_in" = "" ] +if [[ "$install_loc_in" == "" ]] then install_loc_in=$INSTALL_LOC fi install_path="$doc_root_in/$install_loc_in" -if [ -d "$install_path" ] +if [[ -d "$install_path" ]] then echo "The installation path you chose already exists." # Install path exists. - if [ -e "$install_path/db.php" ] + if [[ -e "$install_path/db.php" ]] then # A db.php file was found in the install path if grep -q -e "$APP_NAME" $install_path/db.php @@ -195,12 +195,17 @@ then echo "and restart the install using a new installation location." echo -n "[U]pgrade or [C]ancel? [U] :" read upgrade_choice - if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen + if [[ "$upgrade_choice" == "C" || "$upgrade_choice" == "c" ]] # Cancel chosen then echo "Cancelling installation" abort_exit else # proceed with upgrade + + # take app offline during upgrade + a2disconf $install_loc_in + systemctl reload apache2 + datestamp=$(date +%Y-%m-%d_%H:%M:%S) backupdir=backups/$datestamp mkdir -p $backupdir @@ -246,12 +251,12 @@ then echo "Installing distribution . . ." cp -R distfiles/* $install_path # set symlink for jquery-ui - if [ ! -L "$install_path/jquery-ui" ] + if [[ ! -L "$install_path/jquery-ui" ]] then ln -s $install_path/jquery-ui* $install_path/jquery-ui fi # set symlink for index.php - if [ ! -L "$install_path/index.php" ] + if [[ ! -L "$install_path/index.php" ]] then ln -s $install_path/$LANDING_PAGE $install_path/index.php fi @@ -283,11 +288,11 @@ then echo "Would you like to use this location for a fresh installation or quit and" echo "investigate further? It's probably safest to quit and investigate." proceed="" - while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]] + while [[ "$proceed" != "P" && "$proceed" != "p" && "$proceed" != "Q" && "$proceed" != "q" ]] do read proceed -p "[P]roceed with new install or [Q]uit? : " done - if [[ $proceed == "Q" || $proceed == "q" ]] + if [[ "$proceed" == "Q" || "$proceed" == "q" ]] then abort_exit fi @@ -302,7 +307,7 @@ else echo "This can be changed later in the application itself." echo -n "Installation name [$APP_NAME]: " read new_inst_name - if [ "$new_inst_name" = "" ] + if [[ "$new_inst_name" == "" ]] then new_inst_name="$APP_NAME" fi @@ -319,7 +324,7 @@ else echo "distinctive name." echo -n "database name [$DEFAULT_DB_NAME]: " read new_db_name - if [ "$new_db_name" = "" ] + if [[ "$new_db_name" == "" ]] then new_db_name=$DEFAULT_DB_NAME fi @@ -332,7 +337,7 @@ else echo "This probably means the database already exists." echo -n "Try again with a different database name? [Y/N]: " read dbcreatetry - if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ] + if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]] then abort_exit fi @@ -352,7 +357,7 @@ else # Set the installation name export MYSQL_PWD="$db_pass" mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\"" - if [ "$CONFIG_DEFAULT_COLUMN" != "" ] + if [[ "$CONFIG_DEFAULT_COLUMN" != "" ]] then mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\"" fi @@ -361,7 +366,7 @@ else mkdir $install_path # Create db.php if it doesn't exist - if [ ! -f "$install_path/db.php" ] + if [[ ! -f "$install_path/db.php" ]] then cp db.php.template $install_path/db.php sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php @@ -373,11 +378,11 @@ else # copy distribution to install location echo "Installing distribution . . ." cp -R distfiles/* $install_path - if [ ! -L "$install_path/jquery-ui" ] + if [[ ! -L "$install_path/jquery-ui" ]] then ln -s $install_path/jquery-ui* $install_path/jquery-ui fi - if [ ! -L "$install_path/index.php" ] + if [[ ! -L "$install_path/index.php" ]] then ln -s $install_path/$LANDING_PAGE $install_path/index.php fi @@ -400,7 +405,12 @@ echo "" echo "" echo "$APP_NAME has been $operation." base_url=$install_loc_in -if [ "$operation" = "installed" ] +if [[ "$operation" == "upgraded" ]] +then + a2enconf $base_url + systemctl reload apache2 +fi +if [[ "$operation" == "installed" ]] then echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf echo "" >> $APACHE_CONF_DIR/$base_url.conf @@ -413,10 +423,10 @@ then echo "" >> $APACHE_CONF_DIR/$base_url.conf echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :" read enconf - if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ] + if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]] then a2enconf $base_url.conf >/dev/null - service apache2 reload + systemctl reload apache2 echo "You can now point a web browser to $base_url on your web server " echo "to set up and configure $APP_NAME." echo "" From 513017d3cbc371cbaed5ae1b8be99202c6b9032c Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 21:21:07 -0500 Subject: [PATCH 29/50] Created fix_date and fix_time functions --- distfiles/functions.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/distfiles/functions.php b/distfiles/functions.php index ff1e2d7..830f0b7 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -1000,3 +1000,31 @@ function templateselect($techid, $operation) "; } + +function fix_date($datestring) +{ + // accepts a string as an argument + // returns a valid date string in the format YYYY-MM-DD + // if input string is not a valid date, return the current date + global $db, $today; + + 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; + $datestring = mysqli_real_escape_string($db, $datestring); + return $datestring; +} + +function fix_time($timestring) +{ + // accepts a string as an argument + // returns a valid time string in the format HH:MM:SS + // if input string is not a valid time, return the current time + global $db, $now; + + 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; + $timestring = mysqli_real_escape_string($db, $timestring); + return $timestring; +} From d41519ba91b86dffbb1e952f44cb83cf575e7caf Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 21:21:50 -0500 Subject: [PATCH 30/50] Updated to use fix_date and fix_time functions --- distfiles/logentry.php | 11 +++++++---- distfiles/maintformentry.php | 9 +++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/distfiles/logentry.php b/distfiles/logentry.php index babe693..4bb7d71 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -96,10 +96,9 @@ if ($add) { // add the entry if submit is pressed if ($note) { // sanitize and fix blank date and time - $date = mysqli_real_escape_string($db, $date); - $time = mysqli_real_escape_string($db, $time); - if (!$date) $date = $today; - if (!$time) $time = $now; + $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 @@ -263,6 +262,10 @@ if ($edit) { if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\""); if ($submit) { if ($note) { + // sanitize and fix blank date and time + $date = fix_date($date); + $time = fix_time($time); + // remove cruft from note text $note = strip_tags($note, ""); $note = mysqli_real_escape_string($db, $note); diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index fdd2ff8..0d16adf 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -135,6 +135,9 @@ if ($mfadd) { if ($mfsubmit) { // add the entry if submit is pressed if ($mfmalfunction && ($uid || ($partnum && $sernum))) { + // sanitize and fix blank date and time + $mfdate = fix_date($mfdate); + $mftime = fix_time($mftime); // determine whether supplied date is future or past $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 @@ -236,6 +239,9 @@ if ($mfdelete && $mfauthorized) { if ($actionadd) { if ($actionaddsubmit) { if ($action) { + // sanitize and fix blank date and time + $actiondate = fix_date($actiondate); + $actiontime = fix_time($actiontime); // determine whether supplied date is future or past $datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)")); // if future, set time to 00:00:01, if past, set to 23:59:59 @@ -260,6 +266,9 @@ if ($actionadd) { if ($actionedit) { if ($actioneditsubmit && $actionauthorized) { // update the action + // sanitize and fix blank date and time + $actiondate = fix_date($actiondate); + $actiontime = fix_time($actiontime); // remove cruft from action text $action = htmlentities($action); $action = addslashes($action); From 968964e3fe49374a879f30887b8e3b86f77736d5 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Thu, 19 Feb 2026 21:22:28 -0500 Subject: [PATCH 31/50] updates in work to use fix_date function --- distfiles/schedmaint.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index 1dacf33..ee90f2e 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -1,6 +1,6 @@  You didn't select a device.
"; } // sanitize text data - $start_date = mysqli_real_escape_string($db, $start_date); - $last_date = mysqli_real_escape_string($db, $last_date); - $deferred_date = mysqli_real_escape_string($db, $deferred_date); + if ($start_date == NULL) $start_date = $today; + if ($last_date == NULL) $last_date = "0001-01-01"; + if ($deferred_date == NULL) $deferred_date = "0001-01-01"; + $start_date = fix_date($start_date); + $last_date = fix_date($last_date); + $deferred_date = fix_date($deferred_date); if ($taskselected && $deviceselected) { // determine if device represents a group and break out individual devices if (dblookup($db, "devices", "deviceid", "group_flag", $device)) { @@ -126,9 +130,7 @@ if ($add) { } // run through the memberlist and modify the table foreach ($memberlist as $memberdev) { - if ($start_date == NULL) $start_date = $today; - if ($last_date == NULL) $last_date = "0000-00-00"; - if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + $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); @@ -199,13 +201,13 @@ if ($edit) { if ($update) { // do error checking // sanitize text data - $start_date = mysqli_real_escape_string($db, $start_date); - $last_date = mysqli_real_escape_string($db, $last_date); - $deferred_date = mysqli_real_escape_string($db, $deferred_date); - // update the tasks table if ($start_date == NULL) $start_date = $today; - if ($last_date == NULL) $last_date = "0000-00-00"; - if ($deferred_date == NULL) $deferred_date = "0000-00-00"; + if ($last_date == NULL) $last_date = "0001-01-01"; + if ($deferred_date == NULL) $deferred_date = "0001-01-01"; + $start_date = fix_date($start_date); + $last_date = fix_date($last_date); + $deferred_date = fix_date($deferred_date); + // update the tasks table mysqli_query($db, "update events set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\", deferred_date=\"$deferred_date\",active_flag=\"$active_flag\" @@ -404,9 +406,9 @@ if ($action) { } else { $deferredtag = ""; } - if ($start_date == "0000-00-00") $start_date = $today; - if ($last_date == "0000-00-00") $last_date = ""; - if ($deferred_date == "0000-00-00") $deferred_date = $tomorrow; + if ($start_date == "0001-01-01") $start_date = $today; + //if ($last_date == "0001-01-01") $last_date = ""; + if ($deferred_date == "0001-01-01") $deferred_date = $tomorrow; $deferuntiltag = ""; $startdatetag = ""; $lastdatetag = ""; @@ -487,7 +489,7 @@ if ($action) { "; while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); - if ($start_date == "0000-00-00") $start_date = $today; + if ($start_date == "0001-01-01") $start_date = $today; if ($last_date == "0000-00-00") $last_date = ""; if ($deferred_date == "0000-00-00") $deferred_date = ""; if ($active_flag) { From ed7a25cea361a53e013fabf5af2e2539d33bb97d Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Fri, 20 Feb 2026 07:24:04 -0500 Subject: [PATCH 32/50] Fixed incorrect version for initial database. --- database-initial.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database-initial.sql b/database-initial.sql index 92a1c12..0ca4ab8 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -122,7 +122,7 @@ set autocommit = 0; INSERT INTO `configs` -VALUES (1, 'ol_version', '5.2.4'), +VALUES (1, 'ol_version', '5.3.0'), (2, 'log_name', 'OpenLog'), (3, 'banner', '1'), ( From 5129d309927a7db7873ca546c7d3ba3e6d669bd1 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Fri, 20 Feb 2026 07:24:45 -0500 Subject: [PATCH 33/50] Updated to reflect date/time validation. --- CHANGELOG | 3 +++ distfiles/CHANGELOG | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 49a8129..95f0282 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -278,3 +278,6 @@ installation. - Various code cleanups to prevent php warnings in the logs if logging is enabled. + - Validate all date and time fields to prevent user entered invalid date + formats from crashing php. + diff --git a/distfiles/CHANGELOG b/distfiles/CHANGELOG index 797d929..0df235a 100644 --- a/distfiles/CHANGELOG +++ b/distfiles/CHANGELOG @@ -278,3 +278,6 @@ installation. - Various code cleanups to prevent php warnings in the logs if logging is enabled. + - Validate all date and time fields to prevent user entered invalid date + formats from crashing php. + From ef0599342befc26f21439e3c6629cbf34ca7995e Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Fri, 20 Feb 2026 07:46:18 -0500 Subject: [PATCH 34/50] Added -q option to a2enconf/a2disconf to suppress their output. --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index f31f496..bb719f1 100755 --- a/install.sh +++ b/install.sh @@ -203,7 +203,7 @@ then # proceed with upgrade # take app offline during upgrade - a2disconf $install_loc_in + a2disconf -q $install_loc_in systemctl reload apache2 datestamp=$(date +%Y-%m-%d_%H:%M:%S) @@ -407,7 +407,7 @@ echo "$APP_NAME has been $operation." base_url=$install_loc_in if [[ "$operation" == "upgraded" ]] then - a2enconf $base_url + a2enconf -q $base_url systemctl reload apache2 fi if [[ "$operation" == "installed" ]] @@ -425,7 +425,7 @@ then read enconf if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]] then - a2enconf $base_url.conf >/dev/null + a2enconf -q $base_url.conf >/dev/null systemctl reload apache2 echo "You can now point a web browser to $base_url on your web server " echo "to set up and configure $APP_NAME." From 0600ba18cd939e32bdfdc955cbc2fc4642c125b8 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:30:24 -0500 Subject: [PATCH 35/50] Template apache config file created --- default-apache.conf | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 default-apache.conf diff --git a/default-apache.conf b/default-apache.conf new file mode 100644 index 0000000..d6cb9d2 --- /dev/null +++ b/default-apache.conf @@ -0,0 +1,13 @@ +# _APPNAME_ default Apache configuration + +Alias /_BASEURL_ _DOCROOTIN_/_BASEURL_ + + + AllowOverride Options + Options FollowSymLinks + DirectoryIndex index.php + + #RewriteEngine On + #RewriteBase /_BASEURL_/ + #RewriteRule . maintenancemode.php [L] + From ce8e5d9ca781c05e7776266f7bdb270f3be7017a Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:31:11 -0500 Subject: [PATCH 36/50] Modified to use apache conf template and take app offline during upgrade --- install.sh | 76 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/install.sh b/install.sh index bb719f1..e347366 100755 --- a/install.sh +++ b/install.sh @@ -201,11 +201,38 @@ then abort_exit else # proceed with upgrade - - # take app offline during upgrade + # put app in maintenance mode + echo "Putting the applocation in maintenance mode..." + # make sure mod_rewrite is enabled + if [[ ! -e "$APACHE_CONF_DIR/../mods-enabled/rewrite.load" ]] + then + a2enmod -q rewrite + systemctl restart apache2 + fi + # disable the app a2disconf -q $install_loc_in systemctl reload apache2 - + # modify the apache conf file + if ! grep -q "RewriteEngine" "$APACHE_CONF_DIR/$install_loc_in.conf" + then + # this is an old version of the conf file. Replace with new version + cp -f default-apache.conf $APACHE_CONF_DIR/$install_loc_in.conf + sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$install_loc_in.conf + sed -i "s|_BASEURL_|$install_loc_in|g" $APACHE_CONF_DIR/$install_loc_in.conf + sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$install_loc_in.conf + fi + sed -i "s|#Rewrite|Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf + # copy in the default maintenancemode.php if it's not already there + if [[ ! -e "$install_path/maintenancemode.php" ]] + then + cp maintenancemode.php $install_path/ + # modify the maintenancemode.php file + sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php + fi + # re-enable the app in maintenance mode + a2enconf -q $install_loc_in + systemctl reload apache2 + datestamp=$(date +%Y-%m-%d_%H:%M:%S) backupdir=backups/$datestamp mkdir -p $backupdir @@ -231,8 +258,8 @@ then echo "Backing up current installation to the package directory." cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup - # delete all existing installation files except db.php - find $install_path/ -mindepth 1 -not -name 'db.php' -delete + # delete all existing installation files except db.php and maintenancemode.php + find $install_path/ -mindepth 1 ! \( -name 'db.php' -o -name 'maintenancemode.php' \) -delete echo "Performing database updates..." # apply database updates from sql file @@ -271,6 +298,17 @@ then chown -R $httpd_user_group $install_path echo "Backups of the previous openlog files and the previous database were made" echo "and are located in the $backupdir directory." + + # take app out of maintenance mode + echo "Taking the app out of maintenance mode..." + # disable the app + a2disconf -q $install_loc_in + systemctl reload apache2 + # modify the apache conf file + sed -i "s|Rewrite|#Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf + # re-enable the app in production mode + a2enconf -q $install_loc_in + systemctl reload apache2 fi else # This was a mistake. Exit now to avoid clobbering another app. @@ -369,10 +407,16 @@ else if [[ ! -f "$install_path/db.php" ]] then cp db.php.template $install_path/db.php - sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php - sed -i "s/DBUSER/$db_user/g" $install_path/db.php - sed -i "s/DBPASS/$db_pass/g" $install_path/db.php - sed -i "s/APPNAME/$APP_NAME/g" $install_path/db.php + sed -i "s|DBNAME|$new_db_name|g" $install_path/db.php + sed -i "s|DBUSER|$db_user|g" $install_path/db.php + sed -i "s|DBPASS|$db_pass|g" $install_path/db.php + sed -i "s|APPNAME|$APP_NAME|g" $install_path/db.php + fi + # Create maintenancemode.php if it doesn't exist + if [[ ! -f "$install_path/maintenancemode.php" ]] + then + cp maintenancemode.php $install_path/maintenancemode.php + sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php fi # copy distribution to install location @@ -412,15 +456,11 @@ then fi if [[ "$operation" == "installed" ]] then - echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf - echo "" >> $APACHE_CONF_DIR/$base_url.conf - echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf - echo "" >> $APACHE_CONF_DIR/$base_url.conf - echo "" >> $APACHE_CONF_DIR/$base_url.conf - echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf - echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf - echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf - echo "" >> $APACHE_CONF_DIR/$base_url.conf + cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf + sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf + sed -i "s|_BASEURL_|$base_url|g" $APACHE_CONF_DIR/$base_url.conf + sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$base_url.conf + echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :" read enconf if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]] From ba7db9279d1c5200b76a177719a74a1feb8a37c3 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:31:49 -0500 Subject: [PATCH 37/50] Created landing page to inform users during upgrades --- maintenancemode.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 maintenancemode.php diff --git a/maintenancemode.php b/maintenancemode.php new file mode 100644 index 0000000..f5db8ce --- /dev/null +++ b/maintenancemode.php @@ -0,0 +1,26 @@ + + +_APPNAME_ + + + +



+_APPNAME_ is currently down for maintenance. Please try again later. +

+ + +"; + +?> \ No newline at end of file From eb29a3799cf264390a6169596a3eac4094b1e457 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:33:16 -0500 Subject: [PATCH 38/50] Modified templateselect function to show all users templates in user dropdown if current user is admin --- distfiles/functions.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/distfiles/functions.php b/distfiles/functions.php index 830f0b7..410ac30 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -953,8 +953,9 @@ function templateselect($techid, $operation) { // Displays a line enabling selection of a user or global template // $techid is the id number of the current tech - // $operation is one of "add" "edit" "delete" + // $operation is one of "add" "edit" "delete" or NULL global $db; + $isadmin = dblookup($db, "techs", "techid", "admin", $techid); echo "
"; @@ -967,10 +968,19 @@ function templateselect($techid, $operation)  or  From 9cce143cf9f903302af6444a2fe0f69afe109451 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:34:03 -0500 Subject: [PATCH 39/50] fixed invalid array key php warning --- distfiles/logentry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distfiles/logentry.php b/distfiles/logentry.php index 4bb7d71..a16cf3e 100644 --- a/distfiles/logentry.php +++ b/distfiles/logentry.php @@ -9,7 +9,7 @@ include("functions.php"); -if (!$_SESSION['login'] && !$_REQUEST['partview']) { +if (!array_key_exists("login",$_SESSION) && !array_key_exists("partview",$_REQUEST)) { header("Location: login.php"); } @@ -500,7 +500,7 @@ if ($delete) { format_message(0, "Note deleted. Return to main page."); } -if ($_SESSION['login']) { +if (array_key_exists('login',$_SESSION)) { // show the template selection line templateselect($techid, NULL); } From 11c876886ae6c4a7827d297f7c9b4a247e9de292 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:34:32 -0500 Subject: [PATCH 40/50] fixed invalid array key php warnings --- distfiles/login.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/distfiles/login.php b/distfiles/login.php index 14018e0..442e45b 100644 --- a/distfiles/login.php +++ b/distfiles/login.php @@ -9,11 +9,11 @@ include("functions.php"); -$print = $_REQUEST['print']; -$tech = $_REQUEST['tech']; -$pass = $_REQUEST['pass']; -$login = $_REQUEST['login']; -$cancel = $_REQUEST['cancel']; +$print = $_REQUEST['print'] ?? NULL; +$tech = $_REQUEST['tech'] ?? NULL; +$pass = $_REQUEST['pass'] ?? NULL; +$login = $_REQUEST['login'] ?? NULL; +$cancel = $_REQUEST['cancel'] ?? NULL; if ($cancel) { session_destroy(); From 152bb3002915e0b3c27848f702062da64c4eb445 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:35:10 -0500 Subject: [PATCH 41/50] fixed typo in flagmap table update --- distfiles/maintformentry.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 0d16adf..042e9b6 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -178,6 +178,7 @@ if ($mfadd) { // add the record to maintforms if (! $pdatamismatch) { + $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); @@ -186,7 +187,7 @@ if ($mfadd) { // update the flagmap table foreach ($flags as $thisflag) { // set flag for this maintenance form - mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")"); + mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$newmaintformid\")"); } } } From d23a19a3eba117f8b09eae690a6b9cac6b64ee2b Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:36:25 -0500 Subject: [PATCH 42/50] changed insertion of all zeroes deferred date into the database with a date that will pass validation --- distfiles/schedmaint.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index ee90f2e..00f988d 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -75,7 +75,7 @@ if ($action) { // sanitize user input $completedate = fix_date($completedate); // update events - mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\""); + mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0001-01-01\" where eventid=\"$id\""); if ($addlognote) { $compltaskname = mysqli_fetch_row(mysqli_query($db, "select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0]; $compldevicename = mysqli_fetch_row(mysqli_query($db, "select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0]; @@ -490,8 +490,8 @@ if ($action) { while ($tablerow = mysqli_fetch_assoc($existingdata)) { extract($tablerow); if ($start_date == "0001-01-01") $start_date = $today; - if ($last_date == "0000-00-00") $last_date = ""; - if ($deferred_date == "0000-00-00") $deferred_date = ""; + if ($last_date == "0001-01-01") $last_date = ""; + if ($deferred_date == "0001-01-01") $deferred_date = ""; if ($active_flag) { $statdef = "\"active\""; } else { @@ -857,7 +857,7 @@ if ($action) { $taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$def_task\"")); extract($taskdata, EXTR_PREFIX_ALL, "taskdata"); if (! ($taskdata_period == "once" && $def_last_date > $def_start_date)) { - if ($def_last_date == "0000-00-00") { + if ($def_last_date == "0001-01-01") { $lastdatestrg = "never"; } else { $lastdatestrg = "$def_last_date"; From ec8efec61ea433b5473c6e9134954bd6fc6ab805 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 06:37:51 -0500 Subject: [PATCH 43/50] determine original owner of template to prevent stealing it when the intent is to copy it --- distfiles/templates.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/distfiles/templates.php b/distfiles/templates.php index 8282715..87829df 100644 --- a/distfiles/templates.php +++ b/distfiles/templates.php @@ -162,6 +162,12 @@ if ($usertemplateid) { $loadtemplate = NULL; } +// determine original owner of template +$orig_owner=dblookup($db, "notetemplates","templateid","tech",$templateid); +if ($efftechid != NULL && $efftechid != $orig_owner) { + $operation="add"; +} + if ($operation == "add") { if ($submit) { if ($note) { From 962bd7b5045b7954c44ff37e4b72918ed1afe111 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Mon, 23 Feb 2026 13:36:30 -0500 Subject: [PATCH 44/50] moved the flags part of the constraints generation for log and maintform search to the end to avoid mysql unknown column error --- distfiles/search.php | 77 +++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/distfiles/search.php b/distfiles/search.php index 2c63907..980c6a4 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -35,7 +35,7 @@ $srchploc = $_REQUEST['srchploc'] ?? NULL; $srchnha = $_REQUEST['srchnha'] ?? NULL; $srchrepord = $_REQUEST['srchrepord'] ?? NULL; $srchflags = $_POST['srchflags'] ?? []; -$target = $_REQUEST['target'] ?? NULL; +$target = $_REQUEST['target'] ?? ["log","maintform","part"]; $doparts = PARTS_FUNCTIONS; $logname = LOG_NAME; @@ -56,7 +56,7 @@ framework("begin", "$logname Search", "Search", $print); // echo "REQUEST variables:
"; // var_dump($_REQUEST); - +// echo "
"; // ******** begin database manipulation ******** @@ -92,7 +92,6 @@ if ($search) { $srchpname = trim($srchpname); $srchploc = trim($srchploc); $srchnha = trim($srchnha); - if ($target[0] == "") $target = []; if (in_array("log", $target)) { // define the query constraints // log note id @@ -131,23 +130,6 @@ if ($search) { $logfromtables[] = "lognotes"; $logconstraints[] = "lognotes.lognote like \"%$srchtext%\""; } - // flags - if (!empty($srchflags)) { - unset($flagconstraints); - $flagcount = count($srchflags); - $logfromtables[] = "lognotes"; - $logfromtables[] = "flagmap"; - $flagconstraints[] = "flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; - foreach ($srchflags as $flagid) { - $flagconstraints[] = "\"$flagid\""; - $flagconstraints[] = ","; - } - // remove final comma - array_splice($flagconstraints, -1, 1); - $flagconstraints[] = ") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; - // make flagconstraints a single string so that the final implode doesn't split it - $logconstraints[] = join('', $flagconstraints); - } // uid if ($srchuid != "any" && $srchuid != "") { $logfromtables[] = "lognotes"; @@ -200,12 +182,28 @@ if ($search) { $logfromtables[] = "maintforms"; $logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } + // flags + if (!empty($srchflags)) { + unset($flagconstraints); + $flagcount = count($srchflags); + $logfromtables[] = "lognotes"; + $logfromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in ("; + foreach ($srchflags as $flagid) { + $flagconstraints[] = "\"$flagid\""; + $flagconstraints[] = ","; + } + // remove final comma + array_splice($flagconstraints, -1, 1); + $flagconstraints[] = ") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount"; + // make flagconstraints a single string so that the final implode doesn't split it + $logconstraints[] = join('', $flagconstraints); + } // build the clauses and run the query $logfromclause = implode(",", array_unique($logfromtables)); $logwhereclause = implode(" and ", $logconstraints); $logrowqry = mysqli_query($db, "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); } - if ($target[0] == "") $target = []; if (in_array("maintform", $target)) { // maintforms search // define the query constraints @@ -248,23 +246,6 @@ if ($search) { $mffromtables[] = "maintactions"; $mfconstraints[] = "maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)"; } - // flags - if (!empty($srchflags)) { - unset($flagconstraints); - $flagcount = count($srchflags); - $mffromtables[] = "maintforms"; - $mffromtables[] = "flagmap"; - $flagconstraints[] = "flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; - foreach ($srchflags as $thisflagid) { - $flagconstraints[] = "\"$thisflagid\""; - $flagconstraints[] = ","; - } - // remove final comma - array_splice($flagconstraints, -1, 1); - $flagconstraints[] = ") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; - // make flagconstraints a single string so that the final implode doesn't split it - $mfconstraints[] = join('', $flagconstraints); - } // uid if ($srchuid != "any" && $srchuid != "") { $mffromtables[] = "maintforms"; @@ -307,12 +288,28 @@ if ($search) { $mffromtables[] = "maintforms"; $mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } + // flags + if (!empty($srchflags)) { + unset($flagconstraints); + $flagcount = count($srchflags); + $mffromtables[] = "maintforms"; + $mffromtables[] = "flagmap"; + $flagconstraints[] = "flagmap.maintformid=maintforms.maintformid and flagmap.flagid in ("; + foreach ($srchflags as $thisflagid) { + $flagconstraints[] = "\"$thisflagid\""; + $flagconstraints[] = ","; + } + // remove final comma + array_splice($flagconstraints, -1, 1); + $flagconstraints[] = ") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount"; + // make flagconstraints a single string so that the final implode doesn't split it + $mfconstraints[] = join('', $flagconstraints); + } // build the clauses and run the query $mffromclause = implode(",", array_unique($mffromtables)); $mfwhereclause = implode(" and ", $mfconstraints); $mfrowqry = mysqli_query($db, "select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); } - if ($target[0] == "") $target = []; if (in_array("part", $target)) { // parts search // define the query constraints @@ -334,7 +331,6 @@ if ($search) { // tech doesn't apply to parts // subject doesn't apply to parts // search text doesn't apply to parts - // flags doesn't apply to parts // uid if ($srchuid != "any" && $srchuid != "") { $pfromtables[] = "parts"; @@ -373,6 +369,7 @@ if ($search) { $pfromtables[] = "maintforms"; $pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\""; } + // flags doesn't apply to parts // build the clauses and run the query $pfromclause = implode(",", array_unique($pfromtables)); $pwhereclause = implode(" and ", $pconstraints); From f3db1c1523572329d69d401a6ea8d4a1d34020cc Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 24 Feb 2026 09:46:43 -0500 Subject: [PATCH 45/50] Updated for color preference fix --- CHANGELOG | 3 ++- distfiles/CHANGELOG | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 95f0282..b1224f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/distfiles/CHANGELOG b/distfiles/CHANGELOG index 0df235a..e78488e 100644 --- a/distfiles/CHANGELOG +++ b/distfiles/CHANGELOG @@ -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. + From f84395f79a7a4d88ac7c6d7b6921be48473653c3 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 24 Feb 2026 09:47:38 -0500 Subject: [PATCH 46/50] Reformats --- db.php.template | 10 +++++----- distfiles/functions.php | 10 +++++----- distfiles/logentry.php | 8 ++++---- distfiles/maintformentry.php | 2 +- distfiles/schedmaint.php | 1 - distfiles/search.php | 2 +- distfiles/templates.php | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/db.php.template b/db.php.template index 81521ef..147da5c 100644 --- a/db.php.template +++ b/db.php.template @@ -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); } diff --git a/distfiles/functions.php b/distfiles/functions.php index 410ac30..d66c47b 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -968,15 +968,15 @@ function templateselect($techid, $operation) "; + if (!empty($currentvalues)) { + $name = $currentvalues["techname"]; + $pass = $passconf = "password_is_unchanged"; + $shift = $currentvalues["shift"]; + if ($currentvalues["admin"] == 1) { + $admintag = ""; + } else { + $admintag = ""; + } + if ($currentvalues["status"] == 1) { + $activetag = ""; + } else { + $activetag = ""; + } } else { + $name = NULL; + $pass = NULL; + $shift = NULL; $admintag = ""; - } - if ($currentvalues["status"] == 1) { - $activetag = ""; - } else { $activetag = ""; } } 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 = ""; + if (!empty($currentvalues)) { + $name = $currentvalues["shiftname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; + } else { + $activetag = ""; + } } else { + $name = NULL; $activetag = ""; } } 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 = ""; + if (!empty($currentvalues)) { + $name = $currentvalues["subjectname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; + } else { + $activetag = ""; + } } else { + $name = ""; $activetag = ""; } } 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 = ""; + if (!empty($currentvalues)) { + $name = $currentvalues["displaytxt"]; + $priority = $currentvalues["linkpriority"]; + $url = $currentvalues["urltxt"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; + } else { + $activetag = ""; + } } else { + $name = NULL; + $priority = NULL; + $url = NULL; $activetag = ""; } // 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 = ""; + } else { + $activetag = ""; + } + } else { + $name = NULL; + $flagsym = NULL; + $flagcolor = NULL; + $activetag = ""; + } foreach ($basic_colors as $cname => $chex) { if ($chex == $flagcolor) { $flagcoloropts = $flagcoloropts . ""; @@ -1156,11 +1193,6 @@ switch ($table) { $flagcoloropts = $flagcoloropts . ""; } } - if ($currentvalues["status"] == 1) { - $activetag = ""; - } else { - $activetag = ""; - } } else { // set form options for add $sectiontitle = "Add New Flag

"; @@ -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 = ""; + if (!empty($currentvalues)) { + $name = $currentvalues["lpactionname"]; + if ($currentvalues["status"] == 1) { + $activetag = ""; + } else { + $activetag = ""; + } } else { + $name = NULL; $activetag = ""; } } 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) { From 8647c9b4d86e830a708ae1cc955d25b143e8cb3b Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 24 Feb 2026 09:50:59 -0500 Subject: [PATCH 49/50] Refresh page to show changes when user selects a different color --- distfiles/profile.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distfiles/profile.php b/distfiles/profile.php index 48319d1..9954d63 100644 --- a/distfiles/profile.php +++ b/distfiles/profile.php @@ -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\""); From b70996b4d914ec7a6918666a07b3c374f7f8efc5 Mon Sep 17 00:00:00 2001 From: Rod Wright Date: Tue, 24 Feb 2026 10:22:09 -0500 Subject: [PATCH 50/50] Fixed typo (applocation) --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e347366..8020cf3 100755 --- a/install.sh +++ b/install.sh @@ -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