4 Commits

Author SHA1 Message Date
2bddfba99a Incorporated changes for release 1.3.2 2026-02-24 20:13:13 -05:00
f7b91f4ef0 Incorporated changes for 1.3.1 2026-02-24 20:07:34 -05:00
6e5c6e03e3 Incorporated changes for release 1.3.0 2026-02-24 19:59:54 -05:00
3667c4358f Incorporate changes for 1.2.0 2026-02-24 19:48:08 -05:00
42 changed files with 3327 additions and 1637 deletions

View File

@@ -1,5 +1,5 @@
OpenDRS - Online Discrepancy Reporting System
Copyright (C) 2018 Rod Wright
Copyright (C) 2022 Rod Wright
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,3 +70,56 @@ Changelog
ownership of the installed server directory tree if the http
user and group names were left at the default.
- Updated and tested to support Raspberry Pi 4B hardware.
1.2.0 - 2021-05-05
- Added ability to customize the terminology used for Device,
Period, and Effective/Non-effective to make OpenDRS usable in
a wider range of applications.
1.3.0 - 2022-03-05
- Made several improvements to group functionality. The Writeup Groups
page now displays all groups in a table instead of individually
expandable sections. On the View Writeups and View Open Writeups
pages, if a writeup is a member of only one group, clicking the
icon will take you to the page for that group. If a writeup is
a member of multiple groups, clicking the icon will take you to
the detail page for that writeup where you can view or modify which
groups the writeup is a member of. On the Search page, you can
now choose which group(s) the results should include.
- Made some improvements to the installation process for Raspberry Pi
setup to accomodate the latest version of Raspberry Pi OS.
- If setting up as a Raspberry Pi terminal/server, included the option
to make the terminal a wireless access point if it connects to an
ethernet network.
1.3.1 - 2022-05-11
- Updated installation scripts and instructions to reflect changes in
Raspberry Pi OS Release 2022-04-04.
1.3.2 - 2022-08-08
- Fixed typo in dbadmin.php that prevented adding new When Discovered
items.
- Fixed bug in create.php that prevented the page from working.
- Fixed bug in config.php that prevented banners from being modified.
- Fixed bug where action_by and action_reason were not preselected for
subsequent searches in search.php.
- Fixed bug in about.php and gpl.php that still used old $mts_db
database handle.
- Removed the server session directory option in config.php
Miscellaneous settings. For this to make sense, you'd have to have
shell access to the server and if that's the case, you'd be able
to make the necessary database changes as well.
- Fixed opendrs-initial.sql to make the default banner colors match
the ones in common.php.
- Created changelog.php for use by the "changes" link on the About
page so kiosk terminal users don't get dead-ended in the CHANGELOG
text file with no way to get back to the app.
- Extensive code cleanups/updates in all php files to make application
compatible with php8 and eliminate php warnings in apache2 error
log file.
- For Raspberry Pi:
- Updated server-setup.sh to attempt to install the php-mysqli package
for compatibility with php8.
- Chromium browser will use the printer designated as the local
default if it is selected as such in the Cups printer
configuration.

364
LICENSE
View File

@@ -1,6 +1,3 @@
The following license applies to all OpenDRS code
Copyright (C) 2026 by Rod Wright :
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
@@ -342,364 +339,3 @@ Copyright (C) 2026 by Rod Wright :
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
The following license applies to jquery code :
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery-ui
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code contained within the demos directory.
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/.

115
RPiSetup/ap-setup.sh Normal file
View File

@@ -0,0 +1,115 @@
#!/bin/bash
# ap-setup.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2022 Rod Wright
# SPDX-License-Identifier: GPL-2.0
# Wireless Access Point Raspberry Pi Setup
current_user=`whoami`
if [ "$current_user" != "root" ]
then
echo "You must have root privileges to run this setup."
echo "Try 'sudo ./ap-setup.sh'"
exit 1
fi
echo ""
echo ""
echo "If this terminal connects to a network using ethernet, it can be configured"
echo "as a wireless access point for other terminals. Would you like to configure"
echo -n "this terminal as an access point? [y/N]: "
read wapconf
if [ "$wapconf" = "Y" -o "$wapconf" = "y" ]
then
echo "Configuring as wireless access point."
echo ""
echo "Copying files..."
chmod +x apsetup/usr/local/bin/*
cp apsetup/usr/local/bin/* /usr/local/bin
cp -R apsetup/etc/* /etc
echo ""
wapssidok=0
while [ "$wapssidok" -ne 1 ]
do
echo "This access point will need an SSID. This is what will appear"
echo "as the name of this terminal when other devices connect."
echo -n "Please enter the desired SSID for this access point: "
read wapssid
if [ "$wapssid" = "" ]
then
echo "SSID cannot be blank. Try again."
else
wapssidok=1
fi
done
wappassok=0
while [ "$wappassok" -ne 1 ]
do
echo "You will need to set a passphrase for this access point. It should"
echo "be at least 8 characters in length and cannot be blank."
echo -n "Please enter the desired passphrase for this access point: "
read wappass
wappasslen=`echo -n $wappass | wc -m`
if [ "$wappass" = "" -o "$wappasslen" -lt 8 ]
then
echo "Passphrase doesn't satisfy requirements above. Try again."
else
wappassok=1
fi
done
apt install hostapd
systemctl unmask hostapd
systemctl enable hostapd
echo "[NetDev]" >/etc/systemd/network/bridge-br0.netdev
echo "Name=br0" >>/etc/systemd/network/bridge-br0.netdev
echo "Kind=bridge" >>/etc/systemd/network/bridge-br0.netdev
echo "[Match]" >/etc/systemd/network/br0-member-eth0.network
echo "Name=eth0" >>/etc/systemd/network/br0-member-eth0.network
echo "" >>/etc/systemd/network/br0-member-eth0.network
echo "[Network]" >>/etc/systemd/network/br0-member-eth0.network
echo "Bridge=br0" >>/etc/systemd/network/br0-member-eth0.network
systemctl enable systemd-networkd
mv /etc/dhcpcd.conf /etc/dhcpcd.conf.old
echo "denyinterfaces wlan0 eth0" >/etc/dhcpcd.conf
cat /etc/dhcpcd.conf.old >>/etc/dhcpcd.conf
echo "interface br0" >>/etc/dhcpcd.conf
rfkill unblock wlan
echo "country_code=US" >/etc/hostapd/hostapd.conf
echo "interface=wlan0" >>/etc/hostapd/hostapd.conf
echo "bridge=br0" >>/etc/hostapd/hostapd.conf
echo "ssid=$wapssid" >>/etc/hostapd/hostapd.conf
echo "hw_mode=g" >>/etc/hostapd/hostapd.conf
echo "channel=7" >>/etc/hostapd/hostapd.conf
echo "macaddr_acl=0" >>/etc/hostapd/hostapd.conf
echo "auth_algs=1" >>/etc/hostapd/hostapd.conf
echo "ignore_broadcast_ssid=0" >>/etc/hostapd/hostapd.conf
echo "wpa=2" >>/etc/hostapd/hostapd.conf
echo "wpa_passphrase=$wappass" >>/etc/hostapd/hostapd.conf
echo "wpa_key_mgmt=WPA-PSK" >>/etc/hostapd/hostapd.conf
echo "wpa_pairwise=TKIP" >>/etc/hostapd/hostapd.conf
echo "rsn_pairwise=CCMP" >>/etc/hostapd/hostapd.conf
wget -c http://github.com/pjz/webmin-modules/releases/download/v1.0/hostap.wbm.gz
gzip -d hostap.wbm.gz
/usr/share/webmin/install-module.pl hostap.wbm
echo ""
echo ""
echo "Wireless access point setup is complete. It will be"
echo "automatically enabled after reboot. To change the SSID or"
echo "passphrase in the future, edit the file /etc/hostapd/hostapd.conf"
echo "or use the Host AP module in the Servers section of Webmin."
echo ""
echo "To disable the access point altogether in the future, run:"
echo " sudo wap-disable"
echo "at a command prompt and reboot the terminal. To re-enable it, run:"
echo " sudo wap-enable"
echo "at a command prompt and reboot the terminal."
echo "It can also be enabled or disabled via Custom Commands in the Tools"
echo "section of Webmin."
echo ""
echo -n "Press enter key to continue..."
read cont
else
exit 2
fi

View File

@@ -0,0 +1,3 @@
sudo wap-enable
Enable Wireless Access Point
pi 0 1 0 0 0 0 0 -

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,3 @@
sudo wap-disable
Disable Wireless Access Point
pi 0 1 0 0 0 0 0 -

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,11 @@
/etc/hostapd/hostapd.conf
Edit Wireless Access Point Parameters
systemctl restart hostapd
0
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,8 @@
display_mode=1
params_file=0
params_cmd=0
columns=1
height=
wrap=
width=
sort=

View File

@@ -0,0 +1,4 @@
#!/bin/bash
systemctl stop hostapd
systemctl disable hostapd

View File

@@ -0,0 +1,4 @@
#!/bin/bash
systemctl enable hostapd
systemctl start hostapd

View File

@@ -0,0 +1,16 @@
#!/bin/bash
newppok=0
while [ "$newppok" -ne 1 ]
do
echo -n "New passphrase: "
read newpp
newpplen=`echo -n $newpp | wc -m`
if [ "$newpp" = "" -o "$newpplen" -lt 8 ]
then
echo "Passphrase didn't satisfy requirements. Try again or hit <ctrl>-c to abort."
else
newppok=1
fi
done
sed -i "/wpa_passphrase=.*/c wpa_passphrase=$newpp" /etc/hostapd/hostapd.conf
systemctl restart hostapd

View File

@@ -0,0 +1,15 @@
#!/bin/bash
newssidok=0
while [ "$newssidok" -ne 1 ]
do
echo -n "New SSID: "
read newssid
if [ "$newssid" = "" ]
then
echo "SSID cannot be blank. Try again or hit <ctrl>-c to abort."
else
newssidok=1
fi
done
sed -i "/ssid=.*/c ssid=$newssid" /etc/hostapd/hostapd.conf
systemctl restart hostapd

View File

@@ -1,2 +1,25 @@
# drs.conf
# URL for OpenDRS
DRS_SERVER="http://localhost"
# Set to "1" to prevent screen blanking on some monitors that go to sleep and won't wake up.
INHIBIT_BLANK="0"
# For standard DRS functionality
APP_CMD="chromium-browser --test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito $DRS_SERVER"
ALIVE_STRING="chromium-browse"
KILL_CMD="killall chromium-browser"
CLEANUP_CMD="rm -rf ~/.{config,cache}/chromium/"
# Notes
# --test-type will ignore any warnings and
# --ignore-certificate-errors will allow you to kiosk any https-page without displaying certificate errors
#-----------------------------------------------------------------------
# For test use
#APP_CMD="xterm"
#ALIVE_STRING="xterm"
#KILL_CMD="killall xterm"
#CLEANUP_CMD="sleep 1"

View File

@@ -0,0 +1,695 @@
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc"
xmlns:xi="http://www.w3.org/2001/XInclude">
<resistance>
<strength>10</strength>
<screen_edge_strength>20</screen_edge_strength>
</resistance>
<focus>
<focusNew>yes</focusNew>
<!-- always try to focus new windows when they appear. other rules do
apply -->
<followMouse>no</followMouse>
<!-- move focus to a window when you move the mouse into it -->
<focusLast>yes</focusLast>
<!-- focus the last used window when changing desktops, instead of the one
under the mouse pointer. when followMouse is enabled -->
<underMouse>no</underMouse>
<!-- move focus under the mouse, even when the mouse is not moving -->
<focusDelay>200</focusDelay>
<!-- when followMouse is enabled, the mouse must be inside the window for
this many milliseconds (1000 = 1 sec) before moving focus to it -->
<raiseOnFocus>no</raiseOnFocus>
<!-- when followMouse is enabled, and a window is given focus by moving the
mouse into it, also raise the window -->
</focus>
<placement>
<policy>Smart</policy>
<!-- 'Smart' or 'UnderMouse' -->
<center>yes</center>
<!-- whether to place windows in the center of the free area found or
the top left corner -->
<monitor>Primary</monitor>
<!-- with Smart placement on a multi-monitor system, try to place new windows
on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
the active window is, 'Primary' - only on the primary monitor -->
<primaryMonitor>1</primaryMonitor>
<!-- The monitor where Openbox should place popup dialogs such as the
focus cycling popup, or the desktop switch popup. It can be an index
from 1, specifying a particular monitor. Or it can be one of the
following: 'Mouse' - where the mouse is, or
'Active' - where the active window is -->
</placement>
<theme>
<name>Clearlooks</name>
<titleLayout>NLIMC</titleLayout>
<!--
available characters are NDSLIMC, each can occur at most once.
N: window icon
L: window label (AKA title).
I: iconify
M: maximize
C: close
S: shade (roll up/down)
D: omnipresent (on all desktops).
-->
<keepBorder>yes</keepBorder>
<animateIconify>yes</animateIconify>
<font place="ActiveWindow">
<name>sans</name>
<size>8</size>
<!-- font size in points -->
<weight>bold</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
<font place="InactiveWindow">
<name>sans</name>
<size>8</size>
<!-- font size in points -->
<weight>bold</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
<font place="MenuHeader">
<name>sans</name>
<size>9</size>
<!-- font size in points -->
<weight>normal</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
<font place="MenuItem">
<name>sans</name>
<size>9</size>
<!-- font size in points -->
<weight>normal</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
<font place="ActiveOnScreenDisplay">
<name>sans</name>
<size>9</size>
<!-- font size in points -->
<weight>bold</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
<font place="InactiveOnScreenDisplay">
<name>sans</name>
<size>9</size>
<!-- font size in points -->
<weight>bold</weight>
<!-- 'bold' or 'normal' -->
<slant>normal</slant>
<!-- 'italic' or 'normal' -->
</font>
</theme>
<desktops>
<!-- this stuff is only used at startup, pagers allow you to change them
during a session
these are default values to use when other ones are not already set
by other applications, or saved in your session
use obconf if you want to change these without having to log out
and back in -->
<number>1</number>
<firstdesk>1</firstdesk>
<names>
<!-- set names up here if you want to, like this:
<name>desktop 1</name>
<name>desktop 2</name>
-->
</names>
<popupTime>875</popupTime>
<!-- The number of milliseconds to show the popup for when switching
desktops. Set this to 0 to disable the popup. -->
</desktops>
<resize>
<drawContents>yes</drawContents>
<popupShow>Nonpixel</popupShow>
<!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
<popupPosition>Center</popupPosition>
<!-- 'Center', 'Top', or 'Fixed' -->
<popupFixedPosition>
<!-- these are used if popupPosition is set to 'Fixed' -->
<x>10</x>
<!-- positive number for distance from left edge, negative number for
distance from right edge, or 'Center' -->
<y>10</y>
<!-- positive number for distance from top edge, negative number for
distance from bottom edge, or 'Center' -->
</popupFixedPosition>
</resize>
<!-- You can reserve a portion of your screen where windows will not cover when
they are maximized, or when they are initially placed.
Many programs reserve space automatically, but you can use this in other
cases. -->
<margins>
<top>0</top>
<bottom>0</bottom>
<left>0</left>
<right>0</right>
</margins>
<dock>
<position>TopLeft</position>
<!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
<floatingX>0</floatingX>
<floatingY>0</floatingY>
<noStrut>no</noStrut>
<stacking>Above</stacking>
<!-- 'Above', 'Normal', or 'Below' -->
<direction>Vertical</direction>
<!-- 'Vertical' or 'Horizontal' -->
<autoHide>no</autoHide>
<hideDelay>300</hideDelay>
<!-- in milliseconds (1000 = 1 second) -->
<showDelay>300</showDelay>
<!-- in milliseconds (1000 = 1 second) -->
<moveButton>Middle</moveButton>
<!-- 'Left', 'Middle', 'Right' -->
</dock>
<keyboard>
<!-- Chromium disable opening new window -->
<keybind key="C-n">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening new incognito window -->
<keybind key="C-S-n">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening new tab -->
<keybind key="C-t">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening home page -->
<keybind key="A-Home">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable back -->
<keybind key="A-Left">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable forward -->
<keybind key="A-Right">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening bookmark manager -->
<keybind key="C-S-o">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening history page -->
<keybind key="C-h">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening downloads page -->
<keybind key="C-j">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening task manager -->
<keybind key="S-Escape">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening help center -->
<keybind key="F1">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable saving current page -->
<keybind key="C-s">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable opening local file -->
<keybind key="C-o">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable display source -->
<keybind key="C-u">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable saving bookmark-->
<keybind key="C-d">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Chromium disable saving multi bookmarks -->
<keybind key="C-S-d">
<action name="Execute">
<command>true</command>
</action>
</keybind>
<!-- Enable rebooting with ctrl-alt-shift-del -->
<keybind key="C-A-S-Delete">
<action name="Execute">
<command>shutdown -P now</command>
</action>
</keybind>
<chainQuitKey>C-g</chainQuitKey>
</keyboard>
<mouse>
<dragThreshold>1</dragThreshold>
<!-- number of pixels the mouse must move before a drag begins -->
<doubleClickTime>500</doubleClickTime>
<!-- in milliseconds (1000 = 1 second) -->
<screenEdgeWarpTime>400</screenEdgeWarpTime>
<!-- Time before changing desktops when the pointer touches the edge of the
screen while moving a window, in milliseconds (1000 = 1 second).
Set this to 0 to disable warping -->
<screenEdgeWarpMouse>false</screenEdgeWarpMouse>
<!-- Set this to TRUE to move the mouse pointer across the desktop when
switching due to hitting the edge of the screen -->
<context name="Frame">
<mousebind button="A-Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="A-Left" action="Click">
<action name="Unshade"/>
</mousebind>
<mousebind button="A-Left" action="Drag">
<action name="Move"/>
</mousebind>
<mousebind button="A-Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="A-Right" action="Drag">
<action name="Resize"/>
</mousebind>
<mousebind button="A-Middle" action="Press">
<action name="Lower"/>
<action name="FocusToBottom"/>
<action name="Unfocus"/>
</mousebind>
<mousebind button="A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="C-A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="C-A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="A-S-Up" action="Click">
<action name="SendToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="A-S-Down" action="Click">
<action name="SendToDesktop"><to>next</to></action>
</mousebind>
</context>
<context name="Titlebar">
<mousebind button="Left" action="Drag">
<action name="Move"/>
</mousebind>
<mousebind button="Left" action="DoubleClick">
<action name="ToggleMaximize"/>
</mousebind>
<mousebind button="Up" action="Click">
<action name="if">
<shaded>no</shaded>
<then>
<action name="Shade"/>
<action name="FocusToBottom"/>
<action name="Unfocus"/>
<action name="Lower"/>
</then>
</action>
</mousebind>
<mousebind button="Down" action="Click">
<action name="if">
<shaded>yes</shaded>
<then>
<action name="Unshade"/>
<action name="Raise"/>
</then>
</action>
</mousebind>
</context>
<context name="Titlebar Top Right Bottom Left TLCorner TRCorner BRCorner BLCorner">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Middle" action="Press">
<action name="Lower"/>
<action name="FocusToBottom"/>
<action name="Unfocus"/>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="ShowMenu"><menu>client-menu</menu></action>
</mousebind>
</context>
<context name="Top">
<mousebind button="Left" action="Drag">
<action name="Resize"><edge>top</edge></action>
</mousebind>
</context>
<context name="Left">
<mousebind button="Left" action="Drag">
<action name="Resize"><edge>left</edge></action>
</mousebind>
</context>
<context name="Right">
<mousebind button="Left" action="Drag">
<action name="Resize"><edge>right</edge></action>
</mousebind>
</context>
<context name="Bottom">
<mousebind button="Left" action="Drag">
<action name="Resize"><edge>bottom</edge></action>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="ShowMenu"><menu>client-menu</menu></action>
</mousebind>
</context>
<context name="TRCorner BRCorner TLCorner BLCorner">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Left" action="Drag">
<action name="Resize"/>
</mousebind>
</context>
<context name="Client">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Middle" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
</context>
<context name="Icon">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
<action name="ShowMenu"><menu>client-menu</menu></action>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="ShowMenu"><menu>client-menu</menu></action>
</mousebind>
</context>
<context name="AllDesktops">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Left" action="Click">
<action name="ToggleOmnipresent"/>
</mousebind>
</context>
<context name="Shade">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Left" action="Click">
<action name="ToggleShade"/>
</mousebind>
</context>
<context name="Iconify">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Left" action="Click">
<action name="Iconify"/>
</mousebind>
</context>
<context name="Maximize">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Middle" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Left" action="Click">
<action name="ToggleMaximize"/>
</mousebind>
<mousebind button="Middle" action="Click">
<action name="ToggleMaximize"><direction>vertical</direction></action>
</mousebind>
<mousebind button="Right" action="Click">
<action name="ToggleMaximize"><direction>horizontal</direction></action>
</mousebind>
</context>
<context name="Close">
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
<action name="Unshade"/>
</mousebind>
<mousebind button="Left" action="Click">
<action name="Close"/>
</mousebind>
</context>
<context name="Desktop">
<mousebind button="Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="C-A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="C-A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="Left" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Right" action="Press">
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
</context>
<context name="Root">
<!-- Menus -->
</context>
<context name="MoveResize">
<mousebind button="Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
<mousebind button="A-Up" action="Click">
<action name="GoToDesktop"><to>previous</to></action>
</mousebind>
<mousebind button="A-Down" action="Click">
<action name="GoToDesktop"><to>next</to></action>
</mousebind>
</context>
</mouse>
<menu>
</menu>
<applications>
<!--
# this is an example with comments through out. use these to make your
# own rules, but without the comments of course.
# you may use one or more of the name/class/role/title/type rules to specify
# windows to match
<application name="the window's _OB_APP_NAME property (see obxprop)"
class="the window's _OB_APP_CLASS property (see obxprop)"
groupname="the window's _OB_APP_GROUP_NAME property (see obxprop)"
groupclass="the window's _OB_APP_GROUP_CLASS property (see obxprop)"
role="the window's _OB_APP_ROLE property (see obxprop)"
title="the window's _OB_APP_TITLE property (see obxprop)"
type="the window's _OB_APP_TYPE property (see obxprob)..
(if unspecified, then it is 'dialog' for child windows)">
# you may set only one of name/class/role/title/type, or you may use more
# than one together to restrict your matches.
# the name, class, role, and title use simple wildcard matching such as those
# used by a shell. you can use * to match any characters and ? to match
# any single character.
# the type is one of: normal, dialog, splash, utility, menu, toolbar, dock,
# or desktop
# when multiple rules match a window, they will all be applied, in the
# order that they appear in this list
# each rule element can be left out or set to 'default' to specify to not
# change that attribute of the window
<decor>yes</decor>
# enable or disable window decorations
<shade>no</shade>
# make the window shaded when it appears, or not
<position force="no">
# the position is only used if both an x and y coordinate are provided
# (and not set to 'default')
# when force is "yes", then the window will be placed here even if it
# says you want it placed elsewhere. this is to override buggy
# applications who refuse to behave
<x>center</x>
# a number like 50, or 'center' to center on screen. use a negative number
# to start from the right (or bottom for <y>), ie -50 is 50 pixels from
# the right edge (or bottom). use 'default' to specify using value
# provided by the application, or chosen by openbox, instead.
<y>200</y>
<monitor>1</monitor>
# specifies the monitor in a xinerama setup.
# 1 is the first head, or 'mouse' for wherever the mouse is
</position>
<size>
# the size to make the window.
<width>20</width>
# a number like 20, or 'default' to use the size given by the application.
# you can use fractions such as 1/2 or percentages such as 75% in which
# case the value is relative to the size of the monitor that the window
# appears on.
<height>30%</height>
</size>
<focus>yes</focus>
# if the window should try be given focus when it appears. if this is set
# to yes it doesn't guarantee the window will be given focus. some
# restrictions may apply, but Openbox will try to
<desktop>1</desktop>
# 1 is the first desktop, 'all' for all desktops
<layer>normal</layer>
# 'above', 'normal', or 'below'
<iconic>no</iconic>
# make the window iconified when it appears, or not
<skip_pager>no</skip_pager>
# asks to not be shown in pagers
<skip_taskbar>no</skip_taskbar>
# asks to not be shown in taskbars. window cycling actions will also
# skip past such windows
<fullscreen>yes</fullscreen>
# make the window in fullscreen mode when it appears
<maximized>true</maximized>
# 'Horizontal', 'Vertical' or boolean (yes/no)
</application>
# end of the example
-->
</applications>
</openbox_config>

View File

@@ -0,0 +1,23 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
/usr/bin/startx /etc/X11/Xsession /usr/local/bin/startdrs.sh -- :0

View File

@@ -2,7 +2,7 @@
# server-setup.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2021 Rod Wright
# Copyright (C) 2022 Rod Wright
# SPDX-License-Identifier: GPL-2.0
@@ -11,6 +11,13 @@ docroot_path="/var/www"
apache_user="www-data"
apache_group="www-data"
current_user=`whoami`
if [ "$current_user" != "root" ]
then
echo "You must have root privileges to run this setup."
echo "Try 'sudo ./server-setup.sh'"
exit 1
fi
echo ""
echo ""
echo ""
@@ -20,7 +27,7 @@ echo ""
echo ""
echo "You should have already run the terminal-setup.sh script in this directory."
echo ""
if [ ! -e "/etc/drs.conf" ]
if [ ! -e /etc/drs.conf ]
then
echo "It looks like the terminal-setup.sh script has not been run yet."
echo "This is required before running the server-setup.sh script."
@@ -50,23 +57,40 @@ echo ""
echo "IMPORTANT!: Be sure to make note of usernames and passwords you provide below."
echo "You will need them later."
echo ""
echo "Installing required server packages. Select apache2 as the web server to configure"
echo "automatically. Choose Yes when prompted to install phpmyadmin database and allow it to"
echo "Installing required server packages. You will be prompted about a couple of things:"
echo ""
echo "- Select apache2 as the web server to configure automatically."
echo ""
echo "- Choose Yes when prompted to install phpmyadmin database and allow it to"
echo " generate a random password(leave the field blank)."
echo ""
echo -n "Press enter to continue."
read continueok
echo ""
echo ""
echo ""
echo ""
apt install -y apache2 php php-mcrypt mariadb-server phpmyadmin uuid-runtime
apt install -y apache2 php mariadb-server phpmyadmin uuid-runtime
apt install -y php-mysqli
cp etc/apache2/mods-available/alias.conf /etc/apache2/mods-available
service apache2 restart
echo "...done."
echo ""
echo ""
echo "Configuring the mysql installation. Accept the defaults at the following prompts."
echo "Remember the password you set here. You'll need it during the OpenDRS install."
echo "Configuring the MariaDB installation. There will be some more prompts:"
echo ""
echo "- You'll be prompted for the current password for the root user. You've"
echo " just installed MariaDB and you haven't set one yet, so just press enter."
echo ""
echo "- You'll be prompted to switch to unix_socket authentication. Answer Y."
echo ""
echo "- You'll be prompted to change the root password. Answer Y and enter a password."
echo " Note that this is just the password for the MariaDB root user, not the terminal."
echo " DO NOT FORGET THIS PASSWORD. You'll need it later during OpenDRS install."
echo ""
echo "- Answer Y to remove anonymous users, disallow root login remotely, remove"
echo " test database and access, and reload privilege tables."
echo ""
echo -n "Press enter to proceed."
read continueok
echo ""
@@ -74,7 +98,6 @@ echo ""
echo ""
echo ""
mysql_secure_installation
mysql mysql -e "update user set plugin='';flush privileges;"
echo ""
echo ""
@@ -85,9 +108,13 @@ bad_mysql_adm=1
while [ $bad_mysql_adm -eq 1 ]
do
admintestdb="drsadm`date +%Y%m%d`"
echo "Starting OpenDRS installation."
echo ""
echo "We need to know the username and password of a MySQL administrator"
echo "to be able to create the database and user for OpenDRS. Note that this"
echo "is not necessarily the same as the login and password for the computer."
echo "to be able to create the database and user for OpenDRS. The username"
echo "will be root and the password will be the one you were urged to remember"
echo "a minute ago."
echo ""
echo -n "MySQL admin username: "
read mysql_adm_user
echo ""
@@ -100,7 +127,7 @@ do
bad_mysql_adm=0
else
echo "ERROR: Either the username/password you supplied were incorrect or the user"
echo -n "is not a MySQL administrator. Try again? [Y/N]: "
echo -n "is not a MySQL administrator. Try again? [y/N]: "
read admtry
if [ "$admtry" != "Y" -o "$admtry" != "y" ]
then
@@ -208,6 +235,10 @@ fi
echo "Installing distribution . . ."
cp -Rv ../distfiles/* $install_path
ln -s $install_path/writeups.php $install_path/index.php
if [ ! -L "$install_path/jquery-ui" ]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi
echo ""
echo ""
echo ""
@@ -222,9 +253,11 @@ echo "Enter the user and group separated by a colon (username:groupname)."
echo "Enter the user:group of the OpenDRS installation"
echo -n "directory [$apache_user:$apache_group] :"
read httpd_user_group_in
if [ "$http_user_group_in" != "" ]
if [ "$httpd_user_group_in" != "" ]
then
http_user_group=$http_user_group_in
httpd_user_group="$httpd_user_group_in"
else
httpd_user_group="$apache_user:$apache_group"
fi
echo ""
echo "Setting file ownership . . ."
@@ -246,6 +279,26 @@ echo "<Directory $install_path>" >> /etc/apache2/conf-available/$inst_name.conf
echo " Options FollowSymLinks" >> /etc/apache2/conf-available/$inst_name.conf
echo " DirectoryIndex index.php" >> /etc/apache2/conf-available/$inst_name.conf
echo "</Directory>" >> /etc/apache2/conf-available/$inst_name.conf
grep -q "<title>Apache2 Debian Default Page: It works</title>" /var/www/html/index.html
if [ -$? -eq 0 ]
then
echo "This apache installation appears to be new or unconfigured. Replacing the default"
echo "site index page with a more useful one."
site_hostname=`hostname`
mv /var/www/html/index.html /var/www/html/defaultindex.html
echo "<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>$site_hostname</title>
</head>
<body>
<p>
<a href=\"http://$site_hostname/$inst_name/\">$inst_name</a>
</p>
</body>
</html>" > /var/www/html/index.html
fi
a2enconf $inst_name
service apache2 reload
@@ -265,4 +318,4 @@ echo "REMEMBER THESE CREDENTIALS. Otherwise, you will not be able to log in and"
echo "configure your new installation."
echo "It is highly recommended that you change the initial password to something"
echo "secure after logging in for the first time."
echo "DRS_SERVER=\"http://localhost/$inst_name\"" > /etc/drs.conf
sed -i 's,'DRS_SERVER=.*','DRS_SERVER="\"http://localhost/$inst_name/\""',' /etc/drs.conf

View File

@@ -2,10 +2,18 @@
# terminal-setup.sh
# OpenDRS Online Maintenance Tracking System
# Copyright (C) 2021 Rod Wright
# Copyright (C) 2022 Rod Wright
# SPDX-License-Identifier: GPL-2.0
current_user=`whoami`
current_login=`who am i | awk '{print $1}'`
if [ "$current_user" != "root" ]
then
echo "You must have root privileges to run this setup."
echo "Try 'sudo ./terminal-setup.sh'"
exit 1
fi
echo ""
echo ""
echo ""
@@ -16,20 +24,30 @@ echo ""
echo "You should have already completed the following steps:"
echo ""
echo "1. Created a Raspberry Pi OS Lite SD card from the latest release."
echo "2. Installed the card in a Raspberry Pi, booted it, and logged in as pi."
echo ""
echo "2. Installed the card in a Raspberry Pi, booted it, and completed"
echo " initial configuration."
echo ""
echo "3. Ran sudo raspi-config and :"
echo " a. Set a strong password for the pi user."
echo " b. Set hostname and, if accessing a network through wifi, the SSID and"
echo " passphrase under Network Options."
echo " c. Set locale, timezone, keyboard layout, and wifi country under"
echo " a. Set locale, timezone, and WLAN Country under"
echo " Localisation Options. "
echo " d. Enable SSH under Interfacing Options."
echo " e. Set overscan as required to get rid of any black borders around the"
echo " edge of the display."
echo " f. Reboot when prompted and logged back in as pi."
echo "4. Transferred the OpenDRS distribution package to /home/pi on the"
echo ""
echo " b. Set hostname and Boot / Auto Login to Console under System Options."
echo ""
echo " c. If accessing a network through wifi, the Wireless LAN SSID"
echo " and passphrase under System Options."
echo ""
echo " d. Enable SSH under Interface Options."
echo ""
echo " e. Set underscan as required under Display Options to get rid of any"
echo " black borders around the edge of the display."
echo ""
echo " f. Reboot when prompted and logged back in as $current_login."
echo ""
echo "4. Transferred the OpenDRS distribution package to /home/$current_login on the"
echo " Raspberry Pi and extracted it."
echo "5. Changed directory to RPiSetup in the the extracted distribution directory."
echo "5. Changed directory to RPiSetup in the extracted distribution directory."
echo ""
echo ""
echo "If you have completed these steps, press enter to continue. If not,"
echo -n "press ctrl-c to quit."
@@ -56,6 +74,7 @@ echo ""
echo "Copying files..."
chmod +x usr/local/bin/*
cp usr/local/bin/* /usr/local/bin
cp etc/drs.conf /etc
cp etc/apt/sources.list.d/* /etc/apt/sources.list.d
cp lib/systemd/system/getty@tty1.service /lib/systemd/system
echo ""
@@ -72,14 +91,17 @@ echo ""
echo ""
echo ""
echo ""
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
echo "deb https://download.webmin.com/download/repository sarge contrib" >/etc/apt/sources.list.d/webmin.list
wget https://download.webmin.com/jcameron-key.asc
cat jcameron-key.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/jcameron-key.gpg
rm jcameron-key.asc
apt install apt-transport-https
apt update
apt install -y --no-install-recommends xorg openbox chromium-browser
apt install -y webmin cups libcups2-dev cmake
apt install -y cups libcups2-dev cmake
apt install -y webmin
addgroup lpadmin
usermod -a -G lpadmin pi
usermod -a -G lpadmin $current_login
systemctl enable getty@tty1.service
service cups-browsed stop
systemctl disable cups-browsed.service
@@ -101,14 +123,13 @@ echo "of your choosing."
echo -n "Press enter to continue."
read continueok
echo ""
echo ""
echo "Creating customer user..."
sleep 10
echo ""
echo ""
echo ""
echo ""
cloneuser `who am i | awk '{print $1}'` customer
cloneuser $current_login customer
mkdir -p /home/customer/.config/openbox
cp home/customer/.profile /home/customer
cp home/customer/.config/openbox/rc.xml /home/customer/.config/openbox
@@ -127,24 +148,50 @@ read server_url
if [[ $server_url == "" ]]
then
conftype="Server/Terminal"
touch /etc/drs.conf
./server-setup.sh
else
conftype="Terminal"
echo "DRS_SERVER=\"$server_url\"" > /etc/drs.conf
sed -i 's,'DRS_SERVER=.*','DRS_SERVER="\"$server_url\""',' /etc/drs.conf
fi
echo ""
echo ""
./ap-setup.sh
if [ $? -ne 0 ]
then
echo "If you would like to configure this terminal as an access point at some"
echo "time in the future, log in, change directory to the"
echo "extracted distribution's RPiSetup directory, and run:"
echo " sudo ./ap-setup.sh"
fi
echo ""
echo ""
echo "$conftype configuration is now complete. "
echo ""
echo ""
echo "It is highly recommended that after rebooting, you run ssh pi@$HOSTNAME"
echo "It is highly recommended that after rebooting, you run ssh $current_login@$HOSTNAME"
echo "from another computer on the network, then create new users for"
echo "yourself and any other administrators using the cloneuser command"
echo "(cloneuser pi <new username>)."
echo "any other administrators using the cloneuser command"
echo "(cloneuser $current_login <new username>)."
echo ""
echo ""
echo "Setup complete."
echo -n "Press enter to reboot now."
echo "Terminal setup complete."
echo ""
if [ "$conftype" = "Terminal" ]
then
echo "If you would like to use this terminal as a DRS server, after rebooting"
echo "and logging back in, change directory to the extracted distribution's"
echo "RPiSetup directory, and run:"
echo " sudo ./server-setup.sh"
echo ""
fi
echo ""
echo "A reboot is required to start using this terminal."
echo -n "Would you like to reboot now? [Y/n]: "
read rebootok
if [ "$rebootok" = "N" -o "$rebootok" = "n" ]
then
exit 0
else
reboot
fi

View File

@@ -1,32 +1,37 @@
#!/bin/bash
# startdrs.sh
source /etc/drs.conf
openbox-session &
if [ "$INHIBIT_BLANK" -eq "1" ]
then
xset s off
xset -dpms
else
xset s off
xset +dpms
xset dpms 0 600 1800
fi
while true
do
killall chromium-browser
rm -rf ~/.{config,cache}/chromium/
$KILL_CMD
$CLEANUP_CMD
# start browser to DRS Server
# --test-type will ignore any warnings and
# --ignore-certificate-errors will allow you to kiosk any https-page without displaying certificate errors
chromium-browser --test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito $DRS_SERVER &
# start application
$APP_CMD &
sleep 10
while true
do
pgrep chromium-browse
pgrep $ALIVE_STRING
if [ "$?" -eq "1" ]
then
# relaunch browser if it terminates
chromium-browser --test-type --ignore-certificate-errors --kiosk --no-first-run --check-for-update-interval=1 --simulate-upgrade --incognito $DRS_SERVER &
# relaunch application if it terminates
$APP_CMD &
fi
sleep 1
done

View File

@@ -2,42 +2,37 @@ Raspberry Pi setup
1. Create Raspberry Pi OS Lite SD card from the most recent stable release.
2. Insert SD card in Raspberry Pi and boot.
2. Insert SD card in Raspberry Pi, boot it, and complete initial config.
3. Login as pi.
3. run sudo raspi-config and:
4. sudo raspi-config and:
a. Set a strong password for the default user (pi).
b. Set the desired hostname.
c. Set Wireless LAN SSID and passphrase if using WiFi for networking.
c. Use Localisation Options to:
a. Use Localisation Options to:
1. Set locale to en_US.UTF-8 UTF-8.
2. Set timezone.
3. Set keyboard layout (IMPORTANT! Raspberry Pi OS is made in
England, so unless that's the kind of keyboard you have, the
default layout will make your symbols come out wrong!).
4. Set WLAN country.
3. Set WLAN country.
d. Use Interfacing Options to enable SSH server.
b. Use System Options to:
1. Set the hostname.
2. Set Boot / Auto Login to Console.
3. If accessing the network through WiFi, set the Wireless LAN
SSID and passphrase.
e. If you have black borders on the sides of the screen, use Display
Underscan option to change Overscan compensation.
c. Under Interface Options, enable SSH.
f. When you've finished, tab down to highlight Finish and hit enter.
d. Under Display Options, set underscan as required to get rid of
black screen borders.
g. Reboot when prompted.
e. When you've finished, tab down to highlight Finish and hit enter.
h. Log back in as pi using the password you set in a. above.
f. Reboot when prompted.
5. Copy OpenDRS distribution package to /home/pi on the Raspberry Pi and extract.
g. Log back in as the user you created during initial configuration.
6. Change directory to the extracted distribution.
4. Copy OpenDRS distribution package to the Raspberry Pi and extract.
7. Change directory to RPiSetup.
5. Change directory to the extracted distribution.
8. run sudo ./terminal-setup.sh
6. Change directory to RPiSetup.
7. run sudo ./terminal-setup.sh

11
TODO.txt Normal file
View File

@@ -0,0 +1,11 @@
TODO
- Add ability to save/restore configuration.
- Add ability to backup/restore writeups.
- Add a $border_visible debug variable to the end of settings.php and
use it wherever there's a "border=\"0\"" to be able to see and fix
table layout issues.
- Automate installation on servers running Nginx as well as Apache.

View File

@@ -2,12 +2,17 @@
/*
boilerplate.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
@@ -18,41 +23,51 @@ if ($_REQUEST['cancel']) {
}
// import session variables
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming
// form as "all_parameters" so we need to load those into $incoming[]
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
// copy $_REQUEST to $incoming
// copy $_REQUEST[] to $incoming[]
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
// define local functions
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
*
*/
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
$sbcolor=P_SIDEBAR_COLOR;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($drs_db,"users","id","role",$userid);
// define local functions
framework("begin","$appname","Boilerplate Page",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********

View File

@@ -3,7 +3,7 @@
/*
db.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -1,5 +1,5 @@
OpenDRS - Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,3 +70,56 @@ Changelog
ownership of the installed server directory tree if the http
user and group names were left at the default.
- Updated and tested to support Raspberry Pi 4B hardware.
1.2.0 - 2021-05-05
- Added ability to customize the terminology used for Device,
Period, and Effective/Non-effective to make OpenDRS usable in
a wider range of applications.
1.3.0 - 2022-03-05
- Made several improvements to group functionality. The Writeup Groups
page now displays all groups in a table instead of individually
expandable sections. On the View Writeups and View Open Writeups
pages, if a writeup is a member of only one group, clicking the
icon will take you to the page for that group. If a writeup is
a member of multiple groups, clicking the icon will take you to
the detail page for that writeup where you can view or modify which
groups the writeup is a member of. On the Search page, you can
now choose which group(s) the results should include.
- Made some improvements to the installation process for Raspberry Pi
setup to accomodate the latest version of Raspberry Pi OS.
- If setting up as a Raspberry Pi terminal/server, included the option
to make the terminal a wireless access point if it connects to an
ethernet network.
1.3.1 - 2022-05-11
- Updated installation scripts and instructions to reflect changes in
Raspberry Pi OS Release 2022-04-04.
1.3.2 - 2022-08-08
- Fixed typo in dbadmin.php that prevented adding new When Discovered
items.
- Fixed bug in create.php that prevented the page from working.
- Fixed bug in config.php that prevented banners from being modified.
- Fixed bug where action_by and action_reason were not preselected for
subsequent searches in search.php.
- Fixed bug in about.php and gpl.php that still used old $mts_db
database handle.
- Removed the server session directory option in config.php
Miscellaneous settings. For this to make sense, you'd have to have
shell access to the server and if that's the case, you'd be able
to make the necessary database changes as well.
- Fixed opendrs-initial.sql to make the default banner colors match
the ones in common.php.
- Created changelog.php for use by the "changes" link on the About
page so kiosk terminal users don't get dead-ended in the CHANGELOG
text file with no way to get back to the app.
- Extensive code cleanups/updates in all php files to make application
compatible with php8 and eliminate php warnings in apache2 error
log file.
- For Raspberry Pi:
- Updated server-setup.sh to attempt to install the php-mysqli package
for compatibility with php8.
- Chromium browser will use the printer designated as the local
default if it is selected as such in the Cups printer
configuration.

View File

@@ -2,15 +2,20 @@
/*
about.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
@@ -21,7 +26,6 @@ if ($_REQUEST['cancel']) {
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming
@@ -31,7 +35,7 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
// extract incoming array keys into variables
// define local functions
@@ -42,18 +46,18 @@ $appname=APP_NAME;
$drs_version=DRS_VERSION;
if ($print=="Printer Friendly") {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($mts_db,"users","id","role",$userid);
$role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","About OpenDRS",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -76,14 +80,14 @@ echo "
OpenDRS $drs_version Discrepancy Reporting System
</h3><br>
<p>This program is licensed under the terms of the <a href=\"gpl.php\">GNU General Public License</a>. Click on the link
or see the LICENSE file in the distribution to read it. OpenDRS is Copyright (C) 2018 by Rod Wright.
or see the LICENSE file in the distribution to read it. OpenDRS is Copyright (C) 2022 by Rod Wright.
</p>
<p>
OpenDRS is a simple online maintenance tracking/discrepancy reporting application. It allows anyone with a web browser to create ,
view, and search writeups. The look and feel of the OpenDRS pages are easily changed.
Settings that affect all users can be changed in the Admin Functions menu. User specific settings can be changed in the
My Profile menu. No browser specific HTML is used in OpenDRS, so it should be useable in any browser, and it has been
tested using Google Chrome, Mozilla Firefox and Microsoft Internet Explorer.
tested using Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, and Microsoft Edge.
</p>
<p>
OpenDRS is highly flexible. Instructions are included in the distribution for creating a user terminal with a Raspberry Pi. OpenDRS can be hosted on a
@@ -91,7 +95,7 @@ centralized server, accessed by networked PCs and/or Raspberry Pi terminals. It
terminal as a non-networked standalone system or in a small network of Raspberry Pi terminals.
</p>
<p>
To read about the <a href=\"CHANGELOG\" >changes</a> in this latest version of OpenDRS, click on the link or see the CHANGELOG file in the distribution.
To read about the <a href=\"changelog.php\" >changes</a> in this latest version of OpenDRS, click on the link or see the CHANGELOG file in the distribution.
</p>
<p>Several pieces of Open Source software make OpenDRS possible.

92
distfiles/changelog.php Normal file
View File

@@ -0,0 +1,92 @@
<?php
/*
changelog.php
OpenMTS Online Maintenance Tracking System
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to search.php on cancel button press
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:search.php");
exit();
}
// import session variables
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
// import incoming arrays
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
// copy $_REQUEST to $incoming
$incoming=arrayCopy($_REQUEST);
}
// extract incoming array keys into variables
// define local functions
// assign variables from constants
$appname=APP_NAME;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","OpenDRS Change Log",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
// ******** end database manipulation ********
pagetable("begin");
if (!$print) {
pageblock("left","begin");
sidemenu();
pageblock("left","end");
}
pageblock("right","begin");
banner($print);
echo "<br>";
echo "
<pre>
";
echo file_get_contents("CHANGELOG");
echo "
</pre>
";
echo "<br>";
banner($print);
pageblock("right","end");
pagetable("end");
framework("end","","",$print);
?>

View File

@@ -2,7 +2,7 @@
/*
common.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -26,7 +26,19 @@ if (!file_exists("db.php")) {
include("db.php");
include("settings.php");
// define some constants
// assign variables from constants
$device_term=DEVICE_TERM;
$discovered_term=DISCOVERED_TERM;
$discovered_term_short=DISCOVERED_TERM_SHORT;
$functional_term=FUNCTIONAL_TERM;
$functional_term_short=FUNCTIONAL_TERM_SHORT;
$disc_drop_data=DISC_DROP_DATA;
$functional_yes=FUNCTIONAL_YES;
$functional_no=FUNCTIONAL_NO;
$functional_yes_short=FUNCTIONAL_YES_SHORT;
$functional_no_short=FUNCTIONAL_NO_SHORT;
// define some other constants
define("STAT_OPEN",1);
define("STAT_CLOSED",2);
define("STAT_DEFERRED",3);
@@ -260,9 +272,9 @@ function framework($option,$htmltitle,$pagetitle,$print) {
$( \"#logoutall\" ).checkboxradio({
icon: false
});
$( \"#device, #subsystem, #period, #period_effective, [id|='sel']\" ).selectmenu();
$( \"#device, #subsystem, #discoveredselect, #functional, [id|='sel']\" ).selectmenu();
$( \"#status, #user, #reason\" ).selectmenu();
$( \"#subsystem, #period, #searchstatus, #pass, #passconf\").tooltip();
$( \"#subsystem, #discovered, #searchstatus, #pass, #passconf\").tooltip();
$( \"[id|='ms']\").multiselect();
$( \"#configtabs, #dbadmintabs, #profiletabs\" ).tabs();
</script>
@@ -276,7 +288,6 @@ function framework($option,$htmltitle,$pagetitle,$print) {
exit(1);
}
}
function pagetable($option) {
if ($option=="begin") {
echo "
@@ -447,14 +458,19 @@ function banner($print) {
}
}
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
function dblookup($drs_db,$table,$in_field,$out_field,$in_data) {
// look up a single field in a database given a value for a single field
$out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""));
$lookup_result=(mysqli_query($drs_db,"select $out_field from $table where $in_field=\"$in_data\""));
if (mysqli_num_rows($lookup_result) > 0) {
$out_data=mysqli_fetch_row($lookup_result);
return($out_data[0]);
} else {
return NULL;
}
}
function arrayCopy( array $array ) {
$result = array();
$result=[];
foreach( $array as $key => $val ) {
if( is_array( $val ) ) {
$result[$key] = arrayCopy( $val );
@@ -483,7 +499,7 @@ function validate_password($pass,$passconf) {
// first element is true if passwords match, false if not
// second element is true if passwords meet complexity requirements, false if not
$results=array();
$results=[];
// check for match
if ($pass==$passconf) {
@@ -532,17 +548,24 @@ function validate_password($pass,$passconf) {
}
function displaywriteup($id) {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
global $drs_db;
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id=\"$id\""));
// determine status indicator
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
// determine effective icon
if($writeupdata["period_effective"]==1) {
$effind="<font color=\"#00FF00\" title=\"Period Effective\">EFF</font>";
// determine functional indicator
if($writeupdata["functional"]==1) {
$funcind="<font color=\"#00FF00\" title=\"$functional_yes\">$functional_yes_short</font>";
} else {
$effind="<font color=\"#FF0000\" title=\"Period Non-effective\">NEF</font>";
$funcind="<font color=\"#FF0000\" title=\"$functional_no\">$functional_no_short</font>";
}
// look up text data
$devicename=dblookup($drs_db,"devices","id","name",$writeupdata["device"]);
@@ -552,8 +575,8 @@ function displaywriteup($id) {
$rdate=$writeupdata["report_date"];
$rtime=$writeupdata["report_time"];
$repby=$writeupdata["reported_by"];
$period=$writeupdata["period"];
$periodtimes=dblookup($drs_db,"periods","id","times",$period);
$whendiscoveredname=dblookup($drs_db,"discovered","id","whendiscoveredname",$writeupdata["discovered"]);
$whendiscovereddesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$writeupdata["discovered"]);
$techfname=dblookup($drs_db,"users","id","firstname",$writeupdata["action_by"]);
$techlname=dblookup($drs_db,"users","id","lastname",$writeupdata["action_by"]);
$reasonname=dblookup($drs_db,"reasons","id","text",$writeupdata["action_reason"]);
@@ -577,18 +600,20 @@ function displaywriteup($id) {
if ($group_count == 1) {
$group_ind="<a href=\"groups.php?group=$member_group\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"$imgtitle\"></a></div>";
} else {
$group_ind="<a href=\"groups.php\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"View writeup groups\"></a></div>";
$group_ind="<a href=\"writeupdetail.php?id={$writeupdata['id']}\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"Member of $group_count groups. Click here to view.\"></a></div>";
}
} else {
$group_ind=NULL;
}
echo "
<table border=\"2\" width=\"100%\"><tr><td>
<table border=\"0\">
<tr><td><b>ID:</b> <a href=\"writeupdetail.php?id=$id\" title=\"View or change details of this writeup\">$id</a></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$statusind</b></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Device:</b> $devicename</td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$device_term:</b> $devicename</td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Subsystem:</b> <font title=\"$subsystemdesc\">$subsystemname</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Period:</b> <font title=\"$periodtimes\">$period</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$effind</b></td>
<td><b>$discovered_term:</b> <font title=\"$whendiscovereddesc\">$whendiscoveredname</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$funcind</b></td>
</tr>
</table>
<table border=\"0\">
@@ -649,20 +674,29 @@ function format_message($msgtype,$msgtxt) {
function getsetting($setting_name,$user_id) {
// get the value of a setting for a user
global $drs_db;
$confvalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select id,value from config where name=\"$setting_name\""))['value'];
$uservalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\""))['value'];
$confqry=mysqli_query($drs_db,"select id,value from config where name=\"$setting_name\"");
$confvalue=mysqli_fetch_assoc($confqry)['value'];
$userqry=mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\"");
if (mysqli_num_rows($userqry) > 0) {
$uservalue=mysqli_fetch_assoc($userqry)['value'];
if ($uservalue) {
return $uservalue;
} else {
return $confvalue;
}
} else {
return $confvalue;
}
}
function putsetting($setting_name,$setting_value,$user_id) {
// set the value of a setting for a tech
global $drs_db;
$confvalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from config where name=\"$setting_name\""))['value'];
$uservalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\""))['value'];
$confqry=mysqli_query($drs_db,"select value from config where name=\"$setting_name\"");
$confvalue=mysqli_fetch_assoc($confqry)['value'];
$userqry=mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\"");
if (mysqli_num_rows($userqry) > 0) {
$uservalue=mysqli_fetch_assoc($userqry)['value'];
if ($setting_value==$confvalue) {
mysqli_query($drs_db,"delete from profile where user=\"$user_id\" and name=\"$setting_name\"");
} else {
@@ -672,24 +706,33 @@ function putsetting($setting_name,$setting_value,$user_id) {
mysqli_query($drs_db,"insert into profile(user,name,value) values(\"$user_id\",\"$setting_name\",\"$setting_value\")");
}
}
} else {
mysqli_query($drs_db,"insert into profile(user,name,value) values(\"$user_id\",\"$setting_name\",\"$setting_value\")");
}
}
function group_table($groupid,$role=false,$mode="view",$selection="none",$expanded=false) {
function group_detail($groupid,$role=false,$mode="view",$selection="none") {
// display a table for a single group
// groupid is the group for which detail is to be shown
// role is true if user is logged in, false if not.
// mode is "select" if selection boxes are to be displayed, "view" if not.
// selection is "all" or "none"
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
global $drs_db;
// print group id and name
if ($selection == "all") {
$sel_flag="checked";
} elseif ($selection == "none") {
$sel_flag="";
}
if ($expanded) {
echo "
<a href=\"groups.php\" style=\"text-decoration:none\">
<img src=\"icons/minus-white.png\" alt=\"Unexpand group\">
</a>
";
}
$groupname=dblookup($drs_db,"groups","id","name",$groupid);
if ($groupname == "") {
echo "<b>Group ID: &nbsp;$groupid";
@@ -706,12 +749,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
} else {
@@ -721,12 +764,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
}
@@ -744,13 +787,14 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$writeupdata['period']}\""))[0];
// determine effective icon
if($writeupdata["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine whendiscovered text for discovered id
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$writeupdata['discovered']}\""))[0];
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$writeupdata['discovered']}\""))[0];
// determine functional icon
if($writeupdata["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// print table row
if ($role && $mode=="select") {
@@ -771,12 +815,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
$writeupdata["id"],$writeupdata["id"],
$statusind,
$writeupdata["report_date"],
$ptimes, $writeupdata["period"],
$whendiscdesc, $whendiscname,
$tname,
$ssname,
$writeupdata["reported_by"],
$writeupdata["discrepancy_text"],
$eff_icon
$func_icon
);
} else {
printf(
@@ -794,12 +838,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
$writeupdata["id"],$writeupdata["id"],
$statusind,
$writeupdata["report_date"],
$ptimes, $writeupdata["period"],
$whendiscdesc, $whendiscname,
$tname,
$ssname,
$writeupdata["reported_by"],
$writeupdata["discrepancy_text"],
$eff_icon
$func_icon
);
}
}
@@ -807,4 +851,5 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
}
?>

View File

@@ -2,15 +2,20 @@
/*
config.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
@@ -30,7 +35,6 @@ if ($role != ADMIN) {
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -40,35 +44,55 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$update_display=$incoming['update_display'];
$display_appname=$incoming['display_appname'];
$display_banner=$incoming['display_banner'];
$display_footer=$incoming['display_footer'];
$display_pereffhlp=$incoming['display_pereffhlp'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* update_display
* display_appname
* display_banner
* display_footer
* display_funchelp
* display_device_term
* display_discovered_term
* display_discovered_term_short
* display_disc_drop_data
* display_functional_term
* display_functional_term_short
* display_functional_yes
* display_functional_no
* display_functional_yes_short
* display_functional_no_short
* update_colors
* reset_colors
* newbgc
* newmbgc
* newtc
* newlc
* newvlc
* newhc
* edit_banner
* add_banner
* update_banner
* delete_banner
* bnrid
* bnrname
* bnrcolor
* bnrtxtcolor
* update_misc
* sessttl
* logoutall
*/
$update_colors=$incoming['update_colors'];
$reset_colors=$incoming['reset_colors'];
$newbgc=$incoming['newbgc'];
$newmbgc=$incoming['newmbgc'];
$newtc=$incoming['newtc'];
$newlc=$incoming['newlc'];
$newvlc=$incoming['newvlc'];
$newhc=$incoming['newhc'];
$edit_banner=$incoming['edit_banner'];
$add_banner=$incoming['add_banner'];
$update_banner=$incoming['update_banner'];
$delete_banner=$incoming['delete_banner'];
$bnrid=$incoming['bnrid'];
$bnrname=$incoming['bnrname'];
$bnrcolor=$incoming['bnrcolor'];
$bnrtxtcolor=$incoming['bnrtxtcolor'];
$update_misc=$incoming['update_misc'];
$sessttl=$incoming['sessttl'];
$sessdir=$incoming['sessdir'];
$logoutall=$incoming['logoutall'];
if (!isset($update_display)) $update_display=false;
if (!isset($update_colors)) $update_colors=false;
if (!isset($reset_colors)) $reset_colors=false;
if (!isset($add_banner)) $add_banner=false;
if (!isset($edit_banner)) $edit_banner=false;
if (!isset($update_banner)) $update_banner=false;
if (!isset($delete_banner)) $delete_banner=false;
if (!isset($update_misc)) $update_misc=false;
if (!isset($logoutall)) $logoutall=false;
// assign variables from constants
$appname=APP_NAME;
@@ -81,10 +105,14 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","Configuration",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
$nameunique_err=$namesuppld_err=$ttlsuppld_err=$dirsuppld_err=false;
if ($update_display) {
// remove html tags from footer_message and sanitize
$display_footer=strip_tags($display_footer);
@@ -92,14 +120,52 @@ if ($update_display) {
// remove html tags from app name and sanitize
$display_appname=strip_tags($display_appname);
$clean_display_appname=mysqli_real_escape_string($drs_db,$display_appname);
// remove html tags from period effective help text and sanitize
$display_pereffhlp=strip_tags($display_pereffhlp);
$clean_display_pereffhlp=mysqli_real_escape_string($drs_db,$display_pereffhlp);
// remove html tags from functional help text and sanitize
$display_funchelp=strip_tags($display_funchelp);
$clean_display_funchelp=mysqli_real_escape_string($drs_db,$display_funchelp);
// remove html tags from device term and sanitize
$display_device_term=strip_tags($display_device_term);
$clean_display_device_term=mysqli_real_escape_string($drs_db,$display_device_term);
// remove html tags from discovered term and sanitize
$display_discovered_term=strip_tags($display_discovered_term);
$clean_display_discovered_term=mysqli_real_escape_string($drs_db,$display_discovered_term);
// remove html tags from short discovered term and sanitize
$display_discovered_term_short=strip_tags($display_discovered_term_short);
$clean_display_discovered_term_short=mysqli_real_escape_string($drs_db,$display_discovered_term_short);
// remove html tags from functional term and sanitize
$display_functional_term=strip_tags($display_functional_term);
$clean_display_functional_term=mysqli_real_escape_string($drs_db,$display_functional_term);
// remove html tags from short functional term and sanitize
$display_functional_term_short=strip_tags($display_functional_term_short);
$clean_display_functional_term_short=mysqli_real_escape_string($drs_db,$display_functional_term_short);
// remove html tags from functional yes and sanitize
$display_functional_yes=strip_tags($display_functional_yes);
$clean_display_functional_yes=mysqli_real_escape_string($drs_db,$display_functional_yes);
// remove html tags from functional no and sanitize
$display_functional_no=strip_tags($display_functional_no);
$clean_display_functional_no=mysqli_real_escape_string($drs_db,$display_functional_no);
// remove html tags from short functional yes and sanitize
$display_functional_yes_short=strip_tags($display_functional_yes_short);
$clean_display_functional_yes_short=mysqli_real_escape_string($drs_db,$display_functional_yes_short);
// remove html tags from short functional no and sanitize
$display_functional_no_short=strip_tags($display_functional_no_short);
$clean_display_functional_no_short=mysqli_real_escape_string($drs_db,$display_functional_no_short);
mysqli_query($drs_db,"update config set value=\"$clean_display_appname\" where name=\"app_name\"");
mysqli_query($drs_db,"update config set value=\"$display_banner\" where name=\"banner\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_footer\" where name=\"footer_message\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_pereffhlp\" where name=\"period_eff_help_txt\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_funchelp\" where name=\"functional_help_txt\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_device_term\" where name=\"device_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_discovered_term\" where name=\"discovered_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_discovered_term_short\" where name=\"discovered_term_short\"");
mysqli_query($drs_db,"update config set value=\"$display_disc_drop_data\" where name=\"disc_drop_data\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_term\" where name=\"functional_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_term_short\" where name=\"functional_term_short\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_yes\" where name=\"functional_yes\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_no\" where name=\"functional_no\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_yes_short\" where name=\"functional_yes_short\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_no_short\" where name=\"functional_no_short\"");
echo "<meta http-equiv='refresh' content='0'>";
}
@@ -124,6 +190,7 @@ if ($add_banner) {
// test for name supplied
if (strlen(trim($bnrname))) {
$namesuppld=true;
$namesuppld_err=false;
} else {
$namesuppld=false;
$namesuppld_err=true;
@@ -134,6 +201,7 @@ if ($add_banner) {
$nameunique_err=true;
} else {
$nameunique=true;
$nameunique_err=false;
}
if ($namesuppld && $nameunique) {
// sanitize banner name
@@ -154,17 +222,19 @@ if ($edit_banner) {
// test for name supplied
if (strlen(trim($bnrname))) {
$namesuppld=true;
$namesuppld_err=false;
} else {
$namesuppld=false;
$namesuppld_err=true;
}
// test for name unique
if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$bnrname\" and bannerid!=\"$bnrid\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\" and bannerid!=\"$bnrid\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\""))) {
$nameunique=false;
$nameunique_err=true;
} else {
$nameunique=true;
$nameunique_err=false;
}
} else {
$nameunique=true;
@@ -196,20 +266,8 @@ if ($update_misc) {
$ttlsuppld=false;
$ttlsuppld_err=true;
}
// test for sessdir supplied
if (strlen(trim($sessdir))) {
$dirsuppld=true;
} else {
$dirsuppld=false;
$dirsuppld_err=true;
}
if ($ttlsuppld && $dirsuppld) {
if ($ttlsuppld) {
mysqli_query($drs_db,"update config set value=\"$sessttl\" where name=\"session_ttl_days\"");
if ($ostype == 'WIN') {
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"win_server_session_dir\"");
} else {
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"unix_server_session_dir\"");
}
}
}
@@ -239,7 +297,18 @@ echo "
$curapn=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"app_name\""))[0];
$curbnr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"banner\""))[0];
$curftr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"footer_message\""))[0];
$curpereffhlp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"period_eff_help_txt\""))[0];
$curfunchelp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_help_txt\""))[0];
$curdscterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"discovered_term\""))[0];
$curdscterms=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"discovered_term_short\""))[0];
$curdiscdropdata=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"disc_drop_data\""))[0];
$curfuncterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_term\""))[0];
$curfuncterms=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_term_short\""))[0];
$curfuncyes=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_yes\""))[0];
$curfuncno=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_no\""))[0];
$curfuncyess=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_yes_short\""))[0];
$curfuncnos=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_no_short\""))[0];
$curdevterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"device_term\""))[0];
echo "
<font size=\"+1\"><b>Display Configuration Parameters</b></font><br><br><br><br>
";
@@ -259,12 +328,37 @@ while ($bannerrow=mysqli_fetch_assoc($bannerqry)) {
printf("<option value=\"%s\">%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
}
}
$dropnamestate=$dropdescstate="";
if($curdiscdropdata=="Name") $dropnamestate="checked";
if($curdiscdropdata=="Desc") $dropdescstate="checked";
echo "
</select><br><br><br>
Footer Message (will appear at the bottom of pages):<br>
<input type=\"text\" name=\"display_footer\" size=\"80\" value=\"$curftr\"><br><br><br>
Period Effective Help Text :<br>
<textarea rows=\"4\" cols=\"80\" name=\"display_pereffhlp\" wrap=\"soft\">$curpereffhlp</textarea><br><br><br><br>
Device Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_device_term\" size=\"10\" value=\"$curdevterm\"><br><br><br>
When Discovered Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_discovered_term\" size=\"20\" value=\"$curdscterm\"><br><br><br>
Short When Discovered Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_discovered_term_short\" size=\"9\" value=\"$curdscterms\"><br><br><br>
When Discovered data to show in dropdowns:&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"display_disc_drop_data\" value=\"Name\" $dropnamestate> Name &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"display_disc_drop_data\" value=\"Desc\" $dropdescstate> Description<br><br><br>
Functional Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_term\" size=\"20\" value=\"$curfuncterm\"><br><br><br>
Short Functional Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_term_short\" size=\"4\" value=\"$curfuncterms\"><br><br><br>
Functional Yes Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_yes\" size=\"20\" value=\"$curfuncyes\"><br><br><br>
Functional No Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_no\" size=\"20\" value=\"$curfuncno\"><br><br><br>
Short Functional Yes Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_yes_short\" size=\"4\" value=\"$curfuncyess\"><br><br><br>
Short Functional No Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_no_short\" size=\"4\" value=\"$curfuncnos\"><br><br><br>
Functional Help Text :<br>
<textarea rows=\"4\" cols=\"80\" name=\"display_funchelp\" wrap=\"soft\">$curfunchelp</textarea><br><br><br><br>
<input type=\"submit\" name=\"update_display\" value=\"Update Options\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br><br><br>
</form>
@@ -450,17 +544,10 @@ echo "
<form method=\"post\" action=\"config.php#miscellaneous\">
";
if ($ttlsuppld_err) format_message(1,"Session expiration time cannot be blank.");
if ($dirsuppld_err) format_message(1,"Server session file directory cannot be blank.");
$curttl=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"session_ttl_days\""))[0];
if ($ostype == 'WIN') {
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
} else {
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
}
echo "
<font size=\"+1\"><b>Miscellaneous Configuration Parameters</b></font><br><br><br><br>
Session expiration time (users will have to log in again after this long) : &nbsp;<input type=\"text\" name=\"sessttl\" size=\"3\" value=\"$curttl\"> days<br><br>
Server session file directory (must be writable by the web server process) : <br><input type=\"text\" name=\"sessdir\" size=\"40\" value=\"$curssdir\"><br><br>
Force logout of all users &nbsp;<input type=\"checkbox\" name=\"logoutall\"><br><br><br><br>
<input type=\"submit\" name=\"update_misc\" value=\"Update Options\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>

View File

@@ -2,15 +2,20 @@
/*
create.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to writeups.php on change cancel
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:writeups.php");
@@ -18,10 +23,14 @@ if ($_REQUEST['cancel']) {
}
// import session variables
if (isset($_SESSION['personid'])) $personid=$_SESSION['personid'];
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -31,32 +40,46 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$create=$incoming['create'];
$device=$incoming['device'];
$period=$incoming['period'];
$period_effective=$incoming['period_effective'];
$reported_by=$incoming['reported_by'];
$report_date=$incoming['report_date'];
$report_time=$incoming['report_time'];
$subsystem=$incoming['subsystem'];
$discrepancy_text=$incoming['discrepancy_text'];
$status=$incoming['status'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* create
* device
* discovered
* functional
* reported_by
* report_date
* report_time
* subsystem
* discrepancy_text
* status
*/
if (!isset($device)) $device=NULL;
if (!isset($discovered)) $discovered=NULL;
if (!isset($reported_by)) $reported_by=NULL;
if (!isset($discrepancy_text)) $discrepancy_text=NULL;
if (!isset($functional)) $functional=NULL;
if (!isset($subsystem)) $subsystem=NULL;
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($drs_db,"persons","id","role",$personid);
$role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","New Writeup",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -64,17 +87,17 @@ framework("begin","$appname","New Writeup",$print);
// determine today's date and make it the default
$today=date("Y-m-d");
$now=date("H:i:s");
if (!$report_date || $report_date=="automatic") $report_date=$today;
if (!$report_time || $report_time=="automatic") $report_time=$now;
if (!isset($report_date) || $report_date=="automatic") $report_date=$today;
if (!isset($report_time) || $report_time=="automatic") $report_time=$now;
if ($create) {
if (isset($create)) {
// add the entry if create is pressed
if ($discrepancy_text && $reported_by && $device && $subsystem && $period) {
if ($discrepancy_text!=NULL && $reported_by!=NULL && $device!=NULL && $subsystem!=NULL && $discovered!=NULL) {
// sanitize and fix blank date and time
$report_date=mysqli_real_escape_string($drs_db,$report_date);
$report_time=mysqli_real_escape_string($drs_db,$report_time);
if (!$report_date) $report_date=$today;
if (!$report_time) $report_time=$now;
if (!isset($report_date)) $report_date=$today;
if (!isset($report_time)) $report_time=$now;
// remove html tags from discrepancy text and sanitize
$discrepancy_text=strip_tags($discrepancy_text);
@@ -82,8 +105,8 @@ if ($create) {
$clean_reported_by=mysqli_real_escape_string($drs_db,$reported_by);
// add the record to writeups
mysqli_query($drs_db,"insert into writeups(device,period,period_effective,reported_by,report_date,report_time,subsystem,discrepancy_text,status)
values (\"$device\",\"$period\",\"$period_effective\",\"$clean_reported_by\",\"$report_date\",\"$report_time\",\"$subsystem\",\"$clean_discrepancy_text\",\"$status\")");
mysqli_query($drs_db,"insert into writeups(device,discovered,functional,reported_by,report_date,report_time,subsystem,discrepancy_text,status)
values (\"$device\",\"$discovered\",\"$functional\",\"$clean_reported_by\",\"$report_date\",\"$report_time\",\"$subsystem\",\"$clean_discrepancy_text\",\"$status\")");
}
}
@@ -99,33 +122,33 @@ pageblock("right","begin");
banner($print);
echo "<br>";
// display the form
if ($create) {
if ($discrepancy_text && $reported_by) {
if (isset($create)) {
if ($discrepancy_text!=NULL && $reported_by!=NULL) {
format_message(0,"<strong>Writeup created.</strong> You may create another writeup or <a href=\"writeups.php\">return to Open Writeups page.</a>");
$preserve=FALSE;
$preserve=false;
}
if (!$device) {
format_message(1,"You didn't select a device. Please try again.");
$preserve=TRUE;
if ($device==NULL) {
format_message(1,"You didn't select a $device_term. Please try again.");
$preserve=true;
}
if (!$subsystem) {
if ($subsystem==NULL) {
format_message(1,"You didn't select a subsystem. Please try again.");
$preserve=TRUE;
$preserve=true;
}
if (!$period) {
format_message(1,"You didn't select a period. Please try again.");
$preserve=TRUE;
if ($discovered==NULL) {
format_message(1,"You didn't select a $discovered_term. Please try again.");
$preserve=true;
}
if (!$discrepancy_text) {
if ($discrepancy_text==NULL) {
format_message(1,"You didn't enter any discrepancy text. Please try again.");
$preserve=TRUE;
$preserve=true;
}
if (!$reported_by) {
if ($reported_by==NULL) {
format_message(1,"You didn't enter your name in the Reported by: block. Please try again.");
$preserve=TRUE;
$preserve=true;
}
} else {
$preserve=FALSE;
$preserve=false;
}
echo "
@@ -133,14 +156,11 @@ echo "
";
// start writeup entry section
if ($status==1) $statusind="<b><font color=\"#FF0000\">OPEN</font></b>";
if ($status==2) $statusind="<b><font color=\"#008000\">CLSD</font></b>";
if ($status==3) $statusind="<b><font color=\"#FFFF00\">DFRD</font></b>";
echo "
<table border=\"0\" cellpadding=\"5\">
<tr>
<td align=\"left\">Device<br>
<td align=\"left\">$device_term<br>
<select name=\"device\" id=\"device\">
<option value=\"\">Please select...</option>
";
@@ -170,16 +190,23 @@ echo "
</select></td><td></td>
</tr>
<tr>
<td align=\"left\">Period<br>
<select name=\"period\" id=\"period\">
<td align=\"left\">$discovered_term<br>
<select name=\"discovered\" id=\"discoveredselect\">
<option value=\"\">Please select...</option>
";
$prow=mysqli_query($drs_db,"select * from periods where active is true order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if ($period==$pitem["id"] && $preserve) {
printf("<option value=\"%s\" title=\"Period %s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$drow=mysqli_query($drs_db,"select * from discovered where active is true order by whendiscoveredname asc");
while ($ditem=mysqli_fetch_assoc($drow)) {
if ($discovered==$ditem["id"] && $preserve) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$ditem["id"],$ditem["$discddtitle"],$ditem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$ditem["id"],$ditem["$discddtitle"],$ditem["$discddtext"]);
}
}
@@ -190,12 +217,12 @@ if (!$preserve) {
$reported_by="";
}
$effstate=$nefstate="";
$funcyesstate=$funcnostate="";
if ($preserve) {
if($period_effective==1) $effstate="checked";
if($period_effective==0) $nefstate="checked";
if($functional==1) $funcyesstate="checked";
if($functional==0) $funcnostate="checked";
} else {
$effstate="checked";
$funcyesstate="checked";
}
echo "
@@ -213,9 +240,9 @@ Discrepancy <font size=\"-2\">(required)</font><br>
<tr>
<td>Reported by <font size=\"-2\">(required)</font><br>
<input type=\"text\" name=\"reported_by\" size=\"30\" value=\"$reported_by\" title=\"Who to contact with questions about this writeup\"></td>
<td>Period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
<input type=\"radio\" name=\"period_effective\" value=\"1\" $effstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"period_effective\" value=\"0\" $nefstate> No
<td>$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
<input type=\"radio\" name=\"functional\" value=\"1\" $funcyesstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"functional\" value=\"0\" $funcnostate> No
</td>
<td align=\"right\" valign=\"bottom\"><input type=\"submit\" name=\"create\" value=\"Submit Writeup\" id=\"createbutton\"></td>
</tr>

View File

@@ -2,15 +2,19 @@
/*
dbadmin.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
@@ -30,7 +34,6 @@ if ($role != ADMIN) {
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -40,52 +43,85 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$edit_user=$incoming['edit_user'];
$add_user=$incoming['add_user'];
$update_user=$incoming['update_user'];
$delete_user=$incoming['delete_user'];
$user_id=$incoming['user_id'];
$user_fname=$incoming['user_fname'];
$user_lname=$incoming['user_lname'];
$user_login=$incoming['user_login'];
$user_pass=$incoming['user_pass'];
$user_passconf=$incoming['user_passconf'];
$user_role=$incoming['user_role'];
$user_active=$incoming['user_active'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* edit_user
* add_user
* update_user
* delete_user
* user_id
* user_fname
* user_lname
* user_login
* user_pass
* user_passconf
* user_role
* user_active
* edit_device
* add_device
* update_device
* delete_device
* device_id
* device_name
* device_active
* edit_subsystem
* add_subsystem
* update_subsystem
* delete_subsystem
* subsystem_id
* subsystem_name
* subsystem_desc
* subsystem_active
* edit_reason
* add_reason
* update_reason
* delete_reason
* reason_id
* reason_text
* reason_active
* edit_discovered
* add_discovered
* update_discovered
* delete_discovered
* discovered_id
* discovered_name
* discovered_desc
* discovered_active
*/
$edit_device=$incoming['edit_device'];
$add_device=$incoming['add_device'];
$update_device=$incoming['update_device'];
$delete_device=$incoming['delete_device'];
$device_id=$incoming['device_id'];
$device_name=$incoming['device_name'];
$device_active=$incoming['device_active'];
$edit_subsystem=$incoming['edit_subsystem'];
$add_subsystem=$incoming['add_subsystem'];
$update_subsystem=$incoming['update_subsystem'];
$delete_subsystem=$incoming['delete_subsystem'];
$subsystem_id=$incoming['subsystem_id'];
$subsystem_name=$incoming['subsystem_name'];
$subsystem_desc=$incoming['subsystem_desc'];
$subsystem_active=$incoming['subsystem_active'];
$edit_reason=$incoming['edit_reason'];
$add_reason=$incoming['add_reason'];
$update_reason=$incoming['update_reason'];
$delete_reason=$incoming['delete_reason'];
$reason_id=$incoming['reason_id'];
$reason_text=$incoming['reason_text'];
$reason_active=$incoming['reason_active'];
$edit_period=$incoming['edit_period'];
$add_period=$incoming['add_period'];
$update_period=$incoming['update_period'];
$delete_period=$incoming['delete_period'];
$period_id=$incoming['period_id'];
$period_times=$incoming['period_times'];
$period_active=$incoming['period_active'];
if (!isset($edit_user)) $edit_user=false;
if (!isset($add_user)) $add_user=false;
if (!isset($update_user)) $update_user=false;
if (!isset($delete_user)) $delete_user=false;
if (!isset($edit_device)) $edit_device=false;
if (!isset($add_device)) $add_device=false;
if (!isset($update_device)) $update_device=false;
if (!isset($delete_device)) $delete_device=false;
if (!isset($edit_subsystem)) $edit_subsystem=false;
if (!isset($add_subsystem)) $add_subsystem=false;
if (!isset($update_subsystem)) $update_subsystem=false;
if (!isset($delete_subsystem)) $delete_subsystem=false;
if (!isset($edit_reason)) $edit_reason=false;
if (!isset($add_reason)) $add_reason=false;
if (!isset($update_reason)) $update_reason=false;
if (!isset($delete_reason)) $delete_reason=false;
if (!isset($edit_discovered)) $edit_discovered=false;
if (!isset($add_discovered)) $add_discovered=false;
if (!isset($update_discovered)) $update_discovered=false;
if (!isset($delete_discovered)) $delete_discovered=false;
if (!isset($user_fname)) $user_fname=NULL;
if (!isset($user_lname)) $user_lname=NULL;
if (!isset($user_login)) $user_login=NULL;
if (!isset($user_pass)) $user_pass=NULL;
if (!isset($user_passconf)) $user_passconf=NULL;
if (!isset($device_name)) $device_name=NULL;
if (!isset($subsystem_name)) $subsystem_name=NULL;
if (!isset($subsystem_desc)) $subsystem_desc=NULL;
if (!isset($reason_text)) $reason_text=NULL;
if (!isset($discovered_name)) $discovered_name=NULL;
if (!isset($discovered_desc)) $discovered_desc=NULL;
// define local functions
@@ -93,7 +129,7 @@ $period_active=$incoming['period_active'];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
@@ -101,12 +137,19 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","Database Administration",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
// users-------------------------------------
$usernameunique_err=$fnamesuppld_err=$lnamesuppld_err=false;
$loginsuppld_err=$loginunique_err=$passcomplex_err=$passmatch_err=false;
$userhaswriteups_err=false;
$user_add_fail=false;
if ($add_user) {
// do error checking
// remove html tags from user name
@@ -116,6 +159,7 @@ if ($add_user) {
// test for first name supplied
if (strlen(trim($user_fname))) {
$fnamesuppld=true;
$fnamesuppld_err=false;
} else {
$fnamesuppld=false;
$fnamesuppld_err=true;
@@ -123,6 +167,7 @@ if ($add_user) {
// test for last name supplied
if (strlen(trim($user_lname))) {
$lnamesuppld=true;
$lnamesuppld_err=false;
} else {
$lnamesuppld=false;
$lnamesuppld_err=true;
@@ -133,10 +178,12 @@ if ($add_user) {
$usernameunique_err=true;
} else {
$usernameunique=true;
$usernameunique_err=false;
}
// test for login supplied
if (strlen(trim($user_login))) {
$loginsuppld=true;
$loginsuppld_err=false;
} else {
$loginsuppld=false;
$loginsuppld_err=true;
@@ -147,27 +194,30 @@ if ($add_user) {
$loginunique_err=true;
} else {
$loginunique=true;
$loginunique_err=false;
}
// test passwords
$passresults=validate_password($user_pass,$user_passconf);
if ($passresults['match']) {
$passmatch=true;
$passmatch_err=false;
} else {
$passmatch=false;
$passmatch_err=true;
}
if ($passresults['complex']) {
$passcomplex=true;
$passcomplex_err=false;
} else {
$passcomplex=false;
$passcomplex_err=true;
}
// set role
if (!$user_role) $user_role=USER;
if (!isset($user_role)) $user_role=USER;
// set active status
if (!$user_active) $user_active=0;
if (!isset($user_active)) $user_active=0;
if ($fnamesuppld && $lnamesuppld && $usernameunique && $loginsuppld && $loginunique && $passcomplex && $passmatch) {
// sanitize first name, last name, login
@@ -178,6 +228,7 @@ if ($add_user) {
$passhash=password_hash($user_pass,PASSWORD_DEFAULT);
// modify the table
mysqli_query($drs_db,"insert into users(firstname,lastname,login,password_hash,role,active) values(\"$clean_fname\",\"$clean_lname\",\"$clean_login\",\"$passhash\",\"$user_role\",\"$user_active\")");
$user_add_fail=false;
} else {
$user_add_fail=true;
}
@@ -191,6 +242,7 @@ if ($edit_user) {
$userhaswriteups_err=true;
} else {
$userhaswriteups=false;
$userhaswriteups_err=false;
}
// if none, then remove from db
if (!$userhaswriteups) mysqli_query($drs_db,"delete from users where id=\"$user_id\"");
@@ -204,6 +256,7 @@ if ($edit_user) {
// test for first name supplied
if (strlen(trim($user_fname))) {
$fnamesuppld=true;
$fnamesuppld_err=false;
} else {
$fnamesuppld=false;
$fnamesuppld_err=true;
@@ -211,6 +264,7 @@ if ($edit_user) {
// test for last name supplied
if (strlen(trim($user_lname))) {
$lnamesuppld=true;
$lnamesuppld_err=false;
} else {
$lnamesuppld=false;
$lnamesuppld_err=true;
@@ -222,13 +276,16 @@ if ($edit_user) {
$nameunique_err=true;
} else {
$nameunique=true;
$nameunique_err=false;
}
} else {
$nameunique=true;
$nameunique_err=false;
}
// test for login supplied
if (strlen(trim($user_login))) {
$loginsuppld=true;
$loginsuppld_err=false;
} else {
$loginsuppld=false;
$loginsuppld_err=true;
@@ -240,9 +297,11 @@ if ($edit_user) {
$loginunique_err=true;
} else {
$loginunique=true;
$loginunique_err=false;
}
} else {
$loginunique=true;
$loginunique_err=false;
}
// sanitize first name, last name, login
$clean_fname=mysqli_real_escape_string($drs_db,$user_fname);
@@ -250,22 +309,24 @@ if ($edit_user) {
$clean_login=mysqli_real_escape_string($drs_db,$user_login);
// set role
if (!$user_role) $user_role=USER;
if (!isset($user_role)) $user_role=USER;
// set active status
if (!$user_active) $user_active=0;
if (!isset($user_active)) $user_active=0;
if ($user_pass!="password_is_unchanged") {
// test passwords
$passresults=validate_password($user_pass,$user_passconf);
if ($passresults['match']) {
$passmatch=true;
$passmatch_err=false;
} else {
$passmatch=false;
$passmatch_err=true;
}
if ($passresults['complex']) {
$passcomplex=true;
$passcomplex_err=false;
} else {
$passcomplex=false;
$passcomplex_err=true;
@@ -287,6 +348,10 @@ if ($edit_user) {
}
// devices-------------------------------
$devicenameunique_err=$devicenamesuppld_err=false;
$devicehaswriteups_err=false;
$device_add_fail=false;
if ($add_device) {
// do error checking
// remove html tags from device name
@@ -294,6 +359,7 @@ if ($add_device) {
// test for device name supplied
if (strlen(trim($device_name))) {
$devicenamesuppld=true;
$devicenamesuppld_err=false;
} else {
$devicenamesuppld=false;
$devicenamesuppld_err=true;
@@ -304,16 +370,18 @@ if ($add_device) {
$devicenameunique_err=true;
} else {
$devicenameunique=true;
$devicenameunique_err=false;
}
// set active status
if (!$device_active) $device_active=0;
if (!isset($device_active)) $device_active=0;
if ($devicenamesuppld && $devicenameunique) {
// sanitize device name
$clean_devicename=mysqli_real_escape_string($drs_db,$device_name);
// modify the table
mysqli_query($drs_db,"insert into devices(name,active) values(\"$clean_devicename\",\"$device_active\")");
$device_add_fail=false;
} else {
$device_add_fail=true;
}
@@ -326,6 +394,7 @@ if ($edit_device) {
$devicehaswriteups_err=true;
} else {
$devicehaswriteups=false;
$devicehaswriteups_err=false;
}
// if none, then remove from db
if (!$devicehaswriteups) mysqli_query($drs_db,"delete from devices where id=\"$device_id\"");
@@ -337,6 +406,7 @@ if ($edit_device) {
// test for device name supplied
if (strlen(trim($device_name))) {
$devicenamesuppld=true;
$devicenamesuppld_err=false;
} else {
$devicenamesuppld=false;
$devicenamesuppld_err=true;
@@ -348,13 +418,15 @@ if ($edit_device) {
$devicenameunique_err=true;
} else {
$devicenameunique=true;
$devicenameunique_err=false;
}
} else {
$devicenameunique=true;
$devicenameunique_err=false;
}
// set active status
if (!$user_active) $user_active=0;
if (!isset($device_active)) $device_active=0;
// sanitize device name
$clean_devicename=mysqli_real_escape_string($drs_db,$device_name);
@@ -367,6 +439,10 @@ if ($edit_device) {
}
// subsystems--------------------------------
$ssnameunique_err=$ssnamesuppld_err=false;
$sshaswriteups_err=false;
$subsystem_add_fail=false;
if ($add_subsystem) {
// do error checking
// remove html tags from subsystem name and description
@@ -375,6 +451,7 @@ if ($add_subsystem) {
// test for subsystem name supplied
if (strlen(trim($subsystem_name))) {
$ssnamesuppld=true;
$ssnamesuppld_err=false;
} else {
$ssnamesuppld=false;
$ssnamesuppld_err=true;
@@ -385,10 +462,11 @@ if ($add_subsystem) {
$ssnameunique_err=true;
} else {
$ssnameunique=true;
$ssnameunique_err=false;
}
// set active status
if (!$subsystem_active) $subsystem_active=0;
if (!isset($subsystem_active)) $subsystem_active=0;
if ($ssnamesuppld && $ssnameunique) {
// sanitize subsystem name and description
@@ -396,6 +474,7 @@ if ($add_subsystem) {
$clean_subsystemdesc=mysqli_real_escape_string($drs_db,$subsystem_desc);
// modify the table
mysqli_query($drs_db,"insert into subsystems(name,description,active) values(\"$clean_subsystemname\",\"$clean_subsystemdesc\",\"$subsystem_active\")");
$subsystem_add_fail=false;
} else {
$subsystem_add_fail=true;
}
@@ -408,6 +487,7 @@ if ($edit_subsystem) {
$sshaswriteups_err=true;
} else {
$sshaswriteups=false;
$sshaswriteups_err=false;
}
// if none, then remove from db
if (!$sshaswriteups) mysqli_query($drs_db,"delete from subsystems where id=\"$subsystem_id\"");
@@ -420,6 +500,7 @@ if ($edit_subsystem) {
// test for subsystem name supplied
if (strlen(trim($subsystem_name))) {
$ssnamesuppld=true;
$ssnamesuppld_err=false;
} else {
$ssnamesuppld=false;
$ssnamesuppld_err=true;
@@ -431,9 +512,11 @@ if ($edit_subsystem) {
$ssnameunique_err=true;
} else {
$ssnameunique=true;
$ssnameunique_err=false;
}
} else {
$ssnameunique=true;
$ssnameunique_err=false;
}
// sanitize subsystem name and description
$clean_ssname=mysqli_real_escape_string($drs_db,$subsystem_name);
@@ -447,6 +530,10 @@ if ($edit_subsystem) {
}
// reasons------------------------------------
$reastextunique_err=$reastextsuppld_err=false;
$reashaswriteups_err=false;
$reason_add_fail=false;
if ($add_reason) {
// do error checking
// remove html tags from reason text
@@ -454,6 +541,7 @@ if ($add_reason) {
// test for reason text supplied
if (strlen(trim($reason_text))) {
$reastextsuppld=true;
$reastextsuppld_err=false;
} else {
$reastextsuppld=false;
$reastextsuppld_err=true;
@@ -464,16 +552,18 @@ if ($add_reason) {
$reastextunique_err=true;
} else {
$reastextunique=true;
$reastextunique_err=false;
}
// set active status
if (!$reason_active) $reason_active=0;
if (!isset($reason_active)) $reason_active=0;
if ($reastextsuppld && $reastextunique) {
// sanitize reason text
$clean_reastext=mysqli_real_escape_string($drs_db,$reason_text);
// modify the table
mysqli_query($drs_db,"insert into reasons(text,active) values(\"$clean_reastext\",\"$reason_active\")");
$reason_add_fail=false;
} else {
$reason_add_fail=true;
}
@@ -486,6 +576,7 @@ if ($edit_reason) {
$reashaswriteups_err=true;
} else {
$reashaswriteups=false;
$reashaswriteups_err=false;
}
// if none, then remove from db
if (!$reashaswriteups) mysqli_query($drs_db,"delete from reasons where id=\"$reason_id\"");
@@ -497,6 +588,7 @@ if ($edit_reason) {
// test for reason text supplied
if (strlen(trim($reason_text))) {
$reastextsuppld=true;
$reastextsuppld_err=false;
} else {
$reastextsuppld=false;
$reastextsuppld_err=true;
@@ -508,13 +600,15 @@ if ($edit_reason) {
$reastextunique_err=true;
} else {
$reastextunique=true;
$reastextunique_err=false;
}
} else {
$reastextunique=true;
$reastextunique_err=false;
}
// set active status
if (!$reason_active) $reason_active=0;
if (!isset($reason_active)) $reason_active=0;
// sanitize reason text
$clean_reastext=mysqli_real_escape_string($drs_db,$reason_text);
@@ -526,102 +620,122 @@ if ($edit_reason) {
}
}
// periods-----------------------------------
if ($add_period) {
// when discovered-----------------------------------
$discnamesuppld_err=$discnameunique_err=$discdescsuppld_err=false;
$dischaswriteups_err=false;
$discovered_add_fail=false;
if ($add_discovered) {
// do error checking
// remove html tags from id and times
$period_id=strip_tags($period_id);
$period_times=strip_tags($period_times);
// test for id supplied
if (strlen(trim($period_id))) {
$peridsuppld=true;
// remove html tags from name and description
$discovered_name=strip_tags($discovered_name);
$discovered_desc=strip_tags($discovered_desc);
// test for name supplied
if (strlen(trim($discovered_name))) {
$discnamesuppld=true;
$discnamesuppld_err=false;
} else {
$peridsuppld=false;
$peridsuppld_err=true;
$discnamesuppld=false;
$discnamesuppld_err=true;
}
// test for id is integer
if (preg_match('/^[0-9]+$/',$period_id)) {
$peridisint=true;
// test for name unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\""))) {
$discnameunique=false;
$discnameunique_err=true;
} else {
$peridisint=false;
$peridisint_err=true;
$discnameunique=true;
$discnameunique_err=false;
}
// test for id unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where id=\"$period_id\""))) {
$peridunique=false;
$peridunique_err=true;
// test for description supplied
if (strlen(trim($discovered_desc))) {
$discdescsuppld=true;
$discdescsuppld_err=false;
} else {
$peridunique=true;
$discdescsuppld=false;
$discdescsuppld_err=true;
}
// test for times supplied
if (strlen(trim($period_times))) {
$pertimessuppld=true;
// test for description unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscovereddesc =\"$discovered_desc\""))) {
$discdescunique=false;
$discdescunique_err=true;
} else {
$pertimessuppld=false;
$pertimessuppld_err=true;
}
// test for times unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\""))) {
$pertimesunique=false;
$pertimesunique_err=true;
} else {
$pertimesunique=true;
$discdescunique=true;
$discdescunique_err=false;
}
// set active status
if (!$period_active) $period_active=0;
if (!isset($discovered_active)) $discovered_active=0;
if ($pertimessuppld && $pertimesunique && $peridsuppld && $peridunique && $peridisint) {
// sanitize times
$clean_pertimes=mysqli_real_escape_string($drs_db,$period_times);
if ($discnamesuppld && $discnameunique && $discdescsuppld) {
// sanitize name
$clean_discovered_name=mysqli_real_escape_string($drs_db,$discovered_name);
// sanitize description
$clean_discovered_desc=mysqli_real_escape_string($drs_db,$discovered_desc);
// modify the table
mysqli_query($drs_db,"insert into periods(id,times,active) values(\"$period_id\",\"$clean_pertimes\",\"$period_active\")");
mysqli_query($drs_db,"insert into discovered(whendiscoveredname,whendiscovereddesc,active) values(\"$clean_discovered_name\",\"$clean_discovered_desc\",\"$discovered_active\")");
$discovered_add_fail=false;
} else {
$period_add_fail=true;
$discovered_add_fail=true;
}
}
if ($edit_period) {
if ($delete_period) {
// check for writeups with this period
if (mysqli_num_rows(mysqli_query($drs_db,"select id from writeups where period=\"$period_id\""))) {
$perhaswriteups=true;
$perhaswriteups_err=true;
if ($edit_discovered) {
if ($delete_discovered) {
// check for writeups with this when discovered
if (mysqli_num_rows(mysqli_query($drs_db,"select id from writeups where discovered=\"$discovered_id\""))) {
$dischaswriteups=true;
$dischaswriteups_err=true;
} else {
$perhaswriteups=false;
$dischaswriteups=false;
$dischaswriteups_err=false;
}
// if none, then remove from db
if (!$perhaswriteups) mysqli_query($drs_db,"delete from periods where id=\"$period_id\"");
if (!$dischaswriteups) mysqli_query($drs_db,"delete from discovered where id=\"$discovered_id\"");
}
if ($update_period) {
if ($update_discovered) {
// do error checking
// remove html tags from times
$period_times=strip_tags($period_times);
// test for times supplied
if (strlen(trim($period_times))) {
$pertimessuppld=true;
// remove html tags from name and description
$discovered_name=strip_tags($discovered_name);
$discovered_desc=strip_tags($discovered_desc);
// test for name supplied
if (strlen(trim($discovered_name))) {
$discnamesuppld=true;
$discnamesuppld_err=false;
} else {
$pertimessuppld=false;
$pertimessuppld_err=true;
$discnamesuppld=false;
$discnamesuppld_err=true;
}
// test for period times unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\" and id!=\"$period_id\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\""))) {
$pertimesunique=false;
$pertimesunique_err=true;
// test for name unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\" and id!=\"$discovered_id\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\""))) {
$discnameunique=false;
$discnameunique_err=true;
} else {
$pertimesunique=true;
$discnameunique=true;
$discnameunique_err=false;
}
} else {
$pertimesunique=true;
$discnameunique=true;
$discnameunique_err=false;
}
// test for description supplied
if (strlen(trim($discovered_desc))) {
$discdescsuppld=true;
$discdescsuppld_err=false;
} else {
$discdescsuppld=false;
$discdescsuppld_err=true;
}
// set active status
if (!$period_active) $period_active=0;
if (!isset($discovered_active)) $discovered_active=0;
// sanitize times
$clean_pertimes=mysqli_real_escape_string($drs_db,$period_times);
$updqry="update periods set times=\"$clean_pertimes\",active=\"$period_active\" where id=\"$period_id\"";
if ($pertimessuppld && $pertimesunique) {
// sanitize name
$clean_discovered_name=mysqli_real_escape_string($drs_db,$discovered_name);
// sanitize description
$clean_discovered_desc=mysqli_real_escape_string($drs_db,$discovered_desc);
$updqry="update discovered set whendiscoveredname=\"$clean_discovered_name\",whendiscovereddesc=\"$clean_discovered_desc\",active=\"$discovered_active\" where id=\"$discovered_id\"";
if ($discnamesuppld && $discnameunique && $discdescsuppld) {
// modify the table
mysqli_query($drs_db,$updqry);
}
@@ -646,7 +760,7 @@ echo "
<li><a href=\"#devices\">Device Management</a></li>
<li><a href=\"#subsystems\">Subsystem Management</a></li>
<li><a href=\"#reasons\">Action Reasons Management</a></li>
<li><a href=\"#periods\">Period Management</a></li>
<li><a href=\"#discovered\">When Discovered Management</a></li>
</ul>
<div id=\"users\">
@@ -688,7 +802,7 @@ if ($edit_user && !$delete_user) {
}
} else {
// set form options for add
if (!$user_add_fail) unset($user_id,$user_fname,$user_lname,$user_login,$user_pass,$user_passconf,$user_role,$user_active);
if (!$user_add_fail) $user_id=$user_fname=$user_lname=$user_login=$user_pass=$user_passconf=$user_role=$user_active=NULL;
$sectiontitle="<b><font size=\"+1\">Add New User</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#users\">";
$buttontags="
@@ -793,7 +907,7 @@ if ($edit_device && !$delete_device) {
}
} else {
// set form options for add
if (!$device_add_fail) unset($device_id,$device_name,$device_active);
if (!$device_add_fail) $device_id=$device_name=$device_active=NULL;
$sectiontitle="<b><font size=\"+1\">Add New Device</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#devices\">";
$buttontags="
@@ -870,7 +984,7 @@ if ($edit_subsystem && !$delete_subsystem) {
}
} else {
// set form options for add
if (!$subsystem_add_fail) unset($subsystem_id,$subsystem_name,$subsystem_desc,$subsystem_active);
if (!$subsystem_add_fail) $subsystem_id=$subsystem_name=$subsystem_desc=$subsystem_active=NULL;
$sectiontitle="<b><font size=\"+1\">Add New Subsystem</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#subsystems\">";
$buttontags="
@@ -950,7 +1064,7 @@ if ($edit_reason && !$delete_reason) {
}
} else {
// set form options for add
if (!$reason_add_fail) unset($reason_id,$reason_text,$reason_active);
if (!$reason_add_fail) $reason_id=$reason_text=$reason_active=NULL;
$sectiontitle="<b><font size=\"+1\">Add New Reason</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#reasons\">";
$buttontags="
@@ -1001,53 +1115,50 @@ echo "</table>";
echo "
</div>
<div id=\"periods\">
<div id=\"discovered\">
";
if ($peridisint_err) format_message(1,"Period number must be an integer.");
if ($peridsuppld_err) format_message(1,"Period number cannot be blank.");
if ($peridunique_err) format_message(1,"Period number already exists.");
if ($pertimesunique_err) format_message(1,"Period already exists.");
if ($pertimessuppld_err) format_message(1,"Period times cannot be blank.");
if ($perhaswriteups_err) format_message(1,"Period has writeups in the database and cannot be deleted.");
if ($discnamesuppld_err) format_message(1,"When Discovered name cannot be blank.");
if ($discnameunique_err) format_message(1,"When Discovered name already exists.");
if ($discdescsuppld_err) format_message(1,"When Discovered description cannot be blank.");
if ($dischaswriteups_err) format_message(1,"When Discovered has writeups in the database and cannot be deleted.");
if ($edit_period && !$delete_period) {
if ($edit_discovered && !$delete_discovered) {
// set form options for editing
$sectiontitle="<b><font size=\"+1\">Modify Period</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"dbadmin.php#periods\">Click here to add a new period</a><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php?edit_period=1#periods\">";
$sectiontitle="<b><font size=\"+1\">Modify When Discovered</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"dbadmin.php#discovered\">Click here to add a new when discovered</a><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php?edit_discovered=1#discovered\">";
$buttontags="
<input type=\"hidden\" name=\"period_id\" value=\"$period_id\">
<input type=\"submit\" name=\"update_period\" value=\"Update Period\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"delete_period\" value=\"Delete Period\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"hidden\" name=\"discovered_id\" value=\"$discovered_id\">
<input type=\"submit\" name=\"update_discovered\" value=\"Update When Discovered\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"delete_discovered\" value=\"Delete When Discovered\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
";
// pull current values from database
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from periods where id=$period_id"));
$period_times=$currentvalues["times"];
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from discovered where id=$discovered_id"));
$discovered_name=$currentvalues["whendiscoveredname"];
$discovered_desc=$currentvalues["whendiscovereddesc"];
if ($currentvalues["active"]==1) {
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\" checked>";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\" checked>";
} else {
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\">";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\">";
}
$idtag="$period_id";
} else {
// set form options for add
if (!$period_add_fail) unset($period_id,$period_times,$period_active);
$sectiontitle="<b><font size=\"+1\">Add New Period</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#periods\">";
if (!$discovered_add_fail) $discovered_id=$discovered_name=$discovered_desc=$discovered_active=NULL;
$sectiontitle="<b><font size=\"+1\">Add New When Discovered</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#discovered\">";
$buttontags="
<input type=\"submit\" name=\"add_period\" value=\"Add Period\">
<input type=\"submit\" name=\"add_discovered\" value=\"Add When Discovered\">
";
$idtag="<input type=\"text\" name=\"period_id\" size=\"3\" value=\"$period_id\">";
// set default values
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\" checked>";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\" checked>";
}
echo "
$sectiontitle
$formtag
<table border=\"0\">
<tr><td>
Period Number: &nbsp;$idtag<br><br>
Period Times: &nbsp;<input type=\"text\" name=\"period_times\" size=\"40\" value=\"$period_times\"><br><br>
When Discovered Name: &nbsp;<input type=\"text\" name=\"discovered_name\" size=\"8\" value=\"$discovered_name\"><br><br>
When Discovered Description: &nbsp;<input type=\"text\" name=\"discovered_desc\" size=\"60\" value=\"$discovered_desc\"><br><br>
Active: &nbsp; $activetag <br><br>
</td></tr>
</table>
@@ -1057,11 +1168,11 @@ $buttontags
";
// show the table of entities
$existingdata=mysqli_query($drs_db,"select * from periods order by id asc");
$existingdata=mysqli_query($drs_db,"select * from discovered order by id asc");
echo "
<b>Existing Periods</b>&nbsp;&nbsp;&nbsp;<font size=\"-1\">Click on the Period ID to edit.</font><br><br>
<b>Existing When Discovereds</b>&nbsp;&nbsp;&nbsp;<font size=\"-1\">Click on the When Disc ID to edit.</font><br><br>
<table border=\"1\">
<tr><th>Period ID</th><th>Period Times</th><th>Active</th></tr>
<tr><th>When Disc ID</th><th>Name</th><th>Description</th><th>Active</th></tr>
";
while ($tablerow=mysqli_fetch_assoc($existingdata)) {
if ($tablerow["active"]) {
@@ -1071,12 +1182,14 @@ while ($tablerow=mysqli_fetch_assoc($existingdata)) {
}
printf("
<tr>
<td><a href=\"dbadmin.php?edit_period=1&period_id=%s#periods\">%s</a></td>
<td><a href=\"dbadmin.php?edit_discovered=1&discovered_id=%s#discovered\">%s</a></td>
<td>%s</td>
<td>%s</td>
<td align=\"center\">%s</td>
</tr>",
$tablerow["id"],$tablerow["id"],
$tablerow["times"],
$tablerow["whendiscoveredname"],
$tablerow["whendiscovereddesc"],
$activedef);
}
echo "</table>";

View File

@@ -2,18 +2,23 @@
/*
gpl.php
OpenMTS Online Maintenance Tracking System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
// redirect to search.php on cancel button press
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
header("Location:search.php");
exit();
}
@@ -21,7 +26,6 @@ if ($_REQUEST['cancel']) {
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming
@@ -31,7 +35,7 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
// extract incoming array keys into variables
// define local functions
@@ -40,19 +44,19 @@ if ($print) {
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
$sbcolor=P_SIDEBAR_COLOR;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($mts_db,"users","id","role",$userid);
$role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","GNU General Public License",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********

View File

@@ -2,15 +2,20 @@
/*
groups.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to groups.php on cancel button press
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:groups.php");
@@ -18,10 +23,13 @@ if ($_REQUEST['cancel']) {
}
// import session variables
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming
@@ -31,34 +39,47 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* action
* save
* targets
* group
* name
* search
* s_status
* s_device
* s_subsystem
* s_discovered
* s_report_date_start
* s_report_date_end
* s_report_time_start
* s_report_time_end
* s_discrepancy_text
* s_reported_by
* s_functional
* edit_status
* edit_action_by
* edit_action_reason
* edit_action_date
* edit_action_time
* edit_action_text
*/
$action=$incoming['action'];
$save=$incoming['save'];
$targets=$incoming['targets'];
$group=$incoming['group'];
$name=$incoming['name'];
$expandgrp=$incoming['expandgrp'];
if (!isset($action)) $action=NULL;
if (!isset($s_discrepancy_text)) $s_discrepancy_text=NULL;
if (!isset($s_reported_by)) $s_reported_by=NULL;
if (!isset($edit_status)) $edit_status=NULL;
if (!isset($edit_action_by)) $edit_action_by=NULL;
if (!isset($edit_action_reason)) $edit_action_reason=NULL;
if (!isset($edit_action_text)) $edit_action_text=NULL;
if (!isset($save)) $save=false;
if (!isset($search)) $search=false;
if (!isset($group)) $group=NULL;
if (!isset($name)) $name=NULL;
$search=$incoming['search'];
$s_status=$incoming['s_status'];
$s_device=$incoming['s_device'];
$s_subsystem=$incoming['s_subsystem'];
$s_period=$incoming['s_period'];
$s_report_date_start=$incoming['s_report_date_start'];
$s_report_date_end=$incoming['s_report_date_end'];
$s_report_time_start=$incoming['s_report_time_start'];
$s_report_time_end=$incoming['s_report_time_end'];
$s_discrepancy_text=$incoming['s_discrepancy_text'];
$s_reported_by=$incoming['s_reported_by'];
$s_period_effective=$incoming['s_period_effective'];
$edit_status=$incoming['edit_status'];
$edit_action_by=$incoming['edit_action_by'];
$edit_action_reason=$incoming['edit_action_reason'];
$edit_action_date=$incoming['edit_action_date'];
$edit_action_time=$incoming['edit_action_time'];
$edit_action_text=$incoming['edit_action_text'];
// define local functions
@@ -66,11 +87,9 @@ $edit_action_text=$incoming['edit_action_text'];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
$sbcolor=P_SIDEBAR_COLOR;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
}
@@ -78,7 +97,9 @@ $role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","Writeup Groups",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -90,17 +111,17 @@ $now=date("H:i:s");
// get max report date from writeups table, validate input dates/times and set defaults
$maxrepdate_qry=mysqli_query($drs_db,"select max(report_date) from writeups");
$maxrepdate=mysqli_fetch_row($maxrepdate_qry)[0];
if (!$s_report_date_start || !validateDate($s_report_date_start)) $s_report_date_start=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 30 day)"))[0];
if (!$s_report_date_end || !validateDate($s_report_date_end)) $s_report_date_end=$maxrepdate;
if (!$s_report_time_start || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
if (!$s_report_time_end || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
if (!$edit_action_date || !validateDate($edit_action_date)) $edit_action_date=$today;
if (!$edit_action_time || !validateTime($edit_action_time)) $edit_action_time=$now;
if (!isset($s_report_date_start) || !validateDate($s_report_date_start)) $s_report_date_start=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 30 day)"))[0];
if (!isset($s_report_date_end) || !validateDate($s_report_date_end)) $s_report_date_end=$maxrepdate;
if (!isset($s_report_time_start) || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
if (!isset($s_report_time_end) || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
if (!isset($edit_action_date) || !validateDate($edit_action_date)) $edit_action_date=$today;
if (!isset($edit_action_time) || !validateTime($edit_action_time)) $edit_action_time=$now;
if ($action=="add" && $role && $save) {
$fail=false;
if (!$group) {
if ($group==NULL) {
// group was not supplied, so create a new one
mysqli_query($drs_db,"insert into groups(name) value(\"\")");
$fail=mysqli_error($drs_db);
@@ -116,18 +137,24 @@ if ($action=="add" && $role && $save) {
}
} elseif ($action=="remove" && $role && $save) {
$fail=false;
$writeups=array();
$writeups=[];
$writeups_qry=mysqli_query($drs_db,"select writeupid from links where linkgroup=\"$group\"");
while ($writeuprow=mysqli_fetch_row($writeups_qry)) {
$writeups[]=$writeuprow[0];
}
foreach ($writeups as $writeup) {
if (!in_array($writeup,$targets)) {
if (!isset($targets) || !in_array($writeup,$targets)) {
// remove writeup from group
mysqli_query($drs_db,"delete from links where writeupid=$writeup and linkgroup=$group");
$fail=mysqli_error($drs_db);
}
}
// if there are no longer any writeups in this group, dissolve it
$memb_qty_query=mysqli_query($drs_db,"select id from links where linkgroup=\"$group\"");
if (mysqli_num_rows($memb_qty_query) == 0) {
mysqli_query($drs_db,"delete from groups where id=$group");
$fail=mysqli_error($drs_db);
}
} elseif ($action=="dissolve" && $role && $save) {
$fail=false;
// unassign all writeups from a group and delete the group
@@ -147,7 +174,7 @@ if ($action=="add" && $role && $save) {
$fail=false;
// set the status, action by, reason action date/time and append supplied text to action text
// for all ids in group
if ($edit_action_text) {
if ($edit_action_reason!=NULL) {
// sanitize date and time
$edit_action_date=mysqli_real_escape_string($drs_db,$edit_action_date);
$edit_action_time=mysqli_real_escape_string($drs_db,$edit_action_time);
@@ -159,22 +186,23 @@ if ($action=="add" && $role && $save) {
while ($edit_row=mysqli_fetch_row($groupmem_qry)) {
$writeup_to_edit=$edit_row[0];
$writeup_action_text=dblookup($drs_db,"writeups","id","action_text",$writeup_to_edit);
$full_action_text=$writeup_action_text." STATUS CHANGED: ".$clean_edit_action_text;
$full_action_text=$writeup_action_text." GROUP ACTION TAKEN: ".$clean_edit_action_text;
mysqli_query($drs_db,"update writeups set status=\"$edit_status\",action_by=\"$edit_action_by\",action_date=\"$edit_action_date\",action_time=\"$edit_action_time\",action_reason=\"$edit_action_reason\",action_text=\"$full_action_text\" where id=\"$writeup_to_edit\"");
$fail=mysqli_error($drs_db);
}
} else {
$fail="A status change reason was not selected.";
}
}
if ($search) {
// strip whitespace from beginning and end of text fields
$s_reported_by=trim($s_reported_by);
$s_action_text=trim($s_action_text);
$s_discrepancy_text=trim($s_discrepancy_text);
// build the query string
$query_string="";
// device
if ($s_device) {
if (isset($s_device)) {
$query_string="{$query_string}(";
$device_param="Devices:";
foreach ($s_device as $dev_val) {
@@ -190,7 +218,7 @@ if ($search) {
$query_string="{$query_string} and ";
}
// subsystem
if ($s_subsystem) {
if (isset($s_subsystem)) {
$query_string="{$query_string}(";
$subsystem_param="Subsystems:";
foreach ($s_subsystem as $sub_val) {
@@ -205,39 +233,39 @@ if ($search) {
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period
if ($s_period) {
// discovered
if (isset($s_discovered)) {
$query_string="{$query_string}(";
$period_param="Periods:";
foreach ($s_period as $per_val) {
$query_string="{$query_string}period=\"{$per_val}\" or ";
$period_dsp=$per_val;
$period_param="{$period_param} {$period_dsp}, ";
$discovered_param="{$discovered_term_short}s:";
foreach ($s_discovered as $disc_val) {
$query_string="{$query_string}discovered=\"{$disc_val}\" or ";
$disc_dsp=$disc_val;
$discovered_param="{$discovered_param} {$disc_dsp}, ";
}
$period_param=rtrim($period_param,", ");
$num_periods=mysqli_num_rows(mysqli_query($drs_db,"select id from periods"));
if (count($s_period)==$num_periods) $period_param="Periods: any";
$discovered_param=rtrim($discovered_param,", ");
$num_discovereds=mysqli_num_rows(mysqli_query($drs_db,"select id from discovered"));
if (count($s_discovered)==$num_discovereds) $discovered_param="{$discovered_term_short}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period_effective
if ($s_period_effective) {
// functional
if (isset($s_functional)) {
$query_string="{$query_string}(";
$eff_param="Period effective:";
foreach ($s_period_effective as $eff_val) {
$query_string="{$query_string}period_effective=\"{$eff_val}\" or ";
if ($eff_val=="0") $eff_dsp="<font color=\"#FF0000\">NEF</font>";
if ($eff_val=="1") $eff_dsp="<font color=\"#00FF00\">EFF</font>";
$eff_param="{$eff_param} {$eff_dsp}, ";
$func_param="$functional_term:";
foreach ($s_functional as $func_val) {
$query_string="{$query_string}functional=\"{$func_val}\" or ";
if ($func_val=="0") $func_dsp="<font color=\"#FF0000\">$functional_no_short</font>";
if ($func_val=="1") $func_dsp="<font color=\"#00FF00\">$functional_yes_short</font>";
$func_param="{$func_param} {$func_dsp}, ";
}
$eff_param=rtrim($eff_param,", ");
$func_param=rtrim($func_param,", ");
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// status
if ($s_status) {
if (isset($s_status)) {
$query_string="{$query_string}(";
$status_param="Status:";
foreach ($s_status as $stat_val) {
@@ -265,7 +293,7 @@ if ($search) {
$query_string="{$query_string} and ";
$reporttime_param="Report time between {$s_report_time_start} and {$s_report_time_end}";
// discrepancy text
if ($s_discrepancy_text) {
if (isset($s_discrepancy_text)) {
$query_string="{$query_string}(";
$query_string="{$query_string}discrepancy_text like \"%{$s_discrepancy_text}%\"";
$query_string="{$query_string})";
@@ -275,7 +303,7 @@ if ($search) {
$discrepancytext_param="Text in discrepancy: any";
}
// reported by
if ($s_reported_by) {
if (isset($s_reported_by)) {
$query_string="{$query_string}(";
$query_string="{$query_string}reported_by like \"%{$s_reported_by}%\"";
$query_string="{$query_string})";
@@ -302,6 +330,7 @@ banner($print);
echo "<br>";
if ($action=="add") {
if (!isset($targets)) $targets=[];
if (count($targets) > 1) {
$plural="s";
} else {
@@ -315,7 +344,7 @@ if ($action=="add") {
if ($save) {
// show the group
$mode="view";
group_table($group,$role,$mode);
group_detail($group,$role,$mode);
if ($role) {
// show buttons
echo "
@@ -416,17 +445,17 @@ if ($action=="add") {
<tr>
<td align=\"left\">
";
// Period cell **********************
// Discovered cell **********************
echo "
Period<br>
<select name=\"s_period[]\" id=\"ms-period\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
$discovered_term<br>
<select name=\"s_discovered[]\" id=\"ms-discovered\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$prow=mysqli_query($drs_db,"select * from periods order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if (!$search || in_array($pitem["id"],$s_period,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
$discrow=mysqli_query($drs_db,"select * from discovered order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if (!$search || in_array($discitem["id"],$s_discovered,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["whendiscovereddesc"],$discitem["whendiscoveredname"]);
} else {
printf("<option value=\"%s\" title=\"%s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["whendiscovereddesc"],$discitem["whendiscoveredname"]);
}
}
echo "
@@ -488,21 +517,21 @@ if ($action=="add") {
</td>
<td align=\"left\">
";
// Period effective cell ************
// functional cell ************
echo "
Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($search) {
$effstate=$nefstate="";
if (in_array("1",$s_period_effective,true)) $effstate="selected";
if (in_array("0",$s_period_effective,true)) $nefstate="selected";
$funcyesstate=$funcnostate="";
if (in_array("1",$s_functional,true)) $funcyesstate="selected";
if (in_array("0",$s_functional,true)) $funcnostate="selected";
} else {
$effstate=$nefstate="selected";
$funcyesstate=$funcnostate="selected";
}
echo "
<select name=\"s_period_effective[]\" id=\"ms-period_effective\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $effstate title=\"Training objectives were achieved\">Effective</option>
<option value=\"0\" $nefstate title=\"Training objectives were not achieved\">Non-effective</option>
<select name=\"s_functional[]\" id=\"ms-functional\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $funcyesstate>$functional_yes</option>
<option value=\"0\" $funcnostate>$functional_no</option>
</select>
</td>
";
@@ -530,15 +559,15 @@ if ($action=="add") {
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup_qry)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine functional icon
if($tablerow["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no\">";
}
// determine status indicator
@@ -586,7 +615,7 @@ if ($action=="add") {
$dname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$func_icon
);
}
echo "
@@ -619,7 +648,7 @@ if ($action=="add") {
<input type=\"hidden\" name=\"group\" value=\"$group\">
<input type=\"hidden\" name=\"action\" value=\"remove\">
";
group_table($group,$role,"select","all");
group_detail($group,$role,"select","all");
echo "
Deselect the writeups you want to remove from this group. <br><br>
<b>NOTE:</b> Deselecting them all will dissolve the group.
@@ -651,7 +680,7 @@ if ($action=="add") {
}
// show the group
$mode="view";
group_table($group,$role,$mode);
group_detail($group,$role,$mode);
if ($role) {
// show buttons
echo "
@@ -692,7 +721,7 @@ if ($action=="add") {
}
// show the group
$mode="view";
group_table($group,$role,$mode);
group_detail($group,$role,$mode);
if ($role) {
// show buttons
echo "
@@ -718,7 +747,7 @@ if ($action=="add") {
}
// show the group
$mode="view";
group_table($group,$role,$mode);
group_detail($group,$role,$mode);
if ($role && ! $save) {
// show action form
echo "
@@ -773,9 +802,9 @@ if ($action=="add") {
<select name=\"edit_action_reason\" id=\"reason\">
";
$reasrow=mysqli_query($drs_db,"select id,text from reasons where active is true order by id asc");
if (!$action_reason) echo "<option selected></option>";
if ($edit_action_reason==NULL) echo "<option selected></option>";
while ($reasitem=mysqli_fetch_assoc($reasrow)) {
if ($action_reason==$reasitem["id"]) {
if ($edit_action_reason==$reasitem["id"]) {
printf("<option value=\"%s\" selected>%s</option>",$reasitem["id"],$reasitem["text"]);
} else {
printf("<option value=\"%s\">%s</option>",$reasitem["id"],$reasitem["text"]);
@@ -816,10 +845,10 @@ if ($action=="add") {
<hr>
";
}
if ($group) {
if ($group!=NULL) {
// show only the requested group
$mode="view";
group_table($group,$role,$mode);
group_detail($group,$role,$mode);
if ($role) {
// show buttons
echo "
@@ -839,45 +868,39 @@ if ($action=="add") {
}
echo "<hr><br>";
} else {
// show all groups
$mode="view";
$groups_qry=mysqli_query($drs_db,"select id from groups");
// show group table
$groups_qry=mysqli_query($drs_db,"select * from groups");
if (mysqli_num_rows($groups_qry)) {
echo "
<br><br>
<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
<tr>
<th style=\"width:1%;\">ID</th>
<th>Name</th>
<th style=\"width:1%;\">Writeups assigned</th>
</tr>
";
while ($grouprow=mysqli_fetch_assoc($groups_qry)) {
if ($expandgrp == $grouprow['id']) {
group_table($grouprow['id'],$role,$mode,"none",$expandgrp);
if ($role) {
// show buttons
echo "
<form method=post action=\"groups.php\">
<input type=\"hidden\" name=\"group\" value=\"{$grouprow['id']}\">
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
</form>
";
}
$num_query=mysqli_query($drs_db,"select id from links where linkgroup={$grouprow['id']}");
$num_writeups=mysqli_num_rows($num_query);
if($grouprow['name']=="") {
$name_text="Group {$grouprow['id']} has not been named";
} else {
echo "
<a href=\"groups.php?expandgrp={$grouprow['id']}\" style=\"text-decoration:none\">
<img src=\"icons/plus-white.png\" alt=\"Expand group\">
</a>
";
$groupname=dblookup($drs_db,"groups","id","name",$grouprow['id']);
if ($groupname == "") {
echo "<b>Group ID:</b> &nbsp;{$grouprow['id']}";
} else {
echo "<b>Group Name:</b> &nbsp;$groupname";
$name_text="{$grouprow['name']}";
}
// print table row
printf(
"<tr>
<td align=\"center\" valign=\"top\"><a href=\"groups.php?group=%s\" title=\"View or change details of this group\">%s</a></td>
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">%s</td>
</tr>\n",
$grouprow["id"],$grouprow["id"],
$name_text,
$num_writeups
);
}
echo "<br><br>";
}
echo "</table><br>";
} else {
echo "<br>No writeup groups were found.<br><br><br>";
}

View File

@@ -2,24 +2,49 @@
/*
login.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
$print=$_REQUEST['print'];
$userid=$_REQUEST['userid'];
$userlogin=$_REQUEST['userlogin'];
$pass=$_REQUEST['pass'];
$login=$_REQUEST['login'];
$cancel=$_REQUEST['cancel'];
if ($cancel) {
session_destroy();
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// import incoming arrays
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
// copy $_REQUEST[] to $incoming[]
$incoming=arrayCopy($_REQUEST);
}
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* userid
* userlogin
* pass
* login
* cancel
*/
if (!isset($userlogin)) $userlogin=NULL;
if (!isset($pass)) $pass=NULL;
if (isset($cancel)) {
session_destroy();
} else {
$cancel=false;
}
$appname=APP_NAME;
if ($print) {
@@ -31,7 +56,10 @@ if ($print) {
framework("begin","$appname","Login Page",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
pagetable("begin");
if(!$print){
@@ -41,7 +69,7 @@ if(!$print){
pageblock("left","end");
}
pageblock("right","begin");
if ($login) {
if (isset($login)) {
// get the id from the userlogin
$userid=dblookup($drs_db,"users","login","id",$userlogin);
$useractive=dblookup($drs_db,"users","id","active",$userid);

View File

@@ -2,15 +2,20 @@
/*
profile.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to index.php on cancel button press
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:index.php");
@@ -30,7 +35,6 @@ if (!$role) {
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -40,24 +44,34 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$update_colors=$incoming['update_colors'];
$reset_colors=$incoming['reset_colors'];
$newbgc=$incoming['newbgc'];
$newmbgc=$incoming['newmbgc'];
$newtc=$incoming['newtc'];
$newlc=$incoming['newlc'];
$newvlc=$incoming['newvlc'];
$newhc=$incoming['newhc'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* update_colors
* reset_colors
* newbgc
* newmbgc
* newtc
* newlc
* newvlc
* newhc
* edit_user
* update_user
* user_id
* user_fname
* user_lname
* user_login
* user_pass
* user_passconf
*/
$edit_user=$incoming['edit_user'];
$update_user=$incoming['update_user'];
$user_id=$userid; // ensures that I can only change my own profile
$user_fname=$incoming['user_fname'];
$user_lname=$incoming['user_lname'];
$user_login=$incoming['user_login'];
$user_pass=$incoming['user_pass'];
$user_passconf=$incoming['user_passconf'];
if (!isset($update_colors)) $update_colors=false;
if (!isset($reset_colors)) $reset_colors=false;
if (!isset($edit_user)) $edit_user=false;
if (!isset($update_user)) $update_user=false;
// define local functions
@@ -65,7 +79,7 @@ $user_passconf=$incoming['user_passconf'];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
@@ -74,7 +88,9 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","User Profile",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -92,6 +108,9 @@ if ($reset_colors) {
echo "<meta http-equiv='refresh' content='0'>";
}
$usernameunique_err=$fnamesuppld_err=$lnamesuppld_err=$loginsuppld_err=false;
$loginunique_err=$passcomplex_err=$passmatch_err=false;
if ($edit_user) {
if ($update_user) {
// do error checking
@@ -102,6 +121,7 @@ if ($edit_user) {
// test for first name supplied
if (strlen(trim($user_fname))) {
$fnamesuppld=true;
$fnamesuppld_err=false;
} else {
$fnamesuppld=false;
$fnamesuppld_err=true;
@@ -109,6 +129,7 @@ if ($edit_user) {
// test for last name supplied
if (strlen(trim($user_lname))) {
$lnamesuppld=true;
$lnamesuppld_err=false;
} else {
$lnamesuppld=false;
$lnamesuppld_err=true;
@@ -120,13 +141,16 @@ if ($edit_user) {
$nameunique_err=true;
} else {
$nameunique=true;
$nameunique_err=false;
}
} else {
$nameunique=true;
$nameunique_err=false;
}
// test for login supplied
if (strlen(trim($user_login))) {
$loginsuppld=true;
$loginsuppld_err=false;
} else {
$loginsuppld=false;
$loginsuppld_err=true;
@@ -138,9 +162,11 @@ if ($edit_user) {
$loginunique_err=true;
} else {
$loginunique=true;
$loginunique_err=false;
}
} else {
$loginunique=true;
$loginunique_err=false;
}
// sanitize first name, last name, login
$clean_fname=mysqli_real_escape_string($drs_db,$user_fname);
@@ -152,12 +178,14 @@ if ($edit_user) {
$passresults=validate_password($user_pass,$user_passconf);
if ($passresults['match']) {
$passmatch=true;
$passmatch_err=false;
} else {
$passmatch=false;
$passmatch_err=true;
}
if ($passresults['complex']) {
$passcomplex=true;
$passcomplex_err=false;
} else {
$passcomplex=false;
$passcomplex_err=true;

View File

@@ -2,15 +2,32 @@
/*
search.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2021 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
if ($_REQUEST['exportcsv']) {
$csv_filename="OpenDRS_Search_Results_" . date("Y-m-d_His") . ".csv";
// redirect to search.php on cancel button press
if (array_key_exists('cancel',$_REQUEST)) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:search.php");
exit();
}
// assign variables from constants
$appname=APP_NAME;
if (array_key_exists('exportcsv',$_REQUEST)) {
$exportcsv=true;
$csv_filename="{$appname}_Search_Results_" . date("Y-m-d_His") . ".csv";
// disable caching
$now = gmdate("D, d M Y H:i:s");
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
@@ -25,51 +42,69 @@ if ($_REQUEST['exportcsv']) {
// disposition / encoding on response body
header("Content-Disposition: attachment;filename={$csv_filename}");
header("Content-Transfer-Encoding: binary");
} else {
$exportcsv=false;
}
// import session variables
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
$print=$_REQUEST['print'];
$exportcsv=$_REQUEST['exportcsv'];
if ($print || $exportcsv) {
// if printer friendly or export csv was clicked, values will be
// passed in serialized form as "all_parameters" so we need to load
// those into $incoming[]
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
if (!$_REQUEST['cancel']) $incoming=arrayCopy($_REQUEST);
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$search=$incoming['search'];
$viewtype=$incoming['viewtype'];
$s_device=$incoming['s_device'];
$s_period=$incoming['s_period'];
$s_period_effective=$incoming['s_period_effective'];
$s_reported_by=$incoming['s_reported_by'];
$s_report_date_start=$incoming['s_report_date_start'];
$s_report_date_end=$incoming['s_report_date_end'];
$s_report_time_start=$incoming['s_report_time_start'];
$s_report_time_end=$incoming['s_report_time_end'];
$s_action_date_start=$incoming['s_action_date_start'];
$s_action_date_end=$incoming['s_action_date_end'];
$s_action_time_start=$incoming['s_action_time_start'];
$s_action_time_end=$incoming['s_action_time_end'];
$s_action_by=$incoming['s_action_by'];
$s_action_reason=$incoming['s_action_reason'];
$s_action_text=$incoming['s_action_text'];
$s_subsystem=$incoming['s_subsystem'];
$s_id=$incoming['s_id'];
$s_discrepancy_text=$incoming['s_discrepancy_text'];
$s_status=$incoming['s_status'];
$s_group=$incoming['s_group'];
$sort=$incoming['sort'];
$order=$incoming['order'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* search
* viewtype
* s_device
* s_discovered
* s_functional
* s_reported_by
* s_report_date_start
* s_report_date_end
* s_report_time_start
* s_report_time_end
* s_action_date_start
* s_action_date_end
* s_action_time_start
* s_action_time_end
* s_action_by
* s_action_reason
* s_action_text
* s_subsystem
* s_id
* s_discrepancy_text
* s_status
* s_group
* sort
* order
*/
// assign variables from constants
$appname=APP_NAME;
if (!isset($search)) $search=false;
if (!isset($viewtype)) $viewtype="summary";
if (!isset($s_id)) $s_id=NULL;
if (!isset($s_discrepancy_text)) $s_discrepancy_text=NULL;
if (!isset($s_reported_by)) $s_reported_by=NULL;
if (!isset($s_action_text)) $s_action_text=NULL;
if (!isset($s_action_date_start)) $s_action_date_start=NULL;
if (!isset($s_action_date_end)) $s_action_date_end=NULL;
if (!isset($s_action_time_start)) $s_action_time_start=NULL;
if (!isset($s_action_time_end)) $s_action_time_end=NULL;
if (!isset($sort)) $sort=NULL;
if (!isset($order)) $order=NULL;
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
@@ -93,10 +128,10 @@ if (! $exportcsv) framework("begin","$appname",$pgtitle,$print);
// get min, max report and action_dates from writeups table, validate input dates/times and set defaults
$minmaxqry=mysqli_query($drs_db,"select min(report_date),max(report_date),min(action_date),max(action_date) from writeups");
$minmaxdates=mysqli_fetch_row($minmaxqry);
if (!$s_report_date_start || !validateDate($s_report_date_start)) $s_report_date_start=$minmaxdates[0];
if (!$s_report_date_end || !validateDate($s_report_date_end)) $s_report_date_end=$minmaxdates[1];
if (!$s_report_time_start || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
if (!$s_report_time_end || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
if (!isset($s_report_date_start) || !validateDate($s_report_date_start)) $s_report_date_start=$minmaxdates[0];
if (!isset($s_report_date_end) || !validateDate($s_report_date_end)) $s_report_date_end=$minmaxdates[1];
if (!isset($s_report_time_start) || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
if (!isset($s_report_time_end) || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
if ($search) {
// strip whitespace from beginning and end of text fields
@@ -110,7 +145,7 @@ if ($search) {
// device
if ($s_device) {
$query_string="{$query_string}(";
$device_param="Devices:";
$device_param="{$device_term}s:";
foreach ($s_device as $dev_val) {
$query_string="{$query_string}device=\"{$dev_val}\" or ";
$device_dsp=dblookup($drs_db,"devices","id","name",$dev_val);
@@ -118,7 +153,7 @@ if ($search) {
}
$device_param=rtrim($device_param,", ");
$num_devices=mysqli_num_rows(mysqli_query($drs_db,"select id from devices"));
if (count($s_device)==$num_devices) $device_param="Devices: any";
if (count($s_device)==$num_devices) $device_param="{$device_term}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
@@ -149,33 +184,33 @@ if ($search) {
} else {
$id_param="ID: any";
}
// period
if ($s_period) {
// discovered
if ($s_discovered) {
$query_string="{$query_string}(";
$period_param="Periods:";
foreach ($s_period as $per_val) {
$query_string="{$query_string}period=\"{$per_val}\" or ";
$period_dsp=$per_val;
$period_param="{$period_param} {$period_dsp}, ";
$discovered_param="{$discovered_term_short}:";
foreach ($s_discovered as $disc_val) {
$query_string="{$query_string}discovered=\"{$disc_val}\" or ";
$disc_dsp=$disc_val;
$discovered_param="{$discovered_param} {$disc_dsp}, ";
}
$period_param=rtrim($period_param,", ");
$num_periods=mysqli_num_rows(mysqli_query($drs_db,"select id from periods"));
if (count($s_period)==$num_periods) $period_param="Periods: any";
$discovered_param=rtrim($discovered_param,", ");
$num_discovereds=mysqli_num_rows(mysqli_query($drs_db,"select id from discovered"));
if (count($s_discovered)==$num_discovereds) $discovered_param="{$discovered_term_short}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period_effective
if ($s_period_effective) {
// functional
if ($s_functional) {
$query_string="{$query_string}(";
$eff_param="Period effective:";
foreach ($s_period_effective as $eff_val) {
$query_string="{$query_string}period_effective=\"{$eff_val}\" or ";
if ($eff_val=="0") $eff_dsp="<font color=\"#FF0000\">NEF</font>";
if ($eff_val=="1") $eff_dsp="<font color=\"#00FF00\">EFF</font>";
$eff_param="{$eff_param} {$eff_dsp}, ";
$func_param="$functional_term:";
foreach ($s_functional as $func_val) {
$query_string="{$query_string}functional=\"{$func_val}\" or ";
if ($func_val=="0") $func_dsp="<font color=\"#FF0000\">$functional_no_short</font>";
if ($func_val=="1") $func_dsp="<font color=\"#00FF00\">$functional_yes_short</font>";
$func_param="{$func_param} {$func_dsp}, ";
}
$eff_param=rtrim($eff_param,", ");
$func_param=rtrim($func_param,", ");
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
@@ -303,14 +338,21 @@ if ($search) {
$query_string="select * from writeups where {$query_string} order by $sort $order";
// group membership
if ($s_group) {
if (isset($s_group)) {
$group_param="Group member: ";
// create an array of writeups that are members of the groups specified
$group_writeups=[];
foreach ($s_group as $group_val) {
if ($group_val=="0") $group_dsp="No";
if ($group_val=="1") $group_dsp="Yes";
$group_param="{$group_param} {$group_dsp}, ";
$wulink_query=mysqli_query($drs_db,"select writeupid from links where linkgroup=$group_val");
while($wulinkrow=mysqli_fetch_assoc($wulink_query)){
$group_writeups[]=$wulinkrow['writeupid'];
}
$group_name=dblookup($drs_db,"groups","id","name",$group_val);
$group_param="{$group_param} <font title=\"{$group_name}\">{$group_val}</font>, ";
}
$group_param=rtrim($group_param,", ");
} else {
$group_param="Group member: any";
}
}
@@ -348,7 +390,7 @@ if (! $exportcsv) {
";
// Device cell *********************
echo "
Device<br>
$device_term<br>
<select name=\"s_device[]\" id=\"ms-device\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$drow=mysqli_query($drs_db,"select * from devices order by id asc");
@@ -392,17 +434,24 @@ if (! $exportcsv) {
<tr>
<td align=\"left\">
";
// Period cell **********************
// Discovered cell **********************
echo "
Period<br>
<select name=\"s_period[]\" id=\"ms-period\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
$discovered_term<br>
<select name=\"s_discovered[]\" id=\"ms-discovered\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$prow=mysqli_query($drs_db,"select * from periods order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if (!$search || in_array($pitem["id"],$s_period,true)) {
printf("<option value=\"%s\" title=\"Period %s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$discrow=mysqli_query($drs_db,"select * from discovered order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if (!$search || in_array($discitem["id"],$s_discovered,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
}
}
echo "
@@ -464,21 +513,21 @@ if (! $exportcsv) {
</td>
<td align=\"left\">
";
// Period effective cell ************
// functional cell ************
echo "
Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($search) {
$effstate=$nefstate="";
if (in_array("1",$s_period_effective,true)) $effstate="selected";
if (in_array("0",$s_period_effective,true)) $nefstate="selected";
$funcyesstate=$funcnostate="";
if (in_array("1",$s_functional,true)) $funcyesstate="selected";
if (in_array("0",$s_functional,true)) $funcnostate="selected";
} else {
$effstate=$nefstate="selected";
$funcyesstate=$funcnostate="selected";
}
echo "
<select name=\"s_period_effective[]\" id=\"ms-period_effective\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $effstate>Effective</option>
<option value=\"0\" $nefstate>Non-effective</option>
<select name=\"s_functional[]\" id=\"ms-functional\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $funcyesstate>$functional_yes</option>
<option value=\"0\" $funcnostate>$functional_no</option>
</select>
";
// **********************************
@@ -488,20 +537,31 @@ if (! $exportcsv) {
";
// Group status cell **************
echo "
Group Member?<br>
Group Assignments:<br>
<select style=\"max-width:40%;\" name=\"s_group[]\" id=\"ms-group\" multiple title=\"Select the groups the results should be a member of. If you uncheck them all, this field will not be included in the search.\">
";
if ($search) {
$yesgroupstate=$nogroupstate="";
if (in_array("1",$s_group,true)) $yesgroupstate="selected";
if (in_array("0",$s_group,true)) $nogroupstate="selected";
if (!isset($s_group)) $s_group=[];
$grow=mysqli_query($drs_db,"select * from groups order by id asc");
while ($gitem=mysqli_fetch_assoc($grow)) {
if ($gitem["name"]=="") {
$gname="Group ".$gitem["id"];
} else {
$yesgroupstate=$nogroupstate="selected";
}echo "
<select name=\"s_group[]\" id=\"ms-group\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $yesgroupstate title=\"Writeup is a member of a group\">Show group members</option>
<option value=\"0\" $nogroupstate title=\"Writeup is not a member of a group\">Show non group members</option>
$gname=$gitem["name"];
}
if($search) {
if (in_array($gitem["id"],$s_group,true)) {
printf("<option value=\"%s\" selected>%s</option>",$gitem["id"],$gname);
} else {
printf("<option value=\"%s\">%s</option>",$gitem["id"],$gname);
}
} else {
printf("<option value=\"%s\">%s</option>",$gitem["id"],$gname);
}
}
echo "
</select>
";
// ************************************
echo "
</td></tr>
@@ -542,7 +602,11 @@ if (! $exportcsv) {
";
$persrow=mysqli_query($drs_db,"select id,firstname,lastname from users order by lastname asc");
while ($persitem=mysqli_fetch_assoc($persrow)) {
if (!$search || in_array($persitem["id"],$s_action_by,true)) {
printf("<option value=\"%s\" selected>%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
} else {
printf("<option value=\"%s\">%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
}
}
echo "
</select>
@@ -560,7 +624,11 @@ if (! $exportcsv) {
";
$reasrow=mysqli_query($drs_db,"select id,text from reasons order by id asc");
while ($reasitem=mysqli_fetch_assoc($reasrow)) {
if (!$search || in_array($reasitem["id"],$s_action_reason,true)) {
printf("<option value=\"%s\" selected>%s</option>",$reasitem["id"],$reasitem["text"]);
} else {
printf("<option value=\"%s\">%s</option>",$reasitem["id"],$reasitem["text"]);
}
}
echo "
</select>
@@ -611,7 +679,7 @@ if (! $exportcsv) {
} else {
$summarystat="checked";
}
$idsort=$statussort=$datesort=$periodsort=$devicesort=$subsyssort=$repbysort=$discrepsort=$effsort="";
$idsort=$statussort=$datesort=$discsort=$devicesort=$subsyssort=$repbysort=$discrepsort=$funcsort="";
switch ($sort) {
case "id":
$idsort="checked";
@@ -622,8 +690,8 @@ if (! $exportcsv) {
case "report_date":
$datesort="checked";
break;
case "period":
$periodsort="checked";
case "discovered":
$discsort="checked";
break;
case "device":
$devicesort="checked";
@@ -637,8 +705,8 @@ if (! $exportcsv) {
case "discrepancy_text":
$discrepsort="checked";
break;
case "period_effective":
$effsort="checked";
case "functional":
$funcsort="checked";
break;
default:
$datesort="checked";
@@ -660,12 +728,12 @@ if (! $exportcsv) {
<input type=\"radio\" $idsort name=\"sort\" value=\"id\" id=\"idview\" ><label for=\"idview\" title=\"Sort by ID.\">ID</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $statussort name=\"sort\" value=\"status\" id=\"statusview\" ><label for=\"statusview\" title=\"Sort by Status.\">Status</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $datesort name=\"sort\" value=\"report_date\" id=\"dateview\" ><label for=\"dateview\" title=\"Sort by Report Date.\">Date</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $periodsort name=\"sort\" value=\"period\" id=\"periodview\" ><label for=\"periodview\" title=\"Sort by Period.\">Period</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $devicesort name=\"sort\" value=\"device\" id=\"deviceview\" ><label for=\"deviceview\" title=\"Sort by Device.\">Device</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $discsort name=\"sort\" value=\"discovered\" id=\"discoveredview\" ><label for=\"discoveredview\" title=\"Sort by $discovered_term.\">$discovered_term_short</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $devicesort name=\"sort\" value=\"device\" id=\"deviceview\" ><label for=\"deviceview\" title=\"Sort by $device_term.\">$device_term</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $subsyssort name=\"sort\" value=\"subsystem\" id=\"subsysview\" ><label for=\"subsysview\" title=\"Sort by Subsystem.\">Subsystem</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $repbysort name=\"sort\" value=\"reported_by\" id=\"repbyview\" ><label for=\"repbyview\" title=\"Sort by Reported by.\">Reported by</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $discrepsort name=\"sort\" value=\"discrepancy_text\" id=\"discrepview\" ><label for=\"discrepview\" title=\"Sort by Discrepancy.\">Discrepancy</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $effsort name=\"sort\" value=\"period_effective\" id=\"effview\" ><label for=\"effview\" title=\"Sort by Mission Effective.\">Msn Eff</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $funcsort name=\"sort\" value=\"functional\" id=\"funcview\" ><label for=\"funcview\" title=\"Sort by $functional_term.\">$functional_term_short</label>&nbsp;&nbsp;&nbsp;
<br>Sort Order:<br>
<input type=\"radio\" $ascsort name=\"order\" value=\"asc\" id=\"ascview\" ><label for=\"ascview\" title=\"Sort results in ascending order.\">Ascending</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $descsort name=\"order\" value=\"desc\" id=\"descview\" ><label for=\"descview\" title=\"Sort results in descending order.\">Descending</label>&nbsp;&nbsp;&nbsp;
@@ -704,7 +772,7 @@ if ($search) {
</table>
<table border=\"0\">
<tr>
<td>$period_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$discovered_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$reportdate_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$reporttime_param</td><td>&nbsp;&nbsp;&nbsp;</td>
</tr>
@@ -717,7 +785,7 @@ if ($search) {
<table border=\"0\">
<tr>
<td>$repby_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$eff_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$func_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$group_param</td><td>&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
@@ -752,35 +820,21 @@ if ($search) {
}
$writeup=mysqli_query($drs_db,$query_string);
// create an array of ids returned by the query string
$result_ids=array();
$result_ids=[];
while ($eachid=mysqli_fetch_assoc($writeup)) {
$result_ids[]=$eachid['id'];
}
mysqli_data_seek($writeup,0);
// create an array of all ids in groups
$groupmems=array();
$groupmem_qry=mysqli_query($drs_db,"select writeupid from links");
while ($groupmemrow=mysqli_fetch_row($groupmem_qry)) {
$groupmems[]=$groupmemrow[0];
}
$groupmems=array_unique($groupmems);
// determine how many group members are in results
$member_count=0;
foreach($result_ids as $result_id) {
if (in_array($result_id,$groupmems)) $member_count += 1;
}
if (in_array("1",$s_group)) $show_groupmems=true;
if (in_array("0",$s_group)) $show_nongroupmems=true;
if ($show_groupmems == $show_nongroupmems) $num_results=mysqli_num_rows($writeup); //show members and nonmembers
if ($show_groupmems && !$show_nongroupmems) $num_results=$member_count; //only show members
if (!$show_groupmems && $show_nongroupmems) $num_results=mysqli_num_rows($writeup)-$member_count; //only show nonmembers
mysqli_data_seek($writeup,0);
if (!isset($group_writeups)) $group_writeups=[];
reset($group_writeups);
$num_results=mysqli_num_rows($writeup);
if ($num_results > 0) {
if ($exportcsv) {
// generate csv file
// create an array of lines of the csv data
$csv_data=array();
$csv_data[]=['WriteupID','Status','Device','Subsystem','Period','Effective','Discrepancy','Group','Report date','Report time','Reported by','Action taken by','Status Change Reason','Action taken','Action date','Action time'];
$csv_data=[];
$csv_data[]=['WriteupID','Status',$device_term,'Subsystem',$discovered_term_short,$functional_term,'Discrepancy','Group','Report date','Report time','Reported by','Action taken by','Status Change Reason','Action taken','Action date','Action time'];
$csv_fp=fopen('php://temp', 'w+');
while ($tablerow = mysqli_fetch_assoc($writeup)) {
@@ -799,14 +853,14 @@ if ($search) {
// convert subsystem number to name for csv
$csv_ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// period number for csv
$csv_period="{$tablerow["period"]}";
// discovered name for csv
$csv_discovered=dblookup($drs_db,"discovered","id","whendiscoveredname",$tablerow["discovered"]);
// determine effective text for csv
if($tablerow["period_effective"]==1) {
$csv_eff_text="EFF";
// determine functional text for csv
if($tablerow["functional"]==1) {
$csv_func_text="$functional_yes_short";
} else {
$csv_eff_text="NEF";
$csv_func_text="$functional_no_short";
}
// discrepancy text for csv
@@ -862,14 +916,10 @@ if ($search) {
// action time for csv
$csv_action_time="{$tablerow["action_time"]}";
if (($show_groupmems == $show_nongroupmems) || ($is_member && $show_groupmems) || (!$is_member && $show_nongroupmems)) {
// add line of results to csv array
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_period, $csv_eff_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_discovered, $csv_func_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
}
}
}
foreach ($csv_data as $csv_fields) {
// add row to csv buffer
fputcsv($csv_fp, $csv_fields);
@@ -879,7 +929,6 @@ if ($search) {
rewind($csv_fp);
// send file contents
$csv_contents=stream_get_contents($csv_fp);
//fpassthru($csv_fp);
// Close our pointer and free up memory and /tmp space
fclose($csv_fp);
echo $csv_contents;
@@ -891,12 +940,12 @@ if ($search) {
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
@@ -904,11 +953,11 @@ if ($search) {
$member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\"");
$is_member=mysqli_num_rows($member_qry);
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine functional icon
if($tablerow["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// determine status indicator
@@ -918,8 +967,10 @@ if ($search) {
// convert device number to name
$dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]);
// convert period number to times
$ptimes=dblookup($drs_db,"periods","id","times",$tablerow["period"]);
// convert discovered number to description
$discname=dblookup($drs_db,"discovered","id","whendiscoveredname",$tablerow["discovered"]);
// convert discovered number to description
$discdesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$tablerow["discovered"]);
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
$disc_txt="{$tablerow["discrepancy_text"]}";
@@ -937,11 +988,11 @@ if ($search) {
}
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php?group=$group_num\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"$imgtitle\"></a></div>";
} else {
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"View writeup groups\"></a></div>";
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"writeupdetail.php?id={$tablerow['id']}\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"Member of $group_count groups. Click here to view.\"></a></div>";
}
}
if (($show_groupmems == $show_nongroupmems) || ($is_member && $show_groupmems) || (!$is_member && $show_nongroupmems)) {
if(in_array($tablerow['id'],$group_writeups) || count($s_group)==0) {
// print table row
printf(
"<tr>
@@ -958,12 +1009,12 @@ if ($search) {
$tablerow["id"],$tablerow["id"],
$statusind,
$tablerow["report_date"],
$ptimes,$tablerow["period"],
$discdesc,$discname,
$dname,
$ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$func_icon
);
}
}
@@ -976,7 +1027,7 @@ if ($search) {
// determine if this is a member of a group
$member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\"");
$is_member=mysqli_num_rows($member_qry);
if (($show_groupmems == $show_nongroupmems) || ($is_member && $show_groupmems) || (!$is_member && $show_nongroupmems)) {
if(in_array($tablerow['id'],$group_writeups) || count($s_group)==0) {
displaywriteup($tablerow['id']);
echo "<br>";
}

View File

@@ -2,7 +2,7 @@
/*
settings.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -35,17 +35,23 @@ $configqry=mysqli_query($drs_db,"select name,value from config");
while ($configrow = mysqli_fetch_assoc($configqry)) {
$constname=strtoupper($configrow['name']);
if (isset($userid)) {
$usrval=mysqli_fetch_row(mysqli_query($drs_db,"select value from profile where name=\"{$configrow['name']}\" and user=\"$userid\""))[0];
$usrvalqry=mysqli_query($drs_db,"select value from profile where name=\"{$configrow['name']}\" and user=\"$userid\"");
if (mysqli_num_rows($usrvalqry) > 0) {
$usrrow=mysqli_fetch_row($usrvalqry);
$usrval=$usrrow[0];
}
if ($usrval) {
}
if (isset($usrval)) {
$constvalue=$usrval;
unset($usrval);
} else {
$constvalue=$configrow['value'];
}
define("$constname","$constvalue");
if (!defined("$constname")) define("$constname","$constvalue");
}
//report no errors
// level of error reporting. Set to 0 for production or E_ALL for development/troubleshooting
error_reporting(0);
//error_reporting(E_ALL);
?>

View File

@@ -2,15 +2,20 @@
/*
writeupdetail.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// redirect to writeups.php on change cancel
if ($_REQUEST['cancel']) {
if (array_key_exists('cancel',$_REQUEST)) {
$id=$_REQUEST['id'];
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
@@ -22,7 +27,6 @@ if ($_REQUEST['cancel']) {
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -32,31 +36,42 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$usersave=$incoming['usersave'];
$techsave=$incoming['techsave'];
$useredit=$incoming['useredit'];
$techedit=$incoming['techedit'];
$id=$incoming['id'];
$device=$incoming['device'];
$period=$incoming['period'];
$period_effective=$incoming['period_effective'];
$reported_by=$incoming['reported_by'];
$report_date=$incoming['report_date'];
$report_time=$incoming['report_time'];
$subsystem=$incoming['subsystem'];
$discrepancy_text=$incoming['discrepancy_text'];
$status=$incoming['status'];
$action_by=$incoming['action_by'];
$action_date=$incoming['action_date'];
$action_time=$incoming['action_time'];
$action_reason=$incoming['action_reason'];
$action_text=$incoming['action_text'];
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
* usersave
* techsave
* useredit
* techedit
* id
* device
* discovered
* functional
* reported_by
* report_date
* report_time
* subsystem
* discrepancy_text
* status
* action_by
* action_date
* action_time
* action_reason
* action_text
* group
*/
if (!isset($usersave)) $usersave=false;
if (!isset($techsave)) $techsave=false;
if (!isset($useredit)) $useredit=false;
if (!isset($techedit)) $techedit=false;
if (!isset($group)) $group=[];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
if ($print) {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
@@ -66,6 +81,9 @@ $role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","Writeup Detail",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -89,7 +107,19 @@ if ($usersave) {
$clean_reported_by=mysqli_real_escape_string($drs_db,$reported_by);
// update the record in writeups
mysqli_query($drs_db,"update writeups set device=\"$device\",period=\"$period\",period_effective=\"$period_effective\",reported_by=\"$clean_reported_by\",report_date=\"$report_date\",report_time=\"$report_time\",subsystem=\"$subsystem\",discrepancy_text=\"$clean_discrepancy_text\" where id=\"$id\"");
mysqli_query($drs_db,"update writeups set device=\"$device\",discovered=\"$discovered\",functional=\"$functional\",reported_by=\"$clean_reported_by\",report_date=\"$report_date\",report_time=\"$report_time\",subsystem=\"$subsystem\",discrepancy_text=\"$clean_discrepancy_text\" where id=\"$id\"");
// remove writeup from all groups and add to only selected groups
mysqli_query($drs_db,"delete from links where writeupid=\"$id\"");
foreach($group as &$link) {
if($link==0) {
// new group was requested
mysqli_query($drs_db,"insert into groups(name) value(\"\")");
$newgroup=mysqli_insert_id($drs_db);
$link=$newgroup;
}
mysqli_query($drs_db,"insert into links(linkgroup, writeupid) values(\"$link\", \"$id\")");
}
}
}
elseif ($techsave) {
@@ -115,8 +145,8 @@ elseif ($techsave) {
// get current writeup data from database to populate fields
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id=\"$id\""));
$device=$writeupdata['device'];
$period=$writeupdata['period'];
$period_effective=$writeupdata['period_effective'];
$discovered=$writeupdata['discovered'];
$functional=$writeupdata['functional'];
$reported_by=$writeupdata['reported_by'];
$report_date=$writeupdata['report_date'];
$report_time=$writeupdata['report_time'];
@@ -195,7 +225,7 @@ echo "
<td align=\"left\">Writeup ID<br>
<table border=\"1\" width=\"100%\"><tr><td><center>$id</center></td></tr></table>
</td>
<td align=\"left\">Device<br>
<td align=\"left\">$device_term<br>
";
if ($useredit) {
echo "
@@ -248,41 +278,49 @@ echo "
</td>
</tr>
<tr>
<td align=\"left\">Period<br>
<td align=\"left\">$discovered_term<br>
";
if ($useredit) {
echo "
<select name=\"period\" id=\"period\">
<select name=\"discovered\" id=\"discoveredselect\">
";
$prow=mysqli_query($drs_db,"select * from periods where active is true order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if ($period==$pitem["id"]) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$pitem["id"],$pitem["times"],$pitem["id"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$discrow=mysqli_query($drs_db,"select * from discovered where active is true order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if ($discovered==$discitem["id"]) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"%s\">%s</option>",$pitem["id"],$pitem["times"],$pitem["id"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
}
}
echo "
</select>
";
} else {
$pertimes=dblookup($drs_db,"periods","id","times",$period);
$discname=dblookup($drs_db,"discovered","id","whendiscoveredname",$discovered);
$discdesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$discovered);
echo "
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$pertimes\">$period</font></td></tr></table>
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$discdesc\">$discname</font></td></tr></table>
";
}
echo "
</td>
";
$effstate=$nefstate="";
if($period_effective==1) {
$effstate="checked";
$eff_ind="Effective";
$funcyesstate=$funcnostate="";
if($functional==1) {
$funcyesstate="checked";
$func_ind="$functional_yes";
}
if($period_effective==0) {
$nefstate="checked";
$eff_ind="Non-Effective";
if($functional==0) {
$funcnostate="checked";
$func_ind="$functional_no";
}
$openstate=$closedstate=$deferredstate="";
@@ -340,16 +378,16 @@ if ($useredit) {
";
}
echo "
<td align=\"left\">Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
<td align=\"left\">$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($useredit) {
echo "
<input type=\"radio\" name=\"period_effective\" value=\"1\" $effstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"period_effective\" value=\"0\" $nefstate> No
<input type=\"radio\" name=\"functional\" value=\"1\" $funcyesstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"functional\" value=\"0\" $funcnostate> No
";
} else {
echo "
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$eff_title\">$eff_ind</font></td></tr></table>
<table border=\"1\" width=\"100%\"><tr><td><font title=\"" . FUNCTIONAL_HELP_TXT . "\">$func_ind</font></td></tr></table>
";
}
echo "
@@ -360,13 +398,76 @@ if ($useredit) {
<td align=\"right\" valign=\"bottom\"><input type=\"submit\" name=\"usersave\" value=\"Save Changes\"></td>
</tr>
<tr>
<td></td><td></td><td align=\"right\" valign=\"bottom\">
<td colspan=\"2\">Group Assignments:&nbsp;&nbsp
";
// Group multi-select ********************
echo "
<select style=\"max-width:60%;\" name=\"group[]\" id=\"ms-group\" multiple title=\"Select the groups this writeup should be a member of.\">
";
$linkquery=mysqli_query($drs_db,"select * from links where writeupid=\"$id\"");
// create an array of ids returned by group query
$wugroups=[];
while ($eachlink=mysqli_fetch_assoc($linkquery)) {
$wugroups[]=$eachlink['linkgroup'];
}
reset($wugroups);
$grow=mysqli_query($drs_db,"select * from groups order by id asc");
printf("<option value=\"%s\">%s</option>",0,"New group");
while ($gitem=mysqli_fetch_assoc($grow)) {
if ($gitem["name"]=="") {
$gname="Group ".$gitem["id"];
} else {
$gname=$gitem["name"];
}
if (in_array($gitem["id"],$wugroups,true)) {
printf("<option value=\"%s\" selected>%s</option>",$gitem["id"],$gname);
} else {
printf("<option value=\"%s\">%s</option>",$gitem["id"],$gname);
}
}
echo "
</select>
";
echo "
</td>
<td align=\"right\" valign=\"bottom\">
<input type=\"submit\" name=\"cancel\" value=\"Cancel Changes\"></td>
</tr>
";
} else {
echo "<tr></tr><td colspan=\"2\">Group Assignments:&nbsp;&nbsp";
$wustat=dblookup($drs_db,"writeups","id","status",$id);
if ($wustat==2 && !$role) $allowuseredit="disabled";
if ($wustat==2 && !$role) {
$allowuseredit="disabled";
} else {
$allowuseredit=NULL;
}
// Group multi-select ********************
echo "
<select style=\"max-width:60%;\" name=\"groupshow\" id=\"ms-group\" multiple title=\"The groups this writeup is a member of.\">
";
$linkquery=mysqli_query($drs_db,"select * from links where writeupid=\"$id\"");
// create an array of ids returned by group query
$wugroups=[];
while ($eachlink=mysqli_fetch_assoc($linkquery)) {
$wugroups[]=$eachlink['linkgroup'];
}
reset($wugroups);
$grow=mysqli_query($drs_db,"select * from groups order by id asc");
while ($gitem=mysqli_fetch_assoc($grow)) {
if ($gitem["name"]=="") {
$gname="Group ".$gitem["id"];
} else {
$gname=$gitem["name"];
}
if (in_array($gitem["id"],$wugroups,true)) {
printf("<option value=\"%s\" selected disabled>%s</option>",$gitem["id"],$gname);
}
}
echo "
</select>
</td>
";
echo "
<td align=\"right\" valign=\"bottom\"><input $allowuseredit type=\"submit\" name=\"useredit\" value=\"Edit this Discrepancy\"></td>
</tr>
@@ -515,7 +616,11 @@ if ($techedit) {
</tr>
";
} else {
if (!$role) $live="disabled";
if (!$role) {
$live="disabled";
} else {
$live=NULL;
}
echo "
<td align=\"right\" valign=\"bottom\"><input $live type=\"submit\" name=\"techedit\" value=\"Edit this Action\"></td>
</tr>

View File

@@ -2,18 +2,26 @@
/*
writeups.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2022 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
if (array_key_exists('print',$_REQUEST)) {
$print=true;
} else {
$print=false;
}
// import session variables
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
if (isset($_SESSION['userid'])) {
$userid=$_SESSION['userid'];
} else {
$userid=NULL;
}
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
@@ -24,20 +32,24 @@ if ($print) {
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
// extract incoming array keys into variables
extract($incoming, EXTR_SKIP);
/*
* possible keys are:
*
* view
* start_date
* end_date
* showtoday
* showyesterday
* show7day
* show30day
* viewtype
* togroup
* addtogroup
* selectedids
*/
$view=$incoming['view'];
$start_date=$incoming['start_date'];
$end_date=$incoming['end_date'];
$showtoday=$incoming['showtoday'];
$showyesterday=$incoming['showyesterday'];
$show7day=$incoming['show7day'];
$show30day=$incoming['show30day'];
$viewtype=$incoming['viewtype'];
$togroup=$incoming['togroup'];
$addtogroup=$incoming['addtogroup'];
$selectedids=$incoming['selectedids'];
// assign variables from constants
$appname=APP_NAME;
@@ -51,7 +63,14 @@ if ($print) {
$role=dblookup($drs_db,"users","id","role",$userid);
// define local functions
function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
function opentable($incoming,$start_date,$end_date,$print,$drs_db,$viewtype="summary") {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
// show date range selector
echo "
<form method=post action=\"writeups.php\">
@@ -71,7 +90,7 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
echo "
</form>
";
$writeup=mysqli_query($drs_db,"select * from writeups where status=".STAT_OPEN." and report_date between \"$start_date\" and \"$end_date\" order by report_date desc,period desc,report_time desc");
$writeup=mysqli_query($drs_db,"select * from writeups where status=".STAT_OPEN." and report_date between \"$start_date\" and \"$end_date\" order by report_date desc,report_time desc");
if (mysqli_num_rows($writeup)) {
$now=date("H:i l");
echo "
@@ -80,20 +99,20 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
<tr>
<th style=\"width:1%;\">ID</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
if($tablerow["functional"]==1) {
$funcind="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$funcind="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// convert device number to name
@@ -102,8 +121,12 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$tablerow['period']}\""))[0];
// convert subsystem number to description
$ssdesc=dblookup($drs_db,"subsystems","id","description",$tablerow["subsystem"]);
// determine values for when discovered
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$tablerow['discovered']}\""))[0];
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$tablerow['discovered']}\""))[0];
$disc_txt="{$tablerow['discrepancy_text']}";
@@ -122,7 +145,7 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
if ($group_count == 1) {
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php?group=$member_group\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"$imgtitle\"></a></div>";
} else {
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"View writeup groups\"></a></div>";
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"writeupdetail.php?id={$tablerow['id']}\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"Member of $group_count groups. Click here to view.\"></a></div>";
}
}
@@ -133,28 +156,28 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
<td valign=\"top\">%s</td>
<td valign=\"top\"><font title=\"%s\">%s</font></td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\"><font title=\"%s\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">%s</td>
</tr>\n",
$tablerow["id"],$tablerow["id"],
$tablerow["report_date"],
$ptimes, $tablerow["period"],
$whendiscdesc, $whendiscname,
$dname,
$ssname,
$ssdesc, $ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$funcind
);
}
echo "</table>\n";
} else {
if ($_REQUEST['showyesterday']) {
if (array_key_exists('showyesterday',$incoming)) {
$datespec="yesterday";
} elseif ($_REQUEST['show7day']) {
} elseif (array_key_exists('show7day',$incoming)) {
$datespec="the last 7 days";
} elseif ($_REQUEST['show30day']) {
} elseif (array_key_exists('show30day',$incoming)) {
$datespec="the last 30 days";
} else {
$datespec="today";
@@ -164,6 +187,13 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
}
function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$role) {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
// show date range selector
$summarystat=$detailstat="";
if ($viewtype=="detail") {
@@ -196,7 +226,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
<br><br>
";
}
$writeup=mysqli_query($drs_db,"select * from writeups where report_date between \"$start_date\" and \"$end_date\" order by report_date desc,period desc,report_time desc");
$writeup=mysqli_query($drs_db,"select * from writeups where report_date between \"$start_date\" and \"$end_date\" order by report_date desc,report_time desc");
if (mysqli_num_rows($writeup)) {
$now=date("H:i l");
if ($viewtype == "summary") {
@@ -213,20 +243,20 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
if($tablerow["functional"]==1) {
$funcind="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$funcind="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// determine status indicator
@@ -240,8 +270,10 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$tablerow['period']}\""))[0];
// determine values for when discovered
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$tablerow['discovered']}\""))[0];
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$tablerow['discovered']}\""))[0];
$disc_txt="{$tablerow['discrepancy_text']}";
// determine if this is a member of a group
@@ -259,7 +291,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
if ($group_count == 1) {
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php?group=$member_group\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"$imgtitle\"></a></div>";
} else {
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"groups.php\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"View writeup groups\"></a></div>";
$disc_txt=$disc_txt."<div align=\"right\"><a href=\"writeupdetail.php?id={$tablerow['id']}\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"Member of $group_count groups. Click here to view.\"></a></div>";
}
}
@@ -286,12 +318,12 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
$tablerow["id"],$tablerow["id"],
$statusind,
$tablerow["report_date"],
$ptimes, $tablerow["period"],
$whendiscdesc, $whendiscname,
$dname,
$ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$funcind
);
}
echo "</table>\n";
@@ -317,7 +349,12 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
";
$tgrow=mysqli_query($drs_db,"select id,name from groups order by id asc");
while ($tgitem=mysqli_fetch_assoc($tgrow)) {
printf("<option value=\"%s\">%s</option>",$tgitem["id"],$tgitem["name"]);
if($tgitem["name"]=="") {
$tgname="Group ".$tgitem["id"];
} else {
$tgname=$tgitem["name"];
}
printf("<option value=\"%s\">%s</option>",$tgitem["id"],$tgname);
}
echo "
</select>
@@ -334,39 +371,42 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
// use default date values if not supplied
$today = date("Y-m-d");
if ($start_date=="") $start_date=$today;
if ($end_date=="") $end_date=$today;
if ($showtoday) {
if (!isset($start_date)) $start_date=$today;
if (!isset($end_date)) $end_date=$today;
if (isset($showtoday)) {
$start_date=$today;
$end_date=$today;
}
if ($showyesterday) {
if (isset($showyesterday)) {
$start_date=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 1 day)"))[0];
$end_date=$start_date;
}
if ($show7day) {
if (isset($show7day)) {
$start_date=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 7 day)"))[0];
$end_date=$today;
}
if ($show30day) {
if (isset($show30day)) {
$start_date=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 30 day)"))[0];
$end_date=$today;
}
if ($view) {
if (isset($view)) {
$pgtitle="Recent Writeups";
} else {
$pgtitle="Open Writeups";
}
framework("begin","$appname",$pgtitle,$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
if ($addtogroup && $togroup && $selectedids && $role) {
if (isset($addtogroup) && isset($togroup) && isset($selectedids) && $role!=NULL) {
$fail=false;
if ($togroup=="newgroup") {
// Create a new group
@@ -397,7 +437,7 @@ pageblock("right","begin");
banner($print);
echo "<br>";
if ($addtogroup) {
if (isset($addtogroup)) {
if (count($selectedids) > 1) {
$plural="s";
} else {
@@ -409,14 +449,14 @@ if ($addtogroup) {
format_message(2,"<strong>An error was encountered when adding writeup$plural.</strong> The error was \" $fail \"");
}
}
if (!$viewtype) $viewtype="summary";
if (!isset($viewtype)) $viewtype="summary";
if ($view==1) {
if (isset($view)) {
// show writeup table
viewtable($start_date,$end_date,$print,$drs_db,$viewtype,$role);
} else {
// show open table
opentable($start_date,$end_date,$print,$drs_db,$viewtype);
opentable($incoming,$start_date,$end_date,$print,$drs_db,$viewtype);
}
echo "<br>";

View File

@@ -2,12 +2,12 @@
# install.sh
# OpenDRS Online Discrepancy Reporting System
# Copyright (C) 2021 Rod Wright
# Copyright (C) 2022 Rod Wright
# SPDX-License-Identifier: GPL-2.0
DRS_VERSION="1.1.2"
DRS_VERSION="1.3.2"
DOC_ROOT="/var/www"
INSTALL_LOC="opendrs"
APACHE_USER="www-data"
@@ -78,19 +78,27 @@ then
curr_username=`grep username $install_path/db.php | head -1 | cut -d "\"" -f2`
curr_dbpass=`grep dbpass $install_path/db.php | head -1 | cut -d "\"" -f2`
export MYSQL_PWD="$curr_dbpass"
mysqldump -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
mysqldump --no-tablespaces -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
# back up existing installation
echo "Backing up current installation to the package directory."
cp -R $install_path $install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
# delete all existing installation files except db.php
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
# apply database updates
mysql -u"$curr_username" $curr_dbname < opendrs-update.sql >/dev/null 2>&1
mysql -u"$curr_username" -f -D $curr_dbname < opendrs-update.sql >/dev/null 2>&1
# apply updates to existing db.php
./opendrs-update.sh $install_path
# copy distribution to install location
echo "Installing distribution . . ."
cp -R distfiles/* $install_path
if [ ! -L "$install_path/jquery-ui" ]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi
if [ ! -L "$install_path/index.php" ]
then
ln -s $install_path/writeups.php $install_path/index.php
fi
# set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"
@@ -158,8 +166,13 @@ else
echo "What would you like to call this installation of OpenDRS? If you accept"
echo "the default, it will be called OpenDRS. If you will be running multiple"
echo "instances of OpenDRS on this server, you should choose a distinctive name."
echo "This can be changed later in the application itself."
echo -n "Installation name [OpenDRS]: "
read new_inst_name
if [ "$new_inst_name" = "" ]
then
new_inst_name="OpenDRS"
fi
echo ""
# Create initial database
@@ -226,7 +239,14 @@ else
# copy distribution to install location
echo "Installing distribution . . ."
cp -Rv distfiles/* $install_path
if [ ! -L "$install_path/jquery-ui" ]
then
ln -s $install_path/jquery-ui* $install_path/jquery-ui
fi
if [ ! -L "$install_path/index.php" ]
then
ln -s $install_path/writeups.php $install_path/index.php
fi
# set ownership
echo "In order to set the ownership correctly, we need to know the user and"
echo "group that the webserver expects its files to be owned by. This is"

View File

@@ -37,7 +37,12 @@ CREATE TABLE `banners` (
LOCK TABLES `banners` WRITE;
/*!40000 ALTER TABLE `banners` DISABLE KEYS */;
INSERT INTO `banners` VALUES (1,'no banner','#000000','#000000'),(2,'UNCLASSIFIED','#009900','#FFFFFF'),(3,'CONFIDENTIAL','#000099','#FFFFFF'),(4,'SECRET','#990000','#FFFFFF'),(5,'TOP SECRET','#FF6600','#FFFFFF');
INSERT INTO `banners` VALUES
(1,'no banner','#000000','#FFFFFF'),
(2,'UNCLASSIFIED','#009900','#FFFFFF'),
(3,'CONFIDENTIAL','#000099','#FFFFFF'),
(4,'SECRET','#990000','#FFFFFF'),
(5,'TOP SECRET','#FF6600','#FFFFFF');
/*!40000 ALTER TABLE `banners` ENABLE KEYS */;
UNLOCK TABLES;
@@ -63,7 +68,38 @@ CREATE TABLE `config` (
LOCK TABLES `config` WRITE;
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
INSERT INTO `config` VALUES (1,'drs_version','1.1.2','1.1.2'),(5,'app_name','OpenDRS - Discrepancy Reporting System','OpenDRS Discrepancy Reporting System'),(6,'banner','1','1'),(7,'background_color','0B3144','0B3144'),(8,'p_background_color','FFFFFF','FFFFFF'),(11,'menubg_color','000000','000000'),(12,'p_menubg_color','FFFFFF','FFFFFF'),(13,'text_color','FFFFFF','FFFFFF'),(14,'p_text_color','000000','000000'),(15,'link_color','79EFEA','79EFEA'),(16,'p_link_color','000000','000000'),(17,'vlink_color','79EFEA','79EFEA'),(18,'p_vlink_color','000000','000000'),(19,'heading_color','5AE2B3','5AE2B3'),(20,'p_heading_color','000000','000000'),(21,'footer_message','Please report bugs to Rod Wright (software@rodsplace.net)','Please report bugs to Rod Wright (software@rodsplace.net)'),(26,'unix_server_session_dir','/tmp/opendrs/opendrs/sessions','/tmp/opendrs/opendrs/sessions'),(27,'win_server_session_dir','c:\\Windows\\Temp\\opendrs\\opendrs\\sessions','c:\\Windows\\Temp\\opendrs\\opendrs\\sessions'),(28,'session_ttl_days','30','30'),(29,'period_eff_help_txt','If maintenance issues prevented the training objectives from being achieved and you will have to come back and redo the same training, answer Non-effective. Otherwise, answer Effective.','If maintenance issues prevented the training objectives from being achieved and you will have to come back and redo the same training, answer Non-effective. Otherwise, answer Effective.');
INSERT INTO `config` VALUES
(1,'drs_version','1.3.2','1.3.2'),
(5,'app_name','OpenDRS - Discrepancy Reporting System','OpenDRS Discrepancy Reporting System'),
(6,'banner','1','1'),
(7,'background_color','0B3144','0B3144'),
(8,'p_background_color','FFFFFF','FFFFFF'),
(11,'menubg_color','000000','000000'),
(12,'p_menubg_color','FFFFFF','FFFFFF'),
(13,'text_color','FFFFFF','FFFFFF'),
(14,'p_text_color','000000','000000'),
(15,'link_color','79EFEA','79EFEA'),
(16,'p_link_color','000000','000000'),
(17,'vlink_color','79EFEA','79EFEA'),
(18,'p_vlink_color','000000','000000'),
(19,'heading_color','5AE2B3','5AE2B3'),
(20,'p_heading_color','000000','000000'),
(21,'footer_message','Please report bugs to Rod Wright (software@rodsplace.net)','Please report bugs to Rod Wright (software@rodsplace.net)'),
(26,'unix_server_session_dir','/tmp/opendrs/opendrs/sessions','/tmp/opendrs/opendrs/sessions'),
(27,'win_server_session_dir','c:\\Windows\\Temp\\opendrs\\opendrs\\sessions','c:\\Windows\\Temp\\opendrs\\opendrs\\sessions'),
(28,'session_ttl_days','30','30'),
(29,'functional_help_txt','If this discrepancy renders the device unusable, answer No. Otherwise, answer Yes.',
'If this discrepancy renders the device unusable, answer No. Otherwise, answer Yes.'),
(30,'device_term','Device','Device'),
(31,'discovered_term','When Discovered','When Discovered'),
(32,'discovered_term_short','When Disc','When Disc'),
(33,'functional_term','Functional','Functional'),
(34,'functional_term_short','Func','Func'),
(35,'functional_yes','Functional','Functional'),
(36,'functional_no','Non-functional','Non-functional'),
(37,'functional_yes_short','OK','OK'),
(38,'functional_no_short','INOP','INOP'),
(39,'disc_drop_data','Name','Name');
/*!40000 ALTER TABLE `config` ENABLE KEYS */;
UNLOCK TABLES;
@@ -115,28 +151,29 @@ LOCK TABLES `links` WRITE;
UNLOCK TABLES;
--
-- Table structure for table `periods`
-- Table structure for table `discovered`
--
DROP TABLE IF EXISTS `periods`;
DROP TABLE IF EXISTS `discovered`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `periods` (
`id` int(11) NOT NULL,
`times` text NOT NULL,
CREATE TABLE `discovered` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`whendiscoveredname` text NOT NULL,
`whendiscovereddesc` text NOT NULL,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `periods`
-- Dumping data for table `discovered`
--
LOCK TABLES `periods` WRITE;
/*!40000 ALTER TABLE `periods` DISABLE KEYS */;
INSERT INTO `periods` VALUES (1,'0600 brief, 0645 box, 0830 debrief, 0930 end',1),(2,'0745 brief, 0830 box, 1015 debrief, 1115 end',1),(3,'0930 brief, 1015 box, 1200 debrief, 1300 end',1),(4,'1115 brief, 1200 box, 1345 debrief, 1445 end',1),(5,'1300 brief, 1345 box, 1530 debrief, 1630 end',1),(6,'1445 brief, 1530 box, 1715 debrief, 1815 end',1),(7,'1630 brief, 1715 box, 1900 debrief, 2000 end',1),(8,'1815 brief, 1900 box, 2045 debrief, 2145 end',1);
/*!40000 ALTER TABLE `periods` ENABLE KEYS */;
LOCK TABLES `discovered` WRITE;
/*!40000 ALTER TABLE `discovered` DISABLE KEYS */;
INSERT INTO `discovered` VALUES (1,'Install','Initial installation',1);
/*!40000 ALTER TABLE `discovered` ENABLE KEYS */;
UNLOCK TABLES;
--
@@ -236,6 +273,7 @@ CREATE TABLE `devices` (
LOCK TABLES `devices` WRITE;
/*!40000 ALTER TABLE `devices` DISABLE KEYS */;
INSERT INTO `devices` VALUES (1,'OpenDRS Server',1);
/*!40000 ALTER TABLE `devices` ENABLE KEYS */;
UNLOCK TABLES;
@@ -278,8 +316,8 @@ DROP TABLE IF EXISTS `writeups`;
CREATE TABLE `writeups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`device` int(11) NOT NULL,
`period` int(11) NOT NULL,
`period_effective` tinyint(1) NOT NULL,
`discovered` int(11) NOT NULL,
`functional` tinyint(1) NOT NULL,
`reported_by` tinytext NOT NULL,
`report_date` date NOT NULL,
`report_time` time NOT NULL,
@@ -301,6 +339,7 @@ CREATE TABLE `writeups` (
LOCK TABLES `writeups` WRITE;
/*!40000 ALTER TABLE `writeups` DISABLE KEYS */;
INSERT INTO `writeups` VALUES (1,1,1,1,'R. Wright',CURRENT_DATE(),CURRENT_TIME(),1,'This is a new installation of OpenDRS. There is one admin user (username: drsadmin password: OpenDRS-1). You should immediately log in and click on Manage Database under Admin Functions, go to the User Management tab, and add yourself as a new user, making sure to click the Admin checkbox to give yourself admin rights. You should then edit the DRS Admin user by clicking the User ID number in the table of existing users, and uncheck the Active checkbox. After you have done that, you can close this writeup.',1,0,NULL,NULL,0,NULL);
/*!40000 ALTER TABLE `writeups` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

View File

@@ -39,3 +39,190 @@ UPDATE config SET defaultvalue="c:\Windows\Temp\opendrs\opendrs\sessions" WHERE
-- Update version number
UPDATE config SET value="1.1.2",defaultvalue="1.1.2" WHERE name="drs_version";
-- --------------------------------------
-- ---------- version 1.2.0 -------------
-- Update version number
UPDATE config SET value="1.2.0",defaultvalue="1.2.0" WHERE name="drs_version";
-- Add device_term to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'device_term',
'Device' AS wval,
'Device' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT name FROM config WHERE name = 'device_term'
) LIMIT 1
;
-- Add discovered_term to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'discovered_term',
'When Discovered' AS wval,
'When Discovered' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT name FROM config WHERE name = 'discovered_term'
) LIMIT 1
;
-- Add discovered_term_short to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'discovered_term_short',
'When Disc' AS wval,
'When Disc' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT name FROM config WHERE name = 'discovered_term_short'
) LIMIT 1
;
-- Add disc_drop_data to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'disc_drop_data',
'Name' AS wval,
'Name' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT name FROM config WHERE name = 'disc_drop_data'
) LIMIT 1
;
-- Add functional_term to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_term',
'Functional' AS wval,
'Functional' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_term"
) LIMIT 1
;
-- Add functional_term_short to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_term_short',
'Func' AS wval,
'Func' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_term_short"
) LIMIT 1
;
-- Add functional_yes to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_yes',
'Functional' AS wval,
'Functional' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_yes"
) LIMIT 1
;
-- Add functional_no to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_no',
'Non-functional' AS wval,
'Non-functional' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_no"
) LIMIT 1
;
-- Add functional_yes_short to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_yes_short',
'OK' AS wval,
'OK' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_yes_short"
) LIMIT 1
;
-- Add functional_no_short to config table
INSERT INTO config(name,value,defaultvalue)
SELECT * FROM
(SELECT 'functional_no_short',
'INOP' AS wval,
'INOP' AS dval
)
AS tmp
WHERE NOT EXISTS
(
SELECT `name` FROM `config` WHERE `name` = "functional_no_short"
) LIMIT 1
;
-- Rename period_eff_help_txt config to functional_help_txt
UPDATE `config` SET name="functional_help_txt" WHERE name="period_eff_help_txt";
-- Change the default value of functional_help_text
UPDATE `config` SET defaultvalue="If this discrepancy renders the device unusable, answer No. Otherwise, answer Yes." WHERE name="function_help_txt";
-- Rename periods table to discovered
RENAME TABLE `periods` TO `discovered`;
-- Add whendiscoveredname column to discovered table
ALTER TABLE `discovered` ADD COLUMN `whendiscoveredname` text NOT NULL AFTER id;
-- Copy the contents of the id column to the whendiscoveredname column where whendiscoveredname is empty
UPDATE `discovered` SET `whendiscoveredname`=`id` WHERE `whendiscoveredname`="";
-- Rename times column of discovered table to whendiscovereddesc
ALTER TABLE `discovered` CHANGE COLUMN `times` `whendiscovereddesc` text not null;
-- Add auto_increment flag to id column
ALTER TABLE `discovered` CHANGE COLUMN `id` `id` text not null auto_increment;
-- Rename period column of writeups table to discovered
ALTER TABLE `writeups` CHANGE COLUMN `period` `discovered` int not null;
-- Rename period_effective column of writeups table to functional
ALTER TABLE `writeups` CHANGE COLUMN `period_effective` `functional` tinyint(1) not null;
-- --------------------------------------
-- ---------- version 1.3.0 -------------
-- Update version number
UPDATE config SET value="1.3.0",defaultvalue="1.3.0" WHERE name="drs_version";
-- --------------------------------------
-- ---------- version 1.3.1 -------------
-- Update version number
UPDATE config SET value="1.3.1",defaultvalue="1.3.1" WHERE name="drs_version";
-- --------------------------------------
-- ---------- version 1.3.2 -------------
-- Update version number
UPDATE config SET value="1.3.2",defaultvalue="1.3.2" WHERE name="drs_version";
-- --------------------------------------