7 Commits

18 changed files with 712 additions and 308 deletions

View File

@@ -193,10 +193,54 @@
fixed. Made the corrections to the edit code as well as the fixed. Made the corrections to the edit code as well as the
new entry. new entry.
- In logentry.php, the default times for notes entered using dates - In logentry.php, the default times for notes entered using dates
other than today's date contained a trailing coln that mysql other than today's date contained a trailing colon that mysql
didn't like. Removed trailing colons. didn't like. Removed trailing colons.
- Cleaned up the REQUEST importation in multiple files to default to - Cleaned up the REQUEST importation in multiple files to default to
NULL values for parameters not supplied to prevent warning NULL values for parameters not supplied to prevent warning
messages in the logs. messages in the logs.
- In the install.sh script, removed the prompts for optional package - In the install.sh script, removed the prompts for optional package
installation. Code is still there, just turned off by default. installation. Code is still there, just turned off by default.
5.2.4.1 - 2025-12-10
- Fixed bug in search.php where "Print search results" link on the
search results page resulted in the printable page not showing
any results. This was due to a php fatal error caused by passing
a non-array as the second argument of the php in_array()
function.
5.2.4.2 - 2025-12-11
- Fixed other bugs caused by passing a non-array as the second
argument of the php in_array() function in various files.
5.2.4.3 - 2025-12-16
- Various problems were noted resulting from php's use of UTC as the
default timezone. Now, on installation or upgrade, the installer
gets the correct timezone from the system and sets it as a php
option in a .htaccess file in the install location. This solves
multiple problems and allows today's date and the current time
to be determined from the php date() function as part of the
settings.php once per page load instead of having to query the
database multiple times per page load. Also added the option to
allow apache to read the .htaccess file to the <Directory>
section of the application's conf file in
/etc/apache2/conf-available
- Renamed the installer's db.php_update.sh script to files-update.sh
to reflect that it now can do more than just modify the db.php
file. For this version, it's used to modify the apache conf file
mentioned earlier.
- Completely removed the optional package prompting/installation
code from install.sh. This is best done using separate
installers.
5.2.4.4 - 2025-12-19
-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.

323
LICENSE
View File

@@ -1,5 +1,5 @@
The following license applies to all OpenLog code The following license applies to all OpenLog code
Copyright (C) 2016 by Rod Wright : Copyright (C) 2026 by Rod Wright :
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
@@ -382,3 +382,324 @@ The following license applies to jquery code :
CC0: http://creativecommons.org/publicdomain/zero/1.0/ 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/.

0
README.md Normal file
View File

1
VERSION.txt Normal file
View File

@@ -0,0 +1 @@
5.2.5

View File

@@ -69,7 +69,7 @@ CREATE TABLE `configs` (
LOCK TABLES `configs` WRITE; LOCK TABLES `configs` WRITE;
/*!40000 ALTER TABLE `configs` DISABLE KEYS */; /*!40000 ALTER TABLE `configs` DISABLE KEYS */;
INSERT INTO `configs` VALUES INSERT INTO `configs` VALUES
(1,'ol_version','5.2.4'), (1,'ol_version','5.2.5'),
(2,'log_name','OpenLog'), (2,'log_name','OpenLog'),
(3,'banner','1'), (3,'banner','1'),
(4,'background_color','#003333'), (4,'background_color','#003333'),

39
database-update.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# database-update.sh
# OpenLog Online Logbook
# Copyright (C) 2025 Rod Wright
# SPDX-License-Identifier: GPL-2.0
if [[ $1 == "" ]]
then
echo "This script requires a mysql options file, but none was specified. Aborting."
exit 1
fi
mysql_opt_file=$1
if [[ ! -f $mysql_opt_file ]]
then
echo "The mysql options file specified does not exist. Aborting."
exit 1
fi
margs="--defaults-extra-file=$mysql_opt_file"
# ---------- version x.x.x ----------
# Nothing to be done for versions prior to 5.2.4.3
# -----------------------------------
# ---------- version 5.2.4.3 ----------
# Nothing to do
# -------------------------------------
# ---------- version 5.2.4.4 ----------
# Nothing to do
# -------------------------------------
# ---------- version 5.2.5 ------------
# Nothing to do
# -------------------------------------

View File

@@ -30,3 +30,28 @@ UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version";
-- Update version number -- 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";
-- --------------------------------------
-- ---------- version 5.2.4.2 -----------
-- Update version number
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";
-- --------------------------------------
-- ---------- version 5.2.4.4 -----------
-- Update version number
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";
-- --------------------------------------

View File

@@ -1,19 +0,0 @@
# opendrs-update.sh
install_path=$1
# ---------- version 5.2.1 -------------
# No changes to the db.php file
# ---------------------------------------
# ---------- version 5.2.2 -------------
# No changes to the db.php file
# ---------------------------------------
# ---------- version 5.2.3 -------------
# No changes to the db.php file
# ---------------------------------------
# ---------- version 5.2.4 -------------
# No changes to the db.php file
# ---------------------------------------

View File

@@ -201,3 +201,47 @@
- In the install.sh script, removed the prompts for optional package - In the install.sh script, removed the prompts for optional package
installation. Code is still there, just turned off by default. installation. Code is still there, just turned off by default.
5.2.4.1 - 2025-12-10
- Fixed bug in search.php where "Print search results" link on the
search results page resulted in the printable page not showing
any results. This was due to a php fatal error caused by passing
a non-array as the second argument of the php in_array()
function.
5.2.4.2 - 2025-12-11
- Fixed other bugs caused by passing a non-array as the second
argument of the php in_array() function in various files.
5.2.4.3 - 2025-12-16
- Various problems were noted resulting from php's use of UTC as the
default timezone. Now, on installation or upgrade, the installer
gets the correct timezone from the system and sets it as a php
option in a .htaccess file in the install location. This solves
multiple problems and allows today's date and the current time
to be determined from the php date() function as part of the
settings.php once per page load instead of having to query the
database multiple times per page load. Also added the option to
allow apache to read the .htaccess file to the <Directory>
section of the application's conf file in
/etc/apache2/conf-available
- Renamed the installer's db.php_update.sh script to files-update.sh
to reflect that it now can do more than just modify the db.php
file. For this version, it's used to modify the apache conf file
mentioned earlier.
- Completely removed the optional package prompting/installation
code from install.sh. This is best done using separate
installers.
5.2.4.4 - 2025-12-19
-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.

View File

@@ -721,8 +721,7 @@ function showlinklist($print) {
function nag($tech_id) { function nag($tech_id) {
// nags the user if something is pending // nags the user if something is pending
global $db; global $db, $today;
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
// maintenance forms // maintenance forms
$mfpending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$tech_id\" and pending=1")); $mfpending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
if ($mfpending) { if ($mfpending) {
@@ -820,8 +819,7 @@ function get_upcoming_events() {
// build array of upcoming events // build array of upcoming events
// takes no arguments // takes no arguments
// returns an array containing arrays of upcoming event data // returns an array containing arrays of upcoming event data
global $db; global $db, $today;
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
$uceventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))"); $uceventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
$ucevents=array(); $ucevents=array();
while ($uceventrow=mysqli_fetch_assoc($uceventsqry)) { while ($uceventrow=mysqli_fetch_assoc($uceventsqry)) {

View File

@@ -77,9 +77,6 @@ if ($edit || $delete) {
// ******** begin database manipulation ******** // ******** begin database manipulation ********
// determine today's date and make it the default
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
$now=mysqli_fetch_row(mysqli_query($db,"select current_time"))[0];
if ($add) { if ($add) {
if ($submit) { if ($submit) {
// add the entry if submit is pressed // add the entry if submit is pressed
@@ -249,6 +246,7 @@ if ($add) {
$flagids=mysqli_query($db,"select flagid from flags"); $flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) { while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0]; $thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[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\""))) { 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\")"); mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"notetemplates\",\"$templateid\")");
@@ -368,6 +366,7 @@ if ($edit) {
$chainmembers=generate_chain($noteid); $chainmembers=generate_chain($noteid);
while ($thisflagid=mysqli_fetch_row($flagids)) { while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0]; $thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[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\""))) { if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
// set flag for this noteid // set flag for this noteid

View File

@@ -29,7 +29,6 @@ if ($print) {
} }
// use default date values if not supplied // use default date values if not supplied
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
if ($tgt_date=="") $tgt_date=$today; if ($tgt_date=="") $tgt_date=$today;
// define shifttable_classic function // define shifttable_classic function

View File

@@ -104,9 +104,6 @@ if ($printfmt) {
} }
// ******** begin database manipulation ******** // ******** begin database manipulation ********
// determine today's date and make it the default
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
$now=mysqli_fetch_row(mysqli_query($db,"select current_time"))[0];
//var_dump($_REQUEST); //var_dump($_REQUEST);
@@ -146,10 +143,8 @@ if ($mfadd) {
} }
// remove cruft from malfunction text // remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction); $mfmalfunction=htmlentities($mfmalfunction);
if (!get_magic_quotes_gpc()) { $mfmalfunction=addslashes($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
}
if ($mfauthorized) { if ($mfauthorized) {
$partdatainput=array(); $partdatainput=array();
if ($uid) $partdatainput['uid']=$uid; if ($uid) $partdatainput['uid']=$uid;
@@ -170,6 +165,8 @@ if ($mfadd) {
if ($uid =="" || $partnum == "" || $sernum == "") { if ($uid =="" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data // have the maintenance form stay pending due to incomplete part data
$pending=1; $pending=1;
} else {
$pending=0;
} }
// add the record to maintforms // add the record to maintforms
@@ -195,13 +192,14 @@ if ($mfedit) {
if ($mfmalfunction && ($uid || ($partnum && $sernum))) { if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// remove cruft from malfunction text // remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction); $mfmalfunction=htmlentities($mfmalfunction);
if (!get_magic_quotes_gpc()) { $mfmalfunction=addslashes($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
}
// update parts table // update parts table
if ($uid =="" || $partnum == "" || $sernum == "") { if ($uid =="" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data // have the maintenance form stay pending due to incomplete part data
$pending=1; $pending=1;
} else {
$pending=0;
} }
if (! $pdatamismatch) { 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\"");
@@ -215,6 +213,7 @@ if ($mfedit) {
$flagids=mysqli_query($db,"select flagid from flags"); $flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) { while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0]; $thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[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\""))) { 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\")"); mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")");
@@ -256,10 +255,8 @@ if ($actionadd) {
} }
// remove cruft from action text // remove cruft from action text
$action=htmlentities($action); $action=htmlentities($action);
if (!get_magic_quotes_gpc()) { $action=addslashes($action);
$action=addslashes($action);
}
// add to maintactions table // 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\")"); values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")");
@@ -273,9 +270,8 @@ if ($actionedit) {
// update the action // update the action
// remove cruft from action text // remove cruft from action text
$action=htmlentities($action); $action=htmlentities($action);
if (!get_magic_quotes_gpc()) { $action=addslashes($action);
$action=addslashes($action);
}
// update maintactions table // 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\"");
} }
@@ -399,6 +395,7 @@ if ($printfmt) {
} }
$flagslist=mysqli_query($db,"select * from flags"); $flagslist=mysqli_query($db,"select * from flags");
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagsymbol["flagid"],$theseflags)) { if (in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;"; echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
} }
@@ -491,6 +488,7 @@ if ($printfmt) {
$flagsperline=8; $flagsperline=8;
$flagcount=1; $flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagcheckbox["flagid"],$theseflags)) { if (in_array($flagcheckbox["flagid"],$theseflags)) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>", printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);

View File

@@ -14,50 +14,50 @@ if (isset($_SESSION['login'])) {
} else { } else {
$loggedin=false; $loggedin=false;
} }
$techid=$_SESSION['login']; $techid=$_SESSION['login'] ?? NULL;
$isadmin=dblookup($db,"techs","techid","admin",$techid); $isadmin=dblookup($db,"techs","techid","admin",$techid);
$upcoming=$_REQUEST['upcoming']; $upcoming=$_REQUEST['upcoming'] ?? NULL;
$schedule=$_REQUEST['schedule']; $schedule=$_REQUEST['schedule'] ?? NULL;
$tasks=$_REQUEST['tasks']; $tasks=$_REQUEST['tasks'] ?? NULL;
$devices=$_REQUEST['devices']; $devices=$_REQUEST['devices'] ?? NULL;
$action=$_REQUEST['action']; $action=$_REQUEST['action'] ?? NULL;
$complete=$_REQUEST['complete']; $complete=$_REQUEST['complete'] ?? NULL;
$defer=$_REQUEST['defer']; $defer=$_REQUEST['defer'] ?? NULL;
$add=$_REQUEST['add']; $add=$_REQUEST['add'] ?? NULL;
$edit=$_REQUEST['edit']; $edit=$_REQUEST['edit'] ?? NULL;
$update=$_REQUEST['update']; $update=$_REQUEST['update'] ?? NULL;
$delete=$_REQUEST['delete']; $delete=$_REQUEST['delete'] ?? NULL;
$id=$_REQUEST['id']; $id=$_REQUEST['id'] ?? NULL;
$active_flag=$_REQUEST['active_flag']; $active_flag=$_REQUEST['active_flag'] ?? 0;
$devicename=$_REQUEST['devicename']; $devicename=$_REQUEST['devicename'] ?? NULL;
$devicedesc=$_REQUEST['devicedesc']; $devicedesc=$_REQUEST['devicedesc'] ?? NULL;
$group_flag=$_REQUEST['group_flag']; $group_flag=$_REQUEST['group_flag'] ?? 0;
$members=$_REQUEST['members']; $members=$_REQUEST['members'] ?? [];
$weekdays_only=$_REQUEST['weekdays_only']; $weekdays_only=$_REQUEST['weekdays_only'] ?? NULL;
$nextdue_relative=$_REQUEST['nextdue_relative']; $nextdue_relative=$_REQUEST['nextdue_relative'] ?? NULL;
$taskname=$_REQUEST['taskname']; $taskname=$_REQUEST['taskname'] ?? NULL;
$taskdesc=$_REQUEST['taskdesc']; $taskdesc=$_REQUEST['taskdesc'] ?? NULL;
$frequency=$_REQUEST['frequency']; $frequency=$_REQUEST['frequency'] ?? NULL;
$period=$_REQUEST['period']; $period=$_REQUEST['period'] ?? NULL;
$refdoc_name=$_REQUEST['refdoc_name']; $refdoc_name=$_REQUEST['refdoc_name'] ?? NULL;
$refdoc_url=$_REQUEST['refdoc_url']; $refdoc_url=$_REQUEST['refdoc_url'] ?? NULL;
$deferred_flag=$_REQUEST['deferred_flag']; $deferred_flag=$_REQUEST['deferred_flag'] ?? 0;
$deferred_date=$_REQUEST['deferred_date']; $deferred_date=$_REQUEST['deferred_date'] ?? NULL;
$start_date=$_REQUEST['start_date']; $start_date=$_REQUEST['start_date'] ?? NULL;
$last_date=$_REQUEST['last_date']; $last_date=$_REQUEST['last_date'] ?? NULL;
$task=$_REQUEST['task']; $task=$_REQUEST['task'] ?? NULL;
$device=$_REQUEST['device']; $device=$_REQUEST['device'] ?? NULL;
$deferuntil=$_REQUEST['deferuntil']; $deferuntil=$_REQUEST['deferuntil'] ?? NULL;
$completedate=$_REQUEST['completedate']; $completedate=$_REQUEST['completedate'] ?? NULL;
$addlognote=$_REQUEST['addlognote']; $addlognote=$_REQUEST['addlognote'] ?? NULL;
$logname=LOG_NAME; $logname=LOG_NAME;
$print=$_REQUEST['print']; $print=$_REQUEST['print'] ?? NULL;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor=P_SIDEBAR_COLOR;
@@ -67,7 +67,6 @@ if ($print) {
$mbgcolor=MENUBG_COLOR; $mbgcolor=MENUBG_COLOR;
} }
// **** BEGIN DATABASE OPERATIONS **** // **** BEGIN DATABASE OPERATIONS ****
$today=mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
$tomorrow=mysqli_fetch_row(mysqli_query($db,"select adddate((select current_date),1)"))[0]; $tomorrow=mysqli_fetch_row(mysqli_query($db,"select adddate((select current_date),1)"))[0];
$errorstack=array(); $errorstack=array();
@@ -127,6 +126,9 @@ if ($add) {
} }
// run through the memberlist and modify the table // run through the memberlist and modify the table
foreach ($memberlist as $memberdev) { 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) $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\")"); values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")");
mysqli_query($db,$addqry); mysqli_query($db,$addqry);
@@ -201,6 +203,9 @@ if ($edit) {
$last_date=mysqli_real_escape_string($db,$last_date); $last_date=mysqli_real_escape_string($db,$last_date);
$deferred_date=mysqli_real_escape_string($db,$deferred_date); $deferred_date=mysqli_real_escape_string($db,$deferred_date);
// update the tasks table // 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 mysqli_query($db,"update events
set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\", 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\" deferred_date=\"$deferred_date\",active_flag=\"$active_flag\"
@@ -401,7 +406,7 @@ if ($action) {
} }
if ($start_date=="0000-00-00") $start_date=$today; if ($start_date=="0000-00-00") $start_date=$today;
if ($last_date=="0000-00-00") $last_date=""; if ($last_date=="0000-00-00") $last_date="";
if ($deferred_date=="0000-00-00") $deferred_date=""; if ($deferred_date=="0000-00-00") $deferred_date=$tomorrow;
$deferuntiltag="<input type=\"text\" name=\"deferred_date\" id=\"deferdatepicker\" size=\"10\" maxlength=\"10\" value=\"$deferred_date\" title=\"Format: YYYY-MM-DD\">"; $deferuntiltag="<input type=\"text\" name=\"deferred_date\" id=\"deferdatepicker\" size=\"10\" maxlength=\"10\" value=\"$deferred_date\" title=\"Format: YYYY-MM-DD\">";
$startdatetag="<input type=\"text\" name=\"start_date\" id=\"startdatepicker\" size=\"10\" maxlength=\"10\" value=\"$start_date\" title=\"Format: YYYY-MM-DD\">"; $startdatetag="<input type=\"text\" name=\"start_date\" id=\"startdatepicker\" size=\"10\" maxlength=\"10\" value=\"$start_date\" title=\"Format: YYYY-MM-DD\">";
$lastdatetag="<input type=\"text\" name=\"last_date\" id=\"completedatepicker\" size=\"10\" maxlength=\"10\" value=\"$last_date\" title=\"Format: YYYY-MM-DD\">"; $lastdatetag="<input type=\"text\" name=\"last_date\" id=\"completedatepicker\" size=\"10\" maxlength=\"10\" value=\"$last_date\" title=\"Format: YYYY-MM-DD\">";

View File

@@ -58,20 +58,19 @@ framework("begin","$logname Search","Search",$print);
// ******** begin database manipulation ******** // ******** begin database manipulation ********
// get the date range of lognotes // get the date range of lognotes
$todaysdate = mysqli_fetch_row(mysqli_query($db,"select current_date"))[0];
$logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes"); $logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes");
$logdateresults=mysqli_fetch_row($logdateqry); $logdateresults=mysqli_fetch_row($logdateqry);
$logmindate=$logdateresults[0]; $logmindate=$logdateresults[0];
if ($logmindate == "") $logmindate = $todaysdate; if ($logmindate == "") $logmindate = $today;
$logmaxdate=$logdateresults[1]; $logmaxdate=$logdateresults[1];
if ($logmaxdate == "") $logmaxdate = $todaysdate; if ($logmaxdate == "") $logmaxdate = $today;
// get the date range of maintenance forms // get the date range of maintenance forms
$mfdateqry=mysqli_query($db,"select min(mfdate), max(mfdate) from maintforms"); $mfdateqry=mysqli_query($db,"select min(mfdate), max(mfdate) from maintforms");
$mfdateresults=mysqli_fetch_row($mfdateqry); $mfdateresults=mysqli_fetch_row($mfdateqry);
$mfmindate=$mfdateresults[0]; $mfmindate=$mfdateresults[0];
if ($mfmindate == "") $mfmindate = $todaysdate; if ($mfmindate == "") $mfmindate = $today;
$mfmaxdate=$mfdateresults[1]; $mfmaxdate=$mfdateresults[1];
if ($mfmaxdate == "") $mfmaxdate = $todaysdate; if ($mfmaxdate == "") $mfmaxdate = $today;
// determine entire date range // determine entire date range
$mindate=min($logmindate, $mfmindate); $mindate=min($logmindate, $mfmindate);
$maxdate=max($logmaxdate, $mfmaxdate); $maxdate=max($logmaxdate, $mfmaxdate);
@@ -84,6 +83,7 @@ if ($search) {
$srchpname=trim($srchpname); $srchpname=trim($srchpname);
$srchploc=trim($srchploc); $srchploc=trim($srchploc);
$srchnha=trim($srchnha); $srchnha=trim($srchnha);
if ($target[0]=="") $target=[];
if (in_array("log",$target)) { if (in_array("log",$target)) {
// define the query constraints // define the query constraints
// log note id // log note id
@@ -188,6 +188,7 @@ if ($search) {
$logwhereclause=implode(" and ",$logconstraints); $logwhereclause=implode(" and ",$logconstraints);
$logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc"); $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 (in_array("maintform",$target)) {
// maintforms search // maintforms search
// define the query constraints // define the query constraints
@@ -284,6 +285,7 @@ if ($search) {
$mfwhereclause=implode(" and ",$mfconstraints); $mfwhereclause=implode(" and ",$mfconstraints);
$mfrowqry=mysqli_query($db,"select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc"); $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 (in_array("part",$target)) {
// parts search // parts search
// define the query constraints // define the query constraints
@@ -491,6 +493,7 @@ if (!$print) {
echo " echo "
<b>Search in:</b>&nbsp;&nbsp; <b>Search in:</b>&nbsp;&nbsp;
"; ";
if ($target[0]=="") $target=[];
if (in_array("log", $target)) { if (in_array("log", $target)) {
echo "<input type=\"checkbox\" name=\"target[]\" value=\"log\" title=\"Search in Logbook\" checked>Logbook&nbsp;&nbsp;"; echo "<input type=\"checkbox\" name=\"target[]\" value=\"log\" title=\"Search in Logbook\" checked>Logbook&nbsp;&nbsp;";
} else { } else {
@@ -589,9 +592,12 @@ if (!$print) {
$flagsperline=8; $flagsperline=8;
$flagcount=1; $flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if (in_array($flagcheckbox["flagid"],$srchflags)) { if ($srchflags) {
printf("<font color=\"%s\">%s</font>", if ($srchflags[0]=="") $srchflags=[];
$flagcheckbox["flagcolor"],$flagcheckbox["flagsym"]); if (in_array($flagcheckbox["flagid"],$srchflags)) {
printf("<font color=\"%s\">%s</font>",
$flagcheckbox["flagcolor"],$flagcheckbox["flagsym"]);
}
} }
if ($flagcount<$flagsperline) { if ($flagcount<$flagsperline) {
echo "&nbsp;&nbsp;&nbsp;"; echo "&nbsp;&nbsp;&nbsp;";
@@ -605,6 +611,7 @@ if (!$print) {
<br><br> <br><br>
"; ";
if ($doparts) { if ($doparts) {
if ($target[0]=="") $target=[];
echo " echo "
<b>Search in:</b>&nbsp;&nbsp; <b>Search in:</b>&nbsp;&nbsp;
"; ";
@@ -627,6 +634,7 @@ if (!$print) {
} }
if ($search) { if ($search) {
if ($target[0]=="") $target=[];
if (in_array("log",$target)) { if (in_array("log",$target)) {
// run lognotes query and show results // run lognotes query and show results
if(mysqli_num_rows($logrowqry)) { if(mysqli_num_rows($logrowqry)) {
@@ -684,6 +692,7 @@ if ($search) {
echo "<font size=\"+1\">No Logbook notes match your search criteria.</font><br><hr>"; echo "<font size=\"+1\">No Logbook notes match your search criteria.</font><br><hr>";
} }
} }
if ($target[0]=="") $target=[];
if (in_array("maintform",$target)) { if (in_array("maintform",$target)) {
// run maintforms query and show results // run maintforms query and show results
if(mysqli_num_rows($mfrowqry)) { if(mysqli_num_rows($mfrowqry)) {
@@ -746,6 +755,7 @@ if ($search) {
echo "<font size=\"+1\">No Maintenance Forms match your search criteria.</font><br><hr>"; echo "<font size=\"+1\">No Maintenance Forms match your search criteria.</font><br><hr>";
} }
} }
if ($target[0]=="") $target=[];
if (in_array("part",$target)) { if (in_array("part",$target)) {
// run parts query and show results // run parts query and show results
if(mysqli_num_rows($prowqry)) { if(mysqli_num_rows($prowqry)) {

View File

@@ -7,6 +7,10 @@
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
// determine today's date and time and assign them to variables
$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]; $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)); $ostype=strtoupper(substr(php_uname('s'), 0, 3));
if ($ostype == 'WIN') { if ($ostype == 'WIN') {

48
files-update.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/bash
# files_update.sh
install_path=$1
# ---------- version 5.2.1 -------------
# No changes
# --------------------------------------
# ---------- version 5.2.2 -------------
# No changes
# --------------------------------------
# ---------- version 5.2.3 -------------
# No changes
# --------------------------------------
# ---------- version 5.2.4 -------------
# No changes
# --------------------------------------
# ---------- version 5.2.4.1 -----------
# No changes
# --------------------------------------
# ---------- version 5.2.4.2 -----------
# No changes
# --------------------------------------
# ---------- version 5.2.4.3 -----------
# Add AllowOverride Options to the apache conf-available file
install_loc=$(basename $install_path)
if ! grep -q "AllowOverride Options" /etc/apache2/conf-available/$install_loc.conf
then
sed -i '/^<Directory/a\ AllowOverride Options' /etc/apache2/conf-available/$install_loc.conf
systemctl reload apache2
fi
# --------------------------------------
# ---------- version 5.2.4.4 -----------
# No changes
# --------------------------------------
# ---------- version 5.2.5 -------------
# No changes
# --------------------------------------

View File

@@ -8,21 +8,26 @@
APP_NAME="OpenLog" APP_NAME="OpenLog"
DEFAULT_DB_NAME="openlog" DEFAULT_DB_NAME="openlog"
APP_VERSION="5.2.4" APP_VERSION="5.2.5"
DOC_ROOT="/var/www" DOC_ROOT="/var/www"
INSTALL_LOC="openlog" INSTALL_LOC="openlog"
APACHE_USER="www-data"
APACHE_GROUP="www-data"
APACHE_CONF_DIR="/etc/apache2/conf-available" APACHE_CONF_DIR="/etc/apache2/conf-available"
BACKUP_DIR="openlog-previous-installation" BACKUP_DIR="openlog-previous-installation"
INDEX_FILE="lognotes.php" LANDING_PAGE="lognotes.php"
CONFIG_TABLE="configs" CONFIG_TABLE="configs"
CONFIG_NAME_COLUMN="confname" CONFIG_NAME_COLUMN="confname"
CONFIG_VALUE_COLUMN="confvalue" CONFIG_VALUE_COLUMN="confvalue"
CONFIG_DEFAULT_COLUMN="" CONFIG_DEFAULT_COLUMN=""
OFFER_OPTIONAL_PKGS=false
function privilege_check() {
# test for superuser rights
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with superuser privileges. Try sudo $0"
exit 1
fi
}
function get_new_password() { function get_new_password() {
# Stores new password in the variable $newpassword # Stores new password in the variable $newpassword
pwgood=false pwgood=false
@@ -105,11 +110,22 @@ function abort_exit() {
exit 1 exit 1
} }
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
}
# test for superuser rights # test for superuser rights
if [[ $EUID -ne 0 ]]; then privilege_check
echo "This script must be run with superuser privileges. Try sudo ./install.sh"
abort_exit
fi
echo "" echo ""
@@ -122,182 +138,28 @@ echo "Preparing for installation. Please wait..."
# Prevent unattended-upgrades from interfering # Prevent unattended-upgrades from interfering
restart_uu=false restart_uu=false
while systemctl status unattended-upgrades >/dev/null 2>&1 while dpkg -l|grep unattended-upgrades >/dev/null 2>&1
do do
systemctl stop unattended-upgrades systemctl stop unattended-upgrades
sleep 5 sleep 5
restart_uu=true restart_uu=true
done done
apt-get update apt-get update -qq
# Check for prerequisites and prompt to install # Check for prerequisites and prompt to install
echo "Checking for required packages..." echo "Checking for required packages..."
echo "" echo ""
install_required_packages "apache2" "php" "mysql-server or mariadb-server" "uuid-runtime" install_required_packages "apache2" "php" "mysql-server or mariadb-server" "php-mysql" "uuid-runtime"
echo "" echo ""
echo "Finished required package installation." echo "Finished required package installation."
echo "" echo ""
if $OFFER_OPTIONAL_PKGS # Determine the correct Apache2 user and group
then APACHE_USER=$(grep APACHE_RUN_USER /etc/apache2/envvars | cut -d= -f2)
# Check for optional packages and prompt to install APACHE_GROUP=$(grep APACHE_RUN_GROUP /etc/apache2/envvars | cut -d= -f2)
echo "Checking for optional packages..." httpd_user_group="$APACHE_USER:$APACHE_GROUP"
echo ""
echo "Checking for phpmyadmin installation..."
echo ""
if dpkg -l|grep phpmyadmin >/dev/null 2>&1
then
echo ""
echo "phpmyadmin is installed. Continuing."
echo ""
else
echo "phpmyadmin doesn't seem to be installed."
echo "It is an optional package that enables administration of the mysql/mariadb"
echo "database server using a friendly GUI. It is highly recommended."
echo "Note that this has the potential to be a security risk, especially"
echo "if your passwords aren't sufficiently strong."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing phpmyadmin. Database administration"
echo "will require the use of the mysql/mariadb command line tools."
else
echo ""
echo "Proceeding with phpmyadmin installation"
echo ""
sleep 3
echo ""
echo "During the following installation of phpmyadmin:"
echo ""
echo "- Select apache2 as the web server to configure automatically."
echo ""
echo "- Choose Yes when prompted to install phpmyadmin database and allow it to"
echo " generate a random password(leave the field blank)."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
apt-get install -y phpmyadmin
echo ""
echo ""
echo "In order to log in to the database using phpmyadmin, there must be a"
echo "database user with a password set who has administrator privileges."
echo "After a fresh installation of the MySQL or MariaDB server, the root"
echo "user doesn't have a password, and is unable to log in to the phpmyadmin"
echo "web GUI. You should create a new user with administrative rights now."
echo ""
read -p "New MySQL/MariaDB administrator username: " -r newdbadminuser
echo ""
get_new_password
newdbadminpass=$newpassword
unset newpassword
mysql -e "CREATE USER '$newdbadminuser'@'localhost'
IDENTIFIED VIA mysql_native_password USING password('$newdbadminpass');
GRANT ALL PRIVILEGES ON *.* TO '$newdbadminuser'@'localhost'
REQUIRE NONE WITH GRANT OPTION
MAX_QUERIES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_USER_CONNECTIONS 0;
flush privileges"
echo ""
echo ""
echo "You can now access phpmyadmin using a web browser pointed to:"
echo ""
echo " http://$HOSTNAME/phpmyadmin"
echo ""
echo "*** WARNING!! this url is accessible via unencrypted (http) connections."
echo "This is a huge security risk since the username and password you enter"
echo "on the phpmyadmin login page can be sent in the clear for any potential"
echo "attacker to sniff! You should enable redirection to https for phpmyadmin"
echo "in your apache2 configuration if your site is reachable from the internet."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "Finished with phpmyadmin installation"
echo ""
sleep 3
fi
fi
echo ""
echo "Checking for webmin installation..."
echo ""
if dpkg -l|grep webmin >/dev/null 2>&1
then
echo ""
echo "webmin is installed. Continuing."
echo ""
else
echo "webmin doesn't seem to be installed."
echo "It is an optional package that enables system administration"
echo "using a friendly GUI. It is highly recommended, especially for"
echo "headless servers without any way to log in directly on the machine."
echo "Note that this has the potential to be a security risk, especially"
echo "if your passwords aren't sufficiently strong."
echo -n "Install it now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
then
echo "Proceeding without installing webmin. System administration"
echo "will require login to the server either directly or via ssh."
else
echo ""
echo "Proceeding with webmin installation"
echo ""
sleep 3
echo "Installing webmin..."
skipwebmin="false"
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
then
echo "Warning: failed to download Webmin repo setup script."
echo -n "Ignore and [c]ontinue or [A]bort? [c/A]: "
read wmfailchoice
if [ "$wmfailchoice" = "C" -o "$wmfailchoice" = "c" ]
then
skipwebmin="true"
echo "Continuing without installing Webmin. You should investigate the failure"
echo "and install Webmin manually after the server is set up if you would like"
echo "to be able to manage the server from another computer with a GUI instead"
echo "of through ssh only."
echo -n "Press enter to continue."
read continueok
echo ""
fi
fi
if [ "$skipwebmin" = "false" ]
then
sh setup-repos.sh -f
apt-get install -y --install-recommends webmin
fi
echo "...done."
echo ""
echo "You can now access webmin using a web browser pointed to:"
echo "https://$HOSTNAME:10000"
echo "Unless you have obtained valid ssl certificates, your server is"
echo "using self-signed certs. This is not necessarily a problem, but"
echo "your browser will complain. You can tell the browser to accept the"
echo "self signed certificates and the traffic will still be encrypted,"
echo "however you may be vulnerable to man-in-the-middle attacks. You can"
echo "get free valid certificates through LetsEncrypt."
echo "See http://letsencrypt.org for more information."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo "Finished with webmin installation"
echo ""
sleep 3
fi
fi
echo ""
echo "Finished optional package installation."
fi
echo ""
sleep 3 sleep 3
# prompt for install location # prompt for install location
echo "Where would you like to install this version of $APP_NAME? This should" echo "Where would you like to install this version of $APP_NAME? This should"
@@ -322,6 +184,7 @@ fi
install_path="$doc_root_in/$install_loc_in" install_path="$doc_root_in/$install_loc_in"
if [ -d "$install_path" ] if [ -d "$install_path" ]
then then
echo "The installation path you chose already exists."
# Install path exists. # Install path exists.
if [ -e "$install_path/db.php" ] if [ -e "$install_path/db.php" ]
then then
@@ -329,31 +192,59 @@ then
if grep -q -e "$APP_NAME" $install_path/db.php if grep -q -e "$APP_NAME" $install_path/db.php
then then
# the db.php file is part of a previous installation # the db.php file is part of a previous installation
echo "The installation path you chose already exists."
echo "Would you like to upgrade an existing installation or cancel " echo "Would you like to upgrade an existing installation or cancel "
echo "and restart the install using a new installation location." echo "and restart the install using a new installation location."
echo -n "[U]pgrade or [C]ancel? [C] :" echo -n "[U]pgrade or [C]ancel? [U] :"
read upgrade_choice read upgrade_choice
if [ "$upgrade_choice" = "U" -o "$upgrade_choice" = "u" ] # Upgrade chosen if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen
then then
echo "Cancelling installation"
abort_exit
else
# proceed with upgrade # proceed with upgrade
mkdir -p backups
operation="upgraded" operation="upgraded"
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
# create mysql option file with data for this installation
mysql_opt_file=$(mktemp --tmpdir=/run/shm/)
echo "[client]" > $mysql_opt_file
echo "user = $(grep username $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
echo "password = $(grep dbpass $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
echo "" >> $mysql_opt_file
echo "[mysql]" > $mysql_opt_file
echo "database = $curr_dbname" >> $mysql_opt_file
echo "batch" >> $mysql_opt_file
echo "disable-column-names" >> $mysql_opt_file
# back up existing database # back up existing database
echo "Backing up the current database to the package directory." echo "Backing up the current database to the package directory."
curr_dbname=`grep dbname $install_path/db.php | head -1 | cut -d "\"" -f2` mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
curr_username=`grep username $install_path/db.php | head -1 | cut -d "\"" -f2`
curr_dbpass=`grep dbpass $install_path/db.php | head -1 | cut -d "\"" -f2`
export MYSQL_PWD="$curr_dbpass"
mysqldump --no-tablespaces -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
# back up existing installation # back up existing installation
echo "Backing up current installation to the package directory." echo "Backing up current installation to the package directory."
cp -R $install_path $install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
# delete all existing installation files except db.php # delete all existing installation files except db.php
find $install_path/ -mindepth 1 -not -name 'db.php' -delete find $install_path/ -mindepth 1 -not -name 'db.php' -delete
# apply database updates
mysql -u"$curr_username" -f -D $curr_dbname < database-update.sql >/dev/null 2>&1 echo "Performing database updates. This may take a while..."
# apply updates to existing db.php # apply database updates from sql file
bash ./db.php_update $install_path (mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
task_pid=$!
spinner $task_pid
# apply database updates via script
(bash ./database-update.sh $mysql_opt_file) &
task_pid=$!
spinner $task_pid
echo "... finished with database updates."
rm -f $mysql_opt_file
# apply updates to other files
bash ./files-update.sh $install_path
# copy distribution to install location # copy distribution to install location
echo "Installing distribution . . ." echo "Installing distribution . . ."
cp -R distfiles/* $install_path cp -R distfiles/* $install_path
@@ -365,27 +256,17 @@ then
# set symlink for index.php # set symlink for index.php
if [ ! -L "$install_path/index.php" ] if [ ! -L "$install_path/index.php" ]
then then
ln -s $install_path/$INDEX_FILE $install_path/index.php ln -s $install_path/$LANDING_PAGE $install_path/index.php
fi fi
# add the local timezone to .htaccess
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
echo "Your local timezone is $local_tz"
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
# set ownership # set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
echo "usually not the root account. Refer to the ownership of other files in"
echo "your webserver's document tree to see what this should be."
echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the $APP_NAME installation"
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
read httpd_user_group
if [ "$httpd_user_group" = "" ]
then
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
fi
echo "" echo ""
echo "Setting file ownership . . ." echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path chown -R $httpd_user_group $install_path
else
echo "Cancelling installation"
abort_exit
fi fi
else else
# This was a mistake. Exit now to avoid clobbering another app. # This was a mistake. Exit now to avoid clobbering another app.
@@ -396,8 +277,21 @@ then
else else
# This was a mistake. Exit now to avoid clobbering another app. # This was a mistake. Exit now to avoid clobbering another app.
echo "The installation directory you chose exists, but no previous installation" echo "The installation directory you chose exists, but no previous installation"
echo "of $APP_NAME was found. Please investigate the situation. Aborting now." echo "of $APP_NAME was found."
abort_exit echo ""
echo " CAUTION: If there is anything else in this directory, it will be deleted!"
echo ""
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" ]]
do
read proceed -p "[P]roceed with new install or [Q]uit? : "
done
if [[ $proceed == "Q" || $proceed == "q" ]]
then
abort_exit
fi
fi fi
else else
# This is a fresh install # This is a fresh install
@@ -486,21 +380,14 @@ else
fi fi
if [ ! -L "$install_path/index.php" ] if [ ! -L "$install_path/index.php" ]
then then
ln -s $install_path/lognotes.php $install_path/index.php ln -s $install_path/$LANDING_PAGE $install_path/index.php
fi fi
# add the local timezone to .htaccess
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
echo "Your local timezone is $local_tz"
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
# set ownership # set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
echo "usually not the root account. Refer to the ownership of other files in"
echo "your webserver's document tree to see what this should be."
echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the $APP_NAME installation"
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
read httpd_user_group
if [ "$httpd_user_group" = "" ]
then
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
fi
echo "" echo ""
echo "Setting file ownership . . ." echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path chown -R $httpd_user_group $install_path
@@ -521,6 +408,7 @@ then
echo "Alias /$base_url $doc_root_in/$base_url" >> $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 "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf echo "<Directory $doc_root_in/$base_url>" >> $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 " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf