52 Commits
5.2.5 ... 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
34 changed files with 5026 additions and 3202 deletions

3
BUGS
View File

@@ -1,4 +1,5 @@
BUGS
1. Adding a reference to a note using the magnifying glass icon is possible even if not logged in. This results in a blank tech and shift.
SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There needs to be a specific view only state.)
SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There
needs to be a specific view only state.)

View File

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

323
LICENSE
View File

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

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
1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE
2. Allow admins to create global templates.
2. Allow admins to create global templates. DONE
3. Create a way to restore the global page colors. (db change reqd)
4. Pick a logbook subject to associate with a scheduled task to populate for the logbook entry. (db change reqd)
5. Add info messages to scheduled task page edits.
6. Allow scheduled tasks to be completed as a group instead of having to complete each member.
7. Implement popup calendars for date entry fields. DONE
8. Improve template management interface. It can be confusing. It needs its own page.
9. Remove refs from templates. (db change reqd)
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd)
8. Improve template management interface. It can be confusing. It needs its own page. DONE
9. Remove refs from templates. (db change reqd) DONE
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) DONE
11. allow partids to be autogenerated if user doesn't supply one (db change reqd)
12. If there are no flags, don't offer to set them on reference chain
13. make some flags immutable so they won't be synced on reference chain.

View File

@@ -1 +1 @@
5.2.5
5.3.0

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,19 @@
# SPDX-License-Identifier: GPL-2.0
function spinner() {
local pid="$1"
local delay="0.1"
local spinstr='|/-\\'
local i=0
while ps -p "$pid" > /dev/null; do
i=$(( (i+1) % 4 ))
printf "\r[%c]" "${spinstr:$i:1}"
sleep "$delay"
done
printf "\r \r" # Clear the spinner line
}
if [[ $1 == "" ]]
then
@@ -37,3 +50,97 @@ margs="--defaults-extra-file=$mysql_opt_file"
# ---------- 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,56 +2,85 @@
-- ---------- version 5.2.1 -------------
-- Make confname a unique column
ALTER TABLE configs ADD UNIQUE(confname);
ALTER TABLE configs ADD UNIQUE (confname);
-- Delete db name, user, and password configs
DELETE FROM configs where confname="ol_dbname";
DELETE FROM configs where confname="ol_dbuser";
DELETE FROM configs where confname="ol_dbpass";
DELETE FROM configs where confname = "ol_dbname";
DELETE FROM configs where confname = "ol_dbuser";
DELETE FROM configs where confname = "ol_dbpass";
-- Add config option for server side error logging
INSERT IGNORE INTO configs(confname,confvalue) values('log_errors','0')
INSERT IGNORE INTO
configs (confname, confvalue)
values ('log_errors', '0')
-- Update version number
UPDATE configs SET confvalue="5.2.1" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.2 -------------
-- Update version number
UPDATE configs SET confvalue="5.2.2" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.2" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.3 -------------
-- Update version number
UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.3" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.4 -------------
-- Update version number
UPDATE configs SET confvalue="5.2.4" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.4" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.4.1 -----------
-- Update version number
UPDATE configs SET confvalue="5.2.4.1" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.4.1" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.4.2 -----------
-- Update version number
UPDATE configs SET confvalue="5.2.4.2" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.4.2" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.4.3 -----------
-- Update version number
UPDATE configs SET confvalue="5.2.4.3" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.4.3" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.4.4 -----------
-- Update version number
UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.4.4" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.2.5 -------------
-- Update version number
UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version";
UPDATE configs SET confvalue = "5.2.5" WHERE confname = "ol_version";
-- --------------------------------------
-- ---------- version 5.3.0 -------------
-- Update version number
UPDATE configs SET confvalue = "5.3.0" WHERE confname = "ol_version";
-- 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
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -14,10 +14,10 @@
** DO NOT EDIT **
************************************************************************
*/
$appname="APPNAME";
$dbname="DBNAME";
$username="DBUSER";
$dbpass="DBPASS";
$appname = "APPNAME";
$dbname = "DBNAME";
$username = "DBUSER";
$dbpass = "DBPASS";
function dberrmsg($dbname) {
echo "
@@ -34,7 +34,7 @@ function dberrmsg($dbname) {
exit();
}
$db=@mysqli_connect("localhost",$username,$dbpass,$dbname);
$db = @mysqli_connect("localhost",$username,$dbpass,$dbname);
if (mysqli_errno($db)) {
dberrmsg($dbname);
}

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
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
@@ -233,7 +233,7 @@
installers.
5.2.4.4 - 2025-12-19
-Fixed bugs that caused crashes on the Scheduled Maintenance page
- Fixed bugs that caused crashes on the Scheduled Maintenance page
that were caused by more strict behavior of php regarding mysql
queries.
- Fixed bug where some functions defined in functions.php were not
@@ -245,3 +245,42 @@
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
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
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.
2. Unpack
Unpack the distribution in a convenient place (such as /tmp or My Documents).
Unpack the distribution in a convenient place.
A directory will be created called OpenLog-x.x.x.
3. Review License
Change to the openlog-x.x.x directory and review the LICENSE file.
Change to the OpenLog-x.x.x directory and review the LICENSE file.
4. Run the install script
If installing on a Linux or Unix based system, type ./install.sh at a
command prompt. If installing on a Windows based system, double click
install.bat. Follow the prompts.
Type ./install.sh at a command prompt. Follow the prompts.
5. Check and set Configuration
Click on the Administration menu option on the main page to adjust the initial

View File

@@ -2,33 +2,33 @@
/*
about.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
$version=OL_VERSION;
$version = OL_VERSION;
$print=$_REQUEST['print'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","About OpenLog","About OpenLog",$print);
framework("begin", "About OpenLog", "About OpenLog", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
echo "
<h3 align=\"center\">
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>
</p>
";
pageblock("right","end");
pageblock("right", "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
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -10,25 +10,25 @@
include("functions.php");
$print=$_REQUEST['print'];
$print = $_REQUEST['print'] ?? NULL;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","OpenLog License","OpenLog License",$print);
framework("begin", "OpenLog License", "OpenLog License", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
sidemenu();
pageblock("left","end");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
echo "
<pre>
GNU GENERAL PUBLIC LICENSE
@@ -376,9 +376,7 @@ Public License instead of this License.
</pre>
";
pageblock("right","end");
pageblock("right", "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
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
$print=$_REQUEST['print'];
$tech=$_REQUEST['tech'];
$pass=$_REQUEST['pass'];
$login=$_REQUEST['login'];
$cancel=$_REQUEST['cancel'];
$print = $_REQUEST['print'] ?? NULL;
$tech = $_REQUEST['tech'] ?? NULL;
$pass = $_REQUEST['pass'] ?? NULL;
$login = $_REQUEST['login'] ?? NULL;
$cancel = $_REQUEST['cancel'] ?? NULL;
if ($cancel) {
session_destroy();
}
$techalpha=TECH_ALPHA;
$logname=LOG_NAME;
$techalpha = TECH_ALPHA;
$logname = LOG_NAME;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Login Page",$print);
framework("begin", "$logname", "Login Page", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu("no print");
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
if ($login) {
// 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)) {
$_SESSION['login']=$tech;
$techname=dblookup($db,"techs","techid","techname",$tech);
$_SESSION['login'] = $tech;
$techname = dblookup($db, "techs", "techid", "techname", $tech);
echo "
Welcome $techname. Please select a menu option at the left to continue.
";
} 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 "
Incorrect password. Please <a href=\"login.php\">try again</a>.<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>";
}
}
} else if ($cancel) {
echo "
@@ -72,11 +71,12 @@ if ($login) {
<b>Tech: </b>&nbsp;
<select name=\"tech\">
";
if ($techalpha) $torder="techname"; else $torder="techid";
$techrow=mysqli_query($db,"select * from techs order by $torder asc");
while ($techitem=mysqli_fetch_assoc($techrow)) {
if ($techitem["status"]==1) {
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]);
if ($techalpha) $torder = "techname";
else $torder = "techid";
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
while ($techitem = mysqli_fetch_assoc($techrow)) {
if ($techitem["status"] == 1) {
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
}
}
echo "</select><br><br>
@@ -87,16 +87,14 @@ if ($login) {
<br><hr>
";
} else {
$loginid=$_SESSION['login'];
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0];
$loginid = $_SESSION['login'];
$loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
echo "
You are already logged in as $loggedinas. Please select a menu option at the left to continue.<br><hr>
";
}
}
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,76 +2,77 @@
/*
refchain.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
$print=$_REQUEST['print'];
$chainnote=$_REQUEST['chainnote'];
$print = $_REQUEST['print'] ?? "";
$chainnote = $_REQUEST['chainnote'] ?? NULL;
$logname=LOG_NAME;
$logname = LOG_NAME;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Reference Chain Display",$print);
framework("begin", "$logname", "Reference Chain Display", $print);
// ******** begin database manipulation ********
$master=generate_chain($chainnote);
$master = generate_chain($chainnote);
// ******** end database manipulation ********
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
// display the chain
$mptr=0;
$mptr = 0;
echo "<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>";
while($mptr<count($master)) {
if(mysqli_num_rows(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"))) {
$tablerow = mysqli_fetch_assoc(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"));
$noteid=$tablerow["lognoteid"];
$urldatestr="y=".date("Y",strtotime($tablerow["date"]))."&m=".date("m",strtotime($tablerow["date"]))."&d=".date("d",strtotime($tablerow["date"]));
$refs="&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>";
while ($mptr < count($master)) {
if (mysqli_num_rows(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"))) {
$tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"));
$noteid = $tablerow["lognoteid"];
$urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"]));
$refs = "&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
$shname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
//convert subject number to name
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
// create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]);
$fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$allflagqry=mysqli_query($db,"select flagid from flags");
while ($allflagids=mysqli_fetch_row($allflagqry)) {
$flagid=$allflagids[0];
$flag_tbl="flag_".$flagid;
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
$flagstring = "";
$flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid");
if (mysqli_num_rows($flagmapqry)) {
while ($flagids = mysqli_fetch_row($flagmapqry)) {
$flagid = $flagids[0];
$flagparam = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid\""));
$flagcolor = $flagparam["flagcolor"];
$flagsym = $flagparam["flagsym"];
$flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
}
}
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
printf("
if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
printf(
"
<tr>
<td><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td>
<td>%s &#47; %s</td>
@@ -81,23 +82,24 @@ while($mptr<count($master)) {
<td>%s</td>
<td>%s</td>
</tr>",
$tablerow["lognoteid"],$tablerow["lognoteid"],
$tablerow["date"],$tablerow["time"],
$shname,
$tname,
$subjname,
$fmtnote,
$refs);
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tablerow["date"],
$tablerow["time"],
$shname,
$tname,
$subjname,
$fmtnote,
$refs
);
} else {
printf("<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>";
banner($print);
pageblock("right","end");
pageblock("right", "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 @@
/*
settings.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -11,55 +11,53 @@
$today = date("Y-m-d");
$now = date("H:i:s");
$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0];
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0];
$ostype = strtoupper(substr(php_uname('s'), 0, 3));
if ($ostype == 'WIN') {
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0];
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0];
} else {
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
}
$lifetime=60 * 60 * 24 * $sttl;
$lifetime = 60 * 60 * 24 * $sttl;
if (!is_dir($sdir)) mkdir($sdir, 0700, true);
ini_set('session.cookie_lifetime', $lifetime);
ini_set('session.gc_maxlifetime', $lifetime);
ini_set('session.save_path', $sdir);
$ss=session_status();
if ($ss==PHP_SESSION_NONE) session_start();
$ss = session_status();
if ($ss == PHP_SESSION_NONE) session_start();
// get config options from database and assign them to constants
unset($techid);
if (isset($_SESSION['login']) && $_SESSION['login'] != '') {
$techid=$_SESSION['login'];
$techid = $_SESSION['login'];
}
$configqry=mysqli_query($db,"select confname,confvalue,confid from configs");
$configqry = mysqli_query($db, "select confname,confvalue,confid from configs");
while ($configrow = mysqli_fetch_assoc($configqry)) {
$constname=strtoupper($configrow["confname"]);
$constname = strtoupper($configrow["confname"]);
if (isset($techid)) {
$confid=$configrow["confid"];
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
$confid = $configrow["confid"];
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
if (mysqli_num_rows($custqry)) {
$custrow=mysqli_fetch_row($custqry);
$custval=$custrow[0];
$custrow = mysqli_fetch_row($custqry);
$custval = $custrow[0];
} else {
unset($custval);
}
}
if (isset($custval)) {
$constvalue=$custval;
$constvalue = $custval;
} else {
$constvalue=$configrow["confvalue"];
$constvalue = $configrow["confvalue"];
}
define("$constname","$constvalue");
define("$constname", "$constvalue");
}
// error reporting
$logerrors=LOG_ERRORS;
if ($logerrors==1) {
$logerrors = LOG_ERRORS;
if ($logerrors == 1) {
error_reporting(E_ALL);
} else {
error_reporting(0);
}
?>

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);

View File

@@ -41,8 +41,3 @@ fi
# ---------- version 5.2.4.4 -----------
# No changes
# --------------------------------------
# ---------- version 5.2.5 -------------
# No changes
# --------------------------------------

View File

@@ -2,17 +2,16 @@
# install.sh
# OpenLog Online Logbook
# Copyright (C) 2025 Rod Wright
# Copyright (C) 2026 Rod Wright
# SPDX-License-Identifier: GPL-2.0
APP_NAME="OpenLog"
DEFAULT_DB_NAME="openlog"
APP_VERSION="5.2.5"
APP_VERSION="5.3.0"
DOC_ROOT="/var/www"
INSTALL_LOC="openlog"
APACHE_CONF_DIR="/etc/apache2/conf-available"
BACKUP_DIR="openlog-previous-installation"
LANDING_PAGE="lognotes.php"
CONFIG_TABLE="configs"
CONFIG_NAME_COLUMN="confname"
@@ -22,7 +21,7 @@ CONFIG_DEFAULT_COLUMN=""
function privilege_check() {
# test for superuser rights
if [[ $EUID -ne 0 ]]; then
if [[ "$EUID" != 0 ]]; then
echo "This script must be run with superuser privileges. Try sudo $0"
exit 1
fi
@@ -37,11 +36,11 @@ function get_new_password() {
echo ""
read -p "Re-type new password: " -s -r rnewpw
echo ""
if [ "$newpassword" = "" -o "$rnewpw" = "" ]
if [[ "$newpassword" == "" || "$rnewpw" == "" ]]
then
echo "Password cannot be blank. Please try again."
echo ""
elif [ "$newpassword" != "$rnewpw" ]
elif [[ "$newpassword" != "$rnewpw" ]]
then
echo "Passwords do not match. Please try again."
echo ""
@@ -64,7 +63,7 @@ function install_required_packages() {
gpattern=""
for pkg_option in $(echo $prereq)
do
if [ "$pkg_option" != "or" ]
if [[ "$pkg_option" != "or" ]]
then
gpattern+=" -e $pkg_option"
preferred_pkg=$pkg_option
@@ -77,7 +76,7 @@ function install_required_packages() {
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
echo -n "Install $preferred_pkg now? [Y/n]: "
read reqinstall
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]]
then
echo "$APP_NAME requires $prereq, but you have elected not to install it."
echo "Installation cannot continue."
@@ -173,20 +172,20 @@ echo ""
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
read install_loc_in
echo ""
if [ "$doc_root_in" = "" ]
if [[ "$doc_root_in" == "" ]]
then
doc_root_in=$DOC_ROOT
fi
if [ "$install_loc_in" = "" ]
if [[ "$install_loc_in" == "" ]]
then
install_loc_in=$INSTALL_LOC
fi
install_path="$doc_root_in/$install_loc_in"
if [ -d "$install_path" ]
if [[ -d "$install_path" ]]
then
echo "The installation path you chose already exists."
# Install path exists.
if [ -e "$install_path/db.php" ]
if [[ -e "$install_path/db.php" ]]
then
# A db.php file was found in the install path
if grep -q -e "$APP_NAME" $install_path/db.php
@@ -196,13 +195,47 @@ then
echo "and restart the install using a new installation location."
echo -n "[U]pgrade or [C]ancel? [U] :"
read upgrade_choice
if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen
if [[ "$upgrade_choice" == "C" || "$upgrade_choice" == "c" ]] # Cancel chosen
then
echo "Cancelling installation"
abort_exit
else
# proceed with upgrade
mkdir -p backups
# 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"
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
@@ -219,25 +252,21 @@ then
# back up existing database
echo "Backing up the current database to the package directory."
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > $backupdir/$curr_dbname-$datestamp-backup.sql
# back up existing installation
echo "Backing up current installation to the package directory."
cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
# delete all existing installation files except db.php
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
# delete all existing installation files except db.php and maintenancemode.php
find $install_path/ -mindepth 1 ! \( -name 'db.php' -o -name 'maintenancemode.php' \) -delete
echo "Performing database updates. This may take a while..."
echo "Performing database updates..."
# apply database updates from sql file
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
task_pid=$!
spinner $task_pid
mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1
# apply database updates via script
(bash ./database-update.sh $mysql_opt_file) &
task_pid=$!
spinner $task_pid
bash ./database-update.sh $mysql_opt_file
echo "... finished with database updates."
rm -f $mysql_opt_file
@@ -249,12 +278,12 @@ then
echo "Installing distribution . . ."
cp -R distfiles/* $install_path
# set symlink for jquery-ui
if [ ! -L "$install_path/jquery-ui" ]
if [[ ! -L "$install_path/jquery-ui" ]]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi
# set symlink for index.php
if [ ! -L "$install_path/index.php" ]
if [[ ! -L "$install_path/index.php" ]]
then
ln -s $install_path/$LANDING_PAGE $install_path/index.php
fi
@@ -267,6 +296,19 @@ then
echo ""
echo "Setting file ownership . . ."
chown -R $httpd_user_group $install_path
echo "Backups of the previous openlog files and the previous database were made"
echo "and are located in the $backupdir directory."
# take app out of maintenance mode
echo "Taking the app out of maintenance mode..."
# disable the app
a2disconf -q $install_loc_in
systemctl reload apache2
# modify the apache conf file
sed -i "s|Rewrite|#Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf
# re-enable the app in production mode
a2enconf -q $install_loc_in
systemctl reload apache2
fi
else
# This was a mistake. Exit now to avoid clobbering another app.
@@ -284,11 +326,11 @@ then
echo "Would you like to use this location for a fresh installation or quit and"
echo "investigate further? It's probably safest to quit and investigate."
proceed=""
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
while [[ "$proceed" != "P" && "$proceed" != "p" && "$proceed" != "Q" && "$proceed" != "q" ]]
do
read proceed -p "[P]roceed with new install or [Q]uit? : "
done
if [[ $proceed == "Q" || $proceed == "q" ]]
if [[ "$proceed" == "Q" || "$proceed" == "q" ]]
then
abort_exit
fi
@@ -303,7 +345,7 @@ else
echo "This can be changed later in the application itself."
echo -n "Installation name [$APP_NAME]: "
read new_inst_name
if [ "$new_inst_name" = "" ]
if [[ "$new_inst_name" == "" ]]
then
new_inst_name="$APP_NAME"
fi
@@ -320,7 +362,7 @@ else
echo "distinctive name."
echo -n "database name [$DEFAULT_DB_NAME]: "
read new_db_name
if [ "$new_db_name" = "" ]
if [[ "$new_db_name" == "" ]]
then
new_db_name=$DEFAULT_DB_NAME
fi
@@ -333,7 +375,7 @@ else
echo "This probably means the database already exists."
echo -n "Try again with a different database name? [Y/N]: "
read dbcreatetry
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]]
then
abort_exit
fi
@@ -353,7 +395,7 @@ else
# Set the installation name
export MYSQL_PWD="$db_pass"
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
if [ "$CONFIG_DEFAULT_COLUMN" != "" ]
if [[ "$CONFIG_DEFAULT_COLUMN" != "" ]]
then
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
fi
@@ -362,23 +404,29 @@ else
mkdir $install_path
# Create db.php if it doesn't exist
if [ ! -f "$install_path/db.php" ]
if [[ ! -f "$install_path/db.php" ]]
then
cp db.php.template $install_path/db.php
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
sed -i "s/DBUSER/$db_user/g" $install_path/db.php
sed -i "s/DBPASS/$db_pass/g" $install_path/db.php
sed -i "s/APPNAME/$APP_NAME/g" $install_path/db.php
sed -i "s|DBNAME|$new_db_name|g" $install_path/db.php
sed -i "s|DBUSER|$db_user|g" $install_path/db.php
sed -i "s|DBPASS|$db_pass|g" $install_path/db.php
sed -i "s|APPNAME|$APP_NAME|g" $install_path/db.php
fi
# Create maintenancemode.php if it doesn't exist
if [[ ! -f "$install_path/maintenancemode.php" ]]
then
cp maintenancemode.php $install_path/maintenancemode.php
sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php
fi
# copy distribution to install location
echo "Installing distribution . . ."
cp -R distfiles/* $install_path
if [ ! -L "$install_path/jquery-ui" ]
if [[ ! -L "$install_path/jquery-ui" ]]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi
if [ ! -L "$install_path/index.php" ]
if [[ ! -L "$install_path/index.php" ]]
then
ln -s $install_path/$LANDING_PAGE $install_path/index.php
fi
@@ -401,23 +449,24 @@ echo ""
echo ""
echo "$APP_NAME has been $operation."
base_url=$install_loc_in
if [ "$operation" = "installed" ]
if [[ "$operation" == "upgraded" ]]
then
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
echo "" >> $APACHE_CONF_DIR/$base_url.conf
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
echo "" >> $APACHE_CONF_DIR/$base_url.conf
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
a2enconf -q $base_url
systemctl reload apache2
fi
if [[ "$operation" == "installed" ]]
then
cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf
sed -i "s|_BASEURL_|$base_url|g" $APACHE_CONF_DIR/$base_url.conf
sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$base_url.conf
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
read enconf
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
then
a2enconf $base_url.conf >/dev/null
service apache2 reload
a2enconf -q $base_url.conf >/dev/null
systemctl reload apache2
echo "You can now point a web browser to $base_url on your web server "
echo "to set up and configure $APP_NAME."
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>
";
?>