58 Commits
5.2.4 ... 5.3.0

Author SHA1 Message Date
b0aaf70e4d Merge remote-tracking branch 'origin/5.3.0dev' 2026-02-24 10:46:30 -05:00
b70996b4d9 Fixed typo (applocation) 2026-02-24 10:22:09 -05:00
8647c9b4d8 Refresh page to show changes when user selects a different color 2026-02-24 09:50:59 -05:00
b201ac6d24 Fixes to prevent php warnings about trying to access array offset on null 2026-02-24 09:50:05 -05:00
1480feecf0 Reformats 2026-02-24 09:48:02 -05:00
f84395f79a Reformats 2026-02-24 09:47:38 -05:00
f3db1c1523 Updated for color preference fix 2026-02-24 09:46:43 -05:00
962bd7b504 moved the flags part of the constraints generation for log and maintform search to the end to avoid mysql unknown column error 2026-02-23 13:36:30 -05:00
ec8efec61e determine original owner of template to prevent stealing it when the intent is to copy it 2026-02-23 06:37:51 -05:00
d23a19a3eb changed insertion of all zeroes deferred date into the database with a date that will pass validation 2026-02-23 06:36:25 -05:00
152bb30029 fixed typo in flagmap table update 2026-02-23 06:35:10 -05:00
11c876886a fixed invalid array key php warnings 2026-02-23 06:34:32 -05:00
9cce143cf9 fixed invalid array key php warning 2026-02-23 06:34:03 -05:00
eb29a3799c Modified templateselect function to show all users templates in user dropdown if current user is admin 2026-02-23 06:33:16 -05:00
ba7db9279d Created landing page to inform users during upgrades 2026-02-23 06:31:49 -05:00
ce8e5d9ca7 Modified to use apache conf template and take app offline during upgrade 2026-02-23 06:31:11 -05:00
0600ba18cd Template apache config file created 2026-02-23 06:30:24 -05:00
ef0599342b Added -q option to a2enconf/a2disconf to suppress their output. 2026-02-20 07:46:18 -05:00
5129d30992 Updated to reflect date/time validation. 2026-02-20 07:24:45 -05:00
ed7a25cea3 Fixed incorrect version for initial database. 2026-02-20 07:24:04 -05:00
968964e3fe updates in work to use fix_date function 2026-02-19 21:22:28 -05:00
d41519ba91 Updated to use fix_date and fix_time functions 2026-02-19 21:21:50 -05:00
513017d3cb Created fix_date and fix_time functions 2026-02-19 21:21:07 -05:00
3385954624 Convert single bracket ifs to double bracket. Disable access to app during upgrade. 2026-02-19 19:22:13 -05:00
5a50400a56 changed an info message 2026-02-19 18:48:26 -05:00
b138f462d9 Moved spinners for database upgrades from install.sh to database-update.sh 2026-02-19 18:33:19 -05:00
dd86d2e519 Updated for new version. 2026-02-19 16:03:10 -05:00
41c5b4560b Updated to utf8mb4 encoding 2026-02-19 14:28:10 -05:00
01fd47814b Various reformats. Changed boolean variables from 1/0 to TRUE/FALSE in multiple files. 2026-02-19 14:08:40 -05:00
9122040863 Replaced template line loading code with the templateselect function. 2026-02-18 14:11:52 -05:00
86f1512cc0 Removed hardcoded form action to templates.php in the templateselect function. 2026-02-18 14:10:33 -05:00
0145f5849f Minor cleanups and removed references to installing on Windows since we don't try to support that any more. 2026-02-18 13:00:04 -05:00
c4d2d4334e Cleanup to avoid php undefined array key warning 2026-02-18 12:56:49 -05:00
5e1856f1dc Cleanups to avoid php undefined variable warnings. Changed boolean variables from 1/0 to TRUE/FALSE. Converted flag handling code to the new scheme. 2026-02-18 12:48:29 -05:00
262bd6dcdc Minor cleanups to prevent php undefined variables warnings. 2026-02-18 12:42:03 -05:00
ff71083b49 fixes to get_part_data to prevent php undefined variable warnings 2026-02-18 12:40:40 -05:00
1a4c9a9c2a Fixed bug where the shifts weren't being shown in the existing techs table. 2026-02-18 12:37:45 -05:00
5396f3367b Various cleanups to avoid php undefined variable warnings 2026-02-18 12:33:25 -05:00
557af4db04 Set REQUEST variables to default to NULL if not passed to avoid php warnings 2026-02-18 12:31:44 -05:00
cc2b638a6a Removed useless hyperlinks from headers of parts results table. 2026-02-18 12:29:58 -05:00
63bb7a3445 More work on flags 2026-02-17 14:43:46 -05:00
35173f6faa Update LICENSE
Added license info for the Fugue icon set
2026-02-14 10:57:37 -05:00
f20b4cd8b6 Update LICENSE
Added License info for the Fugue icon set
2026-02-14 10:55:58 -05:00
71f60d353f got lognote multi flag search working 2026-02-13 21:15:52 -05:00
f74385d8f3 flag fixes in work 2026-02-12 21:56:45 -05:00
9e392faa4d restored the flagmap and reflinks table creations that somehow got deleted 2026-02-12 20:40:56 -05:00
d2cb1851d0 restored the flag table and reference chain modifiactions that somehow got deleted 2026-02-12 20:40:05 -05:00
07a6d352b0 changed path of backup directory inside the package directory to avoid cluttering up package directory. 2026-02-12 20:38:40 -05:00
0547e97479 Moved templateselect function from templates.php to functions.php for use in other pages. 2026-02-12 19:42:36 -05:00
a79f73a8ca Continued work on templates.php 2026-02-11 22:28:02 -05:00
78ee18f03b Created a useful README.md file 2026-02-11 15:48:46 -05:00
c11ef1ad8c Updated various files where the version number exists.
Continued work on templates.php.
2026-02-10 22:18:42 -05:00
85f6fc6f4a Added VERSION.txt to base directory so that package creation script will work. 2026-02-10 15:49:23 -05:00
9b7dfbe434 Release version 5.2.5 2026-02-10 15:41:37 -05:00
0265918430 Incorporate changes made for old version 5.2.4.4. 2026-02-10 15:17:09 -05:00
4341c87daa Incorporate changes made for old version 5.2.4.3 2026-02-10 15:02:40 -05:00
6b720a6163 Incorporate changes made for old version 5.2.4.2 2026-02-10 15:01:54 -05:00
3a0cf99432 Incorporate changes made for old version 5.2.4.1 2026-02-10 15:01:05 -05:00
35 changed files with 5315 additions and 3408 deletions

3
BUGS
View File

@@ -1,4 +1,5 @@
BUGS 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. 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.)

View File

@@ -1,6 +1,6 @@
CHANGELOG CHANGELOG
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
@@ -193,10 +193,92 @@
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.
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.
- 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.

34
INSTALL
View File

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

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/.

52
README.md Normal file
View File

@@ -0,0 +1,52 @@
# 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, 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
## Installation ##
> [!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`.
* 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 ##
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.

View File

@@ -1,15 +1,15 @@
TODO.txt TODO.txt
1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE 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) 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) 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. 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. 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 7. Implement popup calendars for date entry fields. DONE
8. Improve template management interface. It can be confusing. It needs its own page. 8. Improve template management interface. It can be confusing. It needs its own page. DONE
9. Remove refs from templates. (db change reqd) 9. Remove refs from templates. (db change reqd) DONE
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) 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) 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 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. 13. make some flags immutable so they won't be synced on reference chain.

1
VERSION.txt Normal file
View File

@@ -0,0 +1 @@
5.3.0

File diff suppressed because it is too large Load Diff

146
database-update.sh Executable file
View File

@@ -0,0 +1,146 @@
#!/bin/bash
# database-update.sh
# OpenLog Online Logbook
# Copyright (C) 2025 Rod Wright
# 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
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
# -------------------------------------
# ---------- version 5.3.0 ------------
#
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 "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'")
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
) &
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 "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")
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
) &
task_pid=$!
spinner $task_pid
echo "...done."
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")
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
) &
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
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."
# -------------------------------------

View File

@@ -2,31 +2,85 @@
-- ---------- version 5.2.1 ------------- -- ---------- version 5.2.1 -------------
-- Make confname a unique column -- 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 db name, user, and password configs
DELETE FROM configs where confname="ol_dbname"; 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_dbuser";
DELETE FROM configs where confname = "ol_dbpass";
-- Add config option for server side error logging -- 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 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 ------------- -- ---------- version 5.2.2 -------------
-- Update version number -- 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 ------------- -- ---------- version 5.2.3 -------------
-- Update version number -- 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 ------------- -- ---------- version 5.2.4 -------------
-- 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";
-- --------------------------------------
-- ---------- 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;
-- -------------------------------------- -- --------------------------------------

View File

@@ -3,7 +3,7 @@
/* /*
db.php db.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -14,10 +14,10 @@
** DO NOT EDIT ** ** DO NOT EDIT **
************************************************************************ ************************************************************************
*/ */
$appname="APPNAME"; $appname = "APPNAME";
$dbname="DBNAME"; $dbname = "DBNAME";
$username="DBUSER"; $username = "DBUSER";
$dbpass="DBPASS"; $dbpass = "DBPASS";
function dberrmsg($dbname) { function dberrmsg($dbname) {
echo " echo "
@@ -34,7 +34,7 @@ function dberrmsg($dbname) {
exit(); exit();
} }
$db=@mysqli_connect("localhost",$username,$dbpass,$dbname); $db = @mysqli_connect("localhost",$username,$dbpass,$dbname);
if (mysqli_errno($db)) { if (mysqli_errno($db)) {
dberrmsg($dbname); dberrmsg($dbname);
} }

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
# ---------------------------------------

13
default-apache.conf Normal file
View File

@@ -0,0 +1,13 @@
# _APPNAME_ default Apache configuration
Alias /_BASEURL_ _DOCROOTIN_/_BASEURL_
<Directory _DOCROOTIN_/_BASEURL_>
AllowOverride Options
Options FollowSymLinks
DirectoryIndex index.php
#RewriteEngine On
#RewriteBase /_BASEURL_/
#RewriteRule . maintenancemode.php [L]
</Directory>

View File

@@ -1,6 +1,6 @@
CHANGELOG CHANGELOG
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
@@ -201,3 +201,86 @@
- 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.
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.
- Validate all date and time fields to prevent user entered invalid date
formats from crashing php.
- Fixed profile page to automatically refresh page to show the results
when a user changes their color preferences.

View File

@@ -1,6 +1,6 @@
INSTALL INSTALL
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
@@ -14,16 +14,14 @@ allow clients to reach them. You'll also need to know the username and
password of the MySQL administrator. password of the MySQL administrator.
2. Unpack 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. A directory will be created called OpenLog-x.x.x.
3. Review License 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 4. Run the install script
If installing on a Linux or Unix based system, type ./install.sh at a Type ./install.sh at a command prompt. Follow the prompts.
command prompt. If installing on a Windows based system, double click
install.bat. Follow the prompts.
5. Check and set Configuration 5. Check and set Configuration
Click on the Administration menu option on the main page to adjust the initial Click on the Administration menu option on the main page to adjust the initial

View File

@@ -2,33 +2,33 @@
/* /*
about.php about.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
include("functions.php"); include("functions.php");
$version=OL_VERSION; $version = OL_VERSION;
$print=$_REQUEST['print'] ?? NULL; $print = $_REQUEST['print'] ?? NULL;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","About OpenLog","About OpenLog",$print); framework("begin", "About OpenLog", "About OpenLog", $print);
pagetable("begin"); pagetable("begin");
if(!$print){ if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
echo " echo "
<h3 align=\"center\"> <h3 align=\"center\">
OpenLog $version OpenLog $version
@@ -88,9 +88,7 @@ border=0></a></td><td><b>Fugue<br>Icons</b></td><td>The icons used in OpenLog ar
</table> </table>
</p> </p>
"; ";
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/* /*
gpl.php gpl.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -10,25 +10,25 @@
include("functions.php"); include("functions.php");
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? NULL;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","OpenLog License","OpenLog License",$print); framework("begin", "OpenLog License", "OpenLog License", $print);
pagetable("begin"); pagetable("begin");
if(!$print){ if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
echo " echo "
<pre> <pre>
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
@@ -376,9 +376,7 @@ Public License instead of this License.
</pre> </pre>
"; ";
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

File diff suppressed because it is too large Load Diff

View File

@@ -2,63 +2,62 @@
/* /*
login.php login.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
include("functions.php"); include("functions.php");
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? NULL;
$tech=$_REQUEST['tech']; $tech = $_REQUEST['tech'] ?? NULL;
$pass=$_REQUEST['pass']; $pass = $_REQUEST['pass'] ?? NULL;
$login=$_REQUEST['login']; $login = $_REQUEST['login'] ?? NULL;
$cancel=$_REQUEST['cancel']; $cancel = $_REQUEST['cancel'] ?? NULL;
if ($cancel) { if ($cancel) {
session_destroy(); session_destroy();
} }
$techalpha=TECH_ALPHA; $techalpha = TECH_ALPHA;
$logname=LOG_NAME; $logname = LOG_NAME;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","$logname","Login Page",$print); framework("begin", "$logname", "Login Page", $print);
pagetable("begin"); pagetable("begin");
if(!$print){ if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu("no print"); sidemenu("no print");
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
if ($login) { if ($login) {
// log me in // log me in
$pwhash=mysqli_fetch_row(mysqli_query($db,"select techpass from techs where techid=\"$tech\""))[0]; $pwhash = mysqli_fetch_row(mysqli_query($db, "select techpass from techs where techid=\"$tech\""))[0];
if (password_verify($pass, $pwhash)) { if (password_verify($pass, $pwhash)) {
$_SESSION['login']=$tech; $_SESSION['login'] = $tech;
$techname=dblookup($db,"techs","techid","techname",$tech); $techname = dblookup($db, "techs", "techid", "techname", $tech);
echo " echo "
Welcome $techname. Please select a menu option at the left to continue. Welcome $techname. Please select a menu option at the left to continue.
"; ";
} else { } else {
$adminqry=mysqli_query($db,"select techname from techs where admin=1 and status=1"); $adminqry = mysqli_query($db, "select techname from techs where admin=1 and status=1");
echo " echo "
Incorrect password. Please <a href=\"login.php\">try again</a>.<br><br> Incorrect password. Please <a href=\"login.php\">try again</a>.<br><br>
Forgot your password? Contact an administrator:<br><br> Forgot your password? Contact an administrator:<br><br>
"; ";
while ($admintech=mysqli_fetch_row($adminqry)[0]) { while ($admintech = mysqli_fetch_row($adminqry)[0]) {
echo "$admintech <br>"; echo "$admintech <br>";
} }
} }
} else if ($cancel) { } else if ($cancel) {
echo " echo "
@@ -72,11 +71,12 @@ if ($login) {
<b>Tech: </b>&nbsp; <b>Tech: </b>&nbsp;
<select name=\"tech\"> <select name=\"tech\">
"; ";
if ($techalpha) $torder="techname"; else $torder="techid"; if ($techalpha) $torder = "techname";
$techrow=mysqli_query($db,"select * from techs order by $torder asc"); else $torder = "techid";
while ($techitem=mysqli_fetch_assoc($techrow)) { $techrow = mysqli_query($db, "select * from techs order by $torder asc");
if ($techitem["status"]==1) { while ($techitem = mysqli_fetch_assoc($techrow)) {
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]); if ($techitem["status"] == 1) {
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
} }
} }
echo "</select><br><br> echo "</select><br><br>
@@ -87,16 +87,14 @@ if ($login) {
<br><hr> <br><hr>
"; ";
} else { } else {
$loginid=$_SESSION['login']; $loginid = $_SESSION['login'];
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0]; $loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
echo " echo "
You are already logged in as $loggedinas. Please select a menu option at the left to continue.<br><hr> You are already logged in as $loggedinas. Please select a menu option at the left to continue.<br><hr>
"; ";
} }
} }
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,7 +2,7 @@
/* /*
lognotes.php lognotes.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -12,107 +12,107 @@ include("functions.php");
//$tgt_year=$_REQUEST['y']; //$tgt_year=$_REQUEST['y'];
//$tgt_month=$_REQUEST['m']; //$tgt_month=$_REQUEST['m'];
//$tgt_day=$_REQUEST['d']; //$tgt_day=$_REQUEST['d'];
$tgt_date=$_REQUEST['tgt_date'] ?? ""; $tgt_date = $_REQUEST['tgt_date'] ?? "";
$print=$_REQUEST['print'] ?? ""; $print = $_REQUEST['print'] ?? "";
if (isset($_SESSION['login'])) $techid=$_SESSION['login']; if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
$logname=LOG_NAME; $logname = LOG_NAME;
$tablestyle=LOG_STYLE; $tablestyle = LOG_STYLE;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
// 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
function shifttable_classic($shift, $tgt_date, $db) { function shifttable_classic($shift, $tgt_date, $db)
{
// convert the shift number to a name for display // convert the shift number to a name for display
$doparts=PARTS_FUNCTIONS; $doparts = PARTS_FUNCTIONS;
$showtime=SHOW_TS; $showtime = SHOW_TS;
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift); $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr=mysqli_fetch_row($dshdrdata); $dshdr = mysqli_fetch_row($dshdrdata);
if ($dshdr) { if ($dshdr) {
// print the shift header // print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname); printf("<b><font size=\"+1\">%s</font></b>\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 "<br><table border=\"1\" width=\"100%\">\n"; echo "<br><table border=\"1\" width=\"100%\">\n";
echo "<tr><th width=\"70\">Note ID</th><th width=\"70\">Tech</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>\n"; echo "<tr><th width=\"70\">Note ID</th><th width=\"70\">Tech</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>\n";
while ($tablerow = mysqli_fetch_assoc($note)) { while ($tablerow = mysqli_fetch_assoc($note)) {
$reftonote=$tablerow["lognoteid"]; $thisnote = $tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>"; $refs = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($tablerow["lognoteid"])) { if (islink($thisnote)) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>"; $refs = $refs . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
} }
// convert tech number to name // 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 //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 // create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]); $fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string // generate the flags string
$flagstring=""; $flagstring = "";
$allflagqry=mysqli_query($db,"select flagid from flags"); $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
while ($allflagids=mysqli_fetch_row($allflagqry)) { while ($flagid = mysqli_fetch_row($flagqry)) {
$flagid=$allflagids[0]; $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
$flag_tbl="flag_".$flagid; $flagcolor = $flagparams["flagcolor"];
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { $flagsym = $flagparams["flagsym"];
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); $flagname = $flagparams["flagname"];
$flagcolor=$flagparam["flagcolor"]; $flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
$flagsym=$flagparam["flagsym"];
$flagname=$flagparam["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
} }
if ($flagstring) { if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; $fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else { } else {
$fmtnote=$fmtnote."<br>"; $fmtnote = $fmtnote . "<br>";
} }
if ($doparts) { if ($doparts) {
// turn on the parts indicator if parts were entered with the note // 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\""))) { if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1&noteid=$reftonote\">PARTS</a>"; $fmtnote = $fmtnote . "<a href=\"logentry.php?partview=1&noteid=$thisnote\">PARTS</a>";
} }
} }
// now print the line in the table // now print the line in the table
if ($showtime) { if ($showtime) {
printf( printf(
"<tr> "<tr>
<td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\" title=\"Edit this note\">%s</a>&nbsp;&nbsp;%s</td> <td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\" title=\"Edit this note\">%s</a>&nbsp;&nbsp;%s</td>
<td valign=\"top\"> %s</td> <td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
</tr>\n", </tr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"], $tablerow["lognoteid"],
$tname, $tablerow["lognoteid"],
$subjname, $tablerow["time"],
$fmtnote, $tname,
$refs $subjname,
$fmtnote,
$refs
); );
} else { } else {
printf( printf(
"<tr> "<tr>
<td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td> <td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td>
<td valign=\"top\"> %s</td> <td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
</tr>\n", </tr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"], $tablerow["lognoteid"],
$tname, $tablerow["lognoteid"],
$subjname, $tname,
$fmtnote, $subjname,
$refs $fmtnote,
$refs
); );
} }
} }
@@ -125,86 +125,85 @@ function shifttable_classic($shift, $tgt_date, $db) {
} }
// define the shifttable_clean function // 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 // convert the shift number to a name for display
$doparts=PARTS_FUNCTIONS; $doparts = PARTS_FUNCTIONS;
$showtime=SHOW_TS; $showtime = SHOW_TS;
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift); $shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\""); $dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr=mysqli_fetch_row($dshdrdata); $dshdr = mysqli_fetch_row($dshdrdata);
if ($dshdr) { if ($dshdr) {
// print the shift header // print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname); printf("<b><font size=\"+1\">%s</font></b>\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 "<br><br>"; echo "<br><br>";
echo "<table border=\"0\" width=\"100%\"><tr><td>\n"; echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
while ($tablerow = mysqli_fetch_assoc($note)) { while ($tablerow = mysqli_fetch_assoc($note)) {
$reftonote=$tablerow["lognoteid"]; $thisnote = $tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>"; $refs = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($tablerow["lognoteid"])) { if (islink($tablerow["lognoteid"])) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>"; $refs = $refs . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
} }
// convert tech number to name // 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 //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 // create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]); $fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string // generate the flags string
$flagstring=""; $flagstring = "";
$allflagqry=mysqli_query($db,"select flagid from flags"); $flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
while ($allflagids=mysqli_fetch_row($allflagqry)) { while ($flagid = mysqli_fetch_row($flagqry)) {
$flagid=$allflagids[0]; $flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
$flag_tbl="flag_".$flagid; $flagcolor = $flagparams["flagcolor"];
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { $flagsym = $flagparams["flagsym"];
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); $flagname = $flagparams["flagname"];
$flagcolor=$flagparam["flagcolor"]; $flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
$flagsym=$flagparam["flagsym"];
$flagname=$flagparam["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
} }
if ($flagstring) { if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; $fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else { } else {
$fmtnote=$fmtnote."<br>"; $fmtnote = $fmtnote . "<br>";
} }
if ($doparts) { if ($doparts) {
// turn on the parts indicator if parts were entered with the note // 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\""))) { if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1&noteid=$reftonote\" title=\"Click here to see note and parts data.\">PARTS</a>"; $fmtnote = $fmtnote . "<a href=\"logentry.php?edit=1&noteid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
} }
} }
// now print the line in the table // now print the line in the table
if ($showtime) { if ($showtime) {
printf( printf(
"<a href=\"logentry.php?edit=1&noteid=%s\" title=\"Note ID. Click to edit.\">%s</a>&nbsp;&nbsp; "<a href=\"logentry.php?edit=1&noteid=%s\" title=\"Note ID. Click to edit.\">%s</a>&nbsp;&nbsp;
<b>%s &nbsp;&nbsp;&nbsp;&nbsp; <b>%s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp; %s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp; %s &nbsp;&nbsp;&nbsp;&nbsp;
%s</b> %s</b>
<br>%s<br> <br>%s<br>
<hr>\n", <hr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"], $tablerow["lognoteid"],
$tablerow["time"], $tablerow["lognoteid"],
$tname, $tablerow["time"],
$subjname, $tname,
$refs, $subjname,
$fmtnote $refs,
$fmtnote
); );
} else { } else {
printf( printf(
"<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>&nbsp;&nbsp; "<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>&nbsp;&nbsp;
<b>%s &nbsp;&nbsp;&nbsp;&nbsp; <b>%s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp; %s &nbsp;&nbsp;&nbsp;&nbsp;
%s</b> %s</b>
<br>%s<br> <br>%s<br>
<hr>\n", <hr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"], $tablerow["lognoteid"],
$tname, $tablerow["lognoteid"],
$subjname, $tname,
$refs, $subjname,
$fmtnote $refs,
$fmtnote
); );
} }
} }
@@ -216,11 +215,11 @@ function shifttable_clean($shift, $tgt_date, $db) {
echo "<br><br>\n"; echo "<br><br>\n";
} }
framework("begin","$logname","Online Logbook",$print); framework("begin", "$logname", "Online Logbook", $print);
pagetable("begin"); pagetable("begin");
if(!$print) { if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
//calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php"); //calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php");
echo "<div id=\"caldate\" style=\"display: none;\">"; echo "<div id=\"caldate\" style=\"display: none;\">";
echo htmlspecialchars($tgt_date); echo htmlspecialchars($tgt_date);
@@ -233,29 +232,27 @@ if(!$print) {
sidemenu(); sidemenu();
echo "<br><br>"; echo "<br><br>";
showlinklist($print); showlinklist($print);
pageblock("left","end"); pageblock("left", "end");
} else { } else {
echo " echo "
<center><b>$tgt_year-$tgt_month-$tgt_day</b></center><br> <center><b>$tgt_year-$tgt_month-$tgt_day</b></center><br>
"; ";
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
if (isset($techid)) nag($techid); if (isset($techid)) nag($techid);
//$date=date("Y-m-d",mktime(0,0,0,$tgt_month,$tgt_day,$tgt_year)); //$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"); $qry = mysqli_query($db, "select shiftid from shifts where status=1 order by shiftid asc");
while ($shnum=mysqli_fetch_row($qry)) { while ($shnum = mysqli_fetch_row($qry)) {
if ($tablestyle==1) { if ($tablestyle == 1) {
shifttable_classic($shnum[0],$tgt_date,$db); shifttable_classic($shnum[0], $tgt_date, $db);
} else if ($tablestyle==2) { } else if ($tablestyle == 2) {
shifttable_clean($shnum[0],$tgt_date,$db); shifttable_clean($shnum[0], $tgt_date, $db);
} }
} }
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,45 +2,47 @@
/* /*
maintform.php maintform.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
include("functions.php"); include("functions.php");
if (isset($_SESSION['login'])) $techid=$_SESSION['login']; if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
$histdays=$_REQUEST['histdays']; $print = $_REQUEST['print'] ?? NULL;
$submit=$_REQUEST['submit']; $histdays = $_REQUEST['histdays'] ?? NULL;
$submit = $_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME; $logname = LOG_NAME;
$uidtext=UID_TEXT; $uidtext = UID_TEXT;
if ($histdays=="") $histdays=30; if ($histdays == "") $histdays = 30;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
// define pendtable function // define pendtable function
function pendtable($tech_id, $db) { function pendtable($tech_id, $db)
$uidtext=UID_TEXT; {
$uidtext = UID_TEXT;
// print section header // print section header
if ($tech_id) { if ($tech_id) {
echo " echo "
<b><font size=\"+1\">Your Pending Maintenance Forms</font></b><br> <b><font size=\"+1\">Your Pending Maintenance Forms</font></b><br>
"; ";
$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 { } else {
echo " echo "
<b><font size=\"+1\">All Pending Maintenance Forms</font></b><br> <b><font size=\"+1\">All Pending Maintenance Forms</font></b><br>
"; ";
$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 " echo "
<br><table border=\"1\" width=\"100%\"> <br><table border=\"1\" width=\"100%\">
@@ -59,26 +61,26 @@ function pendtable($tech_id, $db) {
"; ";
while ($pendrow = mysqli_fetch_assoc($pmf)) { while ($pendrow = mysqli_fetch_assoc($pmf)) {
// look up part data // look up part data
$uid=dblookup($db,"parts","partid","uid",$pendrow["mfpart"]); $uid = dblookup($db, "parts", "partid", "uid", $pendrow["mfpart"]);
if ($uid=="") $uid="&nbsp;"; if ($uid == "") $uid = "&nbsp;";
$partno=dblookup($db,"parts","partid","partnum",$pendrow["mfpart"]); $partno = dblookup($db, "parts", "partid", "partnum", $pendrow["mfpart"]);
if ($partno=="") $partno="&nbsp;"; if ($partno == "") $partno = "&nbsp;";
$serno=dblookup($db,"parts","partid","sernum",$pendrow["mfpart"]); $serno = dblookup($db, "parts", "partid", "sernum", $pendrow["mfpart"]);
if ($serno=="") $serno="&nbsp;"; if ($serno == "") $serno = "&nbsp;";
$partname=dblookup($db,"parts","partid","partname",$pendrow["mfpart"]); $partname = dblookup($db, "parts", "partid", "partname", $pendrow["mfpart"]);
if ($partname=="") $partname="&nbsp;"; if ($partname == "") $partname = "&nbsp;";
// look up tech name // look up tech name
$tname=dblookup($db,"techs","techid","techname",$pendrow["mftech"]); $tname = dblookup($db, "techs", "techid", "techname", $pendrow["mftech"]);
if ($pendrow["lognoteid"]==0) { if ($pendrow["lognoteid"] == 0) {
$noteidval="&nbsp;"; $noteidval = "&nbsp;";
$notetag="%s%s"; $notetag = "%s%s";
} else { } else {
$noteidval=$pendrow["lognoteid"]; $noteidval = $pendrow["lognoteid"];
$notetag="<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>"; $notetag = "<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
} }
if (!$tech_id) { if (!$tech_id) {
printf( printf(
"<tr> "<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td> <td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
@@ -88,18 +90,20 @@ function pendtable($tech_id, $db) {
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td> <td align=\"center\" valign=\"top\">$notetag</td>
</tr>", </tr>",
$pendrow["maintformid"],$pendrow["maintformid"], $pendrow["maintformid"],
$pendrow["mfdate"], $pendrow["maintformid"],
$tname, $pendrow["mfdate"],
$uid, $tname,
$partno, $uid,
$serno, $partno,
$partname, $serno,
$noteidval,$noteidval $partname,
$noteidval,
$noteidval
); );
} else { } else {
printf( printf(
"<tr> "<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td> <td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
@@ -108,13 +112,15 @@ function pendtable($tech_id, $db) {
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td> <td align=\"center\" valign=\"top\">$notetag</td>
</tr>", </tr>",
$pendrow["maintformid"],$pendrow["maintformid"], $pendrow["maintformid"],
$pendrow["mfdate"], $pendrow["maintformid"],
$uid, $pendrow["mfdate"],
$partno, $uid,
$serno, $partno,
$partname, $serno,
$noteidval,$noteidval $partname,
$noteidval,
$noteidval
); );
} }
} }
@@ -124,9 +130,10 @@ function pendtable($tech_id, $db) {
} }
// define histtable function // define histtable function
function histtable($hist_days,$db) { function histtable($hist_days, $db)
$uidtext=UID_TEXT; {
$dayopts=array(30,90,180,365); $uidtext = UID_TEXT;
$dayopts = array(30, 90, 180, 365);
// print section header // print section header
echo " echo "
<form method=\"post\" action=\"maintform.php\"> <form method=\"post\" action=\"maintform.php\">
@@ -134,13 +141,13 @@ function histtable($hist_days,$db) {
<select name=\"histdays\"> <select name=\"histdays\">
"; ";
foreach ($dayopts as $chunk) { foreach ($dayopts as $chunk) {
if ($chunk==$hist_days) { if ($chunk == $hist_days) {
echo "<option value=\"$chunk\" selected>$chunk</option>"; echo "<option value=\"$chunk\" selected>$chunk</option>";
} else { } else {
echo "<option value=\"$chunk\">$chunk</option>"; echo "<option value=\"$chunk\">$chunk</option>";
} }
} }
$histqry=mysqli_query($db,"select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc"); $histqry = mysqli_query($db, "select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc");
echo " echo "
</select> </select>
<b><font size=\"+1\"> Days</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><font size=\"+1\"> Days</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
@@ -159,24 +166,24 @@ function histtable($hist_days,$db) {
"; ";
while ($histrow = mysqli_fetch_assoc($histqry)) { while ($histrow = mysqli_fetch_assoc($histqry)) {
// look up part data // look up part data
$uid=dblookup($db,"parts","partid","uid",$histrow["mfpart"]); $uid = dblookup($db, "parts", "partid", "uid", $histrow["mfpart"]);
$partno=dblookup($db,"parts","partid","partnum",$histrow["mfpart"]); $partno = dblookup($db, "parts", "partid", "partnum", $histrow["mfpart"]);
if ($partno=="") $partno="&nbsp;"; if ($partno == "") $partno = "&nbsp;";
$serno=dblookup($db,"parts","partid","sernum",$histrow["mfpart"]); $serno = dblookup($db, "parts", "partid", "sernum", $histrow["mfpart"]);
if ($serno=="") $serno="&nbsp;"; if ($serno == "") $serno = "&nbsp;";
$partname=dblookup($db,"parts","partid","partname",$histrow["mfpart"]); $partname = dblookup($db, "parts", "partid", "partname", $histrow["mfpart"]);
if ($partname=="") $partname="&nbsp;"; if ($partname == "") $partname = "&nbsp;";
// look up tech name // look up tech name
$tname=dblookup($db,"techs","techid","techname",$histrow["mftech"]); $tname = dblookup($db, "techs", "techid", "techname", $histrow["mftech"]);
if ($histrow["lognoteid"]==0) { if ($histrow["lognoteid"] == 0) {
$noteidval="&nbsp;"; $noteidval = "&nbsp;";
$notetag="%s%s"; $notetag = "%s%s";
} else { } else {
$noteidval=$histrow["lognoteid"]; $noteidval = $histrow["lognoteid"];
$notetag="<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>"; $notetag = "<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
} }
printf( printf(
"<tr> "<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td> <td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
@@ -186,14 +193,16 @@ function histtable($hist_days,$db) {
<td valign=\"top\">%s</td> <td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td> <td align=\"center\" valign=\"top\">$notetag</td>
</tr>", </tr>",
$histrow["maintformid"],$histrow["maintformid"], $histrow["maintformid"],
$histrow["mfdate"], $histrow["maintformid"],
$tname, $histrow["mfdate"],
$uid, $tname,
$partno, $uid,
$serno, $partno,
$partname, $serno,
$noteidval,$noteidval $partname,
$noteidval,
$noteidval
); );
} }
echo " echo "
@@ -201,30 +210,28 @@ function histtable($hist_days,$db) {
"; ";
} }
framework("begin","$logname","Maintenance Forms",$print); framework("begin", "$logname", "Maintenance Forms", $print);
pagetable("begin"); pagetable("begin");
if(!$print) { if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
echo "<br>"; echo "<br>";
$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) { if ($haspending) {
pendtable($techid,$db); pendtable($techid, $db);
echo "<br><hr><br>"; echo "<br><hr><br>";
} }
pendtable(0,$db); pendtable(0, $db);
echo "<br><hr><br>"; echo "<br><hr><br>";
histtable($histdays,$db); histtable($histdays, $db);
echo "<br><br>"; echo "<br><br>";
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,7 +2,7 @@
/* /*
maintformentry.php maintformentry.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -11,123 +11,123 @@ include("functions.php");
if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) { if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
header ("Location: login.php"); header("Location: login.php");
} }
$loggedinas=$_SESSION['login']; $loggedinas = $_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); $isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
function getmfdata($maintformid) { function getmfdata($maintformid)
{
// pull maintenance form data from maintforms table // pull maintenance form data from maintforms table
global $db; 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; return $mfdata;
} }
function getactiondata($maintactionid) { function getactiondata($maintactionid)
{
// pull maintenance action data from maintactions table // pull maintenance action data from maintactions table
global $db; 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; return $actiondata;
} }
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? NULL;
$maintformid=$_REQUEST['maintformid']; $maintformid = $_REQUEST['maintformid'] ?? NULL;
$lognoteid=$_REQUEST['lognoteid']; $lognoteid = $_REQUEST['lognoteid'] ?? NULL;
$mfdate=$_REQUEST['date']; $mfdate = $_REQUEST['date'] ?? NULL;
$mftime=$_REQUEST['time']; $mftime = $_REQUEST['time'] ?? NULL;
$mfsubmit=$_REQUEST['mfsubmit']; $mfsubmit = $_REQUEST['mfsubmit'] ?? NULL;
$mfadd=$_REQUEST['mfadd']; $mfadd = $_REQUEST['mfadd'] ?? NULL;
$mfedit=$_REQUEST['mfedit']; $mfedit = $_REQUEST['mfedit'] ?? NULL;
$mfdelete=$_REQUEST['mfdelete']; $mfdelete = $_REQUEST['mfdelete'] ?? NULL;
$mfpartloc=$_REQUEST['mfpartloc']; $mfpartloc = $_REQUEST['mfpartloc'] ?? NULL;
$mfmalfunction=$_REQUEST['mfmalfunction']; $mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL;
$nha=$_REQUEST['nha']; $nha = $_REQUEST['nha'] ?? NULL;
$repord=$_REQUEST['repord']; $repord = $_REQUEST['repord'] ?? NULL;
$mfpart=$_REQUEST['mfpart']; $mfpart = $_REQUEST['mfpart'] ?? NULL;
$uid=$_REQUEST['uid']; $uid = $_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum']; $partnum = $_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum']; $sernum = $_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname']; $partname = $_REQUEST['partname'] ?? NULL;
$actionadd=$_REQUEST['actionadd']; $actionadd = $_REQUEST['actionadd'] ?? NULL;
$actionedit=$_REQUEST['actionedit']; $actionedit = $_REQUEST['actionedit'] ?? NULL;
$actiondelete=$_REQUEST['actiondelete']; $actiondelete = $_REQUEST['actiondelete'] ?? NULL;
$maintactionid=$_REQUEST['maintactionid']; $maintactionid = $_REQUEST['maintactionid'] ?? NULL;
$actiondate=$_REQUEST['actiondate']; $actiondate = $_REQUEST['actiondate'] ?? NULL;
$actiontime=$_REQUEST['actiontime']; $actiontime = $_REQUEST['actiontime'] ?? NULL;
$actiontech=$_REQUEST['actiontech']; $actiontech = $_REQUEST['actiontech'] ?? NULL;
$action=$_REQUEST['action']; $action = $_REQUEST['action'] ?? NULL;
$actionaddsubmit=$_REQUEST['actionaddsubmit']; $actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL;
$actioneditsubmit=$_REQUEST['actioneditsubmit']; $actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL;
$printfmt=$_REQUEST['printfmt']; $printfmt = $_REQUEST['printfmt'] ?? NULL;
if ($printfmt) $print=1; if ($printfmt) $print = TRUE;
$flags=$_POST['flags']; $flags = $_POST['flags'] ?? [];
$logname=LOG_NAME; $logname = LOG_NAME;
$uidtext=UID_TEXT; $uidtext = UID_TEXT;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
if ($printfmt) { if ($printfmt) {
framework("begin","","",$print); framework("begin", "", "", $print);
} else if ($mfedit) { } else if ($mfedit) {
framework("begin","$logname","Maintenance Form Edit",$print); framework("begin", "$logname", "Maintenance Form Edit", $print);
if ($loggedinas) $mfauthorized=1; if ($loggedinas) $mfauthorized = TRUE;
} else if ($mfdelete) { } else if ($mfdelete) {
framework("begin","$logname","Maintenance Form Edit",$print); framework("begin", "$logname", "Maintenance Form Edit", $print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=1; if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE;
} else if ($actionadd) { } else if ($actionadd) {
framework("begin","$logname","Maintenance Action Entry",$print); framework("begin", "$logname", "Maintenance Action Entry", $print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) { if ($loggedinas) {
$mfauthorized=1; $mfauthorized = TRUE;
$actionauthorized=1; $actionauthorized = TRUE;
} }
} else if ($actionedit || $actiondelete) { } else if ($actionedit || $actiondelete) {
framework("begin","$logname","Maintenance Action Edit",$print); framework("begin", "$logname", "Maintenance Action Edit", $print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid); $mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) $mfauthorized=1; if ($loggedinas) $mfauthorized = TRUE;
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid); $actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1; if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE;
} else { } else {
$mfadd=1; $mfadd = TRUE;
framework("begin","$logname","Maintenance Form Entry",$print); framework("begin", "$logname", "Maintenance Form Entry", $print);
$mftech=$loggedinas; $mftech = $loggedinas;
$mfauthorized=1; $mfauthorized = TRUE;
} }
// ******** 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);
$pdatamismatch = NULL;
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) { if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
// pull mf data from database // pull mf data from database
$mftoedit=getmfdata($maintformid); $mftoedit = getmfdata($maintformid);
$partdatainput=array(); $partdatainput = [];
if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart']; if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart'];
if ($uid) $partdatainput['uid']=$uid; if ($uid) $partdatainput['uid'] = $uid;
if ($partnum) $partdatainput['partnum']=$partnum; if ($partnum) $partdatainput['partnum'] = $partnum;
if ($sernum) $partdatainput['sernum']=$sernum; if ($sernum) $partdatainput['sernum'] = $sernum;
$partinfo=get_part_data($partdatainput); $partinfo = get_part_data($partdatainput);
if ($partinfo['result']==2) { if ($partinfo['result'] == 2) {
$pdatamismatch=1; $pdatamismatch = TRUE;
} else { } else {
unset($pdatamismatch); $pdatamismatch = FALSE;
if ($partinfo['partid']) $mfpart=$partinfo['partid']; if ($partinfo['partid']) $mfpart = $partinfo['partid'];
if ($partinfo['uid']) $uid=$partinfo['uid']; if ($partinfo['uid']) $uid = $partinfo['uid'];
if ($partinfo['partnum']) $partnum=$partinfo['partnum']; if ($partinfo['partnum']) $partnum = $partinfo['partnum'];
if ($partinfo['sernum']) $sernum=$partinfo['sernum']; if ($partinfo['sernum']) $sernum = $partinfo['sernum'];
if ($partinfo['partname']) $partname=$partinfo['partname']; if ($partinfo['partname']) $partname = $partinfo['partname'];
} }
} }
@@ -135,54 +135,59 @@ if ($mfadd) {
if ($mfsubmit) { if ($mfsubmit) {
// add the entry if submit is pressed // add the entry if submit is pressed
if ($mfmalfunction && ($uid || ($partnum && $sernum))) { 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 // 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 future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) { if ($datediff[0] < 0) {
$mftime="23:59:59:"; $mftime = "23:59:59:";
} }
if ($datediff[0]>0) { if ($datediff[0] > 0) {
$mftime="00:00:01:"; $mftime = "00:00:01:";
} }
// 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;
if ($partnum) $partdatainput['partnum']=$partnum; if ($partnum) $partdatainput['partnum'] = $partnum;
if ($sernum) $partdatainput['sernum']=$sernum; if ($sernum) $partdatainput['sernum'] = $sernum;
$partinfo=get_part_data($partdatainput); $partinfo = get_part_data($partdatainput);
// add to parts table // 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 // 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\")"); mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$mfpart=mysqli_insert_id($db); $mfpart = mysqli_insert_id($db);
} else if ($partinfo['result']==2) { } else if ($partinfo['result'] == 2) {
$pdatamismatch=1; $pdatamismatch = TRUE;
} else { } else {
// if it is in parts table, get partid for this record // if it is in parts table, get partid for this record
$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 // 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
if (! $pdatamismatch) { if (! $pdatamismatch) {
mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending) $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\")"); values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
$newmaintformid=mysqli_insert_id($db); $newmaintformid = mysqli_insert_id($db);
$mfidtoprint=$newmaintformid; $mfidtoprint = $newmaintformid;
// add this maintformid to the appropriate flag_tables // update the flagmap table
foreach ($flags as $flagtblnum) { foreach ($flags as $thisflag) {
$flagtblname="flag_".$flagtblnum; // set flag for this maintenance form
mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$newmaintformid\")"); mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$newmaintformid\")");
} }
} }
} }
@@ -190,78 +195,69 @@ if ($mfadd) {
} }
} }
if ($mfedit) { if ($mfedit) {
$mfidtoprint=$maintformid; $mfidtoprint = $maintformid;
if ($mfsubmit && $mfauthorized) { if ($mfsubmit && $mfauthorized) {
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\"");
} }
// update the record in maintforms // update the record in maintforms
if (! $pdatamismatch) { 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\""); 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"); // update the flagmap table
while ($thisflagid=mysqli_fetch_row($flagids)) { mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
$thisflag_tbl="flag_".$thisflagid[0]; foreach ($flags as $thisflag) {
if (in_array($thisflagid[0],$flags)) { // set flag for this maintenance form
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) { mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$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\"");
}
}
} }
} }
} }
} }
// refresh the maintenance form in question from the database // refresh the maintenance form in question from the database
$mftoedit=getmfdata($maintformid); $mftoedit = getmfdata($maintformid);
} }
if ($mfdelete && $mfauthorized) { if ($mfdelete && $mfauthorized) {
// delete from maintforms table // 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 flag_ tables // delete occurances from the flagmap table
$flagids=mysqli_query($db,"select flagid from flags"); mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$delflag_tbl="flag_".$thisflagid[0];
mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
} }
if ($actionadd) { if ($actionadd) {
if ($actionaddsubmit) { if ($actionaddsubmit) {
if ($action) { 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 // 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 future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) { if ($datediff[0] < 0) {
$actiontime="23:59:59:"; $actiontime = "23:59:59:";
} }
if ($datediff[0]>0) { if ($datediff[0] > 0) {
$actiontime="00:00:01:"; $actiontime = "00:00:01:";
} }
// 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\")");
echo mysqli_error($db); echo mysqli_error($db);
} }
@@ -271,21 +267,23 @@ if ($actionadd) {
if ($actionedit) { if ($actionedit) {
if ($actioneditsubmit && $actionauthorized) { if ($actioneditsubmit && $actionauthorized) {
// update the action // update the action
// sanitize and fix blank date and time
$actiondate = fix_date($actiondate);
$actiontime = fix_time($actiontime);
// 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\"");
} }
// refresh the action in question from the database // refresh the action in question from the database
$actiontoedit=getactiondata($maintactionid); $actiontoedit = getactiondata($maintactionid);
} }
if ($actiondelete && $actionauthorized) { if ($actiondelete && $actionauthorized) {
// delete the action // delete the action
mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\""); mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\"");
} }
@@ -293,66 +291,67 @@ if ($actiondelete && $actionauthorized) {
pagetable("begin"); pagetable("begin");
if (!$print) { if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
// display the form // display the form
if ($mfadd || $actionadd) { if ($mfadd || $actionadd) {
$mfdate=$today; $mfdate = $today;
$mftime=$now; $mftime = $now;
$actiondate=$today; $actiondate = $today;
$actiontime=$now; $actiontime = $now;
} }
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) { if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) {
$mfdate=$mftoedit["mfdate"]; $mfdate = $mftoedit["mfdate"];
$mftime=$mftoedit["mftime"]; $mftime = $mftoedit["mftime"];
$mfpart=$mftoedit["mfpart"]; $mfpart = $mftoedit["mfpart"];
$mfpartloc=$mftoedit["mfpartloc"]; $mfpartloc = $mftoedit["mfpartloc"];
$mfmalfunction=$mftoedit["mfmalfunction"]; $mfmalfunction = $mftoedit["mfmalfunction"];
$nha=$mftoedit["nha"]; $nha = $mftoedit["nha"];
$repord=$mftoedit["repord"]; $repord = $mftoedit["repord"];
$lognoteid=$mftoedit["lognoteid"]; $lognoteid = $mftoedit["lognoteid"];
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"]; if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech = $mftoedit["mftech"];
if (! $mftime) $mftime=$now; if (! $mftime) $mftime = $now;
} }
if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) { if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) {
$partinfo=array(); $partinfo = array();
$partinfoinput['partid']=$mfpart; $partinfoinput['partid'] = $mfpart;
$partinfo=get_part_data($partinfoinput); $partinfo = get_part_data($partinfoinput);
$mfpart=$partinfo['partid']; $mfpart = $partinfo['partid'];
$uid=$partinfo['uid']; $uid = $partinfo['uid'];
$partnum=$partinfo['partnum']; $partnum = $partinfo['partnum'];
$sernum=$partinfo['sernum']; $sernum = $partinfo['sernum'];
$partname=$partinfo['partname']; $partname = $partinfo['partname'];
$pluresult=$partinfo['result']; $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); $techname = dblookup($db, "techs", "techid", "techname", $mftech);
if ($mfsubmit) { if ($mfsubmit) {
if ($mfmalfunction) { if ($mfmalfunction) {
if (($uid || ($partnum && $sernum)) || $mfpart) { if (($uid || ($partnum && $sernum)) || $mfpart) {
if ($mfadd) { if ($mfadd) {
format_message(0,"Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>"); format_message(0, "Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
} }
if ($mfedit) { if ($mfedit) {
format_message(0,"Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>"); format_message(0, "Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
} }
} else { } 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 { } 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) { if ($mfdelete) {
format_message(0,"Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>"); format_message(0, "Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
} }
if ($pdatamismatch) { if ($pdatamismatch) {
$advtxt=" $advtxt = "
<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp; <img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;
<b>Warning:</b> The $uidtext doesn't match the Part Number/Serial Number associated <b>Warning:</b> The $uidtext doesn't match the Part Number/Serial Number associated
with it in our database. Please ensure the part information with it in our database. Please ensure the part information
@@ -360,7 +359,7 @@ if ($pdatamismatch) {
the <a href=\"parts.php\">Parts</a> page to correct the database.</b> the <a href=\"parts.php\">Parts</a> page to correct the database.</b>
"; ";
} else { } else {
$advtxt=" $advtxt = "
<font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font> <font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font>
"; ";
} }
@@ -388,31 +387,34 @@ if ($printfmt) {
<b><u>Flags</u></b><br> <b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\"> <table width=\"100%\" border=\"0\">
"; ";
// get an array of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags"); // create an array called theseflags of flagids set for this maintformid
$allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags); unset($theseflags);
while ($thisflag=mysqli_fetch_row($allflags)) { $theseflags = [];
$thisflagtbl="flag_".$thisflag[0]; while ($thisflag = mysqli_fetch_row($allflags)) {
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]; $theseflags[] = $thisflag[0];
} }
} }
$flagslist=mysqli_query($db,"select * from flags"); // display flag symbols for set flags
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) { $flagslist = mysqli_query($db, "select * from flags");
if (in_array($flagsymbol["flagid"],$theseflags)) { while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;"; if ($theseflags[0] == "") $theseflags = [];
if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) {
echo $flagsymbol['flagsym'] . "&nbsp;&nbsp;";
} }
} }
echo " echo "
</table><hr> </table><hr>
<b><u>Maintenance Actions</u></b><br> <b><u>Maintenance Actions</u></b><br>
"; ";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
$actiondate=$actiontable["actiondate"]; $actiondate = $actiontable["actiondate"];
$actiontime=$actiontable["actiontime"]; $actiontime = $actiontable["actiontime"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]); $actiontext = convertweblinks($actiontable["action"]);
// print the actions // print the actions
echo "<table border=\"0\" cellpadding=\"5\"> echo "<table border=\"0\" cellpadding=\"5\">
<tr> <tr>
@@ -473,40 +475,50 @@ if ($printfmt) {
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr> <tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
<tr><td> <tr><td>
"; ";
// 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"); $allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags); unset($theseflags);
$theseflags=[]; $theseflags = [];
while ($thisflag=mysqli_fetch_row($allflags)) { while ($thisflag = mysqli_fetch_row($allflags)) {
$thisflagtbl="flag_".$thisflag[0]; if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) { $theseflags[] = $thisflag[0];
$theseflags[]=$thisflag[0];
} }
} }
if ($mfadd) { if ($mfadd) {
$flagslist=mysqli_query($db,"select * from flags where status=1"); $flagslist = mysqli_query($db, "select * from flags where status=1");
} else { } else {
$flagslist=mysqli_query($db,"select * from flags"); $flagslist = mysqli_query($db, "select * from flags");
} }
$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"],$theseflags)) { //if ($theseflags[0]=="") $theseflags=[];
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>", if (in_array($flagcheckbox["flagid"], $theseflags)) {
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); printf(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
} else { } else {
$flagid=$flagcheckbox["flagid"]; $flagid = $flagcheckbox["flagid"];
if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>", printf(
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); "<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
} }
} }
if ($flagcount<$flagsperline) { if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;"; echo "&nbsp;&nbsp;&nbsp;";
$flagcount++; $flagcount++;
} else { } else {
echo "<br>"; echo "<br>";
$flagcount=1; $flagcount = 1;
} }
} }
echo " echo "
@@ -561,16 +573,16 @@ if ($printfmt) {
if ($actionadd || $actionedit) { if ($actionadd || $actionedit) {
// show the action form // show the action form
if ($actionadd) { if ($actionadd) {
$matime=$now; $matime = $now;
$actiontext=""; $actiontext = "";
$actiontech=$loggedinas; $actiontech = $loggedinas;
} else if ($actionedit) { } else if ($actionedit) {
$actiontext=$actiontoedit['action']; $actiontext = $actiontoedit['action'];
$actiontech=$actiontoedit['actiontech']; $actiontech = $actiontoedit['actiontech'];
$actiondate=$actiontoedit['actiondate']; $actiondate = $actiontoedit['actiondate'];
$actiontime=$actiontoedit['actiontime']; $actiontime = $actiontoedit['actiontime'];
} }
$tname=dblookup($db,"techs","techid","techname",$actiontech); $tname = dblookup($db, "techs", "techid", "techname", $actiontech);
echo "<table width=\"70\" border=\"0\" cellpadding=\"5\"> echo "<table width=\"70\" border=\"0\" cellpadding=\"5\">
<tr> <tr>
<td>Tech:&nbsp;&nbsp;$tname <td>Tech:&nbsp;&nbsp;$tname
@@ -614,19 +626,19 @@ if ($printfmt) {
echo "<br><br>"; echo "<br><br>";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc"); $maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) { while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
$maintactionid=$actiontable["maintactionid"]; $maintactionid = $actiontable["maintactionid"];
$actiondate=$actiontable["actiondate"]; $actiondate = $actiontable["actiondate"];
$actiontime=$actiontable["actiontime"]; $actiontime = $actiontable["actiontime"];
$maintformnum=$actiontable["maintformnum"]; $maintformnum = $actiontable["maintformnum"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]); $tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]); $actiontext = convertweblinks($actiontable["action"]);
// print the table // print the table
echo "<table width=\"100%\" border=\"1\" cellpadding=\"5\"> echo "<table width=\"100%\" border=\"1\" cellpadding=\"5\">
<tr><td> <tr><td>
"; ";
if (($loggedinas==$actiontable["actiontech"]) || $isadmin) { if (($loggedinas == $actiontable["actiontech"]) || $isadmin) {
echo " echo "
<a href=\"maintformentry.php?maintformid=$maintformid&actionedit=1&maintactionid=$maintactionid\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this action\" alt=\"Edit this action\"></a>&nbsp;&nbsp; <a href=\"maintformentry.php?maintformid=$maintformid&actionedit=1&maintactionid=$maintactionid\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this action\" alt=\"Edit this action\"></a>&nbsp;&nbsp;
<a href=\"maintformentry.php?maintformid=$maintformid&actiondelete=1&maintactionid=$maintactionid\"><img src=\"icons/minus-button.png\" border=\"0\" title=\"Delete this action\" alt=\"Delete this action\"></a> <a href=\"maintformentry.php?maintformid=$maintformid&actiondelete=1&maintactionid=$maintactionid\"><img src=\"icons/minus-button.png\" border=\"0\" title=\"Delete this action\" alt=\"Delete this action\"></a>
@@ -656,9 +668,7 @@ if ($printfmt) {
} }
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,7 +2,7 @@
/* /*
partentry.php partentry.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -11,39 +11,39 @@ include("functions.php");
if (!isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
header ("Location: login.php"); header("Location: login.php");
} }
$loggedinas=$_SESSION['login']; $loggedinas = $_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas); $isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add']; $add = $_REQUEST['add'] ?? NULL;
$edit=$_REQUEST['edit']; $edit = $_REQUEST['edit'] ?? NULL;
$delete=$_REQUEST['delete']; $delete = $_REQUEST['delete'] ?? NULL;
$partid=$_REQUEST['partid']; $partid = $_REQUEST['partid'] ?? NULL;
$uid=$_REQUEST['uid']; $uid = $_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum']; $partnum = $_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum']; $sernum = $_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname']; $partname = $_REQUEST['partname'] ?? NULL;
$submit=$_REQUEST['submit']; $submit = $_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME; $logname = LOG_NAME;
$uidtext=UID_TEXT; $uidtext = UID_TEXT;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
if ($edit || $delete) { if ($edit || $delete) {
framework("begin","$logname","Part Edit",$print); framework("begin", "$logname", "Part Edit", $print);
} else { } else {
$add=1; $add = 1;
framework("begin","$logname","Part Entry",$print); framework("begin", "$logname", "Part Entry", $print);
} }
// ******** begin database manipulation ******** // ******** begin database manipulation ********
@@ -53,11 +53,11 @@ if ($add) {
if ($submit) { if ($submit) {
// add the entry if submit is pressed // add the entry if submit is pressed
if ($uid || ($partnum && $sernum)) { 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) { if (! $partexists) {
// add to parts table // add to parts table
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")"); mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$partid=mysqli_insert_id($db); $partid = mysqli_insert_id($db);
} }
} }
} }
@@ -66,18 +66,18 @@ if ($edit) {
if ($submit) { if ($submit) {
if ($uid || ($partnum && $sernum)) { if ($uid || ($partnum && $sernum)) {
// update parts table // 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) { if ($delete) {
// check for occurrence in logparts table // 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 // 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 // delete from parts table
if(!$inlogparts && !$inmaintforms) { if (!$inlogparts && !$inmaintforms) {
mysqli_query($db,"delete from parts where partid=\"$partid\""); mysqli_query($db, "delete from parts where partid=\"$partid\"");
} }
} }
@@ -85,24 +85,24 @@ if ($delete) {
pagetable("begin"); pagetable("begin");
if (!$print) { if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
// display the form // display the form
$partdatainput=array(); $partdatainput = array();
$partdatainput['partid']=$partid; $partdatainput['partid'] = $partid;
$partinfo=get_part_data($partdatainput); $partinfo = get_part_data($partdatainput);
if ($partinfo['result']==2) { if ($partinfo['result'] == 2) {
$pdatamismatch=1; $pdatamismatch = TRUE;
} else { } else {
unset($pdatamismatch); $pdatamismatch = FALSE;
if ($partinfo['uid']) $uid=$partinfo['uid']; $uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL;
if ($partinfo['partnum']) $partnum=$partinfo['partnum']; $partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL;
if ($partinfo['sernum']) $sernum=$partinfo['sernum']; $sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL;
if ($partinfo['partname']) $partname=$partinfo['partname']; $partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL;
} }
if ($delete) { if ($delete) {
if ($inmaintforms) { if ($inmaintforms) {
@@ -168,9 +168,7 @@ echo "
</form> </form>
"; ";
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,7 +2,7 @@
/* /*
parts.php parts.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -10,50 +10,50 @@
include("functions.php"); include("functions.php");
if (isset($_SESSION['login'])) { if (isset($_SESSION['login'])) {
$loggedin=1; $loggedin = TRUE;
} else { } else {
unset($loggedin); $loggedin = FALSE;
} }
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add']; $add = $_REQUEST['add'] ?? NULL;
$sort=$_REQUEST['sort']; $sort = $_REQUEST['sort'] ?? NULL;
$order=$_REQUEST['order']; $order = $_REQUEST['order'] ?? NULL;
$logname=LOG_NAME; $logname = LOG_NAME;
$uidtext=UID_TEXT; $uidtext = UID_TEXT;
if ($add) { 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") { if ($order == "asc") {
$order="desc"; $order = "desc";
} else if ($order == "desc") { } else if ($order == "desc") {
$order="asc"; $order = "asc";
} else { } else {
$order="asc"; $order = "asc";
} }
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","$logname","Parts",$print); framework("begin", "$logname", "Parts", $print);
pagetable("begin"); pagetable("begin");
if(!$print) { if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
if ($loggedin) { if ($loggedin) {
echo " echo "
@@ -71,15 +71,16 @@ echo "
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th> <th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
</tr> </tr>
"; ";
$partqry=mysqli_query($db,"select * from parts order by $sort $order"); $partqry = mysqli_query($db, "select * from parts order by $sort $order");
while ($partline=mysqli_fetch_assoc($partqry)) { while ($partline = mysqli_fetch_assoc($partqry)) {
if (!$partline['uid']) { if (!$partline['uid']) {
$pluidtxt="none"; $pluidtxt = "none";
} else { } else {
$pluidtxt=$partline['uid']; $pluidtxt = $partline['uid'];
} }
if ($loggedin) { if ($loggedin) {
printf(" printf(
"
<tr> <tr>
<td> <td>
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a> <a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
@@ -87,22 +88,24 @@ while ($partline=mysqli_fetch_assoc($partqry)) {
<td>%s</td> <td>%s</td>
<td>%s</td> <td>%s</td>
<td>%s</td>", <td>%s</td>",
$partline['partid'],$pluidtxt, $partline['partid'],
$partline['partnum'], $pluidtxt,
$partline['sernum'], $partline['partnum'],
$partline['partname'] $partline['sernum'],
$partline['partname']
); );
} else { } else {
printf(" printf(
"
<tr> <tr>
<td>%s</td> <td>%s</td>
<td>%s</td> <td>%s</td>
<td>%s</td> <td>%s</td>
<td>%s</td>", <td>%s</td>",
$pluidtxt, $pluidtxt,
$partline['partnum'], $partline['partnum'],
$partline['sernum'], $partline['sernum'],
$partline['partname'] $partline['partname']
); );
} }
echo " echo "
@@ -115,9 +118,7 @@ echo "
echo "<br><br>"; echo "<br><br>";
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,7 +2,7 @@
/* /*
profile.php profile.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
@@ -10,43 +10,43 @@
include("functions.php"); include("functions.php");
if (!isset($_SESSION['login'])) { if (!isset($_SESSION['login'])) {
header ("Location: login.php"); header("Location: login.php");
} }
$techid=$_SESSION['login'] ?? NULL; $techid = $_SESSION['login'] ?? NULL;
$print=$_REQUEST['print'] ?? NULL; $print = $_REQUEST['print'] ?? NULL;
$table=$_REQUEST['table'] ?? NULL; $table = $_REQUEST['table'] ?? NULL;
$updateinfo=$_REQUEST['updateinfo'] ?? NULL; $updateinfo = $_REQUEST['updateinfo'] ?? NULL;
$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL; $updatedisplay = $_REQUEST['updatedisplay'] ?? NULL;
$setcolor=$_REQUEST['setcolor'] ?? NULL; $setcolor = $_REQUEST['setcolor'] ?? NULL;
$name=$_REQUEST['name'] ?? NULL; $name = $_REQUEST['name'] ?? NULL;
$pass=$_REQUEST['pass'] ?? NULL; $pass = $_REQUEST['pass'] ?? NULL;
$passconf=$_REQUEST['passconf'] ?? NULL; $passconf = $_REQUEST['passconf'] ?? NULL;
$shift=$_REQUEST['shift'] ?? NULL; $shift = $_REQUEST['shift'] ?? NULL;
$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL; $display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL;
$display_showts=$_REQUEST['display_showts'] ?? NULL; $display_showts = $_REQUEST['display_showts'] ?? NULL;
$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL; $display_techalpha = $_REQUEST['display_techalpha'] ?? NULL;
$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL; $display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL;
$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL; $display_logstyle = $_REQUEST['display_logstyle'] ?? NULL;
$modcolor=$_REQUEST['modcolor'] ?? NULL; $modcolor = $_REQUEST['modcolor'] ?? NULL;
$hexcolor=$_REQUEST['hexcolor'] ?? NULL; $hexcolor = $_REQUEST['hexcolor'] ?? NULL;
$resetcustom=$_REQUEST["resetcustom"] ?? NULL; $resetcustom = $_REQUEST["resetcustom"] ?? NULL;
$logname=LOG_NAME; $logname = LOG_NAME;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","$logname","My Profile",$print); framework("begin", "$logname", "My Profile", $print);
pagetable("begin"); pagetable("begin");
if(!$print){ if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
// ******** begin database manipulation ******** // ******** begin database manipulation ********
if ($updateinfo) { if ($updateinfo) {
@@ -54,89 +54,94 @@ if(!$print){
// do error checking // do error checking
// test for name supplied // test for name supplied
if (strlen(trim($name))) { if (strlen(trim($name))) {
$namesuppld=1; $namesuppld = TRUE;
} else { } else {
$namesuppld=0; $namesuppld = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name cannot be blank.<br>"; echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name cannot be blank.<br>";
} }
// test for name unique // 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\" and techid!=\"$techid\""))) {
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) { if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
$nameunique=0; $nameunique = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name already exists.<br>"; echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name already exists.<br>";
} else { } else {
$nameunique=1; $nameunique = TRUE;
} }
} else { } else {
$nameunique=1; $nameunique = TRUE;
} }
// test for matching passwords // test for matching passwords
if ($pass!="password_is_unchanged") { if ($pass != "password_is_unchanged") {
if ($pass==$passconf) { if ($pass == $passconf) {
$passmatch=1; $passmatch = TRUE;
$passhash=password_hash($pass,PASSWORD_DEFAULT); $passhash = password_hash($pass, PASSWORD_DEFAULT);
$namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\""); $namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
} else { } else {
$passmatch=0; $passmatch = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;The passwords you supplied don't match.<br>"; echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;The passwords you supplied don't match.<br>";
} }
} else { } else {
$passmatch=1; $passmatch = TRUE;
$namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\""; $namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\"";
} }
if ($namesuppld && $nameunique && $passmatch) { if ($namesuppld && $nameunique && $passmatch) {
mysqli_query($db,$namepassupdqry); mysqli_query($db, $namepassupdqry);
mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\""); mysqli_query($db, "update techs set shift=\"$shift\" where techid=\"$techid\"");
} }
} }
if ($updatedisplay) { if ($updatedisplay) {
// display settings // display settings
if ($display_showts) $display_showts=1; else $display_showts=0; if ($display_showts) $display_showts = 1;
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0; else $display_showts = 0;
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=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 // test for urlchunk supplied
if (strlen(trim($display_urlchunk))) { if (strlen(trim($display_urlchunk))) {
$chunksuppld=1; $chunksuppld = TRUE;
} else { } else {
$chunksuppld=0; $chunksuppld = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;URL chunk size cannot be blank.<br>"; echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;URL chunk size cannot be blank.<br>";
} }
if ($chunksuppld) { if ($chunksuppld) {
putsetting('url_chunk_size',$display_urlchunk,$techid); putsetting('url_chunk_size', $display_urlchunk, $techid);
putsetting('show_ts',$display_showts,$techid); putsetting('show_ts', $display_showts, $techid);
putsetting('tech_alpha',$display_techalpha,$techid); putsetting('tech_alpha', $display_techalpha, $techid);
putsetting('subj_alpha',$display_subjalpha,$techid); putsetting('subj_alpha', $display_subjalpha, $techid);
putsetting('log_style',$display_logstyle,$techid); putsetting('log_style', $display_logstyle, $techid);
} }
} }
if ($setcolor) { if ($setcolor) {
// color settings // color settings
$hexcolor="#".ltrim($hexcolor); $hexcolor = "#" . ltrim($hexcolor);
putsetting($modcolor,$hexcolor,$techid); putsetting($modcolor, $hexcolor, $techid);
$currentpage = $_SERVER['PHP_SELF'];
header("Refresh: .1; url=$currentpage");
} }
if ($resetcustom) mysqli_query($db,"delete from customs where customtech=\"$techid\""); if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\"");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
// pull my current data from tables // pull my current data from tables
$curname=dblookup($db,"techs","techid","techname",$techid); $curname = dblookup($db, "techs", "techid", "techname", $techid);
$curshift=dblookup($db,"techs","techid","shift",$techid); $curshift = dblookup($db, "techs", "techid", "shift", $techid);
$pass=$passconf="password_is_unchanged"; $pass = $passconf = "password_is_unchanged";
// other values from customs // other values from customs
$curlchunk=getsetting('url_chunk_size',$techid)["value"]; $curlchunk = getsetting('url_chunk_size', $techid)["value"];
$curts=getsetting('show_ts',$techid)["value"]; $curts = getsetting('show_ts', $techid)["value"];
$curtdo=getsetting('tech_alpha',$techid)["value"]; $curtdo = getsetting('tech_alpha', $techid)["value"];
$cursdo=getsetting('subj_alpha',$techid)["value"]; $cursdo = getsetting('subj_alpha', $techid)["value"];
$curbgc=getsetting('background_color',$techid)["value"]; $curbgc = getsetting('background_color', $techid)["value"];
$cursbc=getsetting('sidebar_color',$techid)["value"]; $cursbc = getsetting('sidebar_color', $techid)["value"];
$curmbgc=getsetting('menubg_color',$techid)["value"]; $curmbgc = getsetting('menubg_color', $techid)["value"];
$curtc=getsetting('text_color',$techid)["value"]; $curtc = getsetting('text_color', $techid)["value"];
$curlc=getsetting('link_color',$techid)["value"]; $curlc = getsetting('link_color', $techid)["value"];
$curvlc=getsetting('vlink_color',$techid)["value"]; $curvlc = getsetting('vlink_color', $techid)["value"];
$curhc=getsetting('heading_color',$techid)["value"]; $curhc = getsetting('heading_color', $techid)["value"];
$curlogstyle=getsetting('log_style',$techid)["value"]; $curlogstyle = getsetting('log_style', $techid)["value"];
// show the form // show the form
echo " echo "
@@ -149,19 +154,19 @@ Password: &nbsp;<input type=\"password\" name=\"pass\" size=\"40\" value=\"$pass
Repeat Password: &nbsp;<input type=\"password\" name=\"passconf\" size=\"40\" value=\"$passconf\"><br><br> Repeat Password: &nbsp;<input type=\"password\" name=\"passconf\" size=\"40\" value=\"$passconf\"><br><br>
<font size=\"-1\">Need a random password? &nbsp;</font> <font size=\"-1\">Need a random password? &nbsp;</font>
"; ";
$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12); $rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12);
echo " echo "
&nbsp; $rpw<br><br> &nbsp; $rpw<br><br>
<b>Shift: </b>&nbsp; <b>Shift: </b>&nbsp;
<select name=\"shift\"> <select name=\"shift\">
"; ";
$shiftrow=mysqli_query($db,"select * from shifts"); $shiftrow = mysqli_query($db, "select * from shifts");
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) { while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) { if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"]==$curshift) { if ($shiftitem["shiftid"] == $curshift) {
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]); printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
} else { } else {
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]); printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
} }
} }
} }
@@ -176,12 +181,12 @@ echo "
<b>My Display Preferences</b><br><br> <b>My Display Preferences</b><br><br>
Log style (the look of the log notes display): &nbsp;&nbsp;<select name=\"display_logstyle\"> Log style (the look of the log notes display): &nbsp;&nbsp;<select name=\"display_logstyle\">
"; ";
$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\""); $logstyleqry = mysqli_query($db, "select styleid,stylename from styles where styletype=\"logdisplay\"");
while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) { while ($logstylerow = mysqli_fetch_assoc($logstyleqry)) {
if ($logstylerow["styleid"]==$curlogstyle) { if ($logstylerow["styleid"] == $curlogstyle) {
printf("<option value=\"%s\" selected>%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]); printf("<option value=\"%s\" selected>%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
} else { } else {
printf("<option value=\"%s\">%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]); printf("<option value=\"%s\">%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
} }
} }
echo " echo "
@@ -236,7 +241,7 @@ echo "
<hr> <hr>
<b>My Color Preferences</b><br><br> <b>My Color Preferences</b><br><br>
"; ";
switch($modcolor) { switch ($modcolor) {
case "background_color": case "background_color":
echo "<table border=\"0\"><tr><td>Page background color</td><td>"; echo "<table border=\"0\"><tr><td>Page background color</td><td>";
colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor="); colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor=");
@@ -290,9 +295,7 @@ echo "
</form> </form>
"; ";
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

View File

@@ -2,76 +2,77 @@
/* /*
refchain.php refchain.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
include("functions.php"); include("functions.php");
$print=$_REQUEST['print']; $print = $_REQUEST['print'] ?? "";
$chainnote=$_REQUEST['chainnote']; $chainnote = $_REQUEST['chainnote'] ?? NULL;
$logname=LOG_NAME; $logname = LOG_NAME;
if ($print) { if ($print) {
$sbcolor=P_SIDEBAR_COLOR; $sbcolor = P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR; $mbgcolor = P_MENUBG_COLOR;
} else { } else {
$sbcolor=SIDEBAR_COLOR; $sbcolor = SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR; $mbgcolor = MENUBG_COLOR;
} }
framework("begin","$logname","Reference Chain Display",$print); framework("begin", "$logname", "Reference Chain Display", $print);
// ******** begin database manipulation ******** // ******** begin database manipulation ********
$master=generate_chain($chainnote); $master = generate_chain($chainnote);
// ******** end database manipulation ******** // ******** end database manipulation ********
pagetable("begin"); pagetable("begin");
if(!$print){ if (!$print) {
pageblock("left","begin"); pageblock("left", "begin");
sidemenu(); sidemenu();
pageblock("left","end"); pageblock("left", "end");
} }
pageblock("right","begin"); pageblock("right", "begin");
banner($print); banner($print);
// display the chain // display the chain
$mptr=0; $mptr = 0;
echo "<br><br><table border=\"1\" width=\"100%\">"; echo "<br><br><table border=\"1\" width=\"100%\">";
echo "<tr><th>Note ID</th><th>Date &#47; Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>"; echo "<tr><th>Note ID</th><th>Date &#47; Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>";
while($mptr<count($master)) { while ($mptr < count($master)) {
if(mysqli_num_rows(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"))) { 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]")); $tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"));
$noteid=$tablerow["lognoteid"]; $noteid = $tablerow["lognoteid"];
$urldatestr="y=".date("Y",strtotime($tablerow["date"]))."&m=".date("m",strtotime($tablerow["date"]))."&d=".date("d",strtotime($tablerow["date"])); $urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"]));
$refs="&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>"; $refs = "&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>";
// convert the shift number to a name // 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 // 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 //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 // create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]); $fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string // generate the flags string
$flagstring=""; $flagstring = "";
$allflagqry=mysqli_query($db,"select flagid from flags"); $flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid");
while ($allflagids=mysqli_fetch_row($allflagqry)) { if (mysqli_num_rows($flagmapqry)) {
$flagid=$allflagids[0]; while ($flagids = mysqli_fetch_row($flagmapqry)) {
$flag_tbl="flag_".$flagid; $flagid = $flagids[0];
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\""));
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); $flagcolor = $flagparam["flagcolor"];
$flagcolor=$flagparam["flagcolor"]; $flagsym = $flagparam["flagsym"];
$flagsym=$flagparam["flagsym"]; $flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
} }
} }
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
printf(" if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
printf(
"
<tr> <tr>
<td><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td> <td><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td>
<td>%s &#47; %s</td> <td>%s &#47; %s</td>
@@ -81,23 +82,24 @@ while($mptr<count($master)) {
<td>%s</td> <td>%s</td>
<td>%s</td> <td>%s</td>
</tr>", </tr>",
$tablerow["lognoteid"],$tablerow["lognoteid"], $tablerow["lognoteid"],
$tablerow["date"],$tablerow["time"], $tablerow["lognoteid"],
$shname, $tablerow["date"],
$tname, $tablerow["time"],
$subjname, $shname,
$fmtnote, $tname,
$refs); $subjname,
$fmtnote,
$refs
);
} else { } else {
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n",$master[$mptr]); printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n", $master[$mptr]);
} }
$mptr=$mptr+1; $mptr = $mptr + 1;
} }
echo "</table><br><br>"; echo "</table><br><br>";
banner($print); banner($print);
pageblock("right","end"); pageblock("right", "end");
pagetable("end"); pagetable("end");
framework("end","","",$print); framework("end", "", "", $print);
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,60 +2,62 @@
/* /*
settings.php settings.php
OpenLog Online Logbook OpenLog Online Logbook
Copyright (C) 2025 Rod Wright Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0 SPDX-License-Identifier: GPL-2.0
*/ */
$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0]; // determine today's date and time and assign them to variables
$ostype=strtoupper(substr(php_uname('s'), 0, 3)); $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));
if ($ostype == 'WIN') { 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 { } 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); if (!is_dir($sdir)) mkdir($sdir, 0700, true);
ini_set('session.cookie_lifetime', $lifetime); ini_set('session.cookie_lifetime', $lifetime);
ini_set('session.gc_maxlifetime', $lifetime); ini_set('session.gc_maxlifetime', $lifetime);
ini_set('session.save_path', $sdir); ini_set('session.save_path', $sdir);
$ss=session_status(); $ss = session_status();
if ($ss==PHP_SESSION_NONE) session_start(); if ($ss == PHP_SESSION_NONE) session_start();
// get config options from database and assign them to constants // get config options from database and assign them to constants
unset($techid); unset($techid);
if (isset($_SESSION['login']) && $_SESSION['login'] != '') { 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)) { while ($configrow = mysqli_fetch_assoc($configqry)) {
$constname=strtoupper($configrow["confname"]); $constname = strtoupper($configrow["confname"]);
if (isset($techid)) { if (isset($techid)) {
$confid=$configrow["confid"]; $confid = $configrow["confid"];
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\""); $custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
if (mysqli_num_rows($custqry)) { if (mysqli_num_rows($custqry)) {
$custrow=mysqli_fetch_row($custqry); $custrow = mysqli_fetch_row($custqry);
$custval=$custrow[0]; $custval = $custrow[0];
} else { } else {
unset($custval); unset($custval);
} }
} }
if (isset($custval)) { if (isset($custval)) {
$constvalue=$custval; $constvalue = $custval;
} else { } else {
$constvalue=$configrow["confvalue"]; $constvalue = $configrow["confvalue"];
} }
define("$constname","$constvalue"); define("$constname", "$constvalue");
} }
// error reporting // error reporting
$logerrors=LOG_ERRORS; $logerrors = LOG_ERRORS;
if ($logerrors==1) { if ($logerrors == 1) {
error_reporting(E_ALL); error_reporting(E_ALL);
} else { } else {
error_reporting(0); error_reporting(0);
} }
?>

571
distfiles/templates.php Normal file
View File

@@ -0,0 +1,571 @@
<?php
/*
templates.php
OpenLog Online Logbook
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
if (!$_SESSION['login'] && !$_REQUEST['partview']) {
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;
$logname = LOG_NAME;
$techalpha = TECH_ALPHA;
$subjalpha = SUBJ_ALPHA;
$defaultshift = dblookup($db, "techs", "techid", "shift", $techid);
if ($print == "Printer Friendly") {
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin", "$logname", "Note Templates", $print);
// make basic determination about authorization
if ($isadmin) {
$authorized = TRUE;
} else if ($efftechid == $techid) {
$authorized = TRUE;
} else {
$authorized = FALSE;
}
// var_dump($_REQUEST);
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);
if (mysqli_num_rows($templatequery)) {
$hastemplates = TRUE;
} else {
$hastemplates = FALSE;
}
echo "<b><font size=\"+1\">";
if ($hastemplates) {
// print the user header
if ($user == "0") {
echo "Global Templates</font></b>";
} else {
if ($user == $techid) {
echo "My templates</font></b>";
} else {
echo "Templates for $tblusername</font></b>";
}
}
// print the table
echo "<br><table border=\"1\" width=\"100%\">";
echo "<tr><th width=\"70\">Template Name</th><th width=\"100\">Shift</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>";
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 . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote = $fmtnote . "<br>";
}
// 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</a>";
} else {
$nameblock = "<a href=\"templates.php?operation=edit&templateid=$templateid\">$templatename</a>";
}
printf(
"<tr>
<td valign=\"top\">%s</td>
<td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
</tr>\n",
$nameblock,
$shiftname,
$subjname,
$fmtnote,
$refstring
);
};
echo "</table><br><hr><br>";
} else {
if ($user == "0") {
echo "There are no global templates</font></b>";
} else {
if ($user == $techid) {
echo "You have no templates</font></b>";
} else {
echo "$tblusername has no templates</font></b>";
}
}
echo "<br><hr>";
}
echo "<br>";
}
// ******** begin database manipulation ********
if ($usertemplateid) {
$templateid = $usertemplateid;
} else if ($globaltemplateid) {
$templateid = $globaltemplateid;
} else {
$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) {
// remove cruft from note text
$note = strip_tags($note, "<a>");
$note = mysqli_real_escape_string($db, $note);
if ($authorized) {
// 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 ($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, "<a>");
$note = mysqli_real_escape_string($db, $note);
if ($templatename) {
$namesupplied = TRUE;
} else {
$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\"");
// 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)");
}
}
}
}
}
}
if ($operation == "delete") {
if ($authorized) {
// 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 || $operation == "delete") {
// show success/failure messages
$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;
}
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, "<strong>Template created.</strong>");
}
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;
}
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, "<strong>Template modified.</strong>");
}
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, "<strong>Template deleted.</strong>");
}
}
if ($operation == "delete") {
// just show the link back to the templates page
echo "
<br><a href=\"templates.php\">Manage templates</a><br><br><br><br>
";
} else if ($operation == "add" || $operation == "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 ($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 ($efftechid) {
$filltech = $efftechid;
} else if ($isadmin && $loadeddata["tech"] == "0") {
$filltech = "0";
} else {
$filltech = $techid;
}
$fillshift = $loadeddata["shift"];
$fillsubject = $loadeddata["subject"];
$fillnote = $loadeddata["lognote"];
} else {
// use empty values with a defined tech id
$filltemplatename = NULL;
if ($efftechid) {
$filltech = $efftechid;
} else {
$filltech = $techid;
}
$fillshift = $defaultshift;
$fillsubject = NULL;
$fillnote = NULL;
}
if ($operation == "add") $optext = "Creating new";
if ($operation == "edit") $optext = "Editing";
echo "
<br><b>$optext template</b><br><hr>
";
// show the template selection line
templateselect($techid, $operation);
// start template entry section
echo "
<form method=\"post\" action=\"templates.php\">
<table border=\"0\" cellpadding=\"5\">
<tr><td colspan=\"2\"><b>Template Name: </b>&nbsp;
<input type=\"text\" name=\"templatename\" size=\"30\" value=\"$filltemplatename\" title=\"What you'd like to name the template.\"></td></tr>
";
if ($isadmin) {
echo "
<tr><td colspan=\"2\"><b>Tech: </b>&nbsp;
<select name=\"efftechid\">
";
if ($filltech == "0") {
echo "<option value=\"0\" selected>--Global Template--</option>";
} else {
echo "<option value=\"0\">--Global Template--</option>";
}
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("<option value=\"%s\" selected>%s</option>", $techitem["techid"], $techitem["techname"]);
} else {
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
}
}
echo "
</select></td></tr>
";
} else {
$authorized = TRUE;
echo "
<input type=\"hidden\" name=\"efftechid\" value=\"$techid\">
";
}
echo "
<tr>
<td><b>Shift: </b>&nbsp;
<select name=\"shift\">
";
$shiftrow = mysqli_query($db, "select * from shifts");
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"] == $fillshift) {
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
} else {
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
}
}
}
echo "
</select></td>
<td><b>Subject: </b>&nbsp;
<select name=\"subject\">
";
if ($subjalpha) $sorder = "subjectname";
else $sorder = "subjectid";
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
if ($subjitem["status"] == 1) {
if ($subjitem["subjectid"] == $fillsubject) {
printf("<option value=\"%s\" selected>%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
} else {
printf("<option value=\"%s\">%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
}
}
}
echo "
</select></td>
</tr></table>
<b>Note:</b>&nbsp;<img src=\"icons/question.png\" title=\"Enter note text below. To insert a link to a web page, enter it's info in the link fields below the Note box and click Insert Link. You must provide the URL, but the link text is optional. \"><br>
<textarea rows=\"10\" cols=\"60\" name=\"note\" id=\"notetextarea\" wrap=\"soft\">$fillnote";
echo "</textarea><br>
<input type=\"text\" size=\"23\" id=\"linktextfield\" placeholder=\"Enter link text here\">&nbsp;
<input type=\"text\" size=\"23\" id=\"linkurlfield\" placeholder=\"Enter URL here\">&nbsp;
<a href=\"#\" onclick=\"insertUrlAtCaret('notetextarea','linktextfield','linkurlfield');return false;\">Insert Link</a><br>
";
// 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 ($operation == "edit" && in_array($flagcheckbox["flagid"], $theseflags)) {
printf(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$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(
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
}
}
if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount = 1;
}
}
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];
}
}
echo "
<br><br><b>References: </b>&nbsp;
<input type=\"text\" name=\"refstring\" size=\"20\" value=\"$refstring\" title=\"One or more Note ID numbers separated by spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
";
if ($operation == "add" && $authorized) {
echo "
<input type=\"hidden\" name=\"operation\" value=\"add\">
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
";
}
if ($operation == "edit" && $authorized) {
echo "
<input type=\"hidden\" name=\"operation\" value=\"edit\">
<input type=\"hidden\" name=\"templateid\" value=\"$templateid\">
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
<button type=\"submit\" name=\"operation\" value=\"delete\">Delete this template</button><font color=\"#FF0000\"><b>Deleted templates are irretrievable!</b></font>
";
}
echo "
</form>
<br>
";
} else {
echo "<br><font size= \"+1\"><b><a href=\"templates.php?operation=add\">Create or copy a template</a></b></font><br><hr>";
// 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);

43
files-update.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/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
# --------------------------------------

View File

@@ -2,27 +2,31 @@
# install.sh # install.sh
# OpenLog Online Logbook # OpenLog Online Logbook
# Copyright (C) 2025 Rod Wright # Copyright (C) 2026 Rod Wright
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
APP_NAME="OpenLog" APP_NAME="OpenLog"
DEFAULT_DB_NAME="openlog" DEFAULT_DB_NAME="openlog"
APP_VERSION="5.2.4" APP_VERSION="5.3.0"
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" LANDING_PAGE="lognotes.php"
INDEX_FILE="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" != 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
@@ -32,11 +36,11 @@ function get_new_password() {
echo "" echo ""
read -p "Re-type new password: " -s -r rnewpw read -p "Re-type new password: " -s -r rnewpw
echo "" echo ""
if [ "$newpassword" = "" -o "$rnewpw" = "" ] if [[ "$newpassword" == "" || "$rnewpw" == "" ]]
then then
echo "Password cannot be blank. Please try again." echo "Password cannot be blank. Please try again."
echo "" echo ""
elif [ "$newpassword" != "$rnewpw" ] elif [[ "$newpassword" != "$rnewpw" ]]
then then
echo "Passwords do not match. Please try again." echo "Passwords do not match. Please try again."
echo "" echo ""
@@ -59,7 +63,7 @@ function install_required_packages() {
gpattern="" gpattern=""
for pkg_option in $(echo $prereq) for pkg_option in $(echo $prereq)
do do
if [ "$pkg_option" != "or" ] if [[ "$pkg_option" != "or" ]]
then then
gpattern+=" -e $pkg_option" gpattern+=" -e $pkg_option"
preferred_pkg=$pkg_option preferred_pkg=$pkg_option
@@ -72,7 +76,7 @@ function install_required_packages() {
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. " echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
echo -n "Install $preferred_pkg now? [Y/n]: " echo -n "Install $preferred_pkg now? [Y/n]: "
read reqinstall read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ] if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]]
then then
echo "$APP_NAME requires $prereq, but you have elected not to install it." echo "$APP_NAME requires $prereq, but you have elected not to install it."
echo "Installation cannot continue." echo "Installation cannot continue."
@@ -105,11 +109,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 +137,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"
@@ -311,81 +172,143 @@ echo ""
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :" echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
read install_loc_in read install_loc_in
echo "" echo ""
if [ "$doc_root_in" = "" ] if [[ "$doc_root_in" == "" ]]
then then
doc_root_in=$DOC_ROOT doc_root_in=$DOC_ROOT
fi fi
if [ "$install_loc_in" = "" ] if [[ "$install_loc_in" == "" ]]
then then
install_loc_in=$INSTALL_LOC install_loc_in=$INSTALL_LOC
fi 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
# A db.php file was found in the install path # A db.php file was found in the install path
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
# put app 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
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
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 > $backupdir/$curr_dbname-$datestamp-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 $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
# apply database updates find $install_path/ -mindepth 1 ! \( -name 'db.php' -o -name 'maintenancemode.php' \) -delete
mysql -u"$curr_username" -f -D $curr_dbname < database-update.sql >/dev/null 2>&1
# apply updates to existing db.php echo "Performing database updates..."
bash ./db.php_update $install_path # apply database updates from sql file
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
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
# set symlink for jquery-ui # set symlink for jquery-ui
if [ ! -L "$install_path/jquery-ui" ] if [[ ! -L "$install_path/jquery-ui" ]]
then then
ln -s $install_path/jquery-ui* $install_path/jquery-ui ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi fi
# 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 "Backups of the previous openlog files and the previous database were made"
echo "Cancelling installation" echo "and are located in the $backupdir directory."
abort_exit
# 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 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 +319,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
@@ -409,7 +345,7 @@ else
echo "This can be changed later in the application itself." echo "This can be changed later in the application itself."
echo -n "Installation name [$APP_NAME]: " echo -n "Installation name [$APP_NAME]: "
read new_inst_name read new_inst_name
if [ "$new_inst_name" = "" ] if [[ "$new_inst_name" == "" ]]
then then
new_inst_name="$APP_NAME" new_inst_name="$APP_NAME"
fi fi
@@ -426,7 +362,7 @@ else
echo "distinctive name." echo "distinctive name."
echo -n "database name [$DEFAULT_DB_NAME]: " echo -n "database name [$DEFAULT_DB_NAME]: "
read new_db_name read new_db_name
if [ "$new_db_name" = "" ] if [[ "$new_db_name" == "" ]]
then then
new_db_name=$DEFAULT_DB_NAME new_db_name=$DEFAULT_DB_NAME
fi fi
@@ -439,7 +375,7 @@ else
echo "This probably means the database already exists." echo "This probably means the database already exists."
echo -n "Try again with a different database name? [Y/N]: " echo -n "Try again with a different database name? [Y/N]: "
read dbcreatetry read dbcreatetry
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ] if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]]
then then
abort_exit abort_exit
fi fi
@@ -459,7 +395,7 @@ else
# Set the installation name # Set the installation name
export MYSQL_PWD="$db_pass" 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\"" 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 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\"" 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 fi
@@ -468,39 +404,38 @@ else
mkdir $install_path mkdir $install_path
# Create db.php if it doesn't exist # Create db.php if it doesn't exist
if [ ! -f "$install_path/db.php" ] if [[ ! -f "$install_path/db.php" ]]
then then
cp db.php.template $install_path/db.php cp db.php.template $install_path/db.php
sed -i "s/DBNAME/$new_db_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|DBUSER|$db_user|g" $install_path/db.php
sed -i "s/DBPASS/$db_pass/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|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 fi
# 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
if [ ! -L "$install_path/jquery-ui" ] if [[ ! -L "$install_path/jquery-ui" ]]
then then
ln -s $install_path/jquery-ui* $install_path/jquery-ui ln -s $install_path/jquery-ui* $install_path/jquery-ui
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
@@ -514,22 +449,24 @@ echo ""
echo "" echo ""
echo "$APP_NAME has been $operation." echo "$APP_NAME has been $operation."
base_url=$install_loc_in base_url=$install_loc_in
if [ "$operation" = "installed" ] if [[ "$operation" == "upgraded" ]]
then then
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf a2enconf -q $base_url
echo "" >> $APACHE_CONF_DIR/$base_url.conf systemctl reload apache2
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf fi
echo "" >> $APACHE_CONF_DIR/$base_url.conf if [[ "$operation" == "installed" ]]
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf then
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf
echo "</Directory>" >> $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] :" echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
read enconf read enconf
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ] if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
then then
a2enconf $base_url.conf >/dev/null a2enconf -q $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 "You can now point a web browser to $base_url on your web server "
echo "to set up and configure $APP_NAME." echo "to set up and configure $APP_NAME."
echo "" echo ""

26
maintenancemode.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
/*
maintenancemode.php
OpenLog Online Logbook
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
echo "
<html>
<head>
<title>_APPNAME_</title>
<style type=\"text/css\">
* {font-family: Arial, Helvetica, sans-serif;}
</style>
</head>
<body>
<br><br><br><br>
_APPNAME_ is currently down for maintenance. Please try again later.
<br><br>
</body>
</html>
";
?>