Compare commits
1 Commits
main
...
v1.5.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f84d3bcbc |
35
CHANGELOG
35
CHANGELOG
@@ -1,5 +1,5 @@
|
||||
OpenDRS - Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 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
|
||||
@@ -180,36 +180,3 @@ Changelog
|
||||
Open Writeups page entirely. The writeups page now shows all
|
||||
writeups for the selected date range, or today if no dates are
|
||||
specified.
|
||||
|
||||
1.4.4 - 2025-12-10
|
||||
- Fixed bug in writeupdetail.php that emerged with installation on a
|
||||
system using MariaDB-10.11.14. A fatal error occurred when
|
||||
trying to insert a null value into the action_reason field of
|
||||
the writeups table (you left the action reason dropdown blank).
|
||||
Previous versions just left it as is without complaint.
|
||||
|
||||
1.4.5 - 2025-12-16
|
||||
- Various problems were noted resulting from php's use of UTC as the
|
||||
default timezone. Now, on installation or upgrade, the installer
|
||||
gets the correct timezone from the system and sets it as a php
|
||||
option in a .htaccess file in the install location. This solves
|
||||
multiple problems and allows today's date and the current time
|
||||
to be determined from the php date() function as part of the
|
||||
settings.php once per page load instead of having to query the
|
||||
database multiple times per page load. Also added the option to
|
||||
allow apache to read the .htaccess file to the <Directory>
|
||||
section of the application's conf file in
|
||||
/etc/apache2/conf-available
|
||||
- Renamed the installer's opendrs-update.sh script to files_update.sh
|
||||
to align with the standardized installation process used by
|
||||
other applications.
|
||||
- Changed the install.sh script to align with the standardized
|
||||
installation process used by other applications.
|
||||
|
||||
1.4.6 - 2026-02-06
|
||||
- Fixed bug in group_detail() function in common.php where the link
|
||||
members were being sorted by linkid instead of writeupid. This
|
||||
caused the group writeup table to be ordered based on when the
|
||||
writeup was added to the group instead of in the logical writeup
|
||||
order.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
boilerplate.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# database-update.sh
|
||||
# OpenLog Online Logbook
|
||||
# Copyright (C) 2026 Rod Wright
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
if [[ $1 == "" ]]
|
||||
then
|
||||
echo "This script requires a mysql options file, but none was specified. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mysql_opt_file=$1
|
||||
if [[ ! -f $mysql_opt_file ]]
|
||||
then
|
||||
echo "The mysql options file specified does not exist. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
margs="--defaults-extra-file=$mysql_opt_file"
|
||||
|
||||
# ---------- version x.x.x ----------
|
||||
# Nothing to be done for versions prior to 1.4.5
|
||||
# -----------------------------------
|
||||
|
||||
# ---------- version 1.4.5 ----------
|
||||
# Nothing to be done
|
||||
# -----------------------------------
|
||||
|
||||
# ---------- version 1.4.6 ----------
|
||||
# Nothing to be done
|
||||
# -----------------------------------
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
db.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -14,7 +14,6 @@
|
||||
** DO NOT EDIT **
|
||||
************************************************************************
|
||||
*/
|
||||
$appname="APPNAME";
|
||||
$dbname="DBNAME";
|
||||
$username="DBUSER";
|
||||
$dbpass="DBPASS";
|
||||
@@ -27,7 +26,7 @@ function dberrmsg($dbname) {
|
||||
</head>
|
||||
<body>
|
||||
Could not connect to the $dbname database. Please ensure the MySQL server is running. If this is
|
||||
the first time you have used $appname, please consult the INSTALL file included in the distribution.
|
||||
the first time you have used OpenMTS, please consult the INSTALL file included in the distribution.
|
||||
</body>
|
||||
</html>
|
||||
";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
OpenDRS - Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 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
|
||||
@@ -180,35 +180,3 @@ Changelog
|
||||
Open Writeups page entirely. The writeups page now shows all
|
||||
writeups for the selected date range, or today if no dates are
|
||||
specified.
|
||||
|
||||
1.4.4 - 2025-12-10
|
||||
- Fixed bug in writeupdetail.php that emerged with installation on a
|
||||
system using MariaDB-10.11.14. A fatal error occurred when
|
||||
trying to insert a null value into the action_reason field of
|
||||
the writeups table (you left the action reason dropdown blank).
|
||||
Previous versions just left it as is without complaint.
|
||||
|
||||
1.4.5 - 2025-12-16
|
||||
- Various problems were noted resulting from php's use of UTC as the
|
||||
default timezone. Now, on installation or upgrade, the installer
|
||||
gets the correct timezone from the system and sets it as a php
|
||||
option in a .htaccess file in the install location. This solves
|
||||
multiple problems and allows today's date and the current time
|
||||
to be determined from the php date() function as part of the
|
||||
settings.php once per page load instead of having to query the
|
||||
database multiple times per page load. Also added the option to
|
||||
allow apache to read the .htaccess file to the <Directory>
|
||||
section of the application's conf file in
|
||||
/etc/apache2/conf-available
|
||||
- Renamed the installer's opendrs-update.sh script to files_update.sh
|
||||
to align with the standardized installation process used by
|
||||
other applications.
|
||||
- Changed the install.sh script to align with the standardized
|
||||
installation process used by other applications.
|
||||
|
||||
1.4.6 - 2026-02-06
|
||||
- Fixed bug in group_detail() function in common.php where the link
|
||||
members were being sorted by linkid instead of writeupid. This
|
||||
caused the group writeup table to be ordered based on when the
|
||||
writeup was added to the group instead of in the logical writeup
|
||||
order.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
about.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
changelog.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
common.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -785,7 +785,7 @@ function group_detail($groupid,$role=false,$mode="view",$selection="none") {
|
||||
";
|
||||
}
|
||||
|
||||
$writeup_qry=mysqli_query($drs_db,"select writeupid from links where linkgroup=$groupid order by writeupid asc");
|
||||
$writeup_qry=mysqli_query($drs_db,"select writeupid from links where linkgroup=$groupid");
|
||||
while ($writeup=mysqli_fetch_row($writeup_qry)) {
|
||||
// get writeup data
|
||||
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id={$writeup[0]}"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
config.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
create.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -93,6 +93,9 @@ framework("begin","$appname","New Writeup",$print);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
// determine today's date and make it the default
|
||||
$today=date("Y-m-d");
|
||||
$now=date("H:i:s");
|
||||
if (!isset($report_date) || $report_date=="automatic") $report_date=$today;
|
||||
if (!isset($report_time) || $report_time=="automatic") $report_time=$now;
|
||||
|
||||
@@ -130,7 +133,7 @@ echo "<br>";
|
||||
// display the form
|
||||
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 View Writeups page.</a>");
|
||||
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;
|
||||
}
|
||||
if ($device==NULL) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
dbadmin.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
gpl.php
|
||||
OpenMTS Online Maintenance Tracking System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
groups.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -54,18 +54,28 @@ extract($incoming, EXTR_SKIP);
|
||||
* possible keys are:
|
||||
* action
|
||||
* save
|
||||
* targets
|
||||
* candidates
|
||||
* group
|
||||
* name
|
||||
* search
|
||||
* viewtype
|
||||
* s_status
|
||||
* s_group
|
||||
* s_device
|
||||
* s_subsystem
|
||||
* s_id
|
||||
* s_discovered
|
||||
* 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_discrepancy_text
|
||||
* s_reported_by
|
||||
* s_functional
|
||||
@@ -75,17 +85,28 @@ extract($incoming, EXTR_SKIP);
|
||||
* edit_action_date
|
||||
* edit_action_time
|
||||
* edit_action_text
|
||||
* sort
|
||||
* order
|
||||
*/
|
||||
|
||||
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($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 (!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($viewtype)) $viewtype="summary";
|
||||
if (!isset($s_id)) $s_id=NULL;
|
||||
if (!isset($group)) $group=NULL;
|
||||
if (!isset($name)) $name=NULL;
|
||||
|
||||
@@ -106,13 +127,17 @@ $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);
|
||||
echo "_REQUEST array <br>";
|
||||
var_dump($_REQUEST);
|
||||
echo "<br><hr> incoming array <br>";
|
||||
var_dump($incoming);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
// determine today's date and make it the default
|
||||
$today=date("Y-m-d");
|
||||
$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];
|
||||
@@ -132,11 +157,11 @@ if ($action=="add" && $role && $save) {
|
||||
$fail=mysqli_error($drs_db);
|
||||
$group=mysqli_insert_id($drs_db);
|
||||
}
|
||||
foreach ($targets as $target) {
|
||||
foreach ($candidates as $candidate) {
|
||||
// add writeup to the group
|
||||
if (!mysqli_num_rows(mysqli_query($drs_db,"select id from links where writeupid=\"$target\" and linkgroup=\"$group\""))) {
|
||||
// target is not already a member of this group
|
||||
mysqli_query($drs_db,"insert into links (linkgroup,writeupid) values($group,$target)");
|
||||
if (!mysqli_num_rows(mysqli_query($drs_db,"select id from links where writeupid=\"$candidate\" and linkgroup=\"$group\""))) {
|
||||
// candidate is not already a member of this group
|
||||
mysqli_query($drs_db,"insert into links (linkgroup,writeupid) values($group,$candidate)");
|
||||
$fail=mysqli_error($drs_db);
|
||||
}
|
||||
}
|
||||
@@ -148,7 +173,7 @@ if ($action=="add" && $role && $save) {
|
||||
$writeups[]=$writeuprow[0];
|
||||
}
|
||||
foreach ($writeups as $writeup) {
|
||||
if (!isset($targets) || !in_array($writeup,$targets)) {
|
||||
if (!isset($candidates) || !in_array($writeup,$candidates)) {
|
||||
// remove writeup from group
|
||||
mysqli_query($drs_db,"delete from links where writeupid=$writeup and linkgroup=$group");
|
||||
$fail=mysqli_error($drs_db);
|
||||
@@ -202,14 +227,16 @@ if ($action=="add" && $role && $save) {
|
||||
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);
|
||||
$s_id=trim($s_id);
|
||||
|
||||
// build the query string
|
||||
$query_string="";
|
||||
// device
|
||||
if (isset($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);
|
||||
@@ -217,7 +244,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 ";
|
||||
@@ -238,6 +265,16 @@ if ($search) {
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
}
|
||||
// id
|
||||
if ($s_id!=NULL) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}id={$s_id}";
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
$id_param="ID: {$s_id}";
|
||||
} else {
|
||||
$id_param="ID: any";
|
||||
}
|
||||
// discovered
|
||||
if (isset($s_discovered)) {
|
||||
$query_string="{$query_string}(";
|
||||
@@ -285,6 +322,46 @@ if ($search) {
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
}
|
||||
// action by
|
||||
if ($s_action_by) {
|
||||
$query_string="{$query_string}(";
|
||||
$actionby_param="Status changed by:";
|
||||
foreach ($s_action_by as $actby_val) {
|
||||
$query_string="{$query_string}action_by=\"{$actby_val}\" or ";
|
||||
if ($actby_val==0) {
|
||||
$actionby_dsp=" (none set)";
|
||||
} else {
|
||||
$actionby_dsp=dblookup($drs_db,"users","id","firstname",$actby_val)." ".dblookup($drs_db,"users","id","lastname",$actby_val);
|
||||
}
|
||||
$actionby_param="{$actionby_param} {$actionby_dsp}, ";
|
||||
}
|
||||
$actionby_param=rtrim($actionby_param,", ");
|
||||
$num_users=mysqli_num_rows(mysqli_query($drs_db,"select id from users"));
|
||||
if (count($s_action_by)==$num_users+1) $actionby_param="Status changed by: any";
|
||||
$query_string=rtrim($query_string," or ");
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
}
|
||||
// action reason
|
||||
if ($s_action_reason) {
|
||||
$query_string="{$query_string}(";
|
||||
$reason_param="Status change reason:";
|
||||
foreach ($s_action_reason as $actrn_val) {
|
||||
$query_string="{$query_string}action_reason=\"{$actrn_val}\" or ";
|
||||
if ($actrn_val==0) {
|
||||
$reason_dsp=" (none set)";
|
||||
} else {
|
||||
$reason_dsp=dblookup($drs_db,"reasons","id","text",$actrn_val);
|
||||
}
|
||||
$reason_param="{$reason_param} {$reason_dsp}, ";
|
||||
}
|
||||
$reason_param=rtrim($reason_param,", ");
|
||||
$num_reasons=mysqli_num_rows(mysqli_query($drs_db,"select id from reasons"));
|
||||
if (count($s_action_reason)==$num_reasons+1) $reason_param="Status change reason: any";
|
||||
$query_string=rtrim($query_string," or ");
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
}
|
||||
// report date
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}report_date between \"{$s_report_date_start}\" and \"{$s_report_date_end}\"";
|
||||
@@ -297,8 +374,28 @@ if ($search) {
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
$reporttime_param="Report time between {$s_report_time_start} and {$s_report_time_end}";
|
||||
// action date
|
||||
if ($s_action_date_start && $s_action_date_end) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}action_date between \"{$s_action_date_start}\" and \"{$s_action_date_end}\"";
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
$actiondate_param="Action taken date between {$s_action_date_start} and {$s_action_date_end}";
|
||||
} else {
|
||||
$actiondate_param="Action taken date: any";
|
||||
}
|
||||
// action time
|
||||
if ($s_action_time_start && $s_action_time_end) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}action_time between \"{$s_action_time_start}\" and \"{$s_action_time_end}\"";
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
$actiontime_param="Action taken time between {$s_action_time_start} and {$s_action_time_end}";
|
||||
} else {
|
||||
$actiontime_param="Action taken time: any";
|
||||
}
|
||||
// discrepancy text
|
||||
if (isset($s_discrepancy_text)) {
|
||||
if ($s_discrepancy_text!=NULL) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}discrepancy_text like \"%{$s_discrepancy_text}%\"";
|
||||
$query_string="{$query_string})";
|
||||
@@ -307,8 +404,18 @@ if ($search) {
|
||||
} else {
|
||||
$discrepancytext_param="Text in discrepancy: any";
|
||||
}
|
||||
// action text
|
||||
if ($s_action_text) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}action_text like \"%{$s_action_text}%\"";
|
||||
$query_string="{$query_string})";
|
||||
$query_string="{$query_string} and ";
|
||||
$actiontext_param="Text in Action taken: {$s_action_text}";
|
||||
} else {
|
||||
$actiontext_param="Text in Action taken: any";
|
||||
}
|
||||
// reported by
|
||||
if (isset($s_reported_by)) {
|
||||
if ($s_reported_by!=NULL) {
|
||||
$query_string="{$query_string}(";
|
||||
$query_string="{$query_string}reported_by like \"%{$s_reported_by}%\"";
|
||||
$query_string="{$query_string})";
|
||||
@@ -320,6 +427,24 @@ if ($search) {
|
||||
|
||||
$query_string=rtrim($query_string," and ");
|
||||
$query_string="select * from writeups where {$query_string} order by report_date asc";
|
||||
|
||||
// group membership
|
||||
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) {
|
||||
$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";
|
||||
}
|
||||
}
|
||||
|
||||
// ******** end database manipulation ********
|
||||
@@ -335,8 +460,8 @@ banner($print);
|
||||
echo "<br>";
|
||||
|
||||
if ($action=="add") {
|
||||
if (!isset($targets)) $targets=[];
|
||||
if (count($targets) > 1) {
|
||||
if (!isset($candidates)) $candidates=[];
|
||||
if (count($candidates) > 1) {
|
||||
$plural="s";
|
||||
} else {
|
||||
$plural="";
|
||||
@@ -370,7 +495,7 @@ if ($action=="add") {
|
||||
}
|
||||
} else {
|
||||
if ($role){
|
||||
// show mini search with discrepancy data only
|
||||
// show search form
|
||||
echo "
|
||||
<form method=post action=\"groups.php\">
|
||||
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||
@@ -380,24 +505,11 @@ if ($action=="add") {
|
||||
<tr>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// Status cell **********************
|
||||
|
||||
// ID cell *****************
|
||||
echo "
|
||||
Status<br>
|
||||
";
|
||||
if ($search) {
|
||||
$openstate=$clsdstate=$dfrdstate="";
|
||||
if (in_array("1",$s_status,true)) $openstate="selected";
|
||||
if (in_array("2",$s_status,true)) $clsdstate="selected";
|
||||
if (in_array("3",$s_status,true)) $dfrdstate="selected";
|
||||
} else {
|
||||
$openstate=$clsdstate=$dfrdstate="selected";
|
||||
}
|
||||
echo "
|
||||
<select name=\"s_status[]\" id=\"ms-status\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||
<option title=\"Open\" value=\"1\" $openstate>OPEN</option>
|
||||
<option title=\"Closed\" value=\"2\" $clsdstate>CLSD</option>
|
||||
<option title=\"Deferred\" value=\"3\" $dfrdstate>DFRD</option>
|
||||
</select>
|
||||
ID<br>
|
||||
<input type=\"text\" name=\"s_id\" size=\"10\" value=\"$s_id\">
|
||||
";
|
||||
// **********************************
|
||||
echo "
|
||||
@@ -406,7 +518,7 @@ if ($action=="add") {
|
||||
";
|
||||
// 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");
|
||||
@@ -455,12 +567,19 @@ if ($action=="add") {
|
||||
$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.\">
|
||||
";
|
||||
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["whendiscovereddesc"],$discitem["whendiscoveredname"]);
|
||||
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["whendiscovereddesc"],$discitem["whendiscoveredname"]);
|
||||
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
@@ -538,93 +657,509 @@ if ($action=="add") {
|
||||
<option value=\"1\" $funcyesstate>$functional_yes</option>
|
||||
<option value=\"0\" $funcnostate>$functional_no</option>
|
||||
</select>
|
||||
</td>
|
||||
";
|
||||
// **********************************"
|
||||
// **********************************
|
||||
echo "
|
||||
<td align=\"right\">
|
||||
<input type=\"submit\" name=\"search\" value=\"Find Writeups\">
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>";
|
||||
// display the results
|
||||
if ($search) {
|
||||
$writeup_qry=mysqli_query($drs_db,$query_string);
|
||||
if (mysqli_num_rows($writeup_qry)) {
|
||||
echo "
|
||||
<form method=post action=\"groups.php\">
|
||||
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||
<input type=\"hidden\" name=\"action\" value=\"add\">
|
||||
<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
|
||||
<tr>
|
||||
<th style=\"width:1%;\">Select</th>
|
||||
<th style=\"width:1%;\">ID</th>
|
||||
<th style=\"width:1%;\">Status</th>
|
||||
<th style=\"width:100px;\">Date</th>
|
||||
<th style=\"width:1%;\">Device</th>
|
||||
<th style=\"width:1%;\">Reported by</th>
|
||||
<th>Discrepancy</th>
|
||||
<th style=\"width:1%;\">$functional_term_short</th>
|
||||
</tr>
|
||||
";
|
||||
while ($tablerow = mysqli_fetch_assoc($writeup_qry)) {
|
||||
// determine functional icon
|
||||
if($tablerow["functional"]==1) {
|
||||
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes\">";
|
||||
} else {
|
||||
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no\">";
|
||||
}
|
||||
|
||||
// determine status indicator
|
||||
if ($tablerow['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
|
||||
if ($tablerow['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
|
||||
if ($tablerow['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
|
||||
|
||||
// convert device number to name
|
||||
$dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]);
|
||||
$disc_txt="{$tablerow["discrepancy_text"]}";
|
||||
// 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 ($is_member) {
|
||||
$group_count=$is_member;
|
||||
$member_group=mysqli_fetch_row($member_qry)[0];
|
||||
$member_group_name=dblookup($drs_db,"groups","id","name",$member_group);
|
||||
if ($member_group_name) {
|
||||
$imgtitle="Member of group: $member_group_name";
|
||||
} else {
|
||||
$imgtitle="Member of group ID: $member_group";
|
||||
}
|
||||
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>";
|
||||
}
|
||||
}
|
||||
// print table row
|
||||
printf(
|
||||
"<tr>
|
||||
<td align=\"center\" valign=\"top\"><input type=\"checkbox\" name=\"targets[]\" value=\"%s\"></td>
|
||||
<td align=\"center\" valign=\"top\"><a href=\"writeupdetail.php?id=%s\" title=\"View or change details of this writeup\">%s</a></td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td align=\"center\" valign=\"top\">%s</td>
|
||||
</tr>\n",
|
||||
$tablerow["id"],
|
||||
$tablerow["id"],$tablerow["id"],
|
||||
$statusind,
|
||||
$tablerow["report_date"],
|
||||
$dname,
|
||||
$tablerow["reported_by"],
|
||||
$disc_txt,
|
||||
$func_icon
|
||||
);
|
||||
</td>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// Group status cell **************
|
||||
echo "
|
||||
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 (!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 {
|
||||
$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>
|
||||
<tr><td colspan=\"3\" bgcolor=\"black\"></td></tr>
|
||||
<tr><td colspan=\"3\" bgcolor=\"black\"></td></tr>
|
||||
<tr>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// Status cell **********************
|
||||
echo "
|
||||
Status<br>
|
||||
";
|
||||
if ($search) {
|
||||
$openstate=$clsdstate=$dfrdstate="";
|
||||
if (in_array("1",$s_status,true)) $openstate="selected";
|
||||
if (in_array("2",$s_status,true)) $clsdstate="selected";
|
||||
if (in_array("3",$s_status,true)) $dfrdstate="selected";
|
||||
} else {
|
||||
$openstate=$clsdstate=$dfrdstate="selected";
|
||||
}
|
||||
echo "
|
||||
<select name=\"s_status[]\" id=\"ms-status\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||
<option title=\"Open\" value=\"1\" $openstate>OPEN</option>
|
||||
<option title=\"Closed\" value=\"2\" $clsdstate>CLSD</option>
|
||||
<option title=\"Deferred\" value=\"3\" $dfrdstate>DFRD</option>
|
||||
</select>
|
||||
";
|
||||
// **********************************
|
||||
echo "
|
||||
</td>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// action by cell ************
|
||||
echo "
|
||||
Status changed by<br>
|
||||
<select name=\"s_action_by[]\" id=\"ms-user\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||
<option value=\"0\" selected>(none set)</option>
|
||||
";
|
||||
$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>
|
||||
";
|
||||
// ***********************************
|
||||
echo "
|
||||
</td>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// action reason cell *********
|
||||
echo "
|
||||
Status change reason<br>
|
||||
<select name=\"s_action_reason[]\" id=\"ms-reason\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||
<option value=\"0\" selected>(none set)</option>
|
||||
";
|
||||
$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>
|
||||
";
|
||||
// ***********************************
|
||||
echo "
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td></td><td></td><td></td></tr>
|
||||
<tr>
|
||||
<td colspan=\"3\">
|
||||
";
|
||||
// Action taken text cell ************
|
||||
echo "
|
||||
Words in Action Taken<br>
|
||||
<textarea rows=\"5\" cols=\"80\" name=\"s_action_text\" wrap=\"soft\">$s_action_text</textarea><br>
|
||||
";
|
||||
// ***********************************
|
||||
echo "
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=\"left\" >
|
||||
";
|
||||
// Action date cell ******************
|
||||
echo "
|
||||
Action Taken Date Between<br>
|
||||
<input type=\"text\" name=\"s_action_date_start\" size=\"10\" maxlength=\"10\" value=\"$s_action_date_start\" id=\"sdp-action_date\" title=\"Format: YYYY-MM-DD\">
|
||||
and
|
||||
<input type=\"text\" name=\"s_action_date_end\" size=\"10\" maxlength=\"10\" value=\"$s_action_date_end\" id=\"edp-action_date\" title=\"Format: YYYY-MM-DD\">
|
||||
";
|
||||
// ***********************************
|
||||
echo "
|
||||
</td>
|
||||
<td align=\"left\">
|
||||
";
|
||||
// Action time cell ******************
|
||||
echo "
|
||||
Action Taken Time Between<br>
|
||||
<input type=\"text\" name=\"s_action_time_start\" size=\"8\" maxlength=\"8\" value=\"$s_action_time_start\" title=\"Format: HH:MM:SS\">
|
||||
and
|
||||
<input type=\"text\" name=\"s_action_time_end\" size=\"8\" maxlength=\"8\" value=\"$s_action_time_end\" title=\"Format: HH:MM:SS\">
|
||||
";
|
||||
// ***********************************
|
||||
$summarystat=$detailstat="";
|
||||
if ($viewtype=="detail") {
|
||||
$detailstat="checked";
|
||||
} else {
|
||||
$summarystat="checked";
|
||||
}
|
||||
$idsort=$statussort=$datesort=$discsort=$devicesort=$subsyssort=$repbysort=$discrepsort=$funcsort="";
|
||||
switch ($sort) {
|
||||
case "id":
|
||||
$idsort="checked";
|
||||
break;
|
||||
case "status":
|
||||
$statussort="checked";
|
||||
break;
|
||||
case "report_date":
|
||||
$datesort="checked";
|
||||
break;
|
||||
case "discovered":
|
||||
$discsort="checked";
|
||||
break;
|
||||
case "device":
|
||||
$devicesort="checked";
|
||||
break;
|
||||
case "subsystem":
|
||||
$subsyssort="checked";
|
||||
break;
|
||||
case "reported_by":
|
||||
$repbysort="checked";
|
||||
break;
|
||||
case "discrepancy_text":
|
||||
$discrepsort="checked";
|
||||
break;
|
||||
case "functional":
|
||||
$funcsort="checked";
|
||||
break;
|
||||
default:
|
||||
$datesort="checked";
|
||||
}
|
||||
$ascsort=$descsort="";
|
||||
if ($order=="desc") {
|
||||
$descsort="checked";
|
||||
} else {
|
||||
$ascsort="checked";
|
||||
}
|
||||
echo "</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<input type=\"radio\" $summarystat name=\"viewtype\" value=\"summary\" id=\"summaryview\" ><label for=\"summaryview\" title=\"Show one writeup per line with minimal detail.\">Results in summary view</label>
|
||||
<input type=\"radio\" $detailstat name=\"viewtype\" value=\"detail\" id=\"detailview\"><label for=\"detailview\" title=\"Show each writeup's full details.\">Results in detail view</label>
|
||||
<br><br>
|
||||
Sort Field:<br>
|
||||
<input type=\"radio\" $idsort name=\"sort\" value=\"id\" id=\"idview\" ><label for=\"idview\" title=\"Sort by ID.\">ID</label>
|
||||
<input type=\"radio\" $statussort name=\"sort\" value=\"status\" id=\"statusview\" ><label for=\"statusview\" title=\"Sort by Status.\">Status</label>
|
||||
<input type=\"radio\" $datesort name=\"sort\" value=\"report_date\" id=\"dateview\" ><label for=\"dateview\" title=\"Sort by Report Date.\">Date</label>
|
||||
<input type=\"radio\" $discsort name=\"sort\" value=\"discovered\" id=\"discoveredview\" ><label for=\"discoveredview\" title=\"Sort by $discovered_term.\">$discovered_term_short</label>
|
||||
<input type=\"radio\" $devicesort name=\"sort\" value=\"device\" id=\"deviceview\" ><label for=\"deviceview\" title=\"Sort by $device_term.\">$device_term</label>
|
||||
<input type=\"radio\" $subsyssort name=\"sort\" value=\"subsystem\" id=\"subsysview\" ><label for=\"subsysview\" title=\"Sort by Subsystem.\">Subsystem</label>
|
||||
<input type=\"radio\" $repbysort name=\"sort\" value=\"reported_by\" id=\"repbyview\" ><label for=\"repbyview\" title=\"Sort by Reported by.\">Reported by</label>
|
||||
<input type=\"radio\" $discrepsort name=\"sort\" value=\"discrepancy_text\" id=\"discrepview\" ><label for=\"discrepview\" title=\"Sort by Discrepancy.\">Discrepancy</label>
|
||||
<input type=\"radio\" $funcsort name=\"sort\" value=\"functional\" id=\"funcview\" ><label for=\"funcview\" title=\"Sort by $functional_term.\">$functional_term_short</label>
|
||||
<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>
|
||||
<input type=\"radio\" $descsort name=\"order\" value=\"desc\" id=\"descview\" ><label for=\"descview\" title=\"Sort results in descending order.\">Descending</label>
|
||||
<br><br>
|
||||
<input type=\"submit\" name=\"search\" value=\"Search\">
|
||||
|
||||
<input type=\"submit\" name=\"cancel\" value=\"Start New Search\">
|
||||
</form>
|
||||
<br>
|
||||
";
|
||||
|
||||
// display the results ***********************************
|
||||
//display the search parameters used
|
||||
if ($search) {
|
||||
if (!$print) echo "<a id=\"results\"></a>";
|
||||
|
||||
// show the parameters used block
|
||||
echo "
|
||||
<table border=\"2\" width=\"100%\">
|
||||
<tr><td align=\"left\"><b>Parameters used in this search</b>
|
||||
";
|
||||
if (!$print) {
|
||||
echo " <font size=\"-1\">Scroll up to modify parameters</font></td>";
|
||||
} else {
|
||||
echo "</td>";
|
||||
}
|
||||
echo "
|
||||
</tr>
|
||||
<tr><td>
|
||||
<table border=\"0\">
|
||||
<td><b>$status_param</b></td><td> </td>
|
||||
<td>$device_param</td><td> </td>
|
||||
<td>$subsystem_param</td><td> </td>
|
||||
<td>$id_param</td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$discovered_param</td><td> </td>
|
||||
<td>$reportdate_param</td><td> </td>
|
||||
<td>$reporttime_param</td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$discrepancytext_param</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$repby_param</td><td> </td>
|
||||
<td>$func_param</td><td> </td>
|
||||
<td>$group_param</td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$actionby_param</td><td> </td>
|
||||
<td>$reason_param</td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$actiontext_param</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=\"0\">
|
||||
<tr>
|
||||
<td>$actiondate_param</td><td> </td>
|
||||
<td>$actiontime_param</td><td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr></table>
|
||||
<br>
|
||||
";
|
||||
|
||||
// show the results
|
||||
$currentparams=arrayCopy($_REQUEST);
|
||||
echo "
|
||||
<form method=\"post\" target=\"_blank\">
|
||||
<input type=\"hidden\" name=\"all_parameters\" value=\"". htmlentities(serialize($currentparams))."\">
|
||||
";
|
||||
$writeup=mysqli_query($drs_db,$query_string);
|
||||
// create an array of ids returned by the query string
|
||||
$result_ids=[];
|
||||
while ($eachid=mysqli_fetch_assoc($writeup)) {
|
||||
$result_ids[]=$eachid['id'];
|
||||
}
|
||||
|
||||
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 ($viewtype=="summary") {
|
||||
echo "
|
||||
<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
|
||||
<tr>
|
||||
<th style=\"width:1%;\">Select</th>
|
||||
<th style=\"width:1%;\">ID</th>
|
||||
<th style=\"width:1%;\">Status</th>
|
||||
<th style=\"width:100px;\">Date</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%;\">$functional_term_short</th>
|
||||
</tr>
|
||||
";
|
||||
while ($tablerow = mysqli_fetch_assoc($writeup)) {
|
||||
// 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);
|
||||
|
||||
// determine functional icon
|
||||
if($tablerow["functional"]==1) {
|
||||
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
|
||||
} else {
|
||||
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
|
||||
}
|
||||
|
||||
// determine status indicator
|
||||
if ($tablerow['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
|
||||
if ($tablerow['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
|
||||
if ($tablerow['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
|
||||
|
||||
// convert device number to name
|
||||
$dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]);
|
||||
// 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"]}";
|
||||
|
||||
// set group indicator
|
||||
if ($is_member) {
|
||||
$group_count=$is_member;
|
||||
if ($group_count == 1) {
|
||||
$group_num=mysqli_fetch_row(mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\""))[0];
|
||||
$member_group_name=dblookup($drs_db,"groups","id","name",$group_num);
|
||||
if ($member_group_name) {
|
||||
$imgtitle="Member of group: $member_group_name";
|
||||
} else {
|
||||
$imgtitle="Member of group ID: $group_num";
|
||||
}
|
||||
$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=\"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(in_array($tablerow['id'],$group_writeups) || count($s_group)==0) {
|
||||
// print table row
|
||||
printf(
|
||||
"<tr>
|
||||
<td align=\"center\" valign=\"top\"><input type=\"checkbox\" name=\"candidates[]\" value=\"%s\"></td>
|
||||
<td align=\"center\" valign=\"top\"><a href=\"writeupdetail.php?id=%s\" title=\"View or change details of this writeup\">%s</a></td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<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\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td align=\"center\" valign=\"top\">%s</td>
|
||||
</tr>\n",
|
||||
$tablerow["id"],
|
||||
$tablerow["id"],$tablerow["id"],
|
||||
$statusind,
|
||||
$tablerow["report_date"],
|
||||
$discdesc,$discname,
|
||||
$dname,
|
||||
$ssname,
|
||||
$tablerow["reported_by"],
|
||||
$disc_txt,
|
||||
$func_icon
|
||||
);
|
||||
}
|
||||
}
|
||||
echo "</table>\n";
|
||||
} elseif ($viewtype=="detail") {
|
||||
echo "
|
||||
<table border=\"0\"><tr><td>
|
||||
";
|
||||
while ($tablerow = mysqli_fetch_assoc($writeup)) {
|
||||
// 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(in_array($tablerow['id'],$group_writeups) || count($s_group)==0) {
|
||||
echo "<input type=\"checkbox\" name=\"candidates[]\" value={$tablerow['id']}> Select";
|
||||
displaywriteup($tablerow['id']);
|
||||
echo "<br>";
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</td></tr></table>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////begin original display
|
||||
//// display the results
|
||||
//if ($search) {
|
||||
//$writeup_qry=mysqli_query($drs_db,$query_string);
|
||||
//if (mysqli_num_rows($writeup_qry)) {
|
||||
//echo "
|
||||
//<form method=post action=\"groups.php\">
|
||||
//<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||
//<input type=\"hidden\" name=\"action\" value=\"add\">
|
||||
//<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
|
||||
//<tr>
|
||||
//<th style=\"width:1%;\">Select</th>
|
||||
//<th style=\"width:1%;\">ID</th>
|
||||
//<th style=\"width:1%;\">Status</th>
|
||||
//<th style=\"width:100px;\">Date</th>
|
||||
//<th style=\"width:1%;\">Device</th>
|
||||
//<th style=\"width:1%;\">Reported by</th>
|
||||
//<th>Discrepancy</th>
|
||||
//<th style=\"width:1%;\">$functional_term_short</th>
|
||||
//</tr>
|
||||
//";
|
||||
//while ($tablerow = mysqli_fetch_assoc($writeup_qry)) {
|
||||
//// determine functional icon
|
||||
//if($tablerow["functional"]==1) {
|
||||
//$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes\">";
|
||||
//} else {
|
||||
//$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no\">";
|
||||
//}
|
||||
|
||||
//// determine status indicator
|
||||
//if ($tablerow['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
|
||||
//if ($tablerow['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
|
||||
//if ($tablerow['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
|
||||
|
||||
//// convert device number to name
|
||||
//$dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]);
|
||||
//$disc_txt="{$tablerow["discrepancy_text"]}";
|
||||
//// 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 ($is_member) {
|
||||
//$group_count=$is_member;
|
||||
//$member_group=mysqli_fetch_row($member_qry)[0];
|
||||
//$member_group_name=dblookup($drs_db,"groups","id","name",$member_group);
|
||||
//if ($member_group_name) {
|
||||
//$imgtitle="Member of group: $member_group_name";
|
||||
//} else {
|
||||
//$imgtitle="Member of group ID: $member_group";
|
||||
//}
|
||||
//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>";
|
||||
//}
|
||||
//}
|
||||
//// print table row
|
||||
//printf(
|
||||
//"<tr>
|
||||
//<td align=\"center\" valign=\"top\"><input type=\"checkbox\" name=\"candidates[]\" value=\"%s\"></td>
|
||||
//<td align=\"center\" valign=\"top\"><a href=\"writeupdetail.php?id=%s\" title=\"View or change details of this writeup\">%s</a></td>
|
||||
//<td valign=\"top\">%s</td>
|
||||
//<td valign=\"top\">%s</td>
|
||||
//<td valign=\"top\">%s</td>
|
||||
//<td valign=\"top\">%s</td>
|
||||
//<td valign=\"top\">%s</td>
|
||||
//<td align=\"center\" valign=\"top\">%s</td>
|
||||
//</tr>\n",
|
||||
//$tablerow["id"],
|
||||
//$tablerow["id"],$tablerow["id"],
|
||||
//$statusind,
|
||||
//$tablerow["report_date"],
|
||||
//$dname,
|
||||
//$tablerow["reported_by"],
|
||||
//$disc_txt,
|
||||
//$func_icon
|
||||
//);
|
||||
//}
|
||||
//echo "
|
||||
//</table>\n
|
||||
//"
|
||||
//// end original display
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo "
|
||||
</table>\n
|
||||
<br>
|
||||
Select the writeups above you'd like to add to the group and
|
||||
<button name=\"save\" value=\"save\" type=\"submit\">Save group</button>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
login.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
profile.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
search.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -38,10 +38,10 @@ if (array_key_exists('exportcsv',$_REQUEST)) {
|
||||
$exportcsv=true;
|
||||
$csv_filename="{$appname}_Search_Results_" . date("Y-m-d_His") . ".csv";
|
||||
// disable caching
|
||||
$lastmodified = gmdate("D, d M Y H:i:s");
|
||||
$now = gmdate("D, d M Y H:i:s");
|
||||
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
|
||||
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
|
||||
header("Last-Modified: {$lastmodified} GMT");
|
||||
header("Last-Modified: {$now} GMT");
|
||||
|
||||
// force download
|
||||
header("Content-Type: application/force-download");
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
/*
|
||||
settings.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
// determine today's date and time and assign them to variables
|
||||
$today = date("Y-m-d");
|
||||
$now = date("H:i:s");
|
||||
|
||||
$sttl=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"session_ttl_days\""))[0];
|
||||
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
|
||||
if ($ostype == 'WIN') {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
writeupdetail.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -97,6 +97,9 @@ framework("begin","$appname","Writeup Detail",$print);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
// determine today's date and make it the default
|
||||
$today=date("Y-m-d");
|
||||
$now=date("H:i:s");
|
||||
|
||||
if ($usersave) {
|
||||
// user parameters
|
||||
@@ -143,7 +146,6 @@ elseif ($techsave) {
|
||||
$clean_action_text=mysqli_real_escape_string($drs_db,$action_text);
|
||||
|
||||
// update the record in writeups
|
||||
if ($action_reason=='') $action_reason=0;
|
||||
mysqli_query($drs_db,"update writeups set status=\"$status\",action_by=\"$action_by\",action_date=\"$action_date\",action_time=\"$action_time\",action_reason=\"$action_reason\",action_text=\"$clean_action_text\" where id=\"$id\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
writeups.php
|
||||
OpenDRS Online Discrepancy Reporting System
|
||||
Copyright (C) 2026 Rod Wright
|
||||
Copyright (C) 2025 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -130,7 +130,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
|
||||
}
|
||||
$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)) {
|
||||
$as_of=date("H:i l");
|
||||
$now=date("H:i l");
|
||||
if ($viewtype == "summary") {
|
||||
if ($role) {
|
||||
$selcol="<th style=\"width:1%;\">Sel</th>";
|
||||
@@ -138,7 +138,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
|
||||
$selcol="";
|
||||
}
|
||||
echo "
|
||||
<font color=\"red\">As of $as_of</font> <font size=\"-1\">Newest at top</font><br>
|
||||
<font color=\"red\">As of $now</font> <font size=\"-1\">Newest at top</font><br>
|
||||
<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
|
||||
<tr>
|
||||
$selcol
|
||||
@@ -231,7 +231,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
|
||||
echo "</table>\n";
|
||||
} elseif ($viewtype == "detail") {
|
||||
echo "
|
||||
<font color=\"red\">As of $as_of</font> <font size=\"-1\">Newest at top</font><br><br>
|
||||
<font color=\"red\">As of $now</font> <font size=\"-1\">Newest at top</font><br><br>
|
||||
<table border=\"0\"><tr><td>
|
||||
";
|
||||
while ($tablerow = mysqli_fetch_assoc($writeup)) {
|
||||
@@ -272,6 +272,7 @@ 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 (!isset($start_date)) $start_date=$today;
|
||||
if (!isset($end_date)) $end_date=$today;
|
||||
if (isset($showtoday)) {
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/bin/bash
|
||||
# files-update.sh
|
||||
|
||||
if [[ $1 == "" ]]
|
||||
then
|
||||
echo "This script requires an install path, but none was specified. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_path=$1
|
||||
|
||||
# ---------- version 1.0.0 -------------
|
||||
# Initial release
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.1.0 -------------
|
||||
# Change global database value from $mts_db to $drs_db
|
||||
sed -i "s/mts_db/drs_db/g" $install_path/db.php
|
||||
# ---------------------------------------
|
||||
|
||||
# ---------- version 1.1.1 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.1.2 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.2.0 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.3.0 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.3.1 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.3.2 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.3.3 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.0 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.1 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.2 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.3 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.4 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.5 -------------
|
||||
# Add AllowOverride Options to the apache conf-available file
|
||||
install_loc=$(basename $install_path)
|
||||
if ! grep -q "AllowOverride Options" /etc/apache2/conf-available/$install_loc.conf
|
||||
then
|
||||
sed -i '/^<Directory/a\ AllowOverride Options' /etc/apache2/conf-available/$install_loc.conf
|
||||
systemctl reload apache2
|
||||
fi
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 1.4.6 -------------
|
||||
# Nothing to do for this version
|
||||
# --------------------------------------
|
||||
700
install.sh
700
install.sh
@@ -2,175 +2,387 @@
|
||||
|
||||
# install.sh
|
||||
# OpenDRS Online Discrepancy Reporting System
|
||||
# Copyright (C) 2026 Rod Wright
|
||||
# Copyright (C) 2025 Rod Wright
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
APP_NAME="OpenDRS"
|
||||
DEFAULT_DB_NAME="opendrs"
|
||||
APP_VERSION="1.4.6"
|
||||
|
||||
DRS_VERSION="1.4.3"
|
||||
DOC_ROOT="/var/www"
|
||||
INSTALL_LOC="opendrs"
|
||||
APACHE_USER="www-data"
|
||||
APACHE_GROUP="www-data"
|
||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||
BACKUP_DIR="opendrs-previous-installation"
|
||||
LANDING_PAGE="writeups.php"
|
||||
CONFIG_TABLE="config"
|
||||
CONFIG_NAME_COLUMN="name"
|
||||
CONFIG_VALUE_COLUMN="value"
|
||||
CONFIG_DEFAULT_COLUMN="defaultvalue"
|
||||
|
||||
|
||||
function privilege_check() {
|
||||
# test for superuser rights
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run with superuser privileges. Try sudo $0"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function get_new_password() {
|
||||
# Stores new password in the variable $newpassword
|
||||
pwgood=false
|
||||
while ! $pwgood
|
||||
do
|
||||
read -p "New password: " -s -r newpassword
|
||||
echo ""
|
||||
read -p "Re-type new password: " -s -r rnewpw
|
||||
echo ""
|
||||
if [ "$newpassword" = "" -o "$rnewpw" = "" ]
|
||||
then
|
||||
echo "Password cannot be blank. Please try again."
|
||||
echo ""
|
||||
elif [ "$newpassword" != "$rnewpw" ]
|
||||
then
|
||||
echo "Passwords do not match. Please try again."
|
||||
echo ""
|
||||
else
|
||||
pwgood=true
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function install_required_packages() {
|
||||
# Positional parameters supplied to this function should be quoted
|
||||
# apt-get installable package names.
|
||||
# Note: Each package supplied to the for loop below can either be a
|
||||
# single package name or a list of alternatives separated by the word "or".
|
||||
# If supplying a list, the last one in the list will be the one that
|
||||
# gets installed.
|
||||
for prereq in "$@"
|
||||
do
|
||||
echo "Checking for $prereq installation..."
|
||||
gpattern=""
|
||||
for pkg_option in $(echo $prereq)
|
||||
do
|
||||
if [ "$pkg_option" != "or" ]
|
||||
then
|
||||
gpattern+=" -e $pkg_option"
|
||||
preferred_pkg=$pkg_option
|
||||
fi
|
||||
done
|
||||
if dpkg -l|grep $gpattern >/dev/null 2>&1
|
||||
then
|
||||
echo "$prereq is installed. Continuing."
|
||||
else
|
||||
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
|
||||
echo -n "Install $preferred_pkg now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "$APP_NAME requires $prereq, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
abort_exit
|
||||
else
|
||||
echo ""
|
||||
echo "Proceeding with $preferred_pkg installation"
|
||||
echo ""
|
||||
sleep 3
|
||||
apt-get install -y $preferred_pkg
|
||||
echo ""
|
||||
echo "Finished with $preferred_pkg installation"
|
||||
echo ""
|
||||
sleep 3
|
||||
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function clean_exit() {
|
||||
# Re-enable unattended-upgrades
|
||||
if $restart_uu; then systemctl start unattended-upgrades; fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
function abort_exit() {
|
||||
# Re-enable unattended-upgrades
|
||||
if $restart_uu; then systemctl start unattended-upgrades; fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
function spinner() {
|
||||
local pid="$1"
|
||||
local delay="0.1"
|
||||
local spinstr='|/-\\'
|
||||
local i=0
|
||||
|
||||
while ps -p "$pid" > /dev/null; do
|
||||
i=$(( (i+1) % 4 ))
|
||||
printf "\r[%c]" "${spinstr:$i:1}"
|
||||
sleep "$delay"
|
||||
done
|
||||
printf "\r \r" # Clear the spinner line
|
||||
}
|
||||
|
||||
# test for superuser rights
|
||||
privilege_check
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run with superuser privileges. Try sudo ./install.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "* * * * * Welcome to $APP_NAME $APP_VERSION Installation * * * * *"
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Preparing for installation. Please wait..."
|
||||
echo "Preparing for OpenDRS installation or upgrade. Please stand by..."
|
||||
|
||||
# Prevent unattended-upgrades from interfering
|
||||
restart_uu=false
|
||||
while dpkg -l|grep unattended-upgrades >/dev/null 2>&1
|
||||
while systemctl status unattended-upgrades >/dev/null 2>&1
|
||||
do
|
||||
systemctl stop unattended-upgrades
|
||||
sleep 5
|
||||
restart_uu=true
|
||||
done
|
||||
|
||||
apt-get update -qq
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "* * * * * Welcome to OpenDRS $DRS_VERSION Installation * * * * *"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Just press enter at the prompts to accept the defaults shown."
|
||||
echo ""
|
||||
# Check for prerequisites and prompt to install
|
||||
echo "Checking for required packages..."
|
||||
echo "Checking for prerequisites..."
|
||||
echo ""
|
||||
install_required_packages "apache2" "php" "mysql-server or mariadb-server" "php-mysql" "uuid-runtime"
|
||||
echo ""
|
||||
echo "Finished required package installation."
|
||||
echo " Checking for apache2 installation..."
|
||||
echo ""
|
||||
if dpkg -l|grep apache2 >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "apache2 is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo "OpenDRS requires the apache2 http server, but it doesn't seem"
|
||||
echo -n "to be installed. Install it now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "OpenDRS requires apache2, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
exit 1
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with apache2 installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
apt-get install -y apache2
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with apache2 installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo " Checking for php installation..."
|
||||
echo ""
|
||||
if dpkg -l|grep php >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "php is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo ""
|
||||
echo "OpenDRS requires php, but it doesn't seem to be installed."
|
||||
echo -n "Install it now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "OpenDRS requires php, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
exit 1
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with php installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
apt-get install -y php
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with php installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo " Checking for mariadb or mysql installation..."
|
||||
echo ""
|
||||
|
||||
# Determine the correct Apache2 user and group
|
||||
APACHE_USER=$(grep APACHE_RUN_USER /etc/apache2/envvars | cut -d= -f2)
|
||||
APACHE_GROUP=$(grep APACHE_RUN_GROUP /etc/apache2/envvars | cut -d= -f2)
|
||||
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
|
||||
|
||||
if dpkg -l|grep mariadb-server >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "mariadb-server is installed. Continuing."
|
||||
echo ""
|
||||
elif dpkg -l|grep mysql-server >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "mysql-server is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo ""
|
||||
echo "OpenDRS requires either mariadb or mysql server, but neither seem"
|
||||
echo -n "to be installed. Install mariadb-server now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "OpenDRS requires either mariadb or mysql server, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
exit 1
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with mariadb-server installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
apt-get install -y mariadb-server
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with mariadb-server installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with mariadb configuration"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
echo ""
|
||||
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 root login."
|
||||
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 ""
|
||||
mysql_secure_installation
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with mariadb configuration."
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo " Checking for phpmyadmin installation..."
|
||||
echo ""
|
||||
if dpkg -l|grep phpmyadmin >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "phpmyadmin is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo "phpmyadmin is optional, but doesn't seem to be installed."
|
||||
echo "It is an optional package that enables administration of the mysql/mariadb"
|
||||
echo "database server using a friendly GUI. It is highly recommended."
|
||||
echo "Note that this has the potential to be a security risk, especially"
|
||||
echo "if your passwords aren't sufficiently strong."
|
||||
echo -n "Install it now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "Proceeding without installing phpmyadmin. Database administration"
|
||||
echo "will require the use of the mysql/mariadb command line tools."
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with phpmyadmin installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
echo ""
|
||||
echo "During the following installation of phpmyadmin:"
|
||||
echo ""
|
||||
echo "- Select apache2 as the web server to configure automatically."
|
||||
echo ""
|
||||
echo "- Choose Yes when prompted to install phpmyadmin database and allow it to"
|
||||
echo " generate a random password(leave the field blank)."
|
||||
echo ""
|
||||
echo -n "Press enter to continue."
|
||||
read continueok
|
||||
echo ""
|
||||
apt-get install -y phpmyadmin
|
||||
echo ""
|
||||
echo ""
|
||||
echo "You can now access phpmyadmin using a web browser pointed to:"
|
||||
echo "http://$HOSTNAME/phpmyadmin"
|
||||
echo "*** WARNING!! this url is accessible via unencrypted (http), not"
|
||||
echo "encrypted SSL (https) connections. This is a huge security risk"
|
||||
echo "since the username and password you enter will be sent in the"
|
||||
echo "clear for any potential attacker to sniff! You should enable"
|
||||
echo "redirection to https for phpmyadmin in your apache2 configuration."
|
||||
echo ""
|
||||
echo -n "Press enter to continue."
|
||||
read continueok
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with phpmyadmin installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo " Checking for webmin installation..."
|
||||
echo ""
|
||||
if dpkg -l|grep webmin >/dev/null 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "webmin is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo "webmin is optional, but doesn't seem to be installed."
|
||||
echo "It is an optional package that enables system administration"
|
||||
echo "using a friendly GUI. It is highly recommended, especially for"
|
||||
echo "headless servers without any way to log in directly on the machine."
|
||||
echo "Note that this has the potential to be a security risk, especially"
|
||||
echo "if your passwords aren't sufficiently strong."
|
||||
echo -n "Install it now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "Proceeding without installing webmin. System administration"
|
||||
echo "will require login to the server either directly or via ssh."
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with webmin installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
echo "Installing webmin..."
|
||||
skipwebmin="false"
|
||||
if ! curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
|
||||
then
|
||||
echo "Warning: failed to download Webmin repo setup script."
|
||||
echo -n "Ignore and [c]ontinue or [A]bort? [c/A]: "
|
||||
read wmfailchoice
|
||||
if [ "$wmfailchoice" = "C" -o "$wmfailchoice" = "c" ]
|
||||
then
|
||||
skipwebmin="true"
|
||||
echo "Continuing without installing Webmin. You should investigate the failure"
|
||||
echo "and install Webmin manually after the server is set up if you would like"
|
||||
echo "to be able to manage the server from another computer with a GUI instead"
|
||||
echo "of through ssh only."
|
||||
echo -n "Press enter to continue."
|
||||
read continueok
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
if [ "$skipwebmin" = "false" ]
|
||||
then
|
||||
sh setup-repos.sh -f
|
||||
apt-get install -y --install-recommends webmin
|
||||
fi
|
||||
echo "...done."
|
||||
echo ""
|
||||
echo "You can now access webmin using a web browser pointed to:"
|
||||
echo "https://$HOSTNAME:10000"
|
||||
echo "Unless you have obtained valid ssl certificates, your server is"
|
||||
echo "using self-signed certs. This is not necessarily a problem, but"
|
||||
echo "your browser will complain. You can tell the browser to accept the"
|
||||
echo "self signed certificates and the traffic will still be encrypted,"
|
||||
echo "however you may be vulnerable to man-in-the-middle attacks. You can"
|
||||
echo "get free valid certificates through LetsEncrypt."
|
||||
echo "See http://letsencrypt.org for more information."
|
||||
echo ""
|
||||
echo -n "Press enter to continue."
|
||||
read continueok
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with webmin installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo " Checking for uuidgen installation..."
|
||||
echo ""
|
||||
if uuidgen 2>&1
|
||||
then
|
||||
echo ""
|
||||
echo "uuidgen is installed. Continuing."
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo ""
|
||||
echo "OpenDRS requires uuidgen, but it doesn't seem to be installed."
|
||||
echo -n "Install it now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
then
|
||||
echo "OpenDRS requires uuidgen, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
exit 1
|
||||
else
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Proceeding with uuidgen installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
apt-get install -y uuid-runtime
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
echo ""
|
||||
echo "Finished with uuidgen installation"
|
||||
echo ""
|
||||
echo "###################################################################"
|
||||
sleep 3
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Finished checking for and installing prerequisites..."
|
||||
echo ""
|
||||
echo ""
|
||||
sleep 3
|
||||
# prompt for install location
|
||||
echo "Where would you like to install this version of $APP_NAME? This should"
|
||||
echo "Where would you like to install this version of OpenDRS? This should"
|
||||
echo "be somewhere the webserver can find it. If you don't know, refer to the"
|
||||
echo "webserver's documentation and check the server's configuration files."
|
||||
echo "Note that this is where the directory containing $APP_NAME's files will be"
|
||||
echo "Note that this is where the directory containing OpenDRS's files will be"
|
||||
echo "created."
|
||||
echo -n "Enter the webserver's install location [$DOC_ROOT]:"
|
||||
read doc_root_in
|
||||
echo ""
|
||||
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
|
||||
echo -n "Enter name of OpenDRS installation directory [$INSTALL_LOC] :"
|
||||
read install_loc_in
|
||||
echo ""
|
||||
if [ "$doc_root_in" = "" ]
|
||||
@@ -184,14 +396,14 @@ fi
|
||||
install_path="$doc_root_in/$install_loc_in"
|
||||
if [ -d "$install_path" ]
|
||||
then
|
||||
echo "The installation path you chose already exists."
|
||||
# Install path exists.
|
||||
if [ -e "$install_path/db.php" ]
|
||||
then
|
||||
# A db.php file was found in the install path
|
||||
if grep -q -e "$APP_NAME" $install_path/db.php
|
||||
if grep -q -e "OpenDRS" -e "OpenMTS" $install_path/db.php
|
||||
then
|
||||
# the db.php file is part of a previous installation
|
||||
# the db.php file is part of an OpenDRS/OpenMTS installation
|
||||
echo "The installation path you chose already exists."
|
||||
echo "Would you like to upgrade an existing installation or cancel "
|
||||
echo "and restart the install using a new installation location."
|
||||
echo -n "[U]pgrade or [C]ancel? [C] :"
|
||||
@@ -199,113 +411,106 @@ then
|
||||
if [ "$upgrade_choice" = "U" -o "$upgrade_choice" = "u" ] # Upgrade chosen
|
||||
then
|
||||
# proceed with upgrade
|
||||
mkdir -p backups
|
||||
operation="upgraded"
|
||||
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
|
||||
|
||||
# create mysql option file with data for this installation
|
||||
mysql_opt_file=$(mktemp --tmpdir=/run/shm/)
|
||||
echo "[client]" > $mysql_opt_file
|
||||
echo "user = $(grep username $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
|
||||
echo "password = $(grep dbpass $install_path/db.php | head -1 | cut -d\" -f2)" >> $mysql_opt_file
|
||||
echo "" >> $mysql_opt_file
|
||||
echo "[mysql]" > $mysql_opt_file
|
||||
echo "database = $curr_dbname" >> $mysql_opt_file
|
||||
echo "batch" >> $mysql_opt_file
|
||||
echo "disable-column-names" >> $mysql_opt_file
|
||||
|
||||
# back up existing database
|
||||
echo "Backing up the current database to the package directory."
|
||||
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
|
||||
|
||||
curr_dbname=`grep dbname $install_path/db.php | head -1 | cut -d "\"" -f2`
|
||||
curr_username=`grep username $install_path/db.php | head -1 | cut -d "\"" -f2`
|
||||
curr_dbpass=`grep dbpass $install_path/db.php | head -1 | cut -d "\"" -f2`
|
||||
export MYSQL_PWD="$curr_dbpass"
|
||||
mysqldump --no-tablespaces -u"$curr_username" $curr_dbname > $curr_dbname-`date +%Y-%m-%d_%H:%M:%S`-backup.sql
|
||||
# back up existing installation
|
||||
echo "Backing up current installation to the package directory."
|
||||
cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
|
||||
|
||||
cp -R $install_path $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
|
||||
|
||||
echo "Performing database updates. This may take a while..."
|
||||
# apply database updates from sql file
|
||||
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
|
||||
# apply database updates via script
|
||||
(bash ./database-update.sh $mysql_opt_file) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
|
||||
echo "... finished with database updates."
|
||||
rm -f $mysql_opt_file
|
||||
|
||||
# apply updates to other files
|
||||
bash ./files-update.sh $install_path
|
||||
|
||||
# apply database updates
|
||||
mysql -u"$curr_username" -f -D $curr_dbname < opendrs-update.sql >/dev/null 2>&1
|
||||
# apply updates to existing db.php
|
||||
bash ./opendrs-update.sh $install_path
|
||||
# copy distribution to install location
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
# set symlink for jquery-ui
|
||||
if [ ! -L "$install_path/jquery-ui" ]
|
||||
then
|
||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||
fi
|
||||
# set symlink for index.php
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
ln -s $install_path/writeups.php $install_path/index.php
|
||||
fi
|
||||
# add the local timezone to .htaccess
|
||||
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
|
||||
echo "Your local timezone is $local_tz"
|
||||
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
|
||||
|
||||
# set ownership
|
||||
echo "In order to set the ownership correctly, we need to know the user and"
|
||||
echo "group that the webserver expects its files to be owned by. This is"
|
||||
echo "usually not the root account. Refer to the ownership of other files in"
|
||||
echo "your webserver's document tree to see what this should be."
|
||||
echo "Enter the user and group separated by a colon (username:groupname)."
|
||||
echo "Enter the user:group of the OpenDRS installation"
|
||||
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
|
||||
read httpd_user_group
|
||||
if [ "$httpd_user_group" = "" ]
|
||||
then
|
||||
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
|
||||
fi
|
||||
echo ""
|
||||
echo "Setting file ownership . . ."
|
||||
chown -R $httpd_user_group $install_path
|
||||
else
|
||||
echo "Cancelling installation"
|
||||
abort_exit
|
||||
exit
|
||||
fi
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
echo "The installation directory you chose exists, but no previous installation"
|
||||
echo "of $APP_NAME was found. Please investigate the situation. Aborting now."
|
||||
abort_exit
|
||||
echo "of OpenDRS was found. Please investigate the situation. Aborting now."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
echo "The installation directory you chose exists, but no previous installation"
|
||||
echo "of $APP_NAME was found."
|
||||
echo ""
|
||||
echo " CAUTION: If there is anything else in this directory, it will be deleted!"
|
||||
echo ""
|
||||
echo "Would you like to use this location for a fresh installation or quit and"
|
||||
echo "investigate further? It's probably safest to quit and investigate."
|
||||
proceed=""
|
||||
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
|
||||
do
|
||||
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
||||
done
|
||||
if [[ $proceed == "Q" || $proceed == "q" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
echo "of OpenDRS was found. Please investigate the situation. Aborting now."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# This is a fresh install
|
||||
operation="installed"
|
||||
# prompt for mysql information
|
||||
bad_mysql_adm=true
|
||||
while $bad_mysql_adm
|
||||
do
|
||||
admintestdb="drsadm`date +%Y%m%d`"
|
||||
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 -n "MySQL admin username: "
|
||||
read mysql_adm_user
|
||||
echo ""
|
||||
echo -n "MySQL admin password: "
|
||||
read -s mysql_adm_pass
|
||||
export MYSQL_PWD="$mysql_adm_pass"
|
||||
if mysql -u"$mysql_adm_user" -e "create database $admintestdb;drop database $admintestdb"
|
||||
then
|
||||
bad_mysql_adm=false
|
||||
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]: "
|
||||
read admtry
|
||||
if [ "$admtry" != "Y" -o "$admtry" != "y" ]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
echo "What would you like to call this installation of $APP_NAME? If you accept"
|
||||
echo "the default, it will be called $APP_NAME. If you will be running multiple"
|
||||
echo "instances of $APP_NAME on this server, you should choose a distinctive name."
|
||||
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 [$APP_NAME]: "
|
||||
echo -n "Installation name [OpenDRS]: "
|
||||
read new_inst_name
|
||||
if [ "$new_inst_name" = "" ]
|
||||
then
|
||||
new_inst_name="$APP_NAME"
|
||||
new_inst_name="OpenDRS"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
@@ -313,19 +518,20 @@ else
|
||||
db_create_fail=true
|
||||
while $db_create_fail
|
||||
do
|
||||
echo "What would you like to call the database for this installation of $APP_NAME?"
|
||||
echo "If you accept the default, it will be called $DEFAULT_DB_NAME. Again, this is fine"
|
||||
echo "What would you like to call the database for this installation of OpenDRS?"
|
||||
echo "If you accept the default, it will be called opendrs. Again, this is fine"
|
||||
echo "if you will only be running this one instance, but if you will be running"
|
||||
echo "multiple instances of $APP_NAME on this server, you should choose a "
|
||||
echo "multiple instances of OpenDRS on this server, you should choose a "
|
||||
echo "distinctive name."
|
||||
echo -n "database name [$DEFAULT_DB_NAME]: "
|
||||
echo -n "database name [opendrs]: "
|
||||
read new_db_name
|
||||
if [ "$new_db_name" = "" ]
|
||||
then
|
||||
new_db_name=$DEFAULT_DB_NAME
|
||||
new_db_name=opendrs
|
||||
fi
|
||||
echo ""
|
||||
if mysql -e "create database $new_db_name"
|
||||
export MYSQL_PWD="$mysql_adm_pass"
|
||||
if mysql -u"$mysql_adm_user" -e "create database $new_db_name"
|
||||
then
|
||||
db_create_fail=false
|
||||
else
|
||||
@@ -335,28 +541,26 @@ else
|
||||
read dbcreatetry
|
||||
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
|
||||
then
|
||||
abort_exit
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Create user and give rights to database
|
||||
db_user="$new_db_name`date +%Y%m%d%H%M%S`"
|
||||
db_pass=`uuidgen`
|
||||
mysql -e "create user if not exists '$db_user'@'localhost' identified by '$db_pass'"
|
||||
mysql -e "grant all on $new_db_name.* to '$db_user'@'localhost'"
|
||||
mysql -e "flush privileges"
|
||||
drs_user="$new_db_name`date +%Y%m%d%H%M%S`"
|
||||
drs_pass=`uuidgen`
|
||||
export MYSQL_PWD="$mysql_adm_pass"
|
||||
mysql -u"$mysql_adm_user" -e "create user if not exists '$drs_user'@'localhost' identified by '$drs_pass'"
|
||||
mysql -u"$mysql_adm_user" -e "grant all on $new_db_name.* to '$drs_user'@'localhost'"
|
||||
mysql -u"$mysql_adm_user" -e "flush privileges"
|
||||
|
||||
# Populate initial database
|
||||
mysql $new_db_name < database-initial.sql
|
||||
mysql -u"$mysql_adm_user" $new_db_name < opendrs-initial.sql
|
||||
|
||||
# Set the installation name
|
||||
export MYSQL_PWD="$db_pass"
|
||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"app_name\""
|
||||
if [ "$CONFIG_DEFAULT_COLUMN" != "" ]
|
||||
then
|
||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"app_name\""
|
||||
fi
|
||||
export MYSQL_PWD="$drs_pass"
|
||||
mysql -u"$drs_user" $new_db_name -e "update config set value=\"$new_inst_name\",defaultvalue=\"$new_inst_name\" where name=\"app_name\""
|
||||
|
||||
# Create install path
|
||||
echo "Creating installation directory . . ."
|
||||
mkdir $install_path
|
||||
@@ -366,9 +570,8 @@ else
|
||||
then
|
||||
cp db.php.template $install_path/db.php
|
||||
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
|
||||
sed -i "s/DBUSER/$db_user/g" $install_path/db.php
|
||||
sed -i "s/DBPASS/$db_pass/g" $install_path/db.php
|
||||
sed -i "s/APPNAME/$APP_NAME/g" $install_path/db.php
|
||||
sed -i "s/DBUSER/$drs_user/g" $install_path/db.php
|
||||
sed -i "s/DBPASS/$drs_pass/g" $install_path/db.php
|
||||
fi
|
||||
|
||||
# copy distribution to install location
|
||||
@@ -380,14 +583,21 @@ else
|
||||
fi
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
ln -s $install_path/writeups.php $install_path/index.php
|
||||
fi
|
||||
# add the local timezone to .htaccess
|
||||
local_tz=$(timedatectl show -p Timezone|cut -d= -f2)
|
||||
echo "Your local timezone is $local_tz"
|
||||
echo "php_value date.timezone \"$local_tz\"">$install_path/.htaccess
|
||||
|
||||
# set ownership
|
||||
echo "In order to set the ownership correctly, we need to know the user and"
|
||||
echo "group that the webserver expects its files to be owned by. This is"
|
||||
echo "usually not the root account. Refer to the ownership of other files in"
|
||||
echo "your webserver's document tree to see what this should be."
|
||||
echo "Enter the user and group separated by a colon (username:groupname)."
|
||||
echo "Enter the user:group of the OpenDRS installation"
|
||||
echo -n "directory [$APACHE_USER:$APACHE_GROUP] :"
|
||||
read httpd_user_group
|
||||
if [ "$httpd_user_group" = "" ]
|
||||
then
|
||||
httpd_user_group="$APACHE_USER:$APACHE_GROUP"
|
||||
fi
|
||||
echo ""
|
||||
echo "Setting file ownership . . ."
|
||||
chown -R $httpd_user_group $install_path
|
||||
@@ -399,27 +609,26 @@ echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "$APP_NAME has been $operation."
|
||||
echo "OpenDRS has been $operation."
|
||||
base_url=$install_loc_in
|
||||
if [ "$operation" = "installed" ]
|
||||
then
|
||||
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "# OpenDRS default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
|
||||
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y] :"
|
||||
read enconf
|
||||
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
|
||||
then
|
||||
a2enconf $base_url.conf >/dev/null
|
||||
service apache2 reload
|
||||
echo "You can now point a web browser to $base_url on your web server "
|
||||
echo "to set up and configure $APP_NAME."
|
||||
echo "to set up and configure OpenDRS."
|
||||
echo ""
|
||||
echo "IMPORTANT: The default login credentials for the initial admin user are:"
|
||||
echo ""
|
||||
@@ -433,12 +642,13 @@ then
|
||||
else
|
||||
echo "You will need to manually enable the configuration by executing:"
|
||||
echo " a2enconf $base_url.conf"
|
||||
echo " systemctl reload apache2"
|
||||
echo " service apache2 reload"
|
||||
echo "as a superuser before it can be accessed."
|
||||
fi
|
||||
else
|
||||
echo "You can now point a web browser to http://$HOSTNAME/$base_url "
|
||||
echo "to use your upgraded $APP_NAME."
|
||||
echo "You can now point a web browser to $base_url on your web server "
|
||||
echo "to use your upgraded OpenDRS."
|
||||
fi
|
||||
|
||||
clean_exit
|
||||
# Re-enable unattended-upgrades
|
||||
if $restart_uu; then systemctl start unattended-upgrades; fi
|
||||
|
||||
@@ -69,7 +69,7 @@ CREATE TABLE `config` (
|
||||
LOCK TABLES `config` WRITE;
|
||||
/*!40000 ALTER TABLE `config` DISABLE KEYS */;
|
||||
INSERT INTO `config` VALUES
|
||||
(1,'drs_version','1.4.6','1.4.6'),
|
||||
(1,'drs_version','1.4.3','1.4.3'),
|
||||
(5,'app_name','OpenDRS - Discrepancy Reporting System','OpenDRS Discrepancy Reporting System'),
|
||||
(6,'banner','1','1'),
|
||||
(7,'background_color','0B3144','0B3144'),
|
||||
8
opendrs-update.sh
Normal file
8
opendrs-update.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
# opendrs-update.sh
|
||||
|
||||
install_path=$1
|
||||
|
||||
# ---------- version 1.1.0 -------------
|
||||
# Change global database value from $mts_db to $drs_db
|
||||
sed -i "s/mts_db/drs_db/g" $install_path/db.php
|
||||
# ---------------------------------------
|
||||
@@ -265,19 +265,3 @@ UPDATE config SET value="1.4.2",defaultvalue="1.4.2" WHERE name="drs_version";
|
||||
-- Update version number
|
||||
UPDATE config SET value="1.4.3",defaultvalue="1.4.3" WHERE name="drs_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 1.4.4 -------------
|
||||
-- Update version number
|
||||
UPDATE config SET value="1.4.4",defaultvalue="1.4.4" WHERE name="drs_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 1.4.5 -------------
|
||||
-- Update version number
|
||||
UPDATE config SET value="1.4.5",defaultvalue="1.4.5" WHERE name="drs_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 1.4.6 -------------
|
||||
-- Update version number
|
||||
UPDATE config SET value="1.4.6",defaultvalue="1.4.6" WHERE name="drs_version";
|
||||
-- --------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user