Initial commit as release 1.1.0
43
CHANGELOG
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
OpenDRS - Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
|
||||||
|
1.0.0 - 2018-03-13
|
||||||
|
- Initial release as OpenMTS.
|
||||||
|
|
||||||
|
1.1.0 - 2018-05-10
|
||||||
|
- Name change from OpenMTS to OpenDRS.
|
||||||
|
- Added "Go Back" button to left side menu to make up for loss of browser
|
||||||
|
back button in terminal mode.
|
||||||
|
- Added configurable help text for period effective selection.
|
||||||
|
- Changed Sim period effective from selection to yes/no radio buttons.
|
||||||
|
- Writeup groups page shows collapsed list of groups. Click the expand icon
|
||||||
|
to expand each group.
|
||||||
|
- Fixed bug where entries made on stale create page had inaccurate date/time.
|
||||||
|
- For logged in users, added the ability to select writeups directly on the
|
||||||
|
View All Writeups page and assign/create a group.
|
||||||
|
- On the Create New Writeup page, removed the default selections for Device,
|
||||||
|
Subsystem, and Period dropdowns, forcing user to make a selection.
|
||||||
|
- Added a Today button to the View All Writeups page
|
||||||
|
- Changed the Period dropdowns on the Create, Search, and Group pages to show
|
||||||
|
the times instead of the period numbers. Period numbers are still shown
|
||||||
|
in the results tables with mouse hover showing times.
|
||||||
|
- Moved all installation/upgrade functions to the install.sh script.
|
||||||
|
|
||||||
|
|
||||||
28
INSTALL
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Installation or upgrade of OpenDRS is straightforward.
|
||||||
|
|
||||||
|
1. Unpack
|
||||||
|
Unpack the distribution in a convenient place. A directory will
|
||||||
|
created called OpenDRS-x.x.x/.
|
||||||
|
|
||||||
|
2. Review License
|
||||||
|
Change to the OpenDRS-x.x.x/ directory and review the LICENSE file.
|
||||||
|
|
||||||
|
3. Run the install script
|
||||||
|
In the same directory, type ./install.sh at a command prompt and
|
||||||
|
follow the prompts.
|
||||||
|
|
||||||
|
4. Log in
|
||||||
|
Click on the Log In menu option on the main page. If this is a fresh
|
||||||
|
installation The initial user is drsadmin and the initial password
|
||||||
|
is OpenDRS-1. It is highly recommended that you changethis password
|
||||||
|
to a strong one by going to the Manage Database page under the
|
||||||
|
Admin Functions menu. If this an upgrade, your current usernames and
|
||||||
|
passwords are unchanged.
|
||||||
|
|
||||||
|
5. Configure
|
||||||
|
The Admin Functions menu will be shown when logged in as an admin user.
|
||||||
|
Click on Global Settings to set display options, page colors, banners, and
|
||||||
|
miscellaneous options. Click on Manage Database to set users, devices,
|
||||||
|
subsystems, action reasons and periods.
|
||||||
|
|
||||||
|
6. Start making writeups
|
||||||
126
RPiSetup/brlaser-master/CMakeLists.txt
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
project(brlaser CXX)
|
||||||
|
set(BRLASER_VERSION "4")
|
||||||
|
|
||||||
|
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
message(STATUS "No build type selected, default to RelWithDebInfo")
|
||||||
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type (default RelWithDebInfo)" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CMakePushCheckState)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(CheckIncludeFileCXX)
|
||||||
|
|
||||||
|
|
||||||
|
## Enable assertions for all builds
|
||||||
|
## (cmake by default sets NDEBUG for release builds)
|
||||||
|
|
||||||
|
foreach(var
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||||
|
CMAKE_CXX_FLAGS_MINSIZEREL)
|
||||||
|
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " "${var}" "${${var}}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
## Configure the compiler
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
macro(extra_cxx_compiler_flag FLAG)
|
||||||
|
string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SFLAG ${FLAG})
|
||||||
|
check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG})
|
||||||
|
if(COMPILER_SUPPORT_${SFLAG})
|
||||||
|
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${FLAG}")
|
||||||
|
endif()
|
||||||
|
endmacro(extra_cxx_compiler_flag)
|
||||||
|
|
||||||
|
# Compiler warnings
|
||||||
|
extra_cxx_compiler_flag("-Wall")
|
||||||
|
extra_cxx_compiler_flag("-Wno-missing-braces")
|
||||||
|
# Some security flags
|
||||||
|
extra_cxx_compiler_flag("-fstack-protector-strong")
|
||||||
|
extra_cxx_compiler_flag("-Wformat")
|
||||||
|
extra_cxx_compiler_flag("-Werror=format-security")
|
||||||
|
extra_cxx_compiler_flag("-D_FORTIFY_SOURCE=2")
|
||||||
|
# Enable the supported flags, but give priority to CXXFLAGS env var
|
||||||
|
set(CMAKE_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
|
|
||||||
|
## Configure CUPS
|
||||||
|
|
||||||
|
find_program(CUPS_CONFIG NAMES cups-config)
|
||||||
|
if(NOT CUPS_CONFIG)
|
||||||
|
message(FATAL_ERROR "cups-config command not found. Are the CUPS development packages installed?")
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CUPS_CONFIG}" --datadir
|
||||||
|
OUTPUT_VARIABLE CUPS_DATA_DIR
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CUPS_CONFIG}" --serverbin
|
||||||
|
OUTPUT_VARIABLE CUPS_SERVER_BIN
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CUPS_CONFIG}" --cflags
|
||||||
|
OUTPUT_VARIABLE CUPS_CFLAGS
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CUPS_CONFIG}" --ldflags
|
||||||
|
OUTPUT_VARIABLE CUPS_LDFLAGS
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${CUPS_CONFIG}" --image --libs
|
||||||
|
OUTPUT_VARIABLE CUPS_LIBS
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
cmake_push_check_state()
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${CUPS_CFLAGS}")
|
||||||
|
check_include_file_cxx(cups/raster.h HAVE_CUPS_RASTER_H)
|
||||||
|
cmake_pop_check_state()
|
||||||
|
if(NOT HAVE_CUPS_RASTER_H)
|
||||||
|
message(SEND_ERROR "<cups/raster.h> header not found. Are the CUPS development packages installed?")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
## Build instructions
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/brlaser.drv.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/brlaser.drv")
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/config.h")
|
||||||
|
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
|
add_executable(rastertobrlaser src/main.cc src/job.cc src/line.cc src/debug.cc)
|
||||||
|
target_compile_options(rastertobrlaser PRIVATE ${CUPS_CFLAGS})
|
||||||
|
target_link_libraries(rastertobrlaser ${CUPS_LIBS})
|
||||||
|
target_link_libraries(rastertobrlaser ${CUPS_LDFLAGS})
|
||||||
|
|
||||||
|
add_executable(brdecode src/brdecode.cc)
|
||||||
|
add_executable(test_lest test/test_lest.cc)
|
||||||
|
add_executable(test_line test/test_line.cc src/line.cc)
|
||||||
|
add_executable(test_block test/test_block.cc)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_test(test_lest test_lest)
|
||||||
|
add_test(test_line test_line)
|
||||||
|
add_test(test_block test_block)
|
||||||
|
|
||||||
|
# Autotools-style "make check" command
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||||
|
add_dependencies(check test_lest test_line test_block)
|
||||||
|
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS rastertobrlaser
|
||||||
|
DESTINATION "${CUPS_SERVER_BIN}/filter")
|
||||||
|
install(
|
||||||
|
FILES "${PROJECT_BINARY_DIR}/brlaser.drv"
|
||||||
|
DESTINATION "${CUPS_DATA_DIR}/drv")
|
||||||
339
RPiSetup/brlaser-master/COPYING
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
9
RPiSetup/brlaser-master/ChangeLog
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
brlaser v3 (2014-07-07)
|
||||||
|
Added DCP-7065DN description.
|
||||||
|
|
||||||
|
brlaser v2 (2014-06-29)
|
||||||
|
Suppport compilation with GCC 4.6.
|
||||||
|
Add a basic test suite.
|
||||||
|
|
||||||
|
brlaser v1 (2013-12-30)
|
||||||
|
Initial release.
|
||||||
85
RPiSetup/brlaser-master/README.md
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
brlaser: Brother laser printer driver
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
brlaser is a CUPS driver for Brother laser printers.
|
||||||
|
|
||||||
|
Although most Brother printers support a standard printer language
|
||||||
|
such as PCL or PostScript, not all do. If you have a monochrome
|
||||||
|
Brother laser printer (or multi-function device) and the other open
|
||||||
|
source drivers don't work, this one might help.
|
||||||
|
|
||||||
|
This driver is known to work with these printers:
|
||||||
|
|
||||||
|
* Brother DCP-1510
|
||||||
|
* Brother DCP-7030
|
||||||
|
* Brother DCP-7040
|
||||||
|
* Brother DCP-7055
|
||||||
|
* Brother DCP-7055W
|
||||||
|
* Brother DCP-7065DN
|
||||||
|
* Brother HL-L2300D
|
||||||
|
* Brother MFC-7360N
|
||||||
|
|
||||||
|
|
||||||
|
Other printers
|
||||||
|
--------------
|
||||||
|
|
||||||
|
If your printer isn't included in the list above, just try selecting
|
||||||
|
any entry marked 'brlaser' and see if it works.
|
||||||
|
|
||||||
|
If it does, please create a new issue here in Github and include the
|
||||||
|
output of this command:
|
||||||
|
|
||||||
|
sudo lpinfo --include-schemes usb -l -v
|
||||||
|
|
||||||
|
Then I'll be able to add a proper entry for your printer.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Some operating systems already ship this driver. This is the case for
|
||||||
|
at least Debian, Ubuntu, Raspbian, openSUSE and Arch Linux. Look for a
|
||||||
|
package named `printer-driver-brlaser`.
|
||||||
|
|
||||||
|
You'll also need Ghostscript, in case that's not installed
|
||||||
|
automatically.
|
||||||
|
|
||||||
|
Once brlaser is installed, you can add your printer using the usual
|
||||||
|
CUPS interface.
|
||||||
|
|
||||||
|
|
||||||
|
Building from source
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
To compile brlaser you'll need CMake and the CUPS development packages
|
||||||
|
(libcups2-dev, libcupsimage2-dev or similar).
|
||||||
|
|
||||||
|
Get the code by cloning the git repo <!-- or downloading the [latest
|
||||||
|
release] -->. Compile and install with these commands:
|
||||||
|
|
||||||
|
cmake .
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
It might be needed to restart CUPS after this.
|
||||||
|
|
||||||
|
[latest release]: https://github.com/pdewacht/brlaser/releases/latest
|
||||||
|
|
||||||
|
|
||||||
|
Copyright
|
||||||
|
---------
|
||||||
|
|
||||||
|
Copyright © 2013 Peter De Wachter
|
||||||
|
|
||||||
|
brlaser is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
brlaser is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
143
RPiSetup/brlaser-master/brlaser.drv.in
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#define USING "using @CMAKE_PROJECT_NAME@ v@BRLASER_VERSION@"
|
||||||
|
|
||||||
|
// Include standard font and media definitions
|
||||||
|
#include <font.defs>
|
||||||
|
#include <media.defs>
|
||||||
|
|
||||||
|
// List the fonts that are supported, in this case all standard fonts...
|
||||||
|
Font *
|
||||||
|
|
||||||
|
// Manufacturer and driver version.
|
||||||
|
Manufacturer "Brother"
|
||||||
|
Version "@BRLASER_VERSION@"
|
||||||
|
|
||||||
|
// Each filter provided by the driver...
|
||||||
|
Filter application/vnd.cups-raster 33 rastertobrlaser
|
||||||
|
|
||||||
|
// Supported resolutions.
|
||||||
|
// The 1200dpi mode is weird: we need to send 1200x1200dpi raster
|
||||||
|
// data, but Brother only advertises 1200x600dpi. I wonder what
|
||||||
|
// is going on there.
|
||||||
|
// The 300dpi mode is reportedly not supported on all printers, so
|
||||||
|
// it's listed in individual printer blocks where we believe it works.
|
||||||
|
// Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
*Resolution k 1 0 0 0 "600dpi/600 DPI"
|
||||||
|
Resolution k 1 0 0 0 "1200dpi/1200HQ"
|
||||||
|
|
||||||
|
// Supported page sizes.
|
||||||
|
HWMargins 8 8 8 16
|
||||||
|
*MediaSize A4
|
||||||
|
MediaSize A5
|
||||||
|
MediaSize A6
|
||||||
|
MediaSize B5
|
||||||
|
MediaSize B6
|
||||||
|
MediaSize EnvC5
|
||||||
|
MediaSize EnvMonarch
|
||||||
|
MediaSize EnvDL
|
||||||
|
MediaSize Executive
|
||||||
|
MediaSize Legal
|
||||||
|
MediaSize Letter
|
||||||
|
|
||||||
|
// Input trays. Numbers must match the filter source code.
|
||||||
|
*InputSlot 0 "Auto/Auto-select"
|
||||||
|
InputSlot 1 "Tray1/Tray 1"
|
||||||
|
InputSlot 2 "Tray2/Tray 2"
|
||||||
|
InputSlot 3 "Tray3/Tray 3"
|
||||||
|
InputSlot 4 "MPTray/MP Tray"
|
||||||
|
InputSlot 5 "Manual/Manual"
|
||||||
|
|
||||||
|
// Media types.
|
||||||
|
*MediaType 0 "PLAIN/Plain paper"
|
||||||
|
MediaType 1 "THIN/Thin paper"
|
||||||
|
MediaType 2 "THICK/Thick paper"
|
||||||
|
MediaType 3 "THICKER/Thicker paper"
|
||||||
|
MediaType 4 "BOND/Bond paper"
|
||||||
|
MediaType 5 "TRANS/Transparencies"
|
||||||
|
MediaType 6 "ENV/Envelopes"
|
||||||
|
MediaType 7 "ENV-THICK/Thick envelopes"
|
||||||
|
MediaType 8 "ENV-THIN/Thin envelopes"
|
||||||
|
|
||||||
|
Option "brlaserEconomode/Toner save mode" Boolean AnySetup 10
|
||||||
|
*Choice False/Off "<</cupsInteger10 0>>setpagedevice"
|
||||||
|
Choice True/On "<</cupsInteger10 1>>setpagedevice"
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-1510"
|
||||||
|
Attribute "NickName" "" "Brother DCP-1510 series, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,XL2HB;MDL:DCP-1510 series;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
PCFileName "br1510.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-7030"
|
||||||
|
Attribute "NickName" "" "Brother DCP-7030, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7030;CLS:PRINTER;"
|
||||||
|
Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
PCFileName "br7030.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-7040"
|
||||||
|
Attribute "NickName" "" "Brother DCP-7040, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7040;CLS:PRINTER;"
|
||||||
|
Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
PCFileName "br7040.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-7055"
|
||||||
|
Attribute "NickName" "" "Brother DCP-7055, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7055;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
PCFileName "br7055.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-7055W"
|
||||||
|
Attribute "NickName" "" "Brother DCP-7055W, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7055W;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
Resolution k 1 0 0 0 "300dpi/300 DPI"
|
||||||
|
PCFileName "br7055w.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "DCP-7065DN"
|
||||||
|
Attribute "NickName" "" "Brother DCP-7065DN, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:DCP-7065DN;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
Duplex rotated
|
||||||
|
PCFileName "br7065dn.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "HL-L2300D"
|
||||||
|
Attribute "NickName" "" "Brother HL-L2300D, $USING"
|
||||||
|
Attribute "1284DeviceID" "" " MFG:Brother;CMD:PJL,HBP;MDL:HL-L2300D series;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
Duplex rotated
|
||||||
|
PCFileName "brl2300d.ppd"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ModelName "MFC-7360N"
|
||||||
|
Attribute "NickName" "" "Brother MFC-7360N, $USING"
|
||||||
|
Attribute "1284DeviceID" "" "MFG:Brother;CMD:PJL,HBP;MDL:MFC-7360N;CLS:PRINTER;CID:Brother Laser Type1;"
|
||||||
|
PCFileName "br7360n.ppd"
|
||||||
|
}
|
||||||
2
RPiSetup/brlaser-master/config.h.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define PACKAGE "@CMAKE_PROJECT_NAME@"
|
||||||
|
#define VERSION "@BRLASER_VERSION@"
|
||||||
68
RPiSetup/brlaser-master/src/block.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef BLOCK_H
|
||||||
|
#define BLOCK_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class block {
|
||||||
|
public:
|
||||||
|
block(): line_bytes_(0) {
|
||||||
|
lines_.reserve(max_lines_per_block_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return line_bytes_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_line(std::vector<uint8_t> &&line) {
|
||||||
|
assert(!line.empty());
|
||||||
|
assert(line_fits(line.size()));
|
||||||
|
line_bytes_ += line.size();
|
||||||
|
lines_.emplace_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool line_fits(unsigned size) {
|
||||||
|
return lines_.size() != max_lines_per_block_
|
||||||
|
&& line_bytes_ + size < max_block_size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void flush(FILE *f) {
|
||||||
|
if (!empty()) {
|
||||||
|
fprintf(f, "%dw%c%c",
|
||||||
|
line_bytes_ + 2, 0,
|
||||||
|
static_cast<int>(lines_.size()));
|
||||||
|
for (auto &line : lines_) {
|
||||||
|
fwrite(line.data(), 1, line.size(), f);
|
||||||
|
}
|
||||||
|
line_bytes_ = 0;
|
||||||
|
lines_.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const unsigned max_block_size_ = 16350;
|
||||||
|
static const unsigned max_lines_per_block_ = 128;
|
||||||
|
|
||||||
|
std::vector<std::vector<uint8_t>> lines_;
|
||||||
|
int line_bytes_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BLOCK_H
|
||||||
225
RPiSetup/brlaser-master/src/brdecode.cc
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
// A quick-and-dirty tool to convert print files back to pbm images.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <exception>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const size_t MAX_LINE_SIZE = 2000;
|
||||||
|
|
||||||
|
FILE *in_file;
|
||||||
|
std::vector<std::vector<uint8_t>> page;
|
||||||
|
std::vector<uint8_t> line;
|
||||||
|
size_t line_offset;
|
||||||
|
|
||||||
|
|
||||||
|
class unexpected_eof: public std::exception {
|
||||||
|
public:
|
||||||
|
virtual const char *what() const noexcept {
|
||||||
|
return "Unexpected EOF";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class line_overflow: public std::exception {
|
||||||
|
public:
|
||||||
|
virtual const char *what() const noexcept {
|
||||||
|
return "Unreasonable long line, aborting";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t get() {
|
||||||
|
int ch = getc(in_file);
|
||||||
|
if (ch < 0)
|
||||||
|
throw unexpected_eof();
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned read_overflow() {
|
||||||
|
uint8_t ch;
|
||||||
|
unsigned sum = 0;
|
||||||
|
do {
|
||||||
|
ch = get();
|
||||||
|
sum += ch;
|
||||||
|
} while (ch == 255);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_repeat(uint8_t cmd) {
|
||||||
|
uint16_t offset = (cmd >> 5) & 3;
|
||||||
|
if (offset == 3)
|
||||||
|
offset += read_overflow();
|
||||||
|
uint16_t count = cmd & 31;
|
||||||
|
if (count == 31)
|
||||||
|
count += read_overflow();
|
||||||
|
count += 2;
|
||||||
|
uint8_t data = get();
|
||||||
|
|
||||||
|
size_t end = line_offset + offset + count;
|
||||||
|
if (end > line.size()) {
|
||||||
|
if (end > MAX_LINE_SIZE)
|
||||||
|
throw line_overflow();
|
||||||
|
line.resize(end);
|
||||||
|
}
|
||||||
|
line_offset += offset;
|
||||||
|
std::fill_n(line.begin() + line_offset, count, data);
|
||||||
|
line_offset += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_substitute(uint8_t cmd) {
|
||||||
|
uint16_t offset = (cmd >> 3) & 15;
|
||||||
|
if (offset == 15)
|
||||||
|
offset += read_overflow();
|
||||||
|
uint16_t count = cmd & 7;
|
||||||
|
if (count == 7)
|
||||||
|
count += read_overflow();
|
||||||
|
count += 1;
|
||||||
|
|
||||||
|
size_t end = line_offset + offset + count;
|
||||||
|
if (end > line.size()) {
|
||||||
|
if (end > MAX_LINE_SIZE)
|
||||||
|
throw line_overflow();
|
||||||
|
line.resize(end);
|
||||||
|
}
|
||||||
|
line_offset += offset;
|
||||||
|
std::generate_n(line.begin() + line_offset, count, get);
|
||||||
|
line_offset += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_edit() {
|
||||||
|
int8_t cmd = get();
|
||||||
|
if (cmd < 0) {
|
||||||
|
read_repeat(cmd);
|
||||||
|
} else {
|
||||||
|
read_substitute(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_line() {
|
||||||
|
uint8_t num_edits = get();
|
||||||
|
if (num_edits == 255) {
|
||||||
|
line.clear();
|
||||||
|
} else {
|
||||||
|
line_offset = 0;
|
||||||
|
for (int i = 0; i < num_edits; ++i) {
|
||||||
|
read_edit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_block() {
|
||||||
|
unsigned count = get();
|
||||||
|
count = count * 256 + get();
|
||||||
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
|
read_line();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool read_page() {
|
||||||
|
bool in_esc = false;
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
page.clear();
|
||||||
|
line.clear();
|
||||||
|
while ((ch = getc(in_file)) >= 0) {
|
||||||
|
if (ch == '\f') {
|
||||||
|
break;
|
||||||
|
} else if (ch == 033) {
|
||||||
|
in_esc = true;
|
||||||
|
} else if (in_esc && ch == 'w') {
|
||||||
|
read_block();
|
||||||
|
} else if (in_esc && (ch >= 'A' && ch <= 'Z')) {
|
||||||
|
in_esc = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !page.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_pnm(FILE *f) {
|
||||||
|
size_t height = page.size();
|
||||||
|
size_t width = 0;
|
||||||
|
for (auto &l : page) {
|
||||||
|
width = std::max(width, l.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(f, "P4 %zd %zd\n", width * 8, height);
|
||||||
|
std::vector<uint8_t> empty(width);
|
||||||
|
for (auto &l : page) {
|
||||||
|
fwrite(l.data(), 1, l.size(), f);
|
||||||
|
fwrite(empty.data(), 1, width - l.size(), f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
const char *in_filename;
|
||||||
|
std::string out_prefix;
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
in_filename = argv[1];
|
||||||
|
out_prefix = argv[2];
|
||||||
|
} else if (argc > 1) {
|
||||||
|
in_filename = argv[1];
|
||||||
|
out_prefix = argv[1];
|
||||||
|
} else {
|
||||||
|
in_filename = nullptr;
|
||||||
|
out_prefix = "page";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_filename) {
|
||||||
|
in_file = fopen(in_filename, "rb");
|
||||||
|
if (!in_file) {
|
||||||
|
fprintf(stderr, "Can't open file \"%s\"\n", in_filename);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
in_file = stdin;
|
||||||
|
if (isatty(0)) {
|
||||||
|
fprintf(stderr, "No filename given and no input on stdin\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int page_num = 1;
|
||||||
|
while (read_page()) {
|
||||||
|
std::string out_filename = out_prefix
|
||||||
|
+ "-" + std::to_string(page_num) + ".pbm";
|
||||||
|
FILE *out_file = fopen(out_filename.c_str(), "wb");
|
||||||
|
if (!out_file) {
|
||||||
|
fprintf(stderr, "Can't write file \"%s\"\n", out_filename.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
write_pnm(out_file);
|
||||||
|
fclose(out_file);
|
||||||
|
fprintf(stderr, "%s\n", out_filename.c_str());
|
||||||
|
++page_num;
|
||||||
|
}
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
fprintf(stderr, "%s\n", e.what());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
107
RPiSetup/brlaser-master/src/debug.cc
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void dump(const char *name, const T &value) {
|
||||||
|
std::cerr << "DEBUG: " PACKAGE ": page header: " << name << " = " << value << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, int N>
|
||||||
|
void dump(const char *name, const T (&value)[N]) {
|
||||||
|
std::cerr << "DEBUG: " PACKAGE ": page header: " << name << " =";
|
||||||
|
for (int i = 0; i < N; ++i) {
|
||||||
|
std::cerr << ' ' << value[i];
|
||||||
|
}
|
||||||
|
std::cerr << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump(const char *name, const char *value) {
|
||||||
|
std::cerr << "DEBUG: " PACKAGE ": page header: " << name << " = \"" << value << "\"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
template <int N, int M>
|
||||||
|
void dump(const char *name, const char (&value)[N][M]) {
|
||||||
|
std::cerr << "DEBUG: " PACKAGE ": page header: " << name << " =";
|
||||||
|
for (int i = 0; i < N; ++i) {
|
||||||
|
std::cerr << " \"" << value[i] << '"';
|
||||||
|
}
|
||||||
|
std::cerr << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
void dump_page_header(const cups_page_header2_t &h) {
|
||||||
|
#define d(f) dump(#f, h.f)
|
||||||
|
d(MediaClass);
|
||||||
|
d(MediaColor);
|
||||||
|
d(MediaType);
|
||||||
|
d(OutputType);
|
||||||
|
d(AdvanceDistance);
|
||||||
|
d(AdvanceMedia);
|
||||||
|
d(Collate);
|
||||||
|
d(CutMedia);
|
||||||
|
d(Duplex);
|
||||||
|
d(HWResolution);
|
||||||
|
d(ImagingBoundingBox);
|
||||||
|
d(InsertSheet);
|
||||||
|
d(Jog);
|
||||||
|
d(LeadingEdge);
|
||||||
|
d(Margins);
|
||||||
|
d(ManualFeed);
|
||||||
|
d(MediaPosition);
|
||||||
|
d(MediaWeight);
|
||||||
|
d(MirrorPrint);
|
||||||
|
d(NegativePrint);
|
||||||
|
d(NumCopies);
|
||||||
|
d(Orientation);
|
||||||
|
d(OutputFaceUp);
|
||||||
|
d(PageSize);
|
||||||
|
d(Separations);
|
||||||
|
d(TraySwitch);
|
||||||
|
d(Tumble);
|
||||||
|
d(cupsWidth);
|
||||||
|
d(cupsHeight);
|
||||||
|
d(cupsMediaType);
|
||||||
|
d(cupsBitsPerColor);
|
||||||
|
d(cupsBitsPerPixel);
|
||||||
|
d(cupsBytesPerLine);
|
||||||
|
d(cupsColorOrder);
|
||||||
|
d(cupsColorSpace);
|
||||||
|
d(cupsCompression);
|
||||||
|
d(cupsRowCount);
|
||||||
|
d(cupsRowFeed);
|
||||||
|
d(cupsRowStep);
|
||||||
|
d(cupsNumColors);
|
||||||
|
d(cupsBorderlessScalingFactor);
|
||||||
|
d(cupsPageSize);
|
||||||
|
d(cupsImagingBBox);
|
||||||
|
d(cupsInteger);
|
||||||
|
d(cupsReal);
|
||||||
|
d(cupsString);
|
||||||
|
d(cupsMarkerType);
|
||||||
|
d(cupsRenderingIntent);
|
||||||
|
d(cupsPageSizeName);
|
||||||
|
#undef d
|
||||||
|
}
|
||||||
25
RPiSetup/brlaser-master/src/debug.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef DEBUG_H
|
||||||
|
#define DEBUG_H
|
||||||
|
|
||||||
|
#include <cups/raster.h>
|
||||||
|
|
||||||
|
void dump_page_header(const cups_page_header2_t &h);
|
||||||
|
|
||||||
|
#endif
|
||||||
118
RPiSetup/brlaser-master/src/job.cc
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "job.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
#include "line.h"
|
||||||
|
#include "block.h"
|
||||||
|
|
||||||
|
|
||||||
|
job::job(FILE *out, const std::string &job_name)
|
||||||
|
: out_(out),
|
||||||
|
job_name_(job_name),
|
||||||
|
page_params_() {
|
||||||
|
// Delete dubious characters from job name
|
||||||
|
std::replace_if(job_name_.begin(), job_name_.end(), [](char c) {
|
||||||
|
return c < 32 || c >= 127 || c == '"' || c == '\\';
|
||||||
|
}, ' ');
|
||||||
|
|
||||||
|
begin_job();
|
||||||
|
}
|
||||||
|
|
||||||
|
job::~job() {
|
||||||
|
end_job();
|
||||||
|
}
|
||||||
|
|
||||||
|
void job::begin_job() {
|
||||||
|
for (int i = 0; i < 128; ++i) {
|
||||||
|
putc(0, out_);
|
||||||
|
}
|
||||||
|
fprintf(out_, "\033%%-12345X@PJL\n");
|
||||||
|
fprintf(out_, "@PJL JOB NAME=\"%s\"\n", job_name_.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void job::end_job() {
|
||||||
|
fprintf(out_, "\033%%-12345X@PJL\n");
|
||||||
|
fprintf(out_, "@PJL EOJ NAME=\"%s\"\n", job_name_.c_str());
|
||||||
|
fprintf(out_, "\033%%-12345X\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void job::write_page_header() {
|
||||||
|
fprintf(out_, "\033%%-12345X@PJL\n");
|
||||||
|
if (page_params_.resolution != 1200) {
|
||||||
|
fprintf(out_, "@PJL SET RAS1200MODE = FALSE\n");
|
||||||
|
fprintf(out_, "@PJL SET RESOLUTION = %d\n", page_params_.resolution);
|
||||||
|
} else {
|
||||||
|
fprintf(out_, "@PJL SET RAS1200MODE = TRUE\n");
|
||||||
|
fprintf(out_, "@PJL SET RESOLUTION = 600\n");
|
||||||
|
}
|
||||||
|
fprintf(out_, "@PJL SET ECONOMODE = %s\n",
|
||||||
|
page_params_.economode ? "ON" : "OFF");
|
||||||
|
fprintf(out_, "@PJL SET SOURCETRAY = %s\n",
|
||||||
|
page_params_.sourcetray.c_str());
|
||||||
|
fprintf(out_, "@PJL SET MEDIATYPE = %s\n",
|
||||||
|
page_params_.mediatype.c_str());
|
||||||
|
fprintf(out_, "@PJL SET PAPER = %s\n",
|
||||||
|
page_params_.papersize.c_str());
|
||||||
|
fprintf(out_, "@PJL SET PAGEPROTECT = AUTO\n");
|
||||||
|
fprintf(out_, "@PJL SET ORIENTATION = PORTRAIT\n");
|
||||||
|
fprintf(out_, "@PJL ENTER LANGUAGE = PCL\n");
|
||||||
|
|
||||||
|
fputs("\033E", out_);
|
||||||
|
fprintf(out_, "\033&l%dX", std::max(1, page_params_.num_copies));
|
||||||
|
|
||||||
|
if (page_params_.duplex) {
|
||||||
|
fputs("\033&l2S", out_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void job::encode_page(const page_params &page_params,
|
||||||
|
int lines,
|
||||||
|
int linesize,
|
||||||
|
nextline_fn nextline) {
|
||||||
|
if (!(page_params_ == page_params)) {
|
||||||
|
page_params_ = page_params;
|
||||||
|
write_page_header();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> line(linesize);
|
||||||
|
std::vector<uint8_t> reference(linesize);
|
||||||
|
block block;
|
||||||
|
|
||||||
|
if (!nextline(line)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
block.add_line(encode_line(line));
|
||||||
|
std::swap(line, reference);
|
||||||
|
|
||||||
|
fputs("\033*b1030m", out_);
|
||||||
|
|
||||||
|
for (int i = 1; i < lines && nextline(line); ++i) {
|
||||||
|
std::vector<uint8_t> encoded = encode_line(line, reference);
|
||||||
|
if (!block.line_fits(encoded.size())) {
|
||||||
|
block.flush(out_);
|
||||||
|
}
|
||||||
|
block.add_line(std::move(encoded));
|
||||||
|
std::swap(line, reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
block.flush(out_);
|
||||||
|
fputs("1030M\f", out_);
|
||||||
|
fflush(out_);
|
||||||
|
}
|
||||||
68
RPiSetup/brlaser-master/src/job.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef JOB_H
|
||||||
|
#define JOB_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct page_params {
|
||||||
|
int num_copies;
|
||||||
|
int resolution;
|
||||||
|
bool duplex;
|
||||||
|
bool economode;
|
||||||
|
std::string sourcetray;
|
||||||
|
std::string mediatype;
|
||||||
|
std::string papersize;
|
||||||
|
|
||||||
|
bool operator==(const page_params &o) const {
|
||||||
|
return num_copies == o.num_copies
|
||||||
|
&& resolution == o.resolution
|
||||||
|
&& duplex == o.duplex
|
||||||
|
&& economode == o.economode
|
||||||
|
&& sourcetray == o.sourcetray
|
||||||
|
&& mediatype == o.mediatype
|
||||||
|
&& papersize == o.papersize;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class job {
|
||||||
|
public:
|
||||||
|
typedef bool (*nextline_fn)(std::vector<uint8_t> &buf);
|
||||||
|
|
||||||
|
explicit job(FILE *out, const std::string &job_name);
|
||||||
|
~job();
|
||||||
|
|
||||||
|
void encode_page(const page_params ¶ms,
|
||||||
|
int lines,
|
||||||
|
int linesize,
|
||||||
|
nextline_fn nextline);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void begin_job();
|
||||||
|
void end_job();
|
||||||
|
void write_page_header();
|
||||||
|
|
||||||
|
FILE *out_;
|
||||||
|
std::string job_name_;
|
||||||
|
page_params page_params_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // JOB_H
|
||||||
191
RPiSetup/brlaser-master/src/line.cc
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "line.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <algorithm>
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void write_overflow(int value, vector<uint8_t> *out) {
|
||||||
|
if (value >= 0) {
|
||||||
|
if (value < 255) {
|
||||||
|
out->push_back(value);
|
||||||
|
} else {
|
||||||
|
out->insert(out->end(), value / 255, 255);
|
||||||
|
out->push_back(value % 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
void write_substitute(int offset,
|
||||||
|
Iterator first,
|
||||||
|
Iterator last,
|
||||||
|
vector<uint8_t> *out) {
|
||||||
|
assert(offset >= 0);
|
||||||
|
assert(offset < 10000);
|
||||||
|
assert(first != last);
|
||||||
|
|
||||||
|
const int offset_max = 15;
|
||||||
|
const int count_max = 7;
|
||||||
|
int count = std::distance(first, last) - 1;
|
||||||
|
|
||||||
|
int offset_low = std::min(offset, offset_max);
|
||||||
|
int count_low = std::min(count, count_max);
|
||||||
|
out->push_back((offset_low << 3) | count_low);
|
||||||
|
write_overflow(offset - offset_max, out);
|
||||||
|
write_overflow(count - count_max, out);
|
||||||
|
out->insert(out->end(), first, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_repeat(int offset, int count, int value, vector<uint8_t> *out) {
|
||||||
|
assert(offset >= 0);
|
||||||
|
assert(offset < 10000);
|
||||||
|
assert(count >= 2);
|
||||||
|
assert(count < 10000);
|
||||||
|
|
||||||
|
const int offset_max = 3;
|
||||||
|
const int count_max = 31;
|
||||||
|
count -= 2;
|
||||||
|
|
||||||
|
int offset_low = std::min(offset, offset_max);
|
||||||
|
int count_low = std::min(count, count_max);
|
||||||
|
out->push_back(128 | (offset_low << 5) | count_low);
|
||||||
|
write_overflow(offset - offset_max, out);
|
||||||
|
write_overflow(count - count_max, out);
|
||||||
|
out->push_back(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool all_zeros(const vector<uint8_t> &buf) {
|
||||||
|
return std::none_of(buf.begin(), buf.end(), [](uint8_t b) { return b; });
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Iterator1, typename Iterator2>
|
||||||
|
int skip_to_next_mismatch(Iterator1 *first1,
|
||||||
|
Iterator1 last1,
|
||||||
|
Iterator2 *first2) {
|
||||||
|
auto mismatch_it = std::mismatch(*first1, last1, *first2);
|
||||||
|
int skipped = std::distance(*first1, mismatch_it.first);
|
||||||
|
*first1 = mismatch_it.first;
|
||||||
|
*first2 = mismatch_it.second;
|
||||||
|
return skipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
int repeat_length(Iterator first, Iterator last) {
|
||||||
|
if (first != last) {
|
||||||
|
auto k = *first;
|
||||||
|
auto mismatch = std::find_if(std::next(first), last,
|
||||||
|
[=](decltype(k) x) { return x != k; });
|
||||||
|
return std::distance(first, mismatch);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Iterator1, typename Iterator2>
|
||||||
|
int substitute_length(Iterator1 first1, Iterator1 last1, Iterator2 first2) {
|
||||||
|
if (first1 != last1) {
|
||||||
|
Iterator1 it1 = first1;
|
||||||
|
Iterator2 it2 = first2;
|
||||||
|
Iterator1 next1 = std::next(first1);
|
||||||
|
Iterator2 next2 = std::next(first2);
|
||||||
|
Iterator1 prev1 = first1;
|
||||||
|
while (next1 != last1) {
|
||||||
|
if ((*it1 == *it2 && *next1 == *next2)) {
|
||||||
|
return std::distance(first1, it1);
|
||||||
|
}
|
||||||
|
if (*it1 == *next1 && *it1 == *prev1) {
|
||||||
|
return std::distance(first1, prev1);
|
||||||
|
}
|
||||||
|
prev1 = it1;
|
||||||
|
it1 = next1; it2 = next2;
|
||||||
|
++next1; ++next2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::distance(first1, last1);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t reserve_size(const vector<uint8_t> &line) {
|
||||||
|
// Big enough to store the line uncompressed together with an Substitute
|
||||||
|
// command with many overflow bytes.
|
||||||
|
return line.size() + 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
vector<uint8_t> encode_line(const vector<uint8_t> &line,
|
||||||
|
const vector<uint8_t> &reference) {
|
||||||
|
assert(line.size() == reference.size());
|
||||||
|
if (all_zeros(line)) {
|
||||||
|
return vector<uint8_t>(1, 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint8_t> output;
|
||||||
|
output.reserve(reserve_size(line));
|
||||||
|
output.push_back(0); // first byte is the edit count
|
||||||
|
|
||||||
|
const uint8_t max_edits = 254;
|
||||||
|
int num_edits = 0;
|
||||||
|
|
||||||
|
auto line_it = line.begin();
|
||||||
|
auto ref_it = reference.begin();
|
||||||
|
while (1) {
|
||||||
|
int offset = skip_to_next_mismatch(&line_it, line.end(), &ref_it);
|
||||||
|
if (line_it == line.end()) {
|
||||||
|
// No more differences, we're done.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++num_edits == max_edits) {
|
||||||
|
// We've run out of edits. Just output the rest of the line in a big
|
||||||
|
// substitute command.
|
||||||
|
write_substitute(offset, line_it, line.end(), &output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int s = substitute_length(line_it, line.end(), ref_it);
|
||||||
|
if (s > 0) {
|
||||||
|
write_substitute(offset, line_it, std::next(line_it, s), &output);
|
||||||
|
line_it += s;
|
||||||
|
ref_it += s;
|
||||||
|
} else {
|
||||||
|
int r = repeat_length(line_it, line.end());
|
||||||
|
assert(r >= 2);
|
||||||
|
write_repeat(offset, r, *line_it, &output);
|
||||||
|
line_it += r;
|
||||||
|
ref_it += r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(num_edits <= max_edits);
|
||||||
|
output[0] = num_edits;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<uint8_t> encode_line(const vector<uint8_t> &line) {
|
||||||
|
if (all_zeros(line)) {
|
||||||
|
return vector<uint8_t>(1, 0xFF);
|
||||||
|
}
|
||||||
|
vector<uint8_t> buf;
|
||||||
|
buf.reserve(reserve_size(line));
|
||||||
|
buf.push_back(1);
|
||||||
|
write_substitute(0, line.begin(), line.end(), &buf);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
31
RPiSetup/brlaser-master/src/line.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef LINE_H
|
||||||
|
#define LINE_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::vector<uint8_t> encode_line(
|
||||||
|
const std::vector<uint8_t> &line,
|
||||||
|
const std::vector<uint8_t> &reference);
|
||||||
|
|
||||||
|
std::vector<uint8_t> encode_line(
|
||||||
|
const std::vector<uint8_t> &line);
|
||||||
|
|
||||||
|
#endif // LINE_H
|
||||||
205
RPiSetup/brlaser-master/src/main.cc
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2013 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <cups/raster.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
#include <array>
|
||||||
|
#include <map>
|
||||||
|
#include "config.h"
|
||||||
|
#include "job.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
cups_raster_t *ras;
|
||||||
|
volatile sig_atomic_t interrupted = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void sigterm_handler(int sig) {
|
||||||
|
interrupted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool next_line(std::vector<uint8_t> &buf) {
|
||||||
|
if (interrupted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return cupsRasterReadPixels(ras, buf.data(), buf.size()) == buf.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool plain_ascii_string(const char *str) {
|
||||||
|
bool result = true;
|
||||||
|
for (; result && *str; str++) {
|
||||||
|
result = *str >= 32 && *str <= 126;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ascii_job_name(const char *job_id, const char *job_user, const char *job_name) {
|
||||||
|
std::array<const char *, 3> parts = {{
|
||||||
|
job_id,
|
||||||
|
job_user,
|
||||||
|
job_name
|
||||||
|
}};
|
||||||
|
std::string result;
|
||||||
|
for (const char *part : parts) {
|
||||||
|
if (*part && plain_ascii_string(part)) {
|
||||||
|
if (!result.empty()) {
|
||||||
|
result += '/';
|
||||||
|
}
|
||||||
|
result += part;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result.empty()) {
|
||||||
|
result = "brlaser";
|
||||||
|
}
|
||||||
|
const int max_size = 79;
|
||||||
|
if (result.size() > max_size) {
|
||||||
|
result.resize(max_size);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
page_params build_page_params(const cups_page_header2_t &header) {
|
||||||
|
static const std::array<std::string, 6> sources = {{
|
||||||
|
"AUTO", "T1", "T2", "T3", "MP", "MANUAL"
|
||||||
|
}};
|
||||||
|
static const std::map<std::string, std::string> sizes = {
|
||||||
|
{ "A4", "A4" },
|
||||||
|
{ "A5", "A5" },
|
||||||
|
{ "A6", "A6" },
|
||||||
|
{ "B5", "B5" },
|
||||||
|
{ "B6", "B6" },
|
||||||
|
{ "EnvC5", "C5" },
|
||||||
|
{ "EnvMonarch", "MONARCH" },
|
||||||
|
{ "EnvPRC5", "DL" },
|
||||||
|
{ "EnvDL", "DL" },
|
||||||
|
{ "Executive", "EXECUTIVE" },
|
||||||
|
{ "Legal", "LEGAL" },
|
||||||
|
{ "Letter", "LETTER" }
|
||||||
|
};
|
||||||
|
|
||||||
|
page_params p = { };
|
||||||
|
p.num_copies = header.NumCopies;
|
||||||
|
p.resolution = header.HWResolution[0];
|
||||||
|
p.economode = header.cupsInteger[10];
|
||||||
|
p.mediatype = header.MediaType;
|
||||||
|
p.duplex = header.Duplex;
|
||||||
|
|
||||||
|
if (header.MediaPosition < sources.size())
|
||||||
|
p.sourcetray = sources[header.MediaPosition];
|
||||||
|
else
|
||||||
|
p.sourcetray = sources[0];
|
||||||
|
|
||||||
|
auto size_it = sizes.find(header.cupsPageSizeName);
|
||||||
|
if (size_it != sizes.end())
|
||||||
|
p.papersize = size_it->second;
|
||||||
|
else
|
||||||
|
p.papersize = "A4";
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
fprintf(stderr, "INFO: %s version %s\n", PACKAGE, VERSION);
|
||||||
|
|
||||||
|
if (argc != 6 && argc != 7) {
|
||||||
|
fprintf(stderr, "ERROR: rastertobrlaser job-id user title copies options [file]\n");
|
||||||
|
fprintf(stderr, "INFO: This program is a CUPS filter. It is not intended to be run manually.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *job_id = argv[1];
|
||||||
|
const char *job_user = argv[2];
|
||||||
|
const char *job_name = argv[3];
|
||||||
|
// const int job_copies = atoi(argv[4]);
|
||||||
|
// const char *job_options = argv[5];
|
||||||
|
const char *job_filename = argv[6];
|
||||||
|
// const char *job_charset = getenv("CHARSET");
|
||||||
|
|
||||||
|
signal(SIGTERM, sigterm_handler);
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
|
int fd = STDIN_FILENO;
|
||||||
|
if (job_filename) {
|
||||||
|
fd = open(job_filename, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "ERROR: " PACKAGE ": Unable to open raster file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (pledge("stdio", nullptr) != 0) {
|
||||||
|
fprintf(stderr, "ERROR: " PACKAGE ": pledge failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ras = cupsRasterOpen(fd, CUPS_RASTER_READ);
|
||||||
|
if (!ras) {
|
||||||
|
fprintf(stderr, "DEBUG: " PACKAGE ": Cannot read raster data. Most likely an earlier filter in the pipeline failed.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pages = 0;
|
||||||
|
{
|
||||||
|
job job(stdout, ascii_job_name(job_id, job_user, job_name));
|
||||||
|
cups_page_header2_t header;
|
||||||
|
while (!interrupted && cupsRasterReadHeader2(ras, &header)) {
|
||||||
|
if (header.cupsBitsPerPixel != 1
|
||||||
|
|| header.cupsBitsPerColor != 1
|
||||||
|
|| header.cupsNumColors != 1
|
||||||
|
|| header.cupsBytesPerLine > 10000) {
|
||||||
|
fprintf(stderr, "ERROR: " PACKAGE ": Page %d: Bogus raster data.\n", pages + 1);
|
||||||
|
dump_page_header(header);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (pages == 0) {
|
||||||
|
fprintf(stderr, "DEBUG: " PACKAGE ": Page header of first page\n");
|
||||||
|
dump_page_header(header);
|
||||||
|
}
|
||||||
|
job.encode_page(build_page_params(header),
|
||||||
|
header.cupsHeight,
|
||||||
|
header.cupsBytesPerLine,
|
||||||
|
next_line);
|
||||||
|
fprintf(stderr, "PAGE: %d %d\n", ++pages, header.NumCopies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pages == 0) {
|
||||||
|
fprintf(stderr, "ERROR: " PACKAGE ": No pages were found.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fflush(stdout);
|
||||||
|
if (ferror(stdout)) {
|
||||||
|
fprintf(stderr, "DEBUG: " PACKAGE ": Could not write print data. Most likely the CUPS backend failed.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
199
RPiSetup/brlaser-master/test/lest.hpp
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
// Copyright 2013 by Martin Moene
|
||||||
|
//
|
||||||
|
// lest is based on ideas by Kevlin Henney, see video at
|
||||||
|
// http://skillsmatter.com/podcast/agile-testing/kevlin-henney-rethinking-unit-testing-in-c-plus-plus
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0:
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#ifndef LEST_LEST_H_INCLUDED
|
||||||
|
#define LEST_LEST_H_INCLUDED
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#ifndef lest_NO_SHORT_ASSERTION_NAMES
|
||||||
|
# define EXPECT lest_EXPECT
|
||||||
|
# define EXPECT_THROWS lest_EXPECT_THROWS
|
||||||
|
# define EXPECT_THROWS_AS lest_EXPECT_THROWS_AS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define lest_EXPECT( expr ) \
|
||||||
|
try \
|
||||||
|
{ \
|
||||||
|
if ( ! (expr) ) \
|
||||||
|
throw lest::failure{ lest_LOCATION, #expr }; \
|
||||||
|
} \
|
||||||
|
catch( lest::failure const & ) \
|
||||||
|
{ \
|
||||||
|
throw ; \
|
||||||
|
} \
|
||||||
|
catch( std::exception const & e ) \
|
||||||
|
{ \
|
||||||
|
throw lest::unexpected{ lest_LOCATION, #expr, lest::with_message( e.what() ) }; \
|
||||||
|
} \
|
||||||
|
catch(...) \
|
||||||
|
{ \
|
||||||
|
throw lest::unexpected{ lest_LOCATION, #expr, "of unknown type" }; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define lest_EXPECT_THROWS( expr ) \
|
||||||
|
for (;;) \
|
||||||
|
{ \
|
||||||
|
try { lest::serum( expr ); } catch (...) { break; } \
|
||||||
|
throw lest::expected{ lest_LOCATION, #expr }; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define lest_EXPECT_THROWS_AS( expr, excpt ) \
|
||||||
|
for (;;) \
|
||||||
|
{ \
|
||||||
|
try { lest::serum( expr ); } catch ( excpt & ) { break; } catch (...) {} \
|
||||||
|
throw lest::expected{ lest_LOCATION, #expr, lest::of_type( #excpt ) }; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define lest_LOCATION lest::location{__FILE__, __LINE__}
|
||||||
|
|
||||||
|
namespace lest {
|
||||||
|
|
||||||
|
struct test
|
||||||
|
{
|
||||||
|
const std::string name;
|
||||||
|
const std::function<void()> behaviour;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct location
|
||||||
|
{
|
||||||
|
const std::string file;
|
||||||
|
const int line;
|
||||||
|
|
||||||
|
location( std::string file, int line )
|
||||||
|
: file{ file }, line{ line } {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct comment
|
||||||
|
{
|
||||||
|
const std::string text;
|
||||||
|
|
||||||
|
comment( std::string text ) : text{ text } {}
|
||||||
|
explicit operator bool() { return ! text.empty(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct message : std::runtime_error
|
||||||
|
{
|
||||||
|
const std::string kind;
|
||||||
|
const location where;
|
||||||
|
const comment note;
|
||||||
|
|
||||||
|
~message() throw() {} // GCC 4.6
|
||||||
|
|
||||||
|
message( std::string kind, location where, std::string expr, std::string note = "" )
|
||||||
|
: std::runtime_error{ expr }, kind{ kind }, where{ where }, note{ note } {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct failure : message
|
||||||
|
{
|
||||||
|
failure( location where, std::string expr )
|
||||||
|
: message{ "failed", where, expr } {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct expected : message
|
||||||
|
{
|
||||||
|
expected( location where, std::string expr, std::string excpt = "" )
|
||||||
|
: message{ "failed: didn't get exception", where, expr, excpt } {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct unexpected : message
|
||||||
|
{
|
||||||
|
unexpected( location where, std::string expr, std::string note )
|
||||||
|
: message{ "failed: got unexpected exception", where, expr, note } {}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool serum( bool verum ) { return verum; }
|
||||||
|
|
||||||
|
inline std::string with_message( std::string text )
|
||||||
|
{
|
||||||
|
return "with message \"" + text + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string of_type( std::string text )
|
||||||
|
{
|
||||||
|
return "of type " + text;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string pluralise( int n, std::string text )
|
||||||
|
{
|
||||||
|
return n == 1 ? text : text + "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::ostream & operator<<( std::ostream & os, comment note )
|
||||||
|
{
|
||||||
|
return os << (note ? " " + note.text : "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::ostream & operator<<( std::ostream & os, location where )
|
||||||
|
{
|
||||||
|
#ifdef __GNUG__
|
||||||
|
return os << where.file << ":" << where.line;
|
||||||
|
#else
|
||||||
|
return os << where.file << "(" << where.line << ")";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void report( std::ostream & os, message const & e, std::string test )
|
||||||
|
{
|
||||||
|
os << e.where << ": " << e.kind << e.note << ": " << test << ": " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N>
|
||||||
|
int run( test const (&specification)[N], std::ostream & os = std::cout )
|
||||||
|
{
|
||||||
|
int failures = 0;
|
||||||
|
|
||||||
|
for ( auto & testing : specification )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
testing.behaviour();
|
||||||
|
}
|
||||||
|
catch( message const & e )
|
||||||
|
{
|
||||||
|
++failures;
|
||||||
|
report( os, e, testing.name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( failures > 0 )
|
||||||
|
{
|
||||||
|
os << failures << " out of " << N << " " << pluralise(N, "test") << " failed." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace lest
|
||||||
|
|
||||||
|
#endif // LEST_LEST_H_INCLUDED
|
||||||
54
RPiSetup/brlaser-master/test/tempfile.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2014 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef TEMPFILE_H
|
||||||
|
#define TEMPFILE_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class tempfile {
|
||||||
|
public:
|
||||||
|
explicit tempfile()
|
||||||
|
: ptr_(0),
|
||||||
|
size_(0),
|
||||||
|
file_(open_memstream(&ptr_, &size_)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
~tempfile() {
|
||||||
|
fclose(file_);
|
||||||
|
free(ptr_);
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *file() {
|
||||||
|
return file_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> data() {
|
||||||
|
if (fflush(file_))
|
||||||
|
return std::vector<uint8_t>();
|
||||||
|
return std::vector<uint8_t>(ptr_, ptr_ + size_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
char *ptr_;
|
||||||
|
size_t size_;
|
||||||
|
FILE *file_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEMPFILE_H
|
||||||
91
RPiSetup/brlaser-master/test/test_block.cc
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2014 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "lest.hpp"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
#include "tempfile.h"
|
||||||
|
#include "../src/block.h"
|
||||||
|
|
||||||
|
typedef std::vector<uint8_t> vec;
|
||||||
|
|
||||||
|
const lest::test specification[] = {
|
||||||
|
"A block is created empty",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
EXPECT(b.empty());
|
||||||
|
},
|
||||||
|
|
||||||
|
"Adding a line makes a block no longer empty",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
b.add_line(vec{1});
|
||||||
|
EXPECT(!b.empty());
|
||||||
|
},
|
||||||
|
|
||||||
|
"A block can contain 128 lines",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
for (int i = 0; i < 128; ++i) {
|
||||||
|
EXPECT(b.line_fits(1));
|
||||||
|
b.add_line(vec(1));
|
||||||
|
}
|
||||||
|
EXPECT(!b.line_fits(1));
|
||||||
|
},
|
||||||
|
|
||||||
|
"A block has a size limit of about 16 kilobyte",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
for (int i = 0; i < 16; ++i) {
|
||||||
|
EXPECT(b.line_fits(1000));
|
||||||
|
b.add_line(vec(1000));
|
||||||
|
}
|
||||||
|
EXPECT(!b.line_fits(400));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Flushing an empty block does nothing",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
tempfile f;
|
||||||
|
b.flush(f.file());
|
||||||
|
EXPECT(f.data().empty());
|
||||||
|
},
|
||||||
|
|
||||||
|
"Flush() writes the lines to a file with a proper header",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
for (uint8_t n = 1; n < 6; ++n) {
|
||||||
|
b.add_line(vec{n, n});
|
||||||
|
}
|
||||||
|
tempfile f;
|
||||||
|
b.flush(f.file());
|
||||||
|
EXPECT(( f.data() == vec{'1','2','w',0,5,1,1,2,2,3,3,4,4,5,5} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"After flush() a block is empty again",
|
||||||
|
[] {
|
||||||
|
block b;
|
||||||
|
b.add_line(vec{1});
|
||||||
|
tempfile f;
|
||||||
|
b.flush(f.file());
|
||||||
|
EXPECT(b.empty());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return lest::run(specification);
|
||||||
|
}
|
||||||
291
RPiSetup/brlaser-master/test/test_lest.cc
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
// Copyright 2013 by Martin Moene
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0:
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
#include "lest.hpp"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace lest;
|
||||||
|
|
||||||
|
const lest::test specification[] =
|
||||||
|
{
|
||||||
|
"Function to suppress warning \"expression has no effect\" acts as identity function", []
|
||||||
|
{
|
||||||
|
EXPECT( false == serum( false ) );
|
||||||
|
EXPECT( true == serum( true ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Function with_message() returns correct string", []
|
||||||
|
{
|
||||||
|
std::string msg = "Let writing tests become irresistibly easy and attractive.";
|
||||||
|
EXPECT( "with message \"" + msg + "\"" == with_message( msg ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Function of_type() returns correct string", []
|
||||||
|
{
|
||||||
|
std::string msg = "this_type";
|
||||||
|
EXPECT( "of type " + msg == of_type( msg ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Function pluralise() adds 's' except for 1 item", []
|
||||||
|
{
|
||||||
|
std::string word = "hammer";
|
||||||
|
EXPECT( word == pluralise( 1, word ) );
|
||||||
|
for ( auto i : {0,2,3,4,5,6,7,8,9,10,11,12} )
|
||||||
|
EXPECT( word + "s" == pluralise( i, word ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Location constructs properly", []
|
||||||
|
{
|
||||||
|
char const * file = __FILE__; int line = __LINE__;
|
||||||
|
location where{ file, line };
|
||||||
|
EXPECT( file == where.file );
|
||||||
|
EXPECT( line == where.line );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Comment constructs properly", []
|
||||||
|
{
|
||||||
|
std::string text = __FILE__;
|
||||||
|
comment note = text;
|
||||||
|
EXPECT( text == note.text );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Comment converted to bool indicates absence or presence of comment", []
|
||||||
|
{
|
||||||
|
EXPECT( false == bool( comment( "") ) );
|
||||||
|
EXPECT( true == bool( comment("x") ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Failure exception type constructs and prints properly", []
|
||||||
|
{
|
||||||
|
std::string name = "test-name";
|
||||||
|
failure msg( location{"filename.cpp", 765}, "expression" );
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
report( os, msg, name );
|
||||||
|
|
||||||
|
#ifndef __GNUG__
|
||||||
|
EXPECT( os.str() == "filename.cpp(765): failed: test-name: expression\n" );
|
||||||
|
#else
|
||||||
|
EXPECT( os.str() == "filename.cpp:765: failed: test-name: expression\n" );
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expected exception type constructs and prints properly", []
|
||||||
|
{
|
||||||
|
std::string name = "test-name";
|
||||||
|
expected msg( location{"filename.cpp", 765}, "expression" );
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
report( os, msg, name );
|
||||||
|
|
||||||
|
#ifndef __GNUG__
|
||||||
|
EXPECT( os.str() == "filename.cpp(765): failed: didn't get exception: test-name: expression\n" );
|
||||||
|
#else
|
||||||
|
EXPECT( os.str() == "filename.cpp:765: failed: didn't get exception: test-name: expression\n" );
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
|
||||||
|
"Unexpected exception type constructs and prints properly", []
|
||||||
|
{
|
||||||
|
std::string name = "test-name";
|
||||||
|
unexpected msg( location{"filename.cpp", 765}, "expression", "exception-type" );
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
report( os, msg, name );
|
||||||
|
|
||||||
|
#ifndef __GNUG__
|
||||||
|
EXPECT( os.str() == "filename.cpp(765): failed: got unexpected exception exception-type: test-name: expression\n" );
|
||||||
|
#else
|
||||||
|
EXPECT( os.str() == "filename.cpp:765: failed: got unexpected exception exception-type: test-name: expression\n" );
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect generates no message exception for a succeeding test", []
|
||||||
|
{
|
||||||
|
test pass = { "P", [] { EXPECT( true ); } };
|
||||||
|
|
||||||
|
try { pass.behaviour(); }
|
||||||
|
catch(...) { throw failure(location{__FILE__,__LINE__}, "unexpected error generated"); }
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect generates a message exception for a failing test", []
|
||||||
|
{
|
||||||
|
test fail = { "F", [] { EXPECT( false ); } };
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
try { fail.behaviour(); } catch ( message & ) { break; }
|
||||||
|
throw failure(location{__FILE__,__LINE__}, "no error generated");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect succeeds for success (true) and failure (false)", []
|
||||||
|
{
|
||||||
|
test pass[] = {{ "P", [] { EXPECT( true ); } }};
|
||||||
|
test fail[] = {{ "F", [] { EXPECT( false ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass, os ) );
|
||||||
|
EXPECT( 1 == run( fail, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect succeeds for integer comparation", []
|
||||||
|
{
|
||||||
|
test pass [] = {{ "P" , [] { EXPECT( 7 == 7 ); EXPECT( 7 != 8 );
|
||||||
|
EXPECT( 7 >= 6 ); EXPECT( 7 <= 8 );
|
||||||
|
EXPECT( 7 > 6 ); EXPECT( 7 < 8 ); } }};
|
||||||
|
test fail_1[] = {{ "F1", [] { EXPECT( 7 == 8 ); } }};
|
||||||
|
test fail_2[] = {{ "F2", [] { EXPECT( 7 != 7 ); } }};
|
||||||
|
test fail_3[] = {{ "F3", [] { EXPECT( 7 <= 6 ); } }};
|
||||||
|
test fail_4[] = {{ "F4", [] { EXPECT( 7 >= 8 ); } }};
|
||||||
|
test fail_5[] = {{ "F5", [] { EXPECT( 7 < 6 ); } }};
|
||||||
|
test fail_6[] = {{ "F6", [] { EXPECT( 7 > 8 ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass , os ) );
|
||||||
|
EXPECT( 1 == run( fail_1, os ) );
|
||||||
|
EXPECT( 1 == run( fail_2, os ) );
|
||||||
|
EXPECT( 1 == run( fail_3, os ) );
|
||||||
|
EXPECT( 1 == run( fail_4, os ) );
|
||||||
|
EXPECT( 1 == run( fail_5, os ) );
|
||||||
|
EXPECT( 1 == run( fail_6, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect succeeds for string comparation", []
|
||||||
|
{
|
||||||
|
std::string a("a"); std::string b("b");
|
||||||
|
test pass [] = {{ "P" , [=]() { EXPECT( a == a ); EXPECT( a != b );
|
||||||
|
EXPECT( b >= a ); EXPECT( a <= b );
|
||||||
|
EXPECT( b > a ); EXPECT( a < b ); } }};
|
||||||
|
test fail_1[] = {{ "F1", [=]() { EXPECT( a == b ); } }};
|
||||||
|
test fail_2[] = {{ "F2", [=]() { EXPECT( a != a ); } }};
|
||||||
|
test fail_3[] = {{ "F3", [=]() { EXPECT( b <= a ); } }};
|
||||||
|
test fail_4[] = {{ "F4", [=]() { EXPECT( a >= b ); } }};
|
||||||
|
test fail_5[] = {{ "F5", [=]() { EXPECT( b < a ); } }};
|
||||||
|
test fail_6[] = {{ "F6", [=]() { EXPECT( a > b ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass , os ) );
|
||||||
|
EXPECT( 1 == run( fail_1, os ) );
|
||||||
|
EXPECT( 1 == run( fail_2, os ) );
|
||||||
|
EXPECT( 1 == run( fail_3, os ) );
|
||||||
|
EXPECT( 1 == run( fail_4, os ) );
|
||||||
|
EXPECT( 1 == run( fail_5, os ) );
|
||||||
|
EXPECT( 1 == run( fail_6, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Function run() returns the right failure count", []
|
||||||
|
{
|
||||||
|
test pass [] = {{ "P" , [] { EXPECT( 1==1 ); } }};
|
||||||
|
test fail_1[] = {{ "F1", [] { EXPECT( 0==1 ); } }};
|
||||||
|
test fail_3[] = {{ "F1", [] { EXPECT( 0==1 ); } },
|
||||||
|
{ "F2", [] { EXPECT( 0==1 ); } },
|
||||||
|
{ "F3", [] { EXPECT( 0==1 ); } },};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass , os ) );
|
||||||
|
EXPECT( 1 == run( fail_1, os ) );
|
||||||
|
EXPECT( 3 == run( fail_3, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect succeeds with an unexpected standard exception", []
|
||||||
|
{
|
||||||
|
std::string text = "hello-world";
|
||||||
|
test pass[] = {{ "P", [=]() { EXPECT( (throw std::runtime_error(text), true) ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 1 == run( pass, os ) );
|
||||||
|
EXPECT( std::string::npos != os.str().find(text) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect succeeds with an unexpected non-standard exception", []
|
||||||
|
{
|
||||||
|
test pass[] = {{ "P", [] { EXPECT( (throw 77, true) ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 1 == run( pass, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect_throws succeeds with an expected standard exception", []
|
||||||
|
{
|
||||||
|
std::string text = "hello-world";
|
||||||
|
test pass[] = {{ "P", [=]() { EXPECT_THROWS( (throw std::runtime_error(text), true) ); } }};
|
||||||
|
test fail[] = {{ "F", [ ]() { EXPECT_THROWS( true ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass, os ) );
|
||||||
|
EXPECT( 1 == run( fail, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect_throws succeeds with an expected non-standard exception", []
|
||||||
|
{
|
||||||
|
test pass[] = {{ "P", [] { EXPECT_THROWS( (throw 77, true) ); } }};
|
||||||
|
test fail[] = {{ "F", [] { EXPECT_THROWS( true ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass, os ) );
|
||||||
|
EXPECT( 1 == run( fail, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect_throws_as succeeds with a specific expected standard exception", []
|
||||||
|
{
|
||||||
|
test pass[] = {{ "P", [] { EXPECT_THROWS_AS( (throw std::bad_alloc(), true), std::bad_alloc ); } }};
|
||||||
|
test fail[] = {{ "F", [] { EXPECT_THROWS_AS( (throw std::bad_alloc(), true), std::runtime_error ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass, os ) );
|
||||||
|
EXPECT( 1 == run( fail, os ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
"Expect_throws_as succeeds with a specific expected non-standard exception", []
|
||||||
|
{
|
||||||
|
test pass[] = {{ "P", [] { EXPECT_THROWS_AS( (throw 77, true), int ); } }};
|
||||||
|
test fail[] = {{ "F", [] { EXPECT_THROWS_AS( (throw 77, true), std::runtime_error ); } }};
|
||||||
|
|
||||||
|
std::ostringstream os;
|
||||||
|
|
||||||
|
EXPECT( 0 == run( pass, os ) );
|
||||||
|
EXPECT( 1 == run( fail, os ) );
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return lest::run( specification );
|
||||||
|
}
|
||||||
|
|
||||||
|
// cl -nologo -Wall -EHsc test_lest.cpp && test_lest
|
||||||
|
// g++ -Wall -Wextra -Weffc++ -std=c++11 -o test_lest.exe test_lest.cpp && test_lest
|
||||||
|
|
||||||
150
RPiSetup/brlaser-master/test/test_line.cc
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
// This file is part of the brlaser printer driver.
|
||||||
|
//
|
||||||
|
// Copyright 2014 Peter De Wachter
|
||||||
|
//
|
||||||
|
// brlaser is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// brlaser is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with brlaser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "lest.hpp"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <vector>
|
||||||
|
#include "../src/line.h"
|
||||||
|
|
||||||
|
typedef std::vector<uint8_t> vec;
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t sub(uint8_t offset, uint8_t count) {
|
||||||
|
assert(offset < 16);
|
||||||
|
assert(count < 8);
|
||||||
|
return (offset << 3) | count;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t rep(uint8_t offset, uint8_t count) {
|
||||||
|
assert(offset < 4);
|
||||||
|
assert(count < 32);
|
||||||
|
return 128 | (offset << 5) | count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const lest::test specification[] = {
|
||||||
|
"Don't crash on zero-length lines",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{}) == vec{0xFF} ));
|
||||||
|
EXPECT(( encode_line(vec{}, vec{}) == vec{0xFF} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Encoding an initial blank line",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{0,0,0}) == vec{0xFF} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Encoding an initial non-blank line",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,2,3}) == (vec{1,sub(0,2),1,2,3}) ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Encoding a (non-initial) blank line",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{0,0,0}, vec{1,2,3}) == vec{0xFF} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Encoding a repeated line",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,2,3}, vec{1,2,3}) == vec{0} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Using a subsitute command",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{0,0,1,2,3,0,0}, vec(7)) == vec{1,sub(2,2),1,2,3} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Using a repeat command",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{0,0,1,1,0,0}, vec(6)) == vec{1,rep(2,0),1} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Repeat command followed by substitute command",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,1,1,2,3}, vec(5)) == vec{2,rep(0,1),1,sub(0,1),2,3} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Substitute comand followed by repeat command",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{3,2,1,1,1}, vec(5)) == vec{2,sub(0,1),3,2,rep(0,1),1} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Substitute with an unmodified byte in the middle",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,2,3,0,1,2,3}, vec(7)) == vec{1,sub(0,6),1,2,3,0,1,2,3} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Substitue with two unmodified bytes in the middle",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,2,3,0,0,1,2,3}, vec(8)) == vec{2,sub(0,2),1,2,3,sub(2,2),1,2,3} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Repeat with an unmodified byte in the middle",
|
||||||
|
[] {
|
||||||
|
EXPECT(( encode_line(vec{1,1,1,0,1,1,1}, vec(7)) == vec{2,rep(0,1),1,rep(1,1),1} ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"254 edits needed for a single line",
|
||||||
|
[] {
|
||||||
|
vec line, result;
|
||||||
|
for (int i = 0; i < 254; ++i)
|
||||||
|
line.insert(line.end(), {0,0,1});
|
||||||
|
result.push_back(254);
|
||||||
|
for (int i = 0; i < 254; ++i)
|
||||||
|
result.insert(result.end(), {sub(2,0),1});
|
||||||
|
EXPECT(( encode_line(line, vec(line.size())) == result ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Give up if more than 254 edits needed...",
|
||||||
|
[] {
|
||||||
|
vec line, result;
|
||||||
|
for (int i = 0; i < 255; ++i)
|
||||||
|
line.insert(line.end(), {0,0,1});
|
||||||
|
result.push_back(254);
|
||||||
|
for (int i = 0; i < 253; ++i)
|
||||||
|
result.insert(result.end(), {sub(2,0),1});
|
||||||
|
result.insert(result.end(), {sub(2,3),1,0,0,1});
|
||||||
|
EXPECT(( encode_line(line, vec(line.size())) == result ));
|
||||||
|
},
|
||||||
|
|
||||||
|
"Repeat command with overflow bytes",
|
||||||
|
[] {
|
||||||
|
vec line(3, 0);
|
||||||
|
line.insert(line.end(), 512, 1);
|
||||||
|
vec ref(line.size(), 0);
|
||||||
|
vec expected{1,rep(3,31),0,255,224,1};
|
||||||
|
EXPECT(encode_line(line, ref) == expected);
|
||||||
|
},
|
||||||
|
|
||||||
|
"Substitute command with overflow bytes",
|
||||||
|
[] {
|
||||||
|
vec expected{1,sub(15,7),255,0,255,237};
|
||||||
|
vec line(270, 0);
|
||||||
|
for (int i = 0; i < 250; ++i) {
|
||||||
|
expected.insert(expected.end(), {1,2});
|
||||||
|
line.insert(line.end(), {1,2});
|
||||||
|
}
|
||||||
|
vec ref(line.size(), 0);
|
||||||
|
EXPECT(encode_line(line, ref) == expected);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return lest::run(specification);
|
||||||
|
}
|
||||||
10
RPiSetup/etc/apache2/conf-available/opendrs.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# OpenMDRS configuration
|
||||||
|
|
||||||
|
Alias /opendrs /var/www/opendrs
|
||||||
|
|
||||||
|
<Directory /var/www/opendrs>
|
||||||
|
Options Indexes FollowSymLinks MultiViews
|
||||||
|
AllowOverride None
|
||||||
|
Order allow,deny
|
||||||
|
allow from all
|
||||||
|
</Directory>
|
||||||
24
RPiSetup/etc/apache2/mods-available/alias.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<IfModule alias_module>
|
||||||
|
# Aliases: Add here as many aliases as you need (with no limit). The format is
|
||||||
|
# Alias fakename realname
|
||||||
|
#
|
||||||
|
# Note that if you include a trailing / on fakename then the server will
|
||||||
|
# require it to be present in the URL. So "/icons" isn't aliased in this
|
||||||
|
# example, only "/icons/". If the fakename is slash-terminated, then the
|
||||||
|
# realname must also be slash terminated, and if the fakename omits the
|
||||||
|
# trailing slash, the realname must also omit it.
|
||||||
|
#
|
||||||
|
# We include the /icons/ alias for FancyIndexed directory listings. If
|
||||||
|
# you do not use FancyIndexing, you may comment this out.
|
||||||
|
|
||||||
|
#Alias /icons/ "/usr/share/apache2/icons/"
|
||||||
|
|
||||||
|
<Directory "/usr/share/apache2/icons">
|
||||||
|
Options FollowSymlinks
|
||||||
|
AllowOverride None
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||||||
31
RPiSetup/etc/apache2/sites-available/000-default.conf
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
# The ServerName directive sets the request scheme, hostname and port that
|
||||||
|
# the server uses to identify itself. This is used when creating
|
||||||
|
# redirection URLs. In the context of virtual hosts, the ServerName
|
||||||
|
# specifies what hostname must appear in the request's Host: header to
|
||||||
|
# match this virtual host. For the default virtual host (this file) this
|
||||||
|
# value is not decisive as it is used as a last resort host regardless.
|
||||||
|
# However, you must set it for any further virtual host explicitly.
|
||||||
|
#ServerName www.example.com
|
||||||
|
|
||||||
|
ServerAdmin webmaster@localhost
|
||||||
|
DocumentRoot /var/www/opendrs
|
||||||
|
|
||||||
|
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
|
||||||
|
# error, crit, alert, emerg.
|
||||||
|
# It is also possible to configure the loglevel for particular
|
||||||
|
# modules, e.g.
|
||||||
|
#LogLevel info ssl:warn
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
|
||||||
|
# For most configuration files from conf-available/, which are
|
||||||
|
# enabled or disabled at a global level, it is possible to
|
||||||
|
# include a line for only one particular virtual host. For example the
|
||||||
|
# following line enables the CGI configuration for this host only
|
||||||
|
# after it has been globally disabled with "a2disconf".
|
||||||
|
#Include conf-available/serve-cgi-bin.conf
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||||||
1
RPiSetup/etc/apt/sources.list.d/webmin.list
Normal file
@@ -0,0 +1 @@
|
|||||||
|
deb http://download.webmin.com/download/repository sarge contrib
|
||||||
146
RPiSetup/etc/cups/cupsd.conf
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#
|
||||||
|
# Configuration file for the CUPS scheduler. See "man cupsd.conf" for a
|
||||||
|
# complete description of this file.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Log general information in error_log - change "warn" to "debug"
|
||||||
|
# for troubleshooting...
|
||||||
|
LogLevel warn
|
||||||
|
PageLogFormat
|
||||||
|
|
||||||
|
# Deactivate CUPS' internal logrotating, as we provide a better one, especially
|
||||||
|
# LogLevel debug2 gets usable now
|
||||||
|
MaxLogSize 0
|
||||||
|
|
||||||
|
# Only listen for connections from the local machine.
|
||||||
|
#Listen localhost:631
|
||||||
|
Port 631
|
||||||
|
Listen 0.0.0.0:631
|
||||||
|
Listen /var/run/cups/cups.sock
|
||||||
|
|
||||||
|
# Show shared printers on the local network.
|
||||||
|
Browsing On
|
||||||
|
BrowseLocalProtocols dnssd
|
||||||
|
|
||||||
|
# Default authentication type, when authentication is required...
|
||||||
|
DefaultAuthType Basic
|
||||||
|
|
||||||
|
# Web interface setting...
|
||||||
|
WebInterface Yes
|
||||||
|
|
||||||
|
# Restrict access to the server...
|
||||||
|
<Location />
|
||||||
|
Order allow,deny
|
||||||
|
Allow from 192.168.100.*
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
# Restrict access to the admin pages...
|
||||||
|
<Location /admin>
|
||||||
|
AuthType Basic
|
||||||
|
Require valid-user
|
||||||
|
Allow all
|
||||||
|
Order allow,deny
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
# Restrict access to configuration files...
|
||||||
|
<Location /admin/conf>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order allow,deny
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
# Restrict access to log files...
|
||||||
|
<Location /admin/log>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order allow,deny
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
# Set the default printer/job policies...
|
||||||
|
<Policy default>
|
||||||
|
# Job/subscription privacy...
|
||||||
|
JobPrivateAccess default
|
||||||
|
JobPrivateValues default
|
||||||
|
SubscriptionPrivateAccess default
|
||||||
|
SubscriptionPrivateValues default
|
||||||
|
|
||||||
|
# Job-related operations must be done by the owner or an administrator...
|
||||||
|
<Limit Create-Job Print-Job Print-URI Validate-Job>
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
|
||||||
|
Require user @OWNER @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# All administration operations require an administrator to authenticate...
|
||||||
|
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# All printer operations require a printer operator to authenticate...
|
||||||
|
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# Only the owner or an administrator can cancel or authenticate a job...
|
||||||
|
<Limit Cancel-Job CUPS-Authenticate-Job>
|
||||||
|
Require user @OWNER @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
<Limit All>
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
</Policy>
|
||||||
|
|
||||||
|
# Set the authenticated printer/job policies...
|
||||||
|
<Policy authenticated>
|
||||||
|
# Job/subscription privacy...
|
||||||
|
JobPrivateAccess default
|
||||||
|
JobPrivateValues default
|
||||||
|
SubscriptionPrivateAccess default
|
||||||
|
SubscriptionPrivateValues default
|
||||||
|
|
||||||
|
# Job-related operations must be done by the owner or an administrator...
|
||||||
|
<Limit Create-Job Print-Job Print-URI Validate-Job>
|
||||||
|
AuthType Default
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
|
||||||
|
AuthType Default
|
||||||
|
Require user @OWNER @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# All administration operations require an administrator to authenticate...
|
||||||
|
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# All printer operations require a printer operator to authenticate...
|
||||||
|
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
|
||||||
|
AuthType Default
|
||||||
|
Require user @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
# Only the owner or an administrator can cancel or authenticate a job...
|
||||||
|
<Limit Cancel-Job CUPS-Authenticate-Job>
|
||||||
|
AuthType Default
|
||||||
|
Require user @OWNER @SYSTEM
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
|
||||||
|
<Limit All>
|
||||||
|
Order deny,allow
|
||||||
|
</Limit>
|
||||||
|
</Policy>
|
||||||
2
RPiSetup/etc/drs.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DRS_SERVER="http://localhost"
|
||||||
|
|
||||||
53
RPiSetup/lib/systemd/system/getty@tty1.service
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# This file is part of systemd.
|
||||||
|
#
|
||||||
|
# systemd is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Getty on %I
|
||||||
|
Documentation=man:agetty(8) man:systemd-getty-generator(8)
|
||||||
|
Documentation=http://0pointer.de/blog/projects/serial-console.html
|
||||||
|
After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||||
|
After=rc-local.service
|
||||||
|
|
||||||
|
# If additional gettys are spawned during boot then we should make
|
||||||
|
# sure that this is synchronized before getty.target, even though
|
||||||
|
# getty.target didn't actually pull it in.
|
||||||
|
Before=getty.target
|
||||||
|
IgnoreOnIsolate=yes
|
||||||
|
|
||||||
|
# IgnoreOnIsolate causes issues with sulogin, if someone isolates
|
||||||
|
# rescue.target or starts rescue.service from multi-user.target or
|
||||||
|
# graphical.target.
|
||||||
|
Conflicts=rescue.service
|
||||||
|
Before=rescue.service
|
||||||
|
|
||||||
|
# On systems without virtual consoles, don't start any getty. Note
|
||||||
|
# that serial gettys are covered by serial-getty@.service, not this
|
||||||
|
# unit.
|
||||||
|
ConditionPathExists=/dev/tty0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
# the VT is cleared by TTYVTDisallocate
|
||||||
|
ExecStart=-/sbin/agetty -a customer --noclear %I $TERM
|
||||||
|
Type=idle
|
||||||
|
Restart=always
|
||||||
|
RestartSec=0
|
||||||
|
UtmpIdentifier=%I
|
||||||
|
TTYPath=/dev/%I
|
||||||
|
TTYReset=yes
|
||||||
|
TTYVHangup=yes
|
||||||
|
TTYVTDisallocate=yes
|
||||||
|
KillMode=process
|
||||||
|
IgnoreSIGPIPE=no
|
||||||
|
SendSIGHUP=yes
|
||||||
|
|
||||||
|
# Unset locale for the console getty since the console has problems
|
||||||
|
# displaying some internationalized messages.
|
||||||
|
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=getty.target
|
||||||
|
DefaultInstance=tty1
|
||||||
84
RPiSetup/server-setup.sh
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# server-setup.sh
|
||||||
|
# OpenDRS Online Discrepancy Reporting System
|
||||||
|
# Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "This script will configure a Raspberry Pi to be an OpenDRS server."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "You should have already run the terminal-setup.sh script in this directory."
|
||||||
|
echo ""
|
||||||
|
if [ ! -e "/etc/drs.conf" ]
|
||||||
|
then
|
||||||
|
echo "It looks like the terminal-setup.sh script has not been run yet."
|
||||||
|
echo "This is required before running the server-setup.sh script."
|
||||||
|
echo "Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "It looks like you have. Continuing."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Updating Raspbian..."
|
||||||
|
sleep 10
|
||||||
|
apt update && apt dist-upgrade -y
|
||||||
|
echo "...done."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Installing required server packages. Select apache2 as the web server to configure"
|
||||||
|
echo "automatically. Choose Yes when prompted to install phpmyadmin database and allow it to"
|
||||||
|
echo "generate a random password(leave the field blank)."
|
||||||
|
echo -n "Press enter to continue."
|
||||||
|
read continueok
|
||||||
|
sleep 10
|
||||||
|
apt install -y apache2 php php-mcrypt mysql-server phpmyadmin
|
||||||
|
cp etc/apache2/mods-available/alias.conf /etc/apache2/mods-available
|
||||||
|
service apache2 restart
|
||||||
|
echo "...done."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Configuring the mysql installation. Accept the defaults at the following prompts."
|
||||||
|
echo "Remember the password you set here. You'll need it during the OpenDRS install."
|
||||||
|
echo -n "Press enter to proceed."
|
||||||
|
read continueok
|
||||||
|
mysql_secure_installation
|
||||||
|
mysql mysql -e "update user set plugin='';flush privileges;"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Installing OpenDRS."
|
||||||
|
DRS_VERSION="1.1.0"
|
||||||
|
install_path="/var/www/opendrs-$DRS_VERSION"
|
||||||
|
httpd_user_group="www-data:www-data"
|
||||||
|
new_link_name="/var/www/opendrs"
|
||||||
|
echo "Creating installation directory . . ."
|
||||||
|
mkdir $install_path
|
||||||
|
echo "Installing distribution . . ."
|
||||||
|
cp -Rv ../distfiles/* $install_path
|
||||||
|
echo "Setting file ownership . . ."
|
||||||
|
chown -R $httpd_user_group $install_path
|
||||||
|
ln -s $install_path $new_link_name
|
||||||
|
cp etc/apache2/conf-available/opendrs.conf /etc/apache2/conf-available
|
||||||
|
cp etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available
|
||||||
|
a2enconf opendrs
|
||||||
|
echo "DRS_SERVER=\"http://localhost\"" > /etc/drs.conf
|
||||||
|
service apache2 restart
|
||||||
|
echo ""
|
||||||
|
echo "Server configuration is now complete. "
|
||||||
|
echo "Once the reboot is complete you will need to do the final installation of OpenDRS through"
|
||||||
|
echo "the browser. You will need the password you set during the mysql installation above."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "It is highly recommended that after rebooting, you press ctrl-alt-F2,"
|
||||||
|
echo "log in as pi, then create new users for yourself and any other"
|
||||||
|
echo "administrators using the cloneuser command (cloneuser pi newlogin)."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo -n "Press enter to reboot now."
|
||||||
|
read rebootok
|
||||||
|
reboot
|
||||||
123
RPiSetup/terminal-setup.sh
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# terminal-setup.sh
|
||||||
|
# OpenDRS Online Maintenance Tracking System
|
||||||
|
# Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "This script will configure a Raspberry Pi to be an OpenDRS terminal."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "You should have already completed the following steps:"
|
||||||
|
echo ""
|
||||||
|
echo "1. Created a Raspbian Lite SD card from the latest release."
|
||||||
|
echo "2. Installed the card in a Raspberry Pi, booted it, and logged in as pi."
|
||||||
|
echo "3. Ran sudo raspi-config and :"
|
||||||
|
echo " a. Set a strong password for the pi user."
|
||||||
|
echo " b. Set hostname and, if accessing a network through wifi, the SSID and"
|
||||||
|
echo " passphrase under Network Options."
|
||||||
|
echo " c. Set locale, timezone, keyboard layout, and wifi country under"
|
||||||
|
echo " Localisation Options."
|
||||||
|
echo " d. Enable SSH under Interfacing Options."
|
||||||
|
echo " e. Set overscan as required to get rid of any black borders around the"
|
||||||
|
echo " edge of the display."
|
||||||
|
echo " f. Reboot when prompted and logged back in as pi."
|
||||||
|
echo "4. Transferred the OpenDRS distribution package to /home/pi on the"
|
||||||
|
echo " Raspberry Pi and extracted it."
|
||||||
|
echo "5. Changed directory to RPiSetup in the the extracted distribution directory."
|
||||||
|
echo "6. Ran sudo ./terminal-setup.sh (this file)."
|
||||||
|
echo ""
|
||||||
|
echo "If you have completed these steps, press enter to continue. If not,"
|
||||||
|
echo -n "press ctrl-c to quit."
|
||||||
|
read continueok
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Updating Raspbian..."
|
||||||
|
sleep 10
|
||||||
|
apt update && apt dist-upgrade -y
|
||||||
|
echo "...done."
|
||||||
|
echo "Copying files..."
|
||||||
|
chmod +x usr/local/bin/*
|
||||||
|
cp usr/local/bin/* /usr/local/bin
|
||||||
|
cp etc/apt/sources.list.d/* /etc/apt/sources.list.d
|
||||||
|
cp lib/systemd/system/getty@tty1.service /lib/systemd/system
|
||||||
|
rm /lib/systemd/system/ctrl-alt-del.target
|
||||||
|
ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
|
||||||
|
echo "...done."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Installing required terminal packages..."
|
||||||
|
sleep 10
|
||||||
|
wget http://www.webmin.com/jcameron-key.asc
|
||||||
|
apt-key add jcameron-key.asc
|
||||||
|
rm jcameron-key.asc
|
||||||
|
apt update
|
||||||
|
apt install -y --no-install-recommends xorg openbox chromium-browser
|
||||||
|
apt install -y webmin cups libcups2-dev cmake
|
||||||
|
addgroup lpadmin
|
||||||
|
usermod -a -G lpadmin pi
|
||||||
|
systemctl enable getty@tty1.service
|
||||||
|
service cups-browsed stop
|
||||||
|
systemctl disable cups-browsed.service
|
||||||
|
cp etc/cups/cupsd.conf /etc/cups/
|
||||||
|
service cups restart
|
||||||
|
cd brlaser-master
|
||||||
|
cmake . && make && make install
|
||||||
|
cd ..
|
||||||
|
myhn=`hostname`
|
||||||
|
echo "Drivers have been installed for the Brother HL-L2300D printer that may come"
|
||||||
|
echo "with the terminal."
|
||||||
|
echo "After the terminal is set up and working, you can use another network"
|
||||||
|
echo "computer to point a web browser to $myhn:631 to add this or another printer"
|
||||||
|
echo "of your choosing."
|
||||||
|
echo -n "Press enter to continue."
|
||||||
|
read continueok
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Creating customer user..."
|
||||||
|
cloneuser pi customer
|
||||||
|
mkdir -p /home/customer/.config/openbox
|
||||||
|
cp home/customer/.profile /home/customer
|
||||||
|
cp home/customer/.config/openbox/rc.xml /home/customer/.config/openbox
|
||||||
|
chown -R customer:customer /home/customer/.config /home/customer/.profile
|
||||||
|
echo "...done."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "This terminal will need to communicate with an OpenDRS server. If"
|
||||||
|
echo "you intend to host the server directly on this terminal, accept the"
|
||||||
|
echo "default URL shown. Otherwise, enter the server URL."
|
||||||
|
echo -n "[http://localhost] :"
|
||||||
|
read server_url
|
||||||
|
if [[ $server_url == "" ]]
|
||||||
|
then
|
||||||
|
server_url="http://localhost"
|
||||||
|
fi
|
||||||
|
echo "DRS_SERVER=\"$server_url\"" > /etc/drs.conf
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Terminal configuration is now complete. "
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "If this Raspberry Pi will also be used as the OpenDRS server, you will need"
|
||||||
|
echo "to run the server-setup.sh script in this same directory."
|
||||||
|
echo "Would you like to do that now? enter Y if so, or press enter to leave this"
|
||||||
|
echo -n "as a terminal only and reboot :"
|
||||||
|
read serverchoice
|
||||||
|
if [[ $serverchoice == "Y" || $serverchoice == "y" ]]
|
||||||
|
then
|
||||||
|
./server-setup.sh
|
||||||
|
fi
|
||||||
|
echo "It is highly recommended that after rebooting, you press ctrl-alt-F2,"
|
||||||
|
echo "log in as pi, then create new users for yourself and any other"
|
||||||
|
echo "administrators using the cloneuser command (cloneuser pi newlogin)."
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Setup complete."
|
||||||
|
echo -n "Press enter to reboot now."
|
||||||
|
read rebootok
|
||||||
|
reboot
|
||||||
18
RPiSetup/usr/local/bin/cloneuser
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SRC=$1
|
||||||
|
DEST=$2
|
||||||
|
|
||||||
|
SRC_GROUPS=`id -Gn ${SRC}`
|
||||||
|
SRC_SHELL=$(awk -F : -v name=${SRC} '(name == $1) { print $7 }' /etc/passwd)
|
||||||
|
|
||||||
|
echo "Creating user $DEST"
|
||||||
|
useradd --shell ${SRC_SHELL} --create-home ${DEST}
|
||||||
|
for grp in ${SRC_GROUPS};do
|
||||||
|
if [ "$grp" != "$SRC" ]; then
|
||||||
|
echo "Adding user $DEST to group $grp."
|
||||||
|
usermod -a -G $grp ${DEST}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
passwd ${DEST}
|
||||||
|
|
||||||
|
|
||||||
1642
RPiSetup/usr/local/bin/rpi-clone
Normal file
144
RPiSetup/usr/local/bin/rpi-clone-setup
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Usage: rpi-clone-setup {-t|--test} hostname
|
||||||
|
# eg: sudo rpi-clone-setup bozo
|
||||||
|
#
|
||||||
|
# This script is automatically run by rpi-clone (when it is given -s options)
|
||||||
|
# to setup an alternate hostname. A cloned file system mounted on /mnt/clone
|
||||||
|
# is expected unless testing with the -t option.
|
||||||
|
#
|
||||||
|
# Or, this script can be run by hand at the end of a clone when rpi-clone
|
||||||
|
# pauses with the cloned file systems still mounted on /mnt/clone.
|
||||||
|
#
|
||||||
|
# Or, run this script by hand with -t to process files in test directories
|
||||||
|
# under /tmp/clone-test. Run -t and look at the files to see if the files
|
||||||
|
# have been edited OK.
|
||||||
|
# eg: sudo rpi-clone-setup -t bozo
|
||||||
|
#
|
||||||
|
# This is a starter script that handles only /etc/hosts and /etc/hostname.
|
||||||
|
# Make sure the script works correctly for your /etc/hosts file.
|
||||||
|
#
|
||||||
|
# If adding a customization for another file:
|
||||||
|
# Add the file to file_list.
|
||||||
|
# If needed, add a mkdir -p line to the "if ((testing))" part.
|
||||||
|
# Add the scripting necessary to customize the file.
|
||||||
|
# Test new scripting by running: rpi-clone-setup -t newhostname
|
||||||
|
#
|
||||||
|
|
||||||
|
file_list="etc/hostname etc/hosts"
|
||||||
|
|
||||||
|
clone=/mnt/clone
|
||||||
|
clone_test=/tmp/clone-test
|
||||||
|
|
||||||
|
PGM=`basename $0`
|
||||||
|
|
||||||
|
if [ `id -u` != 0 ]
|
||||||
|
then
|
||||||
|
echo "You must be root to run $PGM"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
function usage
|
||||||
|
{
|
||||||
|
echo "Usage: $PGM hostname {-t|--test}"
|
||||||
|
echo " Eg: $PGM rpi1"
|
||||||
|
echo " Modify files appropriate to set up for a new host."
|
||||||
|
echo " Files handled are:"
|
||||||
|
for file in $file_list
|
||||||
|
do
|
||||||
|
echo " $file"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
echo "If testing (-t flag) files are copied and processed to $clone_test"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
testing=0
|
||||||
|
while [ "$1" ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-t|--test)
|
||||||
|
testing=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ "$newhost" != "" ]
|
||||||
|
then
|
||||||
|
echo "Bad args"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
newhost=$1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$newhost" = "" ]
|
||||||
|
then
|
||||||
|
echo -e "You must specify a target hostname\n"
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "\t$newhost\t- target hostname"
|
||||||
|
|
||||||
|
if ((!testing)) && [ ! -d /mnt/clone/etc ]
|
||||||
|
then
|
||||||
|
echo "A destination clone file system is not mounted on /mnt/clone"
|
||||||
|
echo "Aborting!"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((testing))
|
||||||
|
then
|
||||||
|
cd /tmp
|
||||||
|
rm -rf $clone_test
|
||||||
|
clone=$clone_test
|
||||||
|
|
||||||
|
mkdir -p $clone/etc
|
||||||
|
|
||||||
|
echo "**********************************************"
|
||||||
|
echo "Testing setup: copying files to $clone"
|
||||||
|
for file in $file_list
|
||||||
|
do
|
||||||
|
echo " cp /$file $clone/$file"
|
||||||
|
cp /$file $clone/$file
|
||||||
|
done
|
||||||
|
echo "This test run will modify those files."
|
||||||
|
echo "**********************************************"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Set /etc/hostname
|
||||||
|
#
|
||||||
|
cd $clone/etc
|
||||||
|
echo $newhost > hostname
|
||||||
|
#
|
||||||
|
# Read it back to verify.
|
||||||
|
#
|
||||||
|
echo "$clone/etc/hostname - set new hostname: "
|
||||||
|
LINE=`cat hostname`
|
||||||
|
echo -e "$LINE\n"
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Edit /etc/hosts - edit the sed command if editing fails for your /etc/hosts.
|
||||||
|
#
|
||||||
|
cd $clone/etc
|
||||||
|
sed -i s/"$HOSTNAME"/"$newhost"/ hosts
|
||||||
|
#
|
||||||
|
# Read it back to verify.
|
||||||
|
#
|
||||||
|
echo "$clone/etc/hosts - set new hostname \"$newhost\" in lines: "
|
||||||
|
LINE=`grep $newhost hosts`
|
||||||
|
echo -e "$LINE\n"
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Add more customizations if needed.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
37
RPiSetup/usr/local/bin/startdrs.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /etc/drs.conf
|
||||||
|
|
||||||
|
openbox-session &
|
||||||
|
|
||||||
|
xset s off
|
||||||
|
xset +dpms
|
||||||
|
xset dpms 0 600 1800
|
||||||
|
|
||||||
|
#xset dpms force off
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
killall chromium-browser
|
||||||
|
rm -rf ~/.{config,cache}/chromium/
|
||||||
|
|
||||||
|
# start browser in your web site: here, just plain old localhost
|
||||||
|
# -test-type will ignore any warnings and
|
||||||
|
# --ignore-certificate-errors will allow you to kiosk any https-page without displaying certificate errors
|
||||||
|
chromium-browser -test-type --ignore-certificate-errors --kiosk --no-first-run --incognito $DRS_SERVER &
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
pgrep chromium-browse
|
||||||
|
if [ "$?" -eq "1" ]
|
||||||
|
then
|
||||||
|
# here you could execute something that is supposed to happen after the browser was accidentally quit
|
||||||
|
chromium-browser -test-type --ignore-certificate-errors --kiosk --no-first-run --incognito $DRS_SERVER &
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
done
|
||||||
5
RPiSetup/usr/local/bin/updatedrs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
host=$1
|
||||||
|
|
||||||
|
rsync -rlptDvz rwright@$host:/home/rwright/ownCloud/Software_Projects/OpenDRS-1.1.0/distfiles/ /var/www/opendrs/ && chown -R www-data:www-data /var/www/opendrs/*
|
||||||
|
|
||||||
43
RaspberryPiSetup.txt
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
Raspberry Pi setup
|
||||||
|
|
||||||
|
1. Create Raspbian Lite SD card from the most recent stable release.
|
||||||
|
|
||||||
|
2. Insert SD card in Raspberry Pi and boot.
|
||||||
|
|
||||||
|
3. Login as pi.
|
||||||
|
|
||||||
|
4. sudo raspi-config and:
|
||||||
|
|
||||||
|
a. Use option 1 to set a strong password for the default user (pi).
|
||||||
|
|
||||||
|
b. Use option 2 Network Options to:
|
||||||
|
1. Set the desired hostname.
|
||||||
|
2. Set WiFi SSID and passphrase if using WiFi for networking.
|
||||||
|
|
||||||
|
c. Use option 4 Localisation Options to:
|
||||||
|
1. Set locale.
|
||||||
|
2. Set timezone.
|
||||||
|
3. Set keyboard layout (IMPORTANT! Raspbian is made in England, so
|
||||||
|
unless that's the kind of keyboard you have, the default layout
|
||||||
|
will make your symbols come out wrong!).
|
||||||
|
4. Set WiFi country.
|
||||||
|
|
||||||
|
d. Use option 5 Interfacing Options to enable SSH server.
|
||||||
|
|
||||||
|
e. If you have black borders on the sides of the screen, use option 7
|
||||||
|
Advanced Options to select No for Overscan compensation.
|
||||||
|
|
||||||
|
f. When you've finished, tab down to highlight Finish and hit enter.
|
||||||
|
|
||||||
|
g. Reboot when prompted.
|
||||||
|
|
||||||
|
h. Log back in as pi using the password you set in a. above.
|
||||||
|
|
||||||
|
5. Copy OpenDRS distribution package to /home/pi on the Raspberry Pi and extract.
|
||||||
|
|
||||||
|
6. Change directory to the extracted distribution.
|
||||||
|
|
||||||
|
7. Change directory to RPiSetup.
|
||||||
|
|
||||||
|
8. run sudo ./terminal-setup.sh
|
||||||
|
|
||||||
84
boilerplate.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
boilerplate.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to index.php on cancel button press
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST to $incoming
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
|
||||||
|
|
||||||
|
// define local functions
|
||||||
|
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$sbcolor=P_SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$sbcolor=SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role=dblookup($mts_db,"users","id","role",$userid);
|
||||||
|
|
||||||
|
framework("begin","$appname","Boilerplate Page",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//var_dump($incoming);
|
||||||
|
|
||||||
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
|
||||||
|
echo "<center><b><font size=\"+1\">This is the standard template used for all pages in the application.</font></b></center>";
|
||||||
|
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
42
db.php.template
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
db.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
************************************************************************
|
||||||
|
** WARNING! This file is automatically generated during installation **
|
||||||
|
** DO NOT EDIT **
|
||||||
|
************************************************************************
|
||||||
|
*/
|
||||||
|
$dbname="DBNAME";
|
||||||
|
$username="DBUSER";
|
||||||
|
$dbpass="DBPASS";
|
||||||
|
|
||||||
|
function dberrmsg($dbname) {
|
||||||
|
echo "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Database Error!</title>
|
||||||
|
</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 OpenMTS, please consult the INSTALL file included in the distribution.
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$drs_db=@mysqli_connect("localhost",$username,$dbpass,$dbname);
|
||||||
|
if (mysqli_errno($drs_db)) {
|
||||||
|
dberrmsg($dbname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
43
distfiles/CHANGELOG
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
OpenDRS - Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
|
||||||
|
1.0.0 - 2018-03-13
|
||||||
|
- Initial release as OpenMTS.
|
||||||
|
|
||||||
|
1.1.0 - 2018-05-10
|
||||||
|
- Name change from OpenMTS to OpenDRS.
|
||||||
|
- Added "Go Back" button to left side menu to make up for loss of browser
|
||||||
|
back button in terminal mode.
|
||||||
|
- Added configurable help text for period effective selection.
|
||||||
|
- Changed Sim period effective from selection to yes/no radio buttons.
|
||||||
|
- Writeup groups page shows collapsed list of groups. Click the expand icon
|
||||||
|
to expand each group.
|
||||||
|
- Fixed bug where entries made on stale create page had inaccurate date/time.
|
||||||
|
- For logged in users, added the ability to select writeups directly on the
|
||||||
|
View All Writeups page and assign/create a group.
|
||||||
|
- On the Create New Writeup page, removed the default selections for Device,
|
||||||
|
Subsystem, and Period dropdowns, forcing user to make a selection.
|
||||||
|
- Added a Today button to the View All Writeups page
|
||||||
|
- Changed the Period dropdowns on the Create, Search, and Group pages to show
|
||||||
|
the times instead of the period numbers. Period numbers are still shown
|
||||||
|
in the results tables with mouse hover showing times.
|
||||||
|
- Moved all installation/upgrade functions to the install.sh script.
|
||||||
|
|
||||||
|
|
||||||
28
distfiles/INSTALL
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Installation or upgrade of OpenDRS is straightforward.
|
||||||
|
|
||||||
|
1. Unpack
|
||||||
|
Unpack the distribution in a convenient place. A directory will
|
||||||
|
created called OpenDRS-x.x.x/.
|
||||||
|
|
||||||
|
2. Review License
|
||||||
|
Change to the OpenDRS-x.x.x/ directory and review the LICENSE file.
|
||||||
|
|
||||||
|
3. Run the install script
|
||||||
|
In the same directory, type ./install.sh at a command prompt and
|
||||||
|
follow the prompts.
|
||||||
|
|
||||||
|
4. Log in
|
||||||
|
Click on the Log In menu option on the main page. If this is a fresh
|
||||||
|
installation The initial user is drsadmin and the initial password
|
||||||
|
is OpenDRS-1. It is highly recommended that you changethis password
|
||||||
|
to a strong one by going to the Manage Database page under the
|
||||||
|
Admin Functions menu. If this an upgrade, your current usernames and
|
||||||
|
passwords are unchanged.
|
||||||
|
|
||||||
|
5. Configure
|
||||||
|
The Admin Functions menu will be shown when logged in as an admin user.
|
||||||
|
Click on Global Settings to set display options, page colors, banners, and
|
||||||
|
miscellaneous options. Click on Manage Database to set users, devices,
|
||||||
|
subsystems, action reasons and periods.
|
||||||
|
|
||||||
|
6. Start making writeups
|
||||||
341
distfiles/LICENSE
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Library General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The \"Program\", below,
|
||||||
|
refers to any such program or work, and a \"work based on the Program\"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term \"modification\".) Each licensee is addressed as \"you\".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and \"any
|
||||||
|
later version\", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the \"copyright\" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a \"copyright disclaimer\" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Library General
|
||||||
|
Public License instead of this License.
|
||||||
|
|
||||||
139
distfiles/about.php
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
about.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to index.php on cancel button press
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST to $incoming
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
|
||||||
|
|
||||||
|
// define local functions
|
||||||
|
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$sbcolor=P_SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$sbcolor=SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role=dblookup($mts_db,"users","id","role",$userid);
|
||||||
|
|
||||||
|
framework("begin","$appname","About OpenDRS",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//var_dump($incoming);
|
||||||
|
|
||||||
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<h3 align=\"center\">
|
||||||
|
OpenDRS $version Discrepancy Reporting System
|
||||||
|
</h3><br>
|
||||||
|
<p>This program is licensed under the terms of the <a href=\"gpl.php\">GNU General Public License</a>. Click on the link
|
||||||
|
or see the LICENSE file in the distribution to read it. OpenDRS is Copyright (C) 2018 by Rod Wright.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
OpenDRS is a simple online maintenance tracking/discrepancy reporting application. It allows anyone with a web browser to create ,
|
||||||
|
view, and search writeups. The look and feel of the OpenDRS pages are easily changed.
|
||||||
|
Settings that affect all users can be changed in the Admin Functions menu. User specific settings can be changed in the
|
||||||
|
My Profile menu. No browser specific HTML is used in OpenDRS, so it should be useable in any browser, and it has been
|
||||||
|
tested using Google Chrome, Mozilla Firefox and Microsoft Internet Explorer.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
OpenDRS is highly flexible. Instructions are included in the distribution for creating a user terminal with a Raspberry Pi. OpenDRS can be hosted on a
|
||||||
|
centralized server, accessed by networked PCs and/or Raspberry Pi terminals. It can also be hosted directly on a Raspberry Pi
|
||||||
|
terminal as a non-networked standalone system or in a small network of Raspberry Pi terminals.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To read about the <a href=\"CHANGELOG\" >changes</a> in this latest version of OpenDRS, click on the link or see the CHANGELOG file in the distribution.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>Several pieces of Open Source software make OpenDRS possible.
|
||||||
|
<br>
|
||||||
|
<table border=0 cellpadding=20>
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"http://www.linux.org\" target=\"_blank\"><img src=\"images/linux.png\" border=0></a></td><td><b>Linux</b></td><td>All
|
||||||
|
development and most of the testing of OpenDRS was done on computers running the
|
||||||
|
<a href=\"http://www.linux.org\" target=\"_blank\">Linux</a> operating system.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"http://www.php.net\" target=\"_blank\"><img src=\"images/php-small-trans-dark.gif\"
|
||||||
|
border=0></a></td><td><b>PHP</b></td><td>OpenDRS is written in <a href=\"http://www.php.net\" target=\"_blank\">PHP</a>, a hypertext
|
||||||
|
preprocessor, which makes possible the dynamic content of the pages.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"https://mariadb.org\" target=\"_blank\"><img src=\"images/mariadb-badge-180x60.png\"
|
||||||
|
border=0></a></td><td><b>MariaDB</b></td><td>OpenDRS stores its data in a <a href=\"https://mariadb.org\" target=\"_blank\">MariaDB</a>
|
||||||
|
database.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"http://http.apache.org\" target=\"_blank\"><img src=\"images/apache_pb.gif\"
|
||||||
|
border=0></a></td><td><b>Apache</b></td><td>OpenDRS was developed using the <a href=\"httpd.apache.org\" target=\"_blank\">Apache</a> web
|
||||||
|
server.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"http://p.yusukekamiyamane.com\" target=\"_blank\"><img src=\"images/Kamiyamane.png\"
|
||||||
|
border=0></a></td><td><b>Fugue<br>Icons</b></td><td>The icons used in OpenDRS are from the Fugue Icon set created by Yusuke Kamiyamane. The entire set is available at
|
||||||
|
<a href=\"http://p.yusukekamiyamane.com/\" target=\"_blank\">p.yusukekamiyamane.com</a>, and are licensed under a
|
||||||
|
<a href=\"http://creativecommons.org/licenses/by/3.0/legalcode\" target=\"_blank\">Creative Commons Attribution 3.0 License</a>.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
149
distfiles/colorpicker/css/screen.css
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
#pickerPanel { width: 360px; height: 240px; font: normal 11px verdana, sans-serif; color: #333; line-height: 19px; margin: 0; }
|
||||||
|
|
||||||
|
/* slider */
|
||||||
|
|
||||||
|
.dragPanel {
|
||||||
|
position: relative;
|
||||||
|
background-color: #eeeeee;
|
||||||
|
margin: 4px;
|
||||||
|
width: 260px;
|
||||||
|
height: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dragPanel h4 {
|
||||||
|
background-color: #bbbbbb;
|
||||||
|
height: 10px;
|
||||||
|
margin: 0px;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
input { font-size: .85em }
|
||||||
|
.thumb {
|
||||||
|
cursor:default;
|
||||||
|
width:18px;
|
||||||
|
height:18px;
|
||||||
|
z-index: 9;
|
||||||
|
position:absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg {
|
||||||
|
position:absolute;
|
||||||
|
left:10px;
|
||||||
|
height:18px;
|
||||||
|
width:146px;
|
||||||
|
border: 0px solid #aaaaaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg span, .bg p {
|
||||||
|
cursor:default;
|
||||||
|
position: relative;
|
||||||
|
font-size: 2px;
|
||||||
|
overflow: hidden;
|
||||||
|
color: #aaaaaa;
|
||||||
|
top: 4px;
|
||||||
|
height: 10px;
|
||||||
|
width: 4px;
|
||||||
|
display: block;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg span {
|
||||||
|
border-top:1px solid #cccccc;
|
||||||
|
border-bottom:1px solid #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg .lb {
|
||||||
|
border-left:1px solid #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg .rb {
|
||||||
|
border-right:1px solid #cccccc;
|
||||||
|
}
|
||||||
|
#valdiv { position:absolute; top: 100px; left:10px; }
|
||||||
|
|
||||||
|
#rBG {top:30px}
|
||||||
|
#gBG {top:50px}
|
||||||
|
#bBG {top:70px}
|
||||||
|
|
||||||
|
#rgbSwatch {
|
||||||
|
position:absolute;
|
||||||
|
left:160px;
|
||||||
|
top:34px;
|
||||||
|
height:50px;
|
||||||
|
width:50px;
|
||||||
|
border:1px solid #aaaaaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
#rgbPanel {
|
||||||
|
/*
|
||||||
|
top: 400px;
|
||||||
|
left: 20px;
|
||||||
|
*/
|
||||||
|
width: 360px;
|
||||||
|
height: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* picker */
|
||||||
|
|
||||||
|
#hueThumb {
|
||||||
|
cursor:default;
|
||||||
|
width:18px;
|
||||||
|
height:18px;
|
||||||
|
z-index: 9;
|
||||||
|
position:absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hueBg {
|
||||||
|
position:absolute;
|
||||||
|
left:216px;
|
||||||
|
height:198px;
|
||||||
|
width:18px;
|
||||||
|
background:url(../img/hue.png) no-repeat;
|
||||||
|
top:18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pickerDiv {
|
||||||
|
position:absolute;
|
||||||
|
left:10px;
|
||||||
|
height:187px;
|
||||||
|
width:188px;
|
||||||
|
/*
|
||||||
|
background:url(../img/pickerbg.png) no-repeat;
|
||||||
|
*/
|
||||||
|
top:20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pickerbg {
|
||||||
|
position:absolute;
|
||||||
|
z-index: 1;
|
||||||
|
top:0px;
|
||||||
|
left:0px;
|
||||||
|
}
|
||||||
|
#selector {
|
||||||
|
cursor:default;
|
||||||
|
width:11px;
|
||||||
|
height:11px;
|
||||||
|
z-index: 9;
|
||||||
|
position:absolute;
|
||||||
|
top:0px;
|
||||||
|
left:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pickerSwatch {
|
||||||
|
position:absolute;
|
||||||
|
left:260px;
|
||||||
|
top:30px;
|
||||||
|
height:60px;
|
||||||
|
width:60px;
|
||||||
|
border:2px solid #aaaaaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pickervaldiv { text-align:right; position:absolute; top: 86px; left:246px; }
|
||||||
|
|
||||||
|
.colorbox{
|
||||||
|
width: 25px;
|
||||||
|
height: 14px;
|
||||||
|
border: 1px solid black;
|
||||||
|
border-bottom-width: 0;
|
||||||
|
}
|
||||||
196
distfiles/colorpicker/demo.htm
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:x2="http://www.w3.org/TR/xhtml2"
|
||||||
|
xmlns:role="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"
|
||||||
|
xmlns:state="http://www.w3.org/2005/07/aaa">
|
||||||
|
<head>
|
||||||
|
<title>YUI Color Picker</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="css/screen.css">
|
||||||
|
<script type="text/javascript" src="js/ddcolorposter.js"></script>
|
||||||
|
<script type="text/javascript" src="js/YAHOO.js" ></script>
|
||||||
|
<script type="text/javascript2" src="js/log.js" ></script>
|
||||||
|
<script type="text/javascript" src="js/color.js" ></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/event.js" ></script>
|
||||||
|
<script type="text/javascript" src="js/dom.js" ></script>
|
||||||
|
<script type="text/javascript" src="js/animation.js" ></script>
|
||||||
|
<script type="text/javascript" src="js/dragdrop.js" ></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/slider.js" ></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var hue;
|
||||||
|
var picker;
|
||||||
|
//var gLogger;
|
||||||
|
var dd1, dd2;
|
||||||
|
var r, g, b;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
if (typeof(ygLogger) != "undefined")
|
||||||
|
ygLogger.init(document.getElementById("logDiv"));
|
||||||
|
pickerInit();
|
||||||
|
ddcolorposter.fillcolorbox("colorfield1", "colorbox1") //PREFILL "colorbox1" with hex value from "colorfield1"
|
||||||
|
ddcolorposter.fillcolorbox("colorfield2", "colorbox2") //PREFILL "colorbox1" with hex value from "colorfield1"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Picker ---------------------------------------------------------
|
||||||
|
|
||||||
|
function pickerInit() {
|
||||||
|
hue = YAHOO.widget.Slider.getVertSlider("hueBg", "hueThumb", 0, 180);
|
||||||
|
hue.onChange = function(newVal) { hueUpdate(newVal); };
|
||||||
|
|
||||||
|
picker = YAHOO.widget.Slider.getSliderRegion("pickerDiv", "selector",
|
||||||
|
0, 180, 0, 180);
|
||||||
|
picker.onChange = function(newX, newY) { pickerUpdate(newX, newY); };
|
||||||
|
|
||||||
|
hueUpdate();
|
||||||
|
|
||||||
|
dd1 = new YAHOO.util.DD("pickerPanel");
|
||||||
|
dd1.setHandleElId("pickerHandle");
|
||||||
|
dd1.endDrag = function(e) {
|
||||||
|
// picker.thumb.resetConstraints();
|
||||||
|
// hue.thumb.resetConstraints();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
executeonload(init);
|
||||||
|
|
||||||
|
function pickerUpdate(newX, newY) {
|
||||||
|
pickerSwatchUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hueUpdate(newVal) {
|
||||||
|
|
||||||
|
var h = (180 - hue.getValue()) / 180;
|
||||||
|
if (h == 1) { h = 0; }
|
||||||
|
|
||||||
|
var a = YAHOO.util.Color.hsv2rgb( h, 1, 1);
|
||||||
|
|
||||||
|
document.getElementById("pickerDiv").style.backgroundColor =
|
||||||
|
"rgb(" + a[0] + ", " + a[1] + ", " + a[2] + ")";
|
||||||
|
|
||||||
|
pickerSwatchUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickerSwatchUpdate() {
|
||||||
|
var h = (180 - hue.getValue());
|
||||||
|
if (h == 180) { h = 0; }
|
||||||
|
document.getElementById("pickerhval").value = (h*2);
|
||||||
|
|
||||||
|
h = h / 180;
|
||||||
|
|
||||||
|
var s = picker.getXValue() / 180;
|
||||||
|
document.getElementById("pickersval").value = Math.round(s * 100);
|
||||||
|
|
||||||
|
var v = (180 - picker.getYValue()) / 180;
|
||||||
|
document.getElementById("pickervval").value = Math.round(v * 100);
|
||||||
|
|
||||||
|
var a = YAHOO.util.Color.hsv2rgb( h, s, v );
|
||||||
|
|
||||||
|
document.getElementById("pickerSwatch").style.backgroundColor =
|
||||||
|
"rgb(" + a[0] + ", " + a[1] + ", " + a[2] + ")";
|
||||||
|
|
||||||
|
document.getElementById("pickerrval").value = a[0];
|
||||||
|
document.getElementById("pickergval").value = a[1];
|
||||||
|
document.getElementById("pickerbval").value = a[2];
|
||||||
|
var hexvalue = document.getElementById("pickerhexval").value =
|
||||||
|
YAHOO.util.Color.rgb2hex(a[0], a[1], a[2]);
|
||||||
|
ddcolorposter.initialize(a[0], a[1], a[2], hexvalue)
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<!--[if gte IE 5.5000]>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
|
||||||
|
{
|
||||||
|
for(var i=0; i<document.images.length; i++)
|
||||||
|
{
|
||||||
|
var img = document.images[i]
|
||||||
|
var imgName = img.src.toUpperCase()
|
||||||
|
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
|
||||||
|
{
|
||||||
|
var imgID = (img.id) ? "id='" + img.id + "' " : ""
|
||||||
|
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
|
||||||
|
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
|
||||||
|
var imgStyle = "display:inline-block;" + img.style.cssText
|
||||||
|
if (img.align == "left") imgStyle = "float:left;" + imgStyle
|
||||||
|
if (img.align == "right") imgStyle = "float:right;" + imgStyle
|
||||||
|
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
|
||||||
|
var strNewHTML = "<span " + imgID + imgClass + imgTitle
|
||||||
|
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
|
||||||
|
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
|
||||||
|
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
|
||||||
|
img.outerHTML = strNewHTML
|
||||||
|
i = i-1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
YAHOO.util.Event.addListener(window, "load", correctPNG);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h3>Color Picker</h3>
|
||||||
|
<p>
|
||||||
|
Implements a slider region and a vertical slider to implement an HSV color
|
||||||
|
picker.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="pickerPanel" class="dragPanel">
|
||||||
|
<h4 id="pickerHandle"> </h4>
|
||||||
|
<div id="pickerDiv">
|
||||||
|
<img id="pickerbg" src="img/pickerbg.png" alt="">
|
||||||
|
<div id="selector"><img src="img/select.gif"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="hueBg">
|
||||||
|
<div id="hueThumb"><img src="img/hline.png"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pickervaldiv">
|
||||||
|
<form name="pickerform" onsubmit="return pickerUpdate()">
|
||||||
|
<br />
|
||||||
|
R <input name="pickerrval" id="pickerrval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
H <input name="pickerhval" id="pickerhval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
<br />
|
||||||
|
G <input name="pickergval" id="pickergval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
S <input name="pickergsal" id="pickersval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
<br />
|
||||||
|
B <input name="pickerbval" id="pickerbval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
V <input name="pickervval" id="pickervval" type="text" value="0" size="3" maxlength="3" />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
# <input name="pickerhexval" id="pickerhexval" type="text" value="0" size="6" maxlength="6" />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pickerSwatch"> </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<form>
|
||||||
|
# <input type="text" id="colorfield1" onFocus="ddcolorposter.echocolor(this, 'colorbox1')"> <span id="colorbox1" class="colorbox">____</span> <br />
|
||||||
|
# <input type="text" id="colorfield2" onFocus="ddcolorposter.echocolor(this, 'colorbox2')"> <span id="colorbox2" class="colorbox">____</span>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
More info: <a href="http://www.dynamicdrive.com/dynamicindex11/yuicolorpicker/">YUI Color Picker script</a>.
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
distfiles/colorpicker/img/bullet.gif
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
distfiles/colorpicker/img/greybg.png
Normal file
|
After Width: | Height: | Size: 197 B |
BIN
distfiles/colorpicker/img/header.gif
Normal file
|
After Width: | Height: | Size: 203 B |
BIN
distfiles/colorpicker/img/hline.png
Normal file
|
After Width: | Height: | Size: 416 B |
BIN
distfiles/colorpicker/img/hue.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
distfiles/colorpicker/img/navHover2.png
Normal file
|
After Width: | Height: | Size: 875 B |
BIN
distfiles/colorpicker/img/pickerbg.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
distfiles/colorpicker/img/qbottom.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
distfiles/colorpicker/img/qmiddle.png
Normal file
|
After Width: | Height: | Size: 385 B |
BIN
distfiles/colorpicker/img/qtop.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
distfiles/colorpicker/img/select.gif
Normal file
|
After Width: | Height: | Size: 78 B |
BIN
distfiles/colorpicker/img/select.png
Normal file
|
After Width: | Height: | Size: 192 B |
BIN
distfiles/colorpicker/img/vline.png
Normal file
|
After Width: | Height: | Size: 481 B |
60
distfiles/colorpicker/js/YAHOO.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class The Yahoo global namespace
|
||||||
|
*/
|
||||||
|
var YAHOO = function() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yahoo presentation platform utils namespace
|
||||||
|
*/
|
||||||
|
util: {},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yahoo presentation platform widgets namespace
|
||||||
|
*/
|
||||||
|
widget: {},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yahoo presentation platform examples namespace
|
||||||
|
*/
|
||||||
|
example: {},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the namespace specified and creates it if it doesn't exist
|
||||||
|
*
|
||||||
|
* YAHOO.namespace("property.package");
|
||||||
|
* YAHOO.namespace("YAHOO.property.package");
|
||||||
|
*
|
||||||
|
* Either of the above would create YAHOO.property, then
|
||||||
|
* YAHOO.property.package
|
||||||
|
*
|
||||||
|
* @param {String} sNameSpace String representation of the desired
|
||||||
|
* namespace
|
||||||
|
* @return {Object} A reference to the namespace object
|
||||||
|
*/
|
||||||
|
namespace: function( sNameSpace ) {
|
||||||
|
|
||||||
|
if (!sNameSpace || !sNameSpace.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var levels = sNameSpace.split(".");
|
||||||
|
|
||||||
|
var currentNS = YAHOO;
|
||||||
|
|
||||||
|
// YAHOO is implied, so it is ignored if it is included
|
||||||
|
for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
|
||||||
|
currentNS[levels[i]] = currentNS[levels[i]] || {};
|
||||||
|
currentNS = currentNS[levels[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentNS;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} ();
|
||||||
|
|
||||||
39
distfiles/colorpicker/js/animation.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
YAHOO.util.Anim=function(el,attributes,duration,method)
|
||||||
|
{if(el){this.init(el,attributes,duration,method);}};YAHOO.util.Anim.prototype={doMethod:function(attribute,start,end){return this.method(this.currentFrame,start,end-start,this.totalFrames);},setAttribute:function(attribute,val,unit){YAHOO.util.Dom.setStyle(this.getEl(),attribute,val+unit);},getAttribute:function(attribute){return parseFloat(YAHOO.util.Dom.getStyle(this.getEl(),attribute));},defaultUnits:{opacity:' '},defaultUnit:'px',init:function(el,attributes,duration,method){var isAnimated=false;var startTime=null;var endTime=null;var actualFrames=0;var defaultValues={};el=YAHOO.util.Dom.get(el);this.attributes=attributes||{};this.duration=duration||1;this.method=method||YAHOO.util.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=YAHOO.util.AnimMgr.fps;this.getEl=function(){return el;};this.setDefault=function(attribute,val){if(val=='auto'){switch(attribute){case'width':val=el.clientWidth||el.offsetWidth;break;case'height':val=el.clientHeight||el.offsetHeight;break;case'left':if(YAHOO.util.Dom.getStyle(el,'position')=='absolute'){val=el.offsetLeft;}else{val=0;}
|
||||||
|
break;case'top':if(YAHOO.util.Dom.getStyle(el,'position')=='absolute'){val=el.offsetTop;}else{val=0;}
|
||||||
|
break;default:val=0;}}
|
||||||
|
defaultValues[attribute]=val;}
|
||||||
|
this.getDefault=function(attribute){return defaultValues[attribute];};this.isAnimated=function(){return isAnimated;};this.getStartTime=function(){return startTime;};this.animate=function(){this.onStart.fire();this._onStart.fire();this.totalFrames=(this.useSeconds)?Math.ceil(YAHOO.util.AnimMgr.fps*this.duration):this.duration;YAHOO.util.AnimMgr.registerElement(this);var attributes=this.attributes;var el=this.getEl();var val;for(var attribute in attributes){val=this.getAttribute(attribute);this.setDefault(attribute,val);}
|
||||||
|
isAnimated=true;actualFrames=0;startTime=new Date();};this.stop=function(){this.currentFrame=0;endTime=new Date();var data={time:endTime,duration:endTime-startTime,frames:actualFrames,fps:actualFrames/this.duration};isAnimated=false;actualFrames=0;this.onComplete.fire(data);};var onTween=function(){var start;var end=null;var val;var unit;var attributes=this['attributes'];for(var attribute in attributes){unit=attributes[attribute]['unit']||this.defaultUnits[attribute]||this.defaultUnit;if(typeof attributes[attribute]['from']!='undefined'){start=attributes[attribute]['from'];}else{start=this.getDefault(attribute);}
|
||||||
|
if(typeof attributes[attribute]['to']!='undefined'){end=attributes[attribute]['to'];}else if(typeof attributes[attribute]['by']!='undefined'){end=start+attributes[attribute]['by'];}
|
||||||
|
if(end!==null&&typeof end!='undefined'){val=this.doMethod(attribute,start,end);if((attribute=='width'||attribute=='height'||attribute=='opacity')&&val<0){val=0;}
|
||||||
|
this.setAttribute(attribute,val,unit);}}
|
||||||
|
actualFrames+=1;};this._onStart=new YAHOO.util.CustomEvent('_onStart',this);this.onStart=new YAHOO.util.CustomEvent('start',this);this.onTween=new YAHOO.util.CustomEvent('tween',this);this._onTween=new YAHOO.util.CustomEvent('_tween',this);this.onComplete=new YAHOO.util.CustomEvent('complete',this);this._onTween.subscribe(onTween);}};YAHOO.util.AnimMgr=new function(){var thread=null;var queue=[];var tweenCount=0;this.fps=200;this.delay=1;this.registerElement=function(tween){if(tween.isAnimated()){return false;}
|
||||||
|
queue[queue.length]=tween;tweenCount+=1;this.start();};this.start=function(){if(thread===null){thread=setInterval(this.run,this.delay);}};this.stop=function(tween){if(!tween)
|
||||||
|
{clearInterval(thread);for(var i=0,len=queue.length;i<len;++i){if(queue[i].isAnimated()){queue[i].stop();}}
|
||||||
|
queue=[];thread=null;tweenCount=0;}
|
||||||
|
else{tween.stop();tweenCount-=1;if(tweenCount<=0){this.stop();}}};this.run=function(){for(var i=0,len=queue.length;i<len;++i){var tween=queue[i];if(!tween||!tween.isAnimated()){continue;}
|
||||||
|
if(tween.currentFrame<tween.totalFrames||tween.totalFrames===null)
|
||||||
|
{tween.currentFrame+=1;if(tween.useSeconds){correctFrame(tween);}
|
||||||
|
tween.onTween.fire();tween._onTween.fire();}
|
||||||
|
else{YAHOO.util.AnimMgr.stop(tween);}}};var correctFrame=function(tween){var frames=tween.totalFrames;var frame=tween.currentFrame;var expected=(tween.currentFrame*tween.duration*1000/tween.totalFrames);var elapsed=(new Date()-tween.getStartTime());var tweak=0;if(elapsed<tween.duration*1000){tweak=Math.round((elapsed/expected-1)*tween.currentFrame);}else{tweak=frames-(frame+1);}
|
||||||
|
if(tweak>0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);}
|
||||||
|
tween.currentFrame+=tweak;}};}
|
||||||
|
YAHOO.util.Bezier=new function()
|
||||||
|
{this.getPosition=function(points,t)
|
||||||
|
{var n=points.length;var tmp=[];for(var i=0;i<n;++i){tmp[i]=[points[i][0],points[i][1]];}
|
||||||
|
for(var j=1;j<n;++j){for(i=0;i<n-j;++i){tmp[i][0]=(1-t)*tmp[i][0]+t*tmp[parseInt(i+1,10)][0];tmp[i][1]=(1-t)*tmp[i][1]+t*tmp[parseInt(i+1,10)][1];}}
|
||||||
|
return[tmp[0][0],tmp[0][1]];};};YAHOO.util.Easing=new function(){this.easeNone=function(t,b,c,d){return b+c*(t/=d);};this.easeIn=function(t,b,c,d){return b+c*((t/=d)*t*t);};this.easeOut=function(t,b,c,d){var ts=(t/=d)*t;var tc=ts*t;return b+c*(tc+-3*ts+3*t);};this.easeBoth=function(t,b,c,d){var ts=(t/=d)*t;var tc=ts*t;return b+c*(-2*tc+3*ts);};this.backIn=function(t,b,c,d){var ts=(t/=d)*t;var tc=ts*t;return b+c*(-3.4005*tc*ts+10.2*ts*ts+-6.2*tc+0.4*ts);};this.backOut=function(t,b,c,d){var ts=(t/=d)*t;var tc=ts*t;return b+c*(8.292*tc*ts+-21.88*ts*ts+22.08*tc+-12.69*ts+5.1975*t);};this.backBoth=function(t,b,c,d){var ts=(t/=d)*t;var tc=ts*t;return b+c*(0.402*tc*ts+-2.1525*ts*ts+-3.2*tc+8*ts+-2.05*t);};};YAHOO.util.Motion=function(el,attributes,duration,method){if(el){this.initMotion(el,attributes,duration,method);}};YAHOO.util.Motion.prototype=new YAHOO.util.Anim();YAHOO.util.Motion.prototype.defaultUnits.points='px';YAHOO.util.Motion.prototype.doMethod=function(attribute,start,end){var val=null;if(attribute=='points'){var translatedPoints=this.getTranslatedPoints();var t=this.method(this.currentFrame,0,100,this.totalFrames)/100;if(translatedPoints){val=YAHOO.util.Bezier.getPosition(translatedPoints,t);}}else{val=this.method(this.currentFrame,start,end-start,this.totalFrames);}
|
||||||
|
return val;};YAHOO.util.Motion.prototype.getAttribute=function(attribute){var val=null;if(attribute=='points'){val=[this.getAttribute('left'),this.getAttribute('top')];if(isNaN(val[0])){val[0]=0;}
|
||||||
|
if(isNaN(val[1])){val[1]=0;}}else{val=parseFloat(YAHOO.util.Dom.getStyle(this.getEl(),attribute));}
|
||||||
|
return val;};YAHOO.util.Motion.prototype.setAttribute=function(attribute,val,unit){if(attribute=='points'){YAHOO.util.Dom.setStyle(this.getEl(),'left',val[0]+unit);YAHOO.util.Dom.setStyle(this.getEl(),'top',val[1]+unit);}else{YAHOO.util.Dom.setStyle(this.getEl(),attribute,val+unit);}};YAHOO.util.Motion.prototype.initMotion=function(el,attributes,duration,method){YAHOO.util.Anim.call(this,el,attributes,duration,method);attributes=attributes||{};attributes.points=attributes.points||{};attributes.points.control=attributes.points.control||[];this.attributes=attributes;var start;var end=null;var translatedPoints=null;this.getTranslatedPoints=function(){return translatedPoints;};var translateValues=function(val,self){var pageXY=YAHOO.util.Dom.getXY(self.getEl());val=[val[0]-pageXY[0]+start[0],val[1]-pageXY[1]+start[1]];return val;};var onStart=function(){start=this.getAttribute('points');var attributes=this.attributes;var control=attributes['points']['control']||[];if(control.length>0&&control[0].constructor!=Array){control=[control];}
|
||||||
|
if(YAHOO.util.Dom.getStyle(this.getEl(),'position')=='static'){YAHOO.util.Dom.setStyle(this.getEl(),'position','relative');}
|
||||||
|
if(typeof attributes['points']['from']!='undefined'){YAHOO.util.Dom.setXY(this.getEl(),attributes['points']['from']);start=this.getAttribute('points');}
|
||||||
|
else if((start[0]===0||start[1]===0)){YAHOO.util.Dom.setXY(this.getEl(),YAHOO.util.Dom.getXY(this.getEl()));start=this.getAttribute('points');}
|
||||||
|
var i,len;if(typeof attributes['points']['to']!='undefined'){end=translateValues(attributes['points']['to'],this);for(i=0,len=control.length;i<len;++i){control[i]=translateValues(control[i],this);}}else if(typeof attributes['points']['by']!='undefined'){end=[start[0]+attributes['points']['by'][0],start[1]+attributes['points']['by'][1]];for(i=0,len=control.length;i<len;++i){control[i]=[start[0]+control[i][0],start[1]+control[i][1]];}}
|
||||||
|
if(end){translatedPoints=[start];if(control.length>0){translatedPoints=translatedPoints.concat(control);}
|
||||||
|
translatedPoints[translatedPoints.length]=end;}};this._onStart.subscribe(onStart);};YAHOO.util.Scroll=function(el,attributes,duration,method){if(el){YAHOO.util.Anim.call(this,el,attributes,duration,method);}};YAHOO.util.Scroll.prototype=new YAHOO.util.Anim();YAHOO.util.Scroll.prototype.defaultUnits.scroll=' ';YAHOO.util.Scroll.prototype.doMethod=function(attribute,start,end){var val=null;if(attribute=='scroll'){val=[this.method(this.currentFrame,start[0],end[0]-start[0],this.totalFrames),this.method(this.currentFrame,start[1],end[1]-start[1],this.totalFrames)];}else{val=this.method(this.currentFrame,start,end-start,this.totalFrames);}
|
||||||
|
return val;}
|
||||||
|
YAHOO.util.Scroll.prototype.getAttribute=function(attribute){var val=null;var el=this.getEl();if(attribute=='scroll'){val=[el.scrollLeft,el.scrollTop];}else{val=parseFloat(YAHOO.util.Dom.getStyle(el,attribute));}
|
||||||
|
return val;};YAHOO.util.Scroll.prototype.setAttribute=function(attribute,val,unit){var el=this.getEl();if(attribute=='scroll'){el.scrollLeft=val[0];el.scrollTop=val[1];}else{YAHOO.util.Dom.setStyle(el,attribute,val+unit);}};
|
||||||
101
distfiles/colorpicker/js/color.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
|
||||||
|
YAHOO.util.Color = new function() {
|
||||||
|
|
||||||
|
// Adapted from http://www.easyrgb.com/math.html
|
||||||
|
// hsv values = 0 - 1
|
||||||
|
// rgb values 0 - 255
|
||||||
|
this.hsv2rgb = function (h, s, v) {
|
||||||
|
var r, g, b;
|
||||||
|
if ( s == 0 ) {
|
||||||
|
r = v * 255;
|
||||||
|
g = v * 255;
|
||||||
|
b = v * 255;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// h must be < 1
|
||||||
|
var var_h = h * 6;
|
||||||
|
if ( var_h == 6 ) {
|
||||||
|
var_h = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Or ... var_i = floor( var_h )
|
||||||
|
var var_i = Math.floor( var_h );
|
||||||
|
var var_1 = v * ( 1 - s );
|
||||||
|
var var_2 = v * ( 1 - s * ( var_h - var_i ) );
|
||||||
|
var var_3 = v * ( 1 - s * ( 1 - ( var_h - var_i ) ) );
|
||||||
|
|
||||||
|
if ( var_i == 0 ) {
|
||||||
|
var_r = v;
|
||||||
|
var_g = var_3;
|
||||||
|
var_b = var_1;
|
||||||
|
} else if ( var_i == 1 ) {
|
||||||
|
var_r = var_2;
|
||||||
|
var_g = v;
|
||||||
|
var_b = var_1;
|
||||||
|
} else if ( var_i == 2 ) {
|
||||||
|
var_r = var_1;
|
||||||
|
var_g = v;
|
||||||
|
var_b = var_3
|
||||||
|
} else if ( var_i == 3 ) {
|
||||||
|
var_r = var_1;
|
||||||
|
var_g = var_2;
|
||||||
|
var_b = v;
|
||||||
|
} else if ( var_i == 4 ) {
|
||||||
|
var_r = var_3;
|
||||||
|
var_g = var_1;
|
||||||
|
var_b = v;
|
||||||
|
} else {
|
||||||
|
var_r = v;
|
||||||
|
var_g = var_1;
|
||||||
|
var_b = var_2
|
||||||
|
}
|
||||||
|
|
||||||
|
r = var_r * 255 //rgb results = 0 ÷ 255
|
||||||
|
g = var_g * 255
|
||||||
|
b = var_b * 255
|
||||||
|
|
||||||
|
}
|
||||||
|
return [Math.round(r), Math.round(g), Math.round(b)];
|
||||||
|
};
|
||||||
|
|
||||||
|
this.rgb2hex = function (r,g,b) {
|
||||||
|
return this.toHex(r) + this.toHex(g) + this.toHex(b);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hexchars = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
this.toHex = function(n) {
|
||||||
|
n = n || 0;
|
||||||
|
n = parseInt(n, 10);
|
||||||
|
if (isNaN(n)) n = 0;
|
||||||
|
n = Math.round(Math.min(Math.max(0, n), 255));
|
||||||
|
|
||||||
|
return this.hexchars.charAt((n - n % 16) / 16) + this.hexchars.charAt(n % 16);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.toDec = function(hexchar) {
|
||||||
|
return this.hexchars.indexOf(hexchar.toUpperCase());
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hex2rgb = function(str) {
|
||||||
|
var rgb = [];
|
||||||
|
rgb[0] = (this.toDec(str.substr(0, 1)) * 16) +
|
||||||
|
this.toDec(str.substr(1, 1));
|
||||||
|
rgb[1] = (this.toDec(str.substr(2, 1)) * 16) +
|
||||||
|
this.toDec(str.substr(3, 1));
|
||||||
|
rgb[2] = (this.toDec(str.substr(4, 1)) * 16) +
|
||||||
|
this.toDec(str.substr(5, 1));
|
||||||
|
// gLogger.debug("hex2rgb: " + str + ", " + rgb.toString());
|
||||||
|
return rgb;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.isValidRGB = function(a) {
|
||||||
|
if ((!a[0] && a[0] !=0) || isNaN(a[0]) || a[0] < 0 || a[0] > 255) return false;
|
||||||
|
if ((!a[1] && a[1] !=0) || isNaN(a[1]) || a[1] < 0 || a[1] > 255) return false;
|
||||||
|
if ((!a[2] && a[2] !=0) || isNaN(a[2]) || a[2] < 0 || a[2] > 255) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
43
distfiles/colorpicker/js/ddcolorposter.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
======================================================================
|
||||||
|
ddcolorposter.js: By Dynamic Drive (http://www.dynamicdrive.com)
|
||||||
|
Communicates between Yahoo Color Picker and form fields on your page
|
||||||
|
Created: Feb 20th, 06'
|
||||||
|
======================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
function executeonload(functionref){
|
||||||
|
if (window.addEventListener)
|
||||||
|
window.addEventListener("load", functionref, false)
|
||||||
|
else if (window.attachEvent)
|
||||||
|
window.attachEvent("onload", functionref)
|
||||||
|
else if (document.getElementById)
|
||||||
|
window.onload=functionref
|
||||||
|
}
|
||||||
|
|
||||||
|
var ddcolorposter={
|
||||||
|
initialize:function(r,g,b, hexvalue){
|
||||||
|
this.rvalue=r //store red value
|
||||||
|
this.gvalue=g //store green value
|
||||||
|
this.bvalue=b //store blue value
|
||||||
|
this.hexvalue=hexvalue //store combined hex value
|
||||||
|
if (typeof this.targetobj!="undefined"){
|
||||||
|
this.targetobj.value=this.hexvalue //set field to selected hex color value
|
||||||
|
if (typeof this.divobj!="undefined") //set adjacent div to selected hex color value
|
||||||
|
this.divobj.style.backgroundColor="#"+this.hexvalue
|
||||||
|
}
|
||||||
|
},
|
||||||
|
echocolor:function(inputobj, divID){
|
||||||
|
this.targetobj=inputobj
|
||||||
|
this.divobj=document.getElementById(divID)
|
||||||
|
this.targetobj.onblur=function(){
|
||||||
|
if (inputobj.value.search(/^[a-zA-Z0-9]{6}$/)!=-1) //if field contains valid hex value
|
||||||
|
document.getElementById(divID).style.backgroundColor="#"+inputobj.value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fillcolorbox:function(inputID, divID){
|
||||||
|
var inputobj=document.getElementById(inputID)
|
||||||
|
if (inputobj.value.search(/^[a-zA-Z0-9]{6}$/)!=-1) //if field contains valid hex value
|
||||||
|
document.getElementById(divID).style.backgroundColor="#"+inputobj.value
|
||||||
|
}
|
||||||
|
}
|
||||||
26
distfiles/colorpicker/js/dom.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
YAHOO.util.Dom=new function(){this.get=function(el){if(typeof el=='string'){el=document.getElementById(el);}
|
||||||
|
return el;};this.getStyle=function(el,property){var value=null;var dv=document.defaultView;el=this.get(el);if(property=='opacity'&&el.filters){value=1;try{value=el.filters.item('DXImageTransform.Microsoft.Alpha').opacity/100;}catch(e){try{value=el.filters.item('alpha').opacity/100;}catch(e){}}}
|
||||||
|
else if(el.style[property]){value=el.style[property];}
|
||||||
|
else if(el.currentStyle&&el.currentStyle[property]){value=el.currentStyle[property];}
|
||||||
|
else if(dv&&dv.getComputedStyle)
|
||||||
|
{var converted='';for(i=0,len=property.length;i<len;++i){if(property.charAt(i)==property.charAt(i).toUpperCase()){converted=converted+'-'+property.charAt(i).toLowerCase();}else{converted=converted+property.charAt(i);}}
|
||||||
|
if(dv.getComputedStyle(el,'').getPropertyValue(converted)){value=dv.getComputedStyle(el,'').getPropertyValue(converted);}}
|
||||||
|
return value;};this.setStyle=function(el,property,val){el=this.get(el);switch(property){case'opacity':if(el.filters){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle.hasLayout){el.style.zoom=1;}}else{el.style.opacity=val;el.style['-moz-opacity']=val;el.style['-khtml-opacity']=val;}
|
||||||
|
break;default:el.style[property]=val;}};this.getXY=function(el){el=this.get(el);if(el.parentNode===null||this.getStyle(el,'display')=='none'){return false;}
|
||||||
|
var parent=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;var scrollLeft=document.documentElement.scrollLeft||document.body.scrollLeft;return[box.left+scrollLeft,box.top+scrollTop];}
|
||||||
|
else if(document.getBoxObjectFor){box=document.getBoxObjectFor(el);pos=[box.x,box.y];}
|
||||||
|
else{pos=[el.offsetLeft,el.offsetTop];parent=el.offsetParent;if(parent!=el){while(parent){pos[0]+=parent.offsetLeft;pos[1]+=parent.offsetTop;parent=parent.offsetParent;}}
|
||||||
|
var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1||(ua.indexOf('safari')!=-1&&this.getStyle(el,'position')=='absolute')){pos[1]-=document.body.offsetTop;}}
|
||||||
|
if(el.parentNode){parent=el.parentNode;}
|
||||||
|
else{parent=null;}
|
||||||
|
while(parent&&parent.tagName!='BODY'&&parent.tagName!='HTML'){pos[0]-=parent.scrollLeft;pos[1]-=parent.scrollTop;if(parent.parentNode){parent=parent.parentNode;}
|
||||||
|
else{parent=null;}}
|
||||||
|
return pos;};this.getX=function(el){return this.getXY(el)[0];};this.getY=function(el){return this.getXY(el)[1];};this.setXY=function(el,pos,noRetry){el=this.get(el);var pageXY=YAHOO.util.Dom.getXY(el);if(pageXY===false){return false;}
|
||||||
|
var delta=[parseInt(YAHOO.util.Dom.getStyle(el,'left'),10),parseInt(YAHOO.util.Dom.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=0;}
|
||||||
|
if(isNaN(delta[1])){delta[1]=0;}
|
||||||
|
if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';}
|
||||||
|
if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';}
|
||||||
|
var newXY=this.getXY(el);if(!noRetry&&(newXY[0]!=pos[0]||newXY[1]!=pos[1])){this.setXY(el,pos,true);}
|
||||||
|
return true;};this.setX=function(el,x){return this.setXY(el,[x,null]);};this.setY=function(el,y){return this.setXY(el,[null,y]);};this.getRegion=function(el){el=this.get(el);return new YAHOO.util.Region.getRegion(el);};this.getClientWidth=function(){return(document.documentElement.offsetWidth||document.body.offsetWidth);};this.getClientHeight=function(){return(self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight);};};YAHOO.util.Region=function(t,r,b,l){this.top=t;this.right=r;this.bottom=b;this.left=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+" t: "+this.top+", r: "+this.right+", b: "+this.bottom+", l: "+this.left+"}");}
|
||||||
|
YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){this.x=x;this.y=y;this.top=y;this.right=x;this.bottom=y;this.left=x;};YAHOO.util.Point.prototype=new YAHOO.util.Region();
|
||||||
1
distfiles/colorpicker/js/dragdrop.js
vendored
Normal file
1
distfiles/colorpicker/js/event.js
Normal file
34
distfiles/colorpicker/js/key.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
|
||||||
|
YAHOO.util.Key = new function() {
|
||||||
|
// this.logger = new ygLogger("ygEventUtil");
|
||||||
|
// DOM key constants
|
||||||
|
this.DOM_VK_UNDEFINED = 0x0;
|
||||||
|
this.DOM_VK_RIGHT_ALT = 0x12;
|
||||||
|
this.DOM_VK_LEFT_ALT = 0x12;
|
||||||
|
this.DOM_VK_LEFT_CONTROL = 0x11;
|
||||||
|
this.DOM_VK_RIGHT_CONTROL = 0x11;
|
||||||
|
this.DOM_VK_LEFT_SHIFT = 0x10;
|
||||||
|
this.DOM_VK_RIGHT_SHIFT = 0x10;
|
||||||
|
this.DOM_VK_META = 0x9D;
|
||||||
|
this.DOM_VK_BACK_SPACE = 0x08;
|
||||||
|
this.DOM_VK_CAPS_LOCK = 0x14;
|
||||||
|
this.DOM_VK_DELETE = 0x7F;
|
||||||
|
this.DOM_VK_END = 0x23;
|
||||||
|
this.DOM_VK_ENTER = 0x0D;
|
||||||
|
this.DOM_VK_ESCAPE = 0x1B;
|
||||||
|
this.DOM_VK_HOME = 0x24;
|
||||||
|
this.DOM_VK_NUM_LOCK = 0x90;
|
||||||
|
this.DOM_VK_PAUSE = 0x13;
|
||||||
|
this.DOM_VK_PRINTSCREEN = 0x9A;
|
||||||
|
this.DOM_VK_SCROLL_LOCK = 0x91;
|
||||||
|
this.DOM_VK_SPACE = 0x20;
|
||||||
|
this.DOM_VK_TAB = 0x09;
|
||||||
|
this.DOM_VK_LEFT = 0x25;
|
||||||
|
this.DOM_VK_RIGHT = 0x27;
|
||||||
|
this.DOM_VK_UP = 0x26;
|
||||||
|
this.DOM_VK_DOWN = 0x28;
|
||||||
|
this.DOM_VK_PAGE_DOWN = 0x22;
|
||||||
|
this.DOM_VK_PAGE_UP = 0x21;
|
||||||
|
};
|
||||||
|
|
||||||
89
distfiles/colorpicker/js/log.js
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class a general logging class. Expects to be initalized with a reference
|
||||||
|
* to a html element to write to.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @param {String} sModuleName the name of the module this instance belongs
|
||||||
|
* to. Used in the log message to help id where the msg came from.
|
||||||
|
*/
|
||||||
|
function ygLogger(sModuleName) {
|
||||||
|
if (this.setModuleName)
|
||||||
|
this.setModuleName(sModuleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
ygLogger.DEBUG_ENABLED = true;
|
||||||
|
ygLogger.targetEl = null;
|
||||||
|
ygLogger.logStack = [];
|
||||||
|
ygLogger.startLog = new Date().getTime();
|
||||||
|
ygLogger.lastLog = new Date().getTime();
|
||||||
|
ygLogger.locked = true;
|
||||||
|
ygLogger.logTimeout = null;
|
||||||
|
|
||||||
|
ygLogger.init = function(oHostElement) {
|
||||||
|
if (oHostElement) {
|
||||||
|
ygLogger.targetEl = oHostElement;
|
||||||
|
} else {
|
||||||
|
// create element or create window?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ygLogger.prototype.setModuleName = function(sModuleName) {
|
||||||
|
this.logName = sModuleName;
|
||||||
|
};
|
||||||
|
|
||||||
|
ygLogger.prototype.debug = function() {
|
||||||
|
if (ygLogger.DEBUG_ENABLED) {
|
||||||
|
var newDate = new Date();
|
||||||
|
var newTime = newDate.getTime();
|
||||||
|
var timeStamp = newTime - ygLogger.lastLog;
|
||||||
|
var totalSeconds = (newTime - ygLogger.startLog) / 1000;
|
||||||
|
|
||||||
|
ygLogger.lastLog = newTime;
|
||||||
|
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
ygLogger.logStack[ygLogger.logStack.length] =
|
||||||
|
timeStamp + " ms(" + totalSeconds + ") " +
|
||||||
|
newDate.toLocaleTimeString() + "<br />" +
|
||||||
|
this.logName + ": <b>" + arguments[i] + "</b>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ygLogger.logTimeout == null) {
|
||||||
|
ygLogger.logTimeout = setTimeout("ygLogger._outputMessages()" , 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ygLogger.disable = function() {
|
||||||
|
ygLogger.DEBUG_ENABLED = false;
|
||||||
|
try { ygLogger.targetEl.style.visibility = "hidden"; } catch(e) {}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ygLogger.enable = function() {
|
||||||
|
ygLogger.DEBUG_ENABLED = true;
|
||||||
|
try { ygLogger.targetEl.style.visibility = ""; } catch(e) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
ygLogger._outputMessages = function() {
|
||||||
|
if (ygLogger.targetEl != null) {
|
||||||
|
|
||||||
|
for (var i = 0; i < ygLogger.logStack.length; i++) {
|
||||||
|
var sMsg = ygLogger.logStack[i];
|
||||||
|
var oNewElement = ygLogger.targetEl.appendChild(
|
||||||
|
document.createElement("p"));
|
||||||
|
oNewElement.innerHTML = sMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
ygLogger.logStack = [];
|
||||||
|
|
||||||
|
ygLogger.targetEl.scrollTop = ygLogger.targetEl.scrollHeight;
|
||||||
|
|
||||||
|
// debugger;
|
||||||
|
}
|
||||||
|
|
||||||
|
ygLogger.logTimeout = null;
|
||||||
|
};
|
||||||
|
|
||||||
1
distfiles/colorpicker/js/slider.js
Normal file
810
distfiles/common.php
Normal file
@@ -0,0 +1,810 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
common.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// test for correct installation
|
||||||
|
if (!file_exists("db.php")) {
|
||||||
|
echo "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\">
|
||||||
|
<title>Installation error</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Could not find the db.php file required for this installation.
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
include("db.php");
|
||||||
|
include("settings.php");
|
||||||
|
|
||||||
|
// define some constants
|
||||||
|
define("STAT_OPEN",1);
|
||||||
|
define("STAT_CLOSED",2);
|
||||||
|
define("STAT_DEFERRED",3);
|
||||||
|
define("ADMIN",2);
|
||||||
|
define("USER",1);
|
||||||
|
|
||||||
|
// build the basic color array
|
||||||
|
$basic_colors=array(
|
||||||
|
"White" => "#FFFFFF",
|
||||||
|
"Silver" => "#C0C0C0",
|
||||||
|
"Gray" => "#808080",
|
||||||
|
"Black" => "#000000",
|
||||||
|
"Red" => "#FF0000",
|
||||||
|
"Maroon" => "#800000",
|
||||||
|
"Orange" => "#FFA500",
|
||||||
|
"Yellow" => "#FFFF00",
|
||||||
|
"Olive" => "#808000",
|
||||||
|
"Lime" => "#00FF00",
|
||||||
|
"Green" => "#008000",
|
||||||
|
"Aqua" => "#00FFFF",
|
||||||
|
"Teal" => "#008080",
|
||||||
|
"Blue" => "#0000FF",
|
||||||
|
"Navy" => "#000080",
|
||||||
|
"Fuchsia" => "#FF00FF",
|
||||||
|
"Purple" => "#800080");
|
||||||
|
|
||||||
|
// Generic functions
|
||||||
|
|
||||||
|
function framework($option,$htmltitle,$pagetitle,$print) {
|
||||||
|
// generates html code for the beginning and end of all pages
|
||||||
|
if ($option=="begin") {
|
||||||
|
// generates everything down to the sidemenu/pagetable
|
||||||
|
// htmltitle is the page title that appears in the window titlebar
|
||||||
|
// pagetitle is what will appear as the title of the page itself
|
||||||
|
// print is whether to format for printing or not
|
||||||
|
if ($print) {
|
||||||
|
$bgcolor=P_BACKGROUND_COLOR;
|
||||||
|
$textcolor=P_TEXT_COLOR;
|
||||||
|
$linkcolor=P_LINK_COLOR;
|
||||||
|
$vlinkcolor=P_VLINK_COLOR;
|
||||||
|
$hdgcolor=P_HEADING_COLOR;
|
||||||
|
} else {
|
||||||
|
$bgcolor=BACKGROUND_COLOR;
|
||||||
|
$textcolor=TEXT_COLOR;
|
||||||
|
$linkcolor=LINK_COLOR;
|
||||||
|
$vlinkcolor=VLINK_COLOR;
|
||||||
|
$hdgcolor=HEADING_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv=\"x-ua-compatible\" content=\"IE=edge\">
|
||||||
|
<title>$htmltitle</title>
|
||||||
|
<style type=\"text/css\">
|
||||||
|
table.writeup {table-layout:fixed;}
|
||||||
|
td.forcewrap {word-wrap: break-word;}
|
||||||
|
</style>
|
||||||
|
<style type=\"text/css\">
|
||||||
|
.fixed {
|
||||||
|
position:fixed;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function goBack() {
|
||||||
|
window.history.back()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<link href=\"jquery-ui/jquery-ui.css\" rel=\"stylesheet\">
|
||||||
|
<link href=\"jquery-ui/jquery.multiselect.css\" rel=\"stylesheet\">
|
||||||
|
<style>div.ui-datepicker{font-size:12px;}</style>
|
||||||
|
|
||||||
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"colorpicker/css/screen.css\">
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/ddcolorposter.js\"></script>
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/YAHOO.js\" ></script>
|
||||||
|
<script type=\"text/javascript2\" src=\"colorpicker/js/log.js\" ></script>
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/color.js\" ></script>
|
||||||
|
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/event.js\" ></script>
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/dom.js\" ></script>
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/animation.js\" ></script>
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/dragdrop.js\" ></script>
|
||||||
|
|
||||||
|
<script type=\"text/javascript\" src=\"colorpicker/js/slider.js\" ></script>
|
||||||
|
<script type=\"text/javascript\">
|
||||||
|
|
||||||
|
var hue;
|
||||||
|
var picker;
|
||||||
|
//var gLogger;
|
||||||
|
var dd1, dd2;
|
||||||
|
var r, g, b;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
if (typeof(ygLogger) != \"undefined\")
|
||||||
|
ygLogger.init(document.getElementById(\"logDiv\"));
|
||||||
|
pickerInit();
|
||||||
|
ddcolorposter.fillcolorbox(\"bgcfield\", \"bgcbox\")
|
||||||
|
ddcolorposter.fillcolorbox(\"mbgcfield\", \"mbgcbox\")
|
||||||
|
ddcolorposter.fillcolorbox(\"tcfield\", \"tcbox\")
|
||||||
|
ddcolorposter.fillcolorbox(\"lcfield\", \"lcbox\")
|
||||||
|
ddcolorposter.fillcolorbox(\"vlcfield\", \"vlcbox\")
|
||||||
|
ddcolorposter.fillcolorbox(\"hcfield\", \"hcbox\")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Picker ---------------------------------------------------------
|
||||||
|
|
||||||
|
function pickerInit() {
|
||||||
|
hue = YAHOO.widget.Slider.getVertSlider(\"hueBg\", \"hueThumb\", 0, 180);
|
||||||
|
hue.onChange = function(newVal) { hueUpdate(newVal); };
|
||||||
|
|
||||||
|
picker = YAHOO.widget.Slider.getSliderRegion(\"pickerDiv\", \"selector\",
|
||||||
|
0, 180, 0, 180);
|
||||||
|
picker.onChange = function(newX, newY) { pickerUpdate(newX, newY); };
|
||||||
|
|
||||||
|
hueUpdate();
|
||||||
|
|
||||||
|
dd1 = new YAHOO.util.DD(\"pickerPanel\");
|
||||||
|
dd1.setHandleElId(\"pickerHandle\");
|
||||||
|
dd1.endDrag = function(e) {
|
||||||
|
// picker.thumb.resetConstraints();
|
||||||
|
// hue.thumb.resetConstraints();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
executeonload(init);
|
||||||
|
|
||||||
|
function pickerUpdate(newX, newY) {
|
||||||
|
pickerSwatchUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hueUpdate(newVal) {
|
||||||
|
|
||||||
|
var h = (180 - hue.getValue()) / 180;
|
||||||
|
if (h == 1) { h = 0; }
|
||||||
|
|
||||||
|
var a = YAHOO.util.Color.hsv2rgb( h, 1, 1);
|
||||||
|
|
||||||
|
document.getElementById(\"pickerDiv\").style.backgroundColor =
|
||||||
|
\"rgb(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";
|
||||||
|
|
||||||
|
pickerSwatchUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickerSwatchUpdate() {
|
||||||
|
var h = (180 - hue.getValue());
|
||||||
|
if (h == 180) { h = 0; }
|
||||||
|
document.getElementById(\"pickerhval\").value = (h*2);
|
||||||
|
|
||||||
|
h = h / 180;
|
||||||
|
|
||||||
|
var s = picker.getXValue() / 180;
|
||||||
|
document.getElementById(\"pickersval\").value = Math.round(s * 100);
|
||||||
|
|
||||||
|
var v = (180 - picker.getYValue()) / 180;
|
||||||
|
document.getElementById(\"pickervval\").value = Math.round(v * 100);
|
||||||
|
|
||||||
|
var a = YAHOO.util.Color.hsv2rgb( h, s, v );
|
||||||
|
|
||||||
|
document.getElementById(\"pickerSwatch\").style.backgroundColor =
|
||||||
|
\"rgb(\" + a[0] + \", \" + a[1] + \", \" + a[2] + \")\";
|
||||||
|
|
||||||
|
document.getElementById(\"pickerrval\").value = a[0];
|
||||||
|
document.getElementById(\"pickergval\").value = a[1];
|
||||||
|
document.getElementById(\"pickerbval\").value = a[2];
|
||||||
|
var hexvalue = document.getElementById(\"pickerhexval\").value =
|
||||||
|
YAHOO.util.Color.rgb2hex(a[0], a[1], a[2]);
|
||||||
|
ddcolorposter.initialize(a[0], a[1], a[2], hexvalue)
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
<body bgcolor=\"#$bgcolor\" text=\"#$textcolor\" link=\"#$linkcolor\" vlink=\"#$vlinkcolor\">
|
||||||
|
";
|
||||||
|
if ($htmltitle || $pagetitle) {
|
||||||
|
echo "<font size=5 color=\"#$hdgcolor\"><b> $htmltitle - $pagetitle</b></font>";
|
||||||
|
if ($print) {
|
||||||
|
echo "
|
||||||
|
<input type=\"button\" onClick=\"window.print()\" value=\"Print\" id=\"printbutton\">
|
||||||
|
<input type=\"button\" onClick=\"window.close()\" value=\"Close\" id=\"closebutton\">
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "<br>";
|
||||||
|
}
|
||||||
|
} else if ($option=="end") {
|
||||||
|
echo "
|
||||||
|
<script src=\"jquery-ui/external/jquery/jquery.js\"></script>
|
||||||
|
<script src=\"jquery-ui/jquery-ui.js\"></script>
|
||||||
|
<script src=\"jquery-ui/jquery.multiselect.js\"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$( \".sidemenu\").addClass(\"fixed\");
|
||||||
|
|
||||||
|
$( \":button, :submit, :reset\" ).button();
|
||||||
|
|
||||||
|
$( \"#singledatepicker, #reportdatepicker, #actiondatepicker, [id|='onedp']\" ).datepicker({
|
||||||
|
showOn: \"focus\",
|
||||||
|
showButtonPanel: true,
|
||||||
|
changeMonth: true,
|
||||||
|
changeYear: true,
|
||||||
|
dateFormat: \"yy-mm-dd\"
|
||||||
|
});
|
||||||
|
|
||||||
|
$( \"#startdatepicker, [id|='sdp']\" ).datepicker({
|
||||||
|
showOn: \"focus\",
|
||||||
|
buttonImage: \"icons/calendar.gif\",
|
||||||
|
buttonImageOnly: true,
|
||||||
|
buttonText: \"Select start date\",
|
||||||
|
inline: true,
|
||||||
|
showButtonPanel: true,
|
||||||
|
changeMonth: true,
|
||||||
|
changeYear: true,
|
||||||
|
dateFormat: \"yy-mm-dd\"
|
||||||
|
});
|
||||||
|
|
||||||
|
$( \"#enddatepicker, [id|='edp']\" ).datepicker({
|
||||||
|
showOn: \"focus\",
|
||||||
|
buttonImage: \"icons/calendar.gif\",
|
||||||
|
buttonImageOnly: true,
|
||||||
|
buttonText: \"Select end date\",
|
||||||
|
inline: true,
|
||||||
|
showButtonPanel: true,
|
||||||
|
changeMonth: true,
|
||||||
|
changeYear: true,
|
||||||
|
dateFormat: \"yy-mm-dd\"
|
||||||
|
});
|
||||||
|
|
||||||
|
$( \"#logoutall\" ).checkboxradio({
|
||||||
|
icon: false
|
||||||
|
});
|
||||||
|
$( \"#device, #subsystem, #period, #period_effective, [id|='sel']\" ).selectmenu();
|
||||||
|
$( \"#status, #user, #reason\" ).selectmenu();
|
||||||
|
$( \"#subsystem, #period, #searchstatus, #pass, #passconf\").tooltip();
|
||||||
|
$( \"[id|='ms']\").multiselect();
|
||||||
|
$( \"#configtabs, #dbadmintabs, #profiletabs\" ).tabs();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<br>Invalid option \"$option\" passed to framework(). Valid options are \"begin\" and \"end\".<br>
|
||||||
|
";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pagetable($option) {
|
||||||
|
if ($option=="begin") {
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table border=\"0\" width=\"100%\" cellpadding=\"10\">
|
||||||
|
<tr>
|
||||||
|
";
|
||||||
|
} else if ($option=="end") {
|
||||||
|
echo "
|
||||||
|
</tr></table>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<br>Invalid option \"$option\" passed to pagetable(). Valid options are \"begin\" and \"end\".<br>
|
||||||
|
";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageblock($block,$option) {
|
||||||
|
if ($block=="left") {
|
||||||
|
if ($option=="begin") {
|
||||||
|
echo "
|
||||||
|
<td width=\"210\" valign=\"top\">
|
||||||
|
";
|
||||||
|
} else if ($option=="end") {
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<br>Invalid option \"$option\" passed to pageblock(). Valid options are \"begin\" and \"end\".<br>
|
||||||
|
";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else if ($block=="right") {
|
||||||
|
if ($option=="begin") {
|
||||||
|
echo "
|
||||||
|
<td valign=\"top\">
|
||||||
|
";
|
||||||
|
} else if ($option=="end") {
|
||||||
|
if (defined("FOOTER_MESSAGE")) {
|
||||||
|
$footer_msg=FOOTER_MESSAGE;
|
||||||
|
echo "
|
||||||
|
<br><br>
|
||||||
|
<center>$footer_msg</center><br>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<br>Invalid option \"$option\" passed to pageblock(). Valid options are \"begin\" and \"end\".<br>
|
||||||
|
";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<br>Invalid block \"$block\" passed to pageblock(). Valid blocks are \"left\" and \"right\".<br>
|
||||||
|
";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sidemenu($printable=true) {
|
||||||
|
// Displays sidebar menu
|
||||||
|
global $drs_db,$mbgcolor;
|
||||||
|
echo "
|
||||||
|
<div class=\"sidemenu\">
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><a href=\"create.php\" title=\"Create new writeup\"><font size=\"+1\"><b>Create New Writeup</b></font></a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>";
|
||||||
|
echo "
|
||||||
|
<center><button onclick=\"goBack()\">Go Back</button></center>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><a href=\"writeups.php\" title=\"View open writeups\"><font size=\"+1\"><b>View Open Writeups</b></font></a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"writeups.php?view=1\" title=\"View all writeups for a date range\">View All Writeups</a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"groups.php\" title=\"View writeup groups\">Writeup Groups</a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"search.php\">Search Writeups</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
";
|
||||||
|
|
||||||
|
if (isset($_SESSION['userid'])) {
|
||||||
|
$menuuser=$_SESSION['userid'];
|
||||||
|
if (mysqli_fetch_row(mysqli_query($drs_db,"select role from users where id=\"$menuuser\""))[0] == ADMIN) {
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><b>Admin Functions</b></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"config.php\" title=\"Control global settings. Must be an administrator.\">Global Settings</a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"dbadmin.php\" title=\"Manage the database. Must be an administrator.\">Manage Database</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION['userid'])) {
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><b>My Account</b></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"login.php\"><b>Log In</b></a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>";
|
||||||
|
} else {
|
||||||
|
$loginid=$_SESSION['userid'];
|
||||||
|
$loggedinas=mysqli_fetch_row(mysqli_query($drs_db,"select firstname,lastname from users where id=\"$loginid\""));
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><b>My Account</b></td></tr>
|
||||||
|
<tr><td align=\"center\">Logged in as $loggedinas[0] $loggedinas[1]</td></tr><tr><td align=\"center\"><a href=\"login.php?cancel=1\"><b>Log Out</b></a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"profile.php\">My Profile</a></td></tr>
|
||||||
|
</table>
|
||||||
|
<br>";
|
||||||
|
}
|
||||||
|
if ($printable) {
|
||||||
|
$currentparams=arrayCopy($_REQUEST);
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<center>
|
||||||
|
<form method=\"post\" target=\"_blank\">
|
||||||
|
<input type=\"hidden\" name=\"all_parameters\" value=\"". htmlentities(serialize($currentparams))."\">
|
||||||
|
<input type=\"submit\" name=\"print\" value=\"Show Printable\" id=\"showprintable\"></form>
|
||||||
|
</center>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
<br>
|
||||||
|
<table style=\"table-layout:fixed;width:210px;\" bgcolor=\"#$mbgcolor\" border=\"1\" width=\"100%\">
|
||||||
|
<tr><td align=\"center\"><a href=\"about.php\">About</a></td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
function banner($print) {
|
||||||
|
// displays a banner
|
||||||
|
global $drs_db;
|
||||||
|
$bannerid=BANNER;
|
||||||
|
// get banner parameters from banner table
|
||||||
|
$banrow=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from banners where bannerid=\"$bannerid\""));
|
||||||
|
if (!$banrow) {
|
||||||
|
$bannerid=1;
|
||||||
|
} else {
|
||||||
|
$bannertext=$banrow["bannername"];
|
||||||
|
if ($print) {
|
||||||
|
$bannercolor="#FFFFFF";
|
||||||
|
$bannertxtcolor="#000000";
|
||||||
|
} else {
|
||||||
|
$bannercolor=$banrow["bannercolor"];
|
||||||
|
$bannertxtcolor=$banrow["textcolor"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($bannerid != 1) {
|
||||||
|
echo "
|
||||||
|
<table width=\"100%\">
|
||||||
|
<tr bgcolor=\"$bannercolor\" align=\"center\"><td colspan=2><font size=\"+1\" color=\"$bannertxtcolor\"><b>$bannertext</b></font></td></tr></table>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
|
||||||
|
// look up a single field in a database given a value for a single field
|
||||||
|
$out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""));
|
||||||
|
return($out_data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function arrayCopy( array $array ) {
|
||||||
|
$result = array();
|
||||||
|
foreach( $array as $key => $val ) {
|
||||||
|
if( is_array( $val ) ) {
|
||||||
|
$result[$key] = arrayCopy( $val );
|
||||||
|
} elseif ( is_object( $val ) ) {
|
||||||
|
$result[$key] = clone $val;
|
||||||
|
} else {
|
||||||
|
$result[$key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateDate($date, $format = 'Y-m-d') {
|
||||||
|
$d = DateTime::createFromFormat($format, $date);
|
||||||
|
return $d && $d->format($format) == $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateTime($time, $format = 'H:i:s') {
|
||||||
|
$t = DateTime::createFromFormat($format, $time);
|
||||||
|
return $t && $t->format($format) == $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_password($pass,$passconf) {
|
||||||
|
// run some checks on supplied passwords
|
||||||
|
// returns a two element array
|
||||||
|
// first element is true if passwords match, false if not
|
||||||
|
// second element is true if passwords meet complexity requirements, false if not
|
||||||
|
|
||||||
|
$results=array();
|
||||||
|
|
||||||
|
// check for match
|
||||||
|
if ($pass==$passconf) {
|
||||||
|
$results['match']=true;
|
||||||
|
} else {
|
||||||
|
$results['match']=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for complexity
|
||||||
|
// length
|
||||||
|
if (strlen($pass) < 8) {
|
||||||
|
$passlength=false;
|
||||||
|
} else {
|
||||||
|
$passlength=true;
|
||||||
|
}
|
||||||
|
// upper case
|
||||||
|
if (preg_match('/[A-Z]/',$pass)) {
|
||||||
|
$hasupper=true;
|
||||||
|
} else {
|
||||||
|
$hasupper=false;
|
||||||
|
}
|
||||||
|
// lower case
|
||||||
|
if (preg_match('/[a-z]/',$pass)) {
|
||||||
|
$haslower=true;
|
||||||
|
} else {
|
||||||
|
$haslower=false;
|
||||||
|
}
|
||||||
|
// number
|
||||||
|
if (preg_match('/[0-9]/',$pass)) {
|
||||||
|
$hasnumber=true;
|
||||||
|
} else {
|
||||||
|
$hasnumber=false;
|
||||||
|
}
|
||||||
|
// special character
|
||||||
|
if (preg_match('/[[:punct:]]/',$pass)) {
|
||||||
|
$hasspecial=true;
|
||||||
|
} else {
|
||||||
|
$hasspecial=false;
|
||||||
|
}
|
||||||
|
if ($passlength && $hasupper && $haslower && $hasnumber && $hasspecial) {
|
||||||
|
$results['complex']=true;
|
||||||
|
} else {
|
||||||
|
$results['complex']=false;
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function displaywriteup($id) {
|
||||||
|
global $drs_db;
|
||||||
|
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id=\"$id\""));
|
||||||
|
// determine status indicator
|
||||||
|
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
|
||||||
|
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
|
||||||
|
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
|
||||||
|
// determine effective icon
|
||||||
|
if($writeupdata["period_effective"]==1) {
|
||||||
|
$effind="<font color=\"#00FF00\" title=\"Period Effective\">EFF</font>";
|
||||||
|
} else {
|
||||||
|
$effind="<font color=\"#FF0000\" title=\"Period Non-effective\">NEF</font>";
|
||||||
|
}
|
||||||
|
// look up text data
|
||||||
|
$devicename=dblookup($drs_db,"devices","id","name",$writeupdata["device"]);
|
||||||
|
$subsystemname=dblookup($drs_db,"subsystems","id","name",$writeupdata["subsystem"]);
|
||||||
|
$subsystemdesc=dblookup($drs_db,"subsystems","id","description",$writeupdata["subsystem"]);
|
||||||
|
$discrtxt=$writeupdata["discrepancy_text"];
|
||||||
|
$rdate=$writeupdata["report_date"];
|
||||||
|
$rtime=$writeupdata["report_time"];
|
||||||
|
$repby=$writeupdata["reported_by"];
|
||||||
|
$period=$writeupdata["period"];
|
||||||
|
$periodtimes=dblookup($drs_db,"periods","id","times",$period);
|
||||||
|
$techfname=dblookup($drs_db,"users","id","firstname",$writeupdata["action_by"]);
|
||||||
|
$techlname=dblookup($drs_db,"users","id","lastname",$writeupdata["action_by"]);
|
||||||
|
$reasonname=dblookup($drs_db,"reasons","id","text",$writeupdata["action_reason"]);
|
||||||
|
$actxt=$writeupdata["action_text"];
|
||||||
|
$adate=$writeupdata["action_date"];
|
||||||
|
if ($adate=="0000-00-00") $adate="";
|
||||||
|
$atime=$writeupdata["action_time"];
|
||||||
|
|
||||||
|
// determine if this is a member of a group
|
||||||
|
$member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$writeupdata['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) {
|
||||||
|
$group_ind="<a href=\"groups.php?group=$member_group\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"$imgtitle\"></a></div>";
|
||||||
|
} else {
|
||||||
|
$group_ind="<a href=\"groups.php\"><img src=\"icons/block.png\" alt=\"GRP\" title=\"View writeup groups\"></a></div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
<table border=\"2\" width=\"100%\"><tr><td>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr><td><b>ID:</b> <a href=\"writeupdetail.php?id=$id\" title=\"View or change details of this writeup\">$id</a></td><td> </td>
|
||||||
|
<td><b>$statusind</b></td><td> </td>
|
||||||
|
<td><b>Device:</b> $devicename</td><td> </td>
|
||||||
|
<td><b>Subsystem:</b> <font title=\"$subsystemdesc\">$subsystemname</font></td><td> </td>
|
||||||
|
<td><b>Period:</b> <font title=\"$periodtimes\">$period</font></td><td> </td>
|
||||||
|
<td><b>$effind</b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr>
|
||||||
|
<td><b>Discrepancy:</b><br>$discrtxt</td><td> </td>
|
||||||
|
<td align=\"right\" valign=\"bottom\">$group_ind</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr>
|
||||||
|
<td><b>Report date:</b> $rdate</td><td> </td>
|
||||||
|
<td><b>Report time:</b> $rtime</td><td> </td>
|
||||||
|
<td><b>Reported by:</b> $repby</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr>
|
||||||
|
<td><b>Action taken by:</b> $techfname $techlname</td><td> </td>
|
||||||
|
<td><b>Status change reason:</b> $reasonname</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr>
|
||||||
|
<td><b>Action taken:</b><br>$actxt</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr>
|
||||||
|
<td><b>Action date:</b> $adate</td><td> </td>
|
||||||
|
<td><b>Action time:</b> $atime</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td></tr></table>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
function format_message($msgtype,$msgtxt) {
|
||||||
|
// displays a formatted message
|
||||||
|
// $msgtype is 0 for success or anything else for failure
|
||||||
|
// $msgtxt is the string to display
|
||||||
|
if ($msgtype == 0) {
|
||||||
|
$state="ui-state-highlight";
|
||||||
|
$icon="ui-icon-info";
|
||||||
|
} else {
|
||||||
|
$state="ui-state-error";
|
||||||
|
$icon="ui-icon-alert";
|
||||||
|
}
|
||||||
|
if ($msgtxt == "") $msgtxt="PROGRAM ERROR: No message text was supplied.";
|
||||||
|
echo "
|
||||||
|
<div class=\"$state ui-corner-all\" style=\"margin-top: 20px; padding: 0 .7em;\">
|
||||||
|
<p><span class=\"ui-icon $icon\" style=\"float: left; margin-right: .3em;\"></span>
|
||||||
|
$msgtxt</p>
|
||||||
|
</div><br><br>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getsetting($setting_name,$user_id) {
|
||||||
|
// get the value of a setting for a user
|
||||||
|
global $drs_db;
|
||||||
|
$confvalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select id,value from config where name=\"$setting_name\""))['value'];
|
||||||
|
$uservalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\""))['value'];
|
||||||
|
if ($uservalue) {
|
||||||
|
return $uservalue;
|
||||||
|
} else {
|
||||||
|
return $confvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function putsetting($setting_name,$setting_value,$user_id) {
|
||||||
|
// set the value of a setting for a tech
|
||||||
|
global $drs_db;
|
||||||
|
$confvalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from config where name=\"$setting_name\""))['value'];
|
||||||
|
$uservalue=mysqli_fetch_assoc(mysqli_query($drs_db,"select value from profile where name=\"$setting_name\" and user=\"$user_id\""))['value'];
|
||||||
|
if ($setting_value==$confvalue) {
|
||||||
|
mysqli_query($drs_db,"delete from profile where user=\"$user_id\" and name=\"$setting_name\"");
|
||||||
|
} else {
|
||||||
|
if ($uservalue) {
|
||||||
|
if ($uservalue != $setting_value) mysqli_query($drs_db,"update profile set value=\"$setting_value\" where name=\"$setting_name\" and user=\"$user_id\"");
|
||||||
|
} else {
|
||||||
|
mysqli_query($drs_db,"insert into profile(user,name,value) values(\"$user_id\",\"$setting_name\",\"$setting_value\")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function group_table($groupid,$role=false,$mode="view",$selection="none",$expanded=false) {
|
||||||
|
// display a table for a single group
|
||||||
|
global $drs_db;
|
||||||
|
// print group id and name
|
||||||
|
if ($selection == "all") {
|
||||||
|
$sel_flag="checked";
|
||||||
|
} elseif ($selection == "none") {
|
||||||
|
$sel_flag="";
|
||||||
|
}
|
||||||
|
if ($expanded) {
|
||||||
|
echo "
|
||||||
|
<a href=\"groups.php\" style=\"text-decoration:none\">
|
||||||
|
<img src=\"icons/minus-white.png\" alt=\"Unexpand group\">
|
||||||
|
</a>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
$groupname=dblookup($drs_db,"groups","id","name",$groupid);
|
||||||
|
if ($groupname == "") {
|
||||||
|
echo "<b>Group ID: $groupid";
|
||||||
|
} else {
|
||||||
|
echo "<b>Group Name: $groupname";
|
||||||
|
}
|
||||||
|
echo "</b><br>";
|
||||||
|
// print table headers
|
||||||
|
if ($role && $mode=="select") {
|
||||||
|
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%;\">Period</th>
|
||||||
|
<th style=\"width:1%;\">Device</th>
|
||||||
|
<th style=\"width:1%;\">Subsystem</th>
|
||||||
|
<th style=\"width:1%;\">Reported by</th>
|
||||||
|
<th>Discrepancy</th>
|
||||||
|
<th style=\"width:1%;\">Msn Eff</th>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<table border=\"1\" cellpadding=\"5\" style=\"width:100%;\">
|
||||||
|
<tr>
|
||||||
|
<th style=\"width:1%;\">ID</th>
|
||||||
|
<th style=\"width:1%;\">Status</th>
|
||||||
|
<th style=\"width:100px;\">Date</th>
|
||||||
|
<th style=\"width:1%;\">Period</th>
|
||||||
|
<th style=\"width:1%;\">Device</th>
|
||||||
|
<th style=\"width:1%;\">Subsystem</th>
|
||||||
|
<th style=\"width:1%;\">Reported by</th>
|
||||||
|
<th>Discrepancy</th>
|
||||||
|
<th style=\"width:1%;\">Msn Eff</th>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
$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]}"));
|
||||||
|
|
||||||
|
// convert device number to name
|
||||||
|
$tname=dblookup($drs_db,"devices","id","name",$writeupdata["device"]);
|
||||||
|
// convert subsystem number to name
|
||||||
|
$ssname=dblookup($drs_db,"subsystems","id","name",$writeupdata["subsystem"]);
|
||||||
|
// determine status indicator
|
||||||
|
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
|
||||||
|
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
|
||||||
|
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
|
||||||
|
// determine times for period
|
||||||
|
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$writeupdata['period']}\""))[0];
|
||||||
|
// determine effective icon
|
||||||
|
if($writeupdata["period_effective"]==1) {
|
||||||
|
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
|
||||||
|
} else {
|
||||||
|
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
|
||||||
|
}
|
||||||
|
// print table row
|
||||||
|
if ($role && $mode=="select") {
|
||||||
|
printf(
|
||||||
|
"<tr>
|
||||||
|
<td align=\"center\" valign=\"top\"><input type=\"checkbox\" name=\"targets[]\" value=\"%s\" $sel_flag></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",
|
||||||
|
$writeupdata["id"],
|
||||||
|
$writeupdata["id"],$writeupdata["id"],
|
||||||
|
$statusind,
|
||||||
|
$writeupdata["report_date"],
|
||||||
|
$ptimes, $writeupdata["period"],
|
||||||
|
$tname,
|
||||||
|
$ssname,
|
||||||
|
$writeupdata["reported_by"],
|
||||||
|
$writeupdata["discrepancy_text"],
|
||||||
|
$eff_icon
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
printf(
|
||||||
|
"<tr>
|
||||||
|
<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",
|
||||||
|
$writeupdata["id"],$writeupdata["id"],
|
||||||
|
$statusind,
|
||||||
|
$writeupdata["report_date"],
|
||||||
|
$ptimes, $writeupdata["period"],
|
||||||
|
$tname,
|
||||||
|
$ssname,
|
||||||
|
$writeupdata["reported_by"],
|
||||||
|
$writeupdata["discrepancy_text"],
|
||||||
|
$eff_icon
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</table><br>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
480
distfiles/config.php
Normal file
@@ -0,0 +1,480 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
config.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to index.php on cancel button press
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||||
|
$role=dblookup($drs_db,"users","id","role",$userid);
|
||||||
|
// redirect to index.php if not an admin
|
||||||
|
|
||||||
|
if ($role != ADMIN) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming[]
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST[] to $incoming[]
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
$update_display=$incoming['update_display'];
|
||||||
|
$display_appname=$incoming['display_appname'];
|
||||||
|
$display_banner=$incoming['display_banner'];
|
||||||
|
$display_footer=$incoming['display_footer'];
|
||||||
|
$display_pereffhlp=$incoming['display_pereffhlp'];
|
||||||
|
|
||||||
|
$update_colors=$incoming['update_colors'];
|
||||||
|
$reset_colors=$incoming['reset_colors'];
|
||||||
|
$newbgc=$incoming['newbgc'];
|
||||||
|
$newmbgc=$incoming['newmbgc'];
|
||||||
|
$newtc=$incoming['newtc'];
|
||||||
|
$newlc=$incoming['newlc'];
|
||||||
|
$newvlc=$incoming['newvlc'];
|
||||||
|
$newhc=$incoming['newhc'];
|
||||||
|
|
||||||
|
$edit_banner=$incoming['edit_banner'];
|
||||||
|
$add_banner=$incoming['add_banner'];
|
||||||
|
$update_banner=$incoming['update_banner'];
|
||||||
|
$delete_banner=$incoming['delete_banner'];
|
||||||
|
$bnrid=$incoming['bnrid'];
|
||||||
|
$bnrname=$incoming['bnrname'];
|
||||||
|
$bnrcolor=$incoming['bnrcolor'];
|
||||||
|
$bnrtxtcolor=$incoming['bnrtxtcolor'];
|
||||||
|
|
||||||
|
$update_misc=$incoming['update_misc'];
|
||||||
|
$sessttl=$incoming['sessttl'];
|
||||||
|
$sessdir=$incoming['sessdir'];
|
||||||
|
$logoutall=$incoming['logoutall'];
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
framework("begin","$appname","Configuration",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//var_dump($incoming);
|
||||||
|
|
||||||
|
// ******** begin database manipulation ********
|
||||||
|
if ($update_display) {
|
||||||
|
// remove html tags from footer_message and sanitize
|
||||||
|
$display_footer=strip_tags($display_footer);
|
||||||
|
$clean_display_footer=mysqli_real_escape_string($drs_db,$display_footer);
|
||||||
|
// remove html tags from app name and sanitize
|
||||||
|
$display_appname=strip_tags($display_appname);
|
||||||
|
$clean_display_appname=mysqli_real_escape_string($drs_db,$display_appname);
|
||||||
|
// remove html tags from period effective help text and sanitize
|
||||||
|
$display_pereffhlp=strip_tags($display_pereffhlp);
|
||||||
|
$clean_display_pereffhlp=mysqli_real_escape_string($drs_db,$display_pereffhlp);
|
||||||
|
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$clean_display_appname\" where name=\"app_name\"");
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$display_banner\" where name=\"banner\"");
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$clean_display_footer\" where name=\"footer_message\"");
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$clean_display_pereffhlp\" where name=\"period_eff_help_txt\"");
|
||||||
|
echo "<meta http-equiv='refresh' content='0'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($update_colors) {
|
||||||
|
if ($newbgc) mysqli_query($drs_db,"update config set value=\"$newbgc\" where name=\"background_color\"");
|
||||||
|
if ($newmbgc) mysqli_query($drs_db,"update config set value=\"$newmbgc\" where name=\"menubg_color\"");
|
||||||
|
if ($newtc) mysqli_query($drs_db,"update config set value=\"$newtc\" where name=\"text_color\"");
|
||||||
|
if ($newlc) mysqli_query($drs_db,"update config set value=\"$newlc\" where name=\"link_color\"");
|
||||||
|
if ($newvlc) mysqli_query($drs_db,"update config set value=\"$newvlc\" where name=\"vlink_color\"");
|
||||||
|
if ($newhc) mysqli_query($drs_db,"update config set value=\"$newhc\" where name=\"heading_color\"");
|
||||||
|
echo "<meta http-equiv='refresh' content='0'>";
|
||||||
|
}
|
||||||
|
if ($reset_colors) {
|
||||||
|
mysqli_query($drs_db,"update config set value=defaultvalue where name like \"%_color\"");
|
||||||
|
echo "<meta http-equiv='refresh' content='0'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add_banner) {
|
||||||
|
// do error checking
|
||||||
|
// remove html tags from banner name
|
||||||
|
$bnrname=strip_tags($bnrname);
|
||||||
|
// test for name supplied
|
||||||
|
if (strlen(trim($bnrname))) {
|
||||||
|
$namesuppld=true;
|
||||||
|
} else {
|
||||||
|
$namesuppld=false;
|
||||||
|
$namesuppld_err=true;
|
||||||
|
}
|
||||||
|
// test for name unique
|
||||||
|
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\""))) {
|
||||||
|
$nameunique=false;
|
||||||
|
$nameunique_err=true;
|
||||||
|
} else {
|
||||||
|
$nameunique=true;
|
||||||
|
}
|
||||||
|
if ($namesuppld && $nameunique) {
|
||||||
|
// sanitize banner name
|
||||||
|
$clean_bnrname=mysqli_real_escape_string($drs_db,$bnrname);
|
||||||
|
// modify the table
|
||||||
|
mysqli_query($drs_db,"insert into banners(bannername,bannercolor,textcolor) values(\"$clean_bnrname\",\"$bnrcolor\",\"$bnrtxtcolor\")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($edit_banner) {
|
||||||
|
if ($delete_banner) {
|
||||||
|
mysqli_query($drs_db,"delete from banners where bannerid=\"$bnrid\"");
|
||||||
|
unset($edit_banner);
|
||||||
|
}
|
||||||
|
if ($update_banner) {
|
||||||
|
// do error checking
|
||||||
|
// remove html tags from banner name
|
||||||
|
$bnrname=strip_tags($bnrname);
|
||||||
|
// test for name supplied
|
||||||
|
if (strlen(trim($bnrname))) {
|
||||||
|
$namesuppld=true;
|
||||||
|
} else {
|
||||||
|
$namesuppld=false;
|
||||||
|
$namesuppld_err=true;
|
||||||
|
}
|
||||||
|
// test for name unique
|
||||||
|
if (mysqli_num_rows(mysqli_query($db,"select bannerid from banners where bannername=\"$bnrname\" and bannerid!=\"$bnrid\""))) {
|
||||||
|
if (mysqli_num_rows(mysqli_query($drs_db,"select bannerid from banners where bannername=\"$bnrname\""))) {
|
||||||
|
$nameunique=false;
|
||||||
|
$nameunique_err=true;
|
||||||
|
} else {
|
||||||
|
$nameunique=true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$nameunique=true;
|
||||||
|
}
|
||||||
|
if ($namesuppld && $nameunique) {
|
||||||
|
// sanitize banner name
|
||||||
|
$clean_bnrname=mysqli_real_escape_string($drs_db,$bnrname);
|
||||||
|
// modify the table
|
||||||
|
mysqli_query($drs_db,"update banners set bannername=\"$bnrname\",bannercolor=\"$bnrcolor\",textcolor=\"$bnrtxtcolor\" where bannerid=\"$bnrid\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($update_misc) {
|
||||||
|
if ($logoutall) {
|
||||||
|
if ($ostype == 'WIN') {
|
||||||
|
$sessfileloc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
|
||||||
|
} else {
|
||||||
|
$sessfileloc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
|
||||||
|
}
|
||||||
|
foreach (glob($sessfileloc."/*") as $sessfile) {
|
||||||
|
unlink($sessfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// test for sessttl supplied
|
||||||
|
if (strlen(trim($sessttl))) {
|
||||||
|
$ttlsuppld=true;
|
||||||
|
} else {
|
||||||
|
$ttlsuppld=false;
|
||||||
|
$ttlsuppld_err=true;
|
||||||
|
}
|
||||||
|
// test for sessdir supplied
|
||||||
|
if (strlen(trim($sessdir))) {
|
||||||
|
$dirsuppld=true;
|
||||||
|
} else {
|
||||||
|
$dirsuppld=false;
|
||||||
|
$dirsuppld_err=true;
|
||||||
|
}
|
||||||
|
if ($ttlsuppld && $dirsuppld) {
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$sessttl\" where name=\"session_ttl_days\"");
|
||||||
|
if ($ostype == 'WIN') {
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"win_server_session_dir\"");
|
||||||
|
} else {
|
||||||
|
mysqli_query($drs_db,"update config set value=\"$sessdir\" where name=\"unix_server_session_dir\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
echo "
|
||||||
|
<div id=\"configtabs\">
|
||||||
|
<ul>
|
||||||
|
<li><a href=\"#display_options\">Display Options</a></li>
|
||||||
|
<li><a href=\"#page_colors\">Page Colors</a></li>
|
||||||
|
<li><a href=\"#banners\">Banners</a></li>
|
||||||
|
<li><a href=\"#miscellaneous\">Miscellaneous Options</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div id=\"display_options\">
|
||||||
|
<form method=\"post\" action=\"config.php\">
|
||||||
|
";
|
||||||
|
$curapn=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"app_name\""))[0];
|
||||||
|
$curbnr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"banner\""))[0];
|
||||||
|
$curftr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"footer_message\""))[0];
|
||||||
|
$curpereffhlp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"period_eff_help_txt\""))[0];
|
||||||
|
echo "
|
||||||
|
<font size=\"+1\"><b>Display Configuration Parameters</b></font><br><br><br><br>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
Application Name (will appear at the top of every page):<br>
|
||||||
|
<input type=\"text\" name=\"display_appname\" size=\"80\" value=\"$curapn\">
|
||||||
|
<br><br><br>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
Banner (will appear at the top and bottom of pages): <select name=\"display_banner\" id=\"sel-banner\">
|
||||||
|
";
|
||||||
|
$bannerqry=mysqli_query($drs_db,"select * from banners");
|
||||||
|
while ($bannerrow=mysqli_fetch_assoc($bannerqry)) {
|
||||||
|
if ($bannerrow["bannerid"]==$curbnr) {
|
||||||
|
printf("<option value=\"%s\" selected>%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\">%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select><br><br><br>
|
||||||
|
Footer Message (will appear at the bottom of pages):<br>
|
||||||
|
<input type=\"text\" name=\"display_footer\" size=\"80\" value=\"$curftr\"><br><br><br>
|
||||||
|
Period Effective Help Text :<br>
|
||||||
|
<textarea rows=\"4\" cols=\"80\" name=\"display_pereffhlp\" wrap=\"soft\">$curpereffhlp</textarea><br><br><br><br>
|
||||||
|
<input type=\"submit\" name=\"update_display\" value=\"Update Options\">
|
||||||
|
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br><br><br>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
|
||||||
|
echo "
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"page_colors\">
|
||||||
|
";
|
||||||
|
$curbgc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"background_color\""))[0];
|
||||||
|
$curmbgc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"menubg_color\""))[0];
|
||||||
|
$curtc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"text_color\""))[0];
|
||||||
|
$curlc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"link_color\""))[0];
|
||||||
|
$curvlc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"vlink_color\""))[0];
|
||||||
|
$curhc=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"heading_color\""))[0];
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<font size=\"+1\"><b>Color Configuration Parameters</b></font><br><br>
|
||||||
|
<table border=\"0\"><tr>
|
||||||
|
<td>
|
||||||
|
<form method=\"post\" action=\"config.php#page_colors\">
|
||||||
|
<b>Select the color you'd like to change then use the color picker to select a new color</b><br><br>
|
||||||
|
<table border=\"0\" cellpadding=\"10\">
|
||||||
|
<tr><td>Page background color</td><td>#<input type=\"text\" name=\"newbgc\" value=\"$curbgc\" id=\"bgcfield\" onFocus=\"ddcolorposter.echocolor(this, 'bgcbox')\"> <span id=\"bgcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
<tr><td>Menu background color</td><td>#<input type=\"text\" name=\"newmbgc\" value=\"$curmbgc\" id=\"mbgcfield\" onFocus=\"ddcolorposter.echocolor(this, 'mbgcbox')\"> <span id=\"mbgcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
<tr><td>Normal text color</td><td>#<input type=\"text\" name=\"newtc\" value=\"$curtc\" id=\"tcfield\" onFocus=\"ddcolorposter.echocolor(this, 'tcbox')\"> <span id=\"tcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
<tr><td>Link color</td><td>#<input type=\"text\" name=\"newlc\" value=\"$curlc\" id=\"lcfield\" onFocus=\"ddcolorposter.echocolor(this, 'lcbox')\"> <span id=\"lcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
<tr><td>Visited link color</td><td>#<input type=\"text\" name=\"newvlc\" value=\"$curvlc\" id=\"vlcfield\" onFocus=\"ddcolorposter.echocolor(this, 'vlcbox')\"> <span id=\"vlcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
<tr><td>Heading color</td><td>#<input type=\"text\" name=\"newhc\" value=\"$curhc\" id=\"hcfield\" onFocus=\"ddcolorposter.echocolor(this, 'hcbox')\"> <span id=\"hcbox\" class=\"colorbox\">____</span></td></tr>
|
||||||
|
</table>
|
||||||
|
<br><br>
|
||||||
|
<input type=\"submit\" name=\"update_colors\" value=\"Update Colors\">
|
||||||
|
<input type=\"submit\" name=\"reset_colors\" value=\"Reset Colors to Defaults\">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div id=\"pickerPanel\" class=\"dragPanel\">
|
||||||
|
<h4 id=\"pickerHandle\"> </h4>
|
||||||
|
<div id=\"pickerDiv\">
|
||||||
|
<img id=\"pickerbg\" src=\"colorpicker/img/pickerbg.png\" alt=\"\">
|
||||||
|
<div id=\"selector\"><img src=\"colorpicker/img/select.gif\"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"hueBg\">
|
||||||
|
<div id=\"hueThumb\"><img src=\"colorpicker/img/hline.png\"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"pickervaldiv\">
|
||||||
|
<form name=\"pickerform\" onsubmit=\"return pickerUpdate()\">
|
||||||
|
<font size=\"-3\">
|
||||||
|
<br />
|
||||||
|
R <input name=\"pickerrval\" id=\"pickerrval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
H <input name=\"pickerhval\" id=\"pickerhval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
<br />
|
||||||
|
G <input name=\"pickergval\" id=\"pickergval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
S <input name=\"pickergsal\" id=\"pickersval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
<br />
|
||||||
|
B <input name=\"pickerbval\" id=\"pickerbval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
V <input name=\"pickervval\" id=\"pickervval\" type=\"text\" value=\"0\" size=\"3\" maxlength=\"3\" />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
# <input name=\"pickerhexval\" id=\"pickerhexval\" type=\"text\" value=\"0\" size=\"6\" maxlength=\"6\" />
|
||||||
|
<br />
|
||||||
|
</font>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"pickerSwatch\"> </div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr></table>
|
||||||
|
";
|
||||||
|
|
||||||
|
echo "
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"banners\">
|
||||||
|
";
|
||||||
|
if ($nameunique_err) format_message(1,"Banner name already exists. Please try another.");
|
||||||
|
if ($namesuppld_err) format_message(1,"Banner name cannot be blank.");
|
||||||
|
if ($edit_banner) {
|
||||||
|
// set form options for editing
|
||||||
|
$sectiontitle="<font size=\"+1\"><b>Modify Banner</b></font><br><br>";
|
||||||
|
$formtag="<form method=\"post\" action=\"config.php?edit_banner=1#banners\">";
|
||||||
|
$buttontags="
|
||||||
|
<input type=\"hidden\" name=\"bnrid\" value=\"$bnrid\">
|
||||||
|
<input type=\"submit\" name=\"update_banner\" value=\"Update Banner\">
|
||||||
|
<input type=\"submit\" name=\"delete_banner\" value=\"Delete Banner\">
|
||||||
|
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
|
||||||
|
";
|
||||||
|
// pull current values from database
|
||||||
|
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from banners where bannerid=$bnrid"));
|
||||||
|
$bnrname=$currentvalues["bannername"];
|
||||||
|
$bnrcolor=$currentvalues["bannercolor"];
|
||||||
|
$bnrtextcolor=$currentvalues["textcolor"];
|
||||||
|
$bnrcoloropts="";
|
||||||
|
foreach($basic_colors as $cname => $chex) {
|
||||||
|
if ($chex==$bnrcolor) {
|
||||||
|
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
||||||
|
} else {
|
||||||
|
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\">$cname</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$bnrtextcoloropts="";
|
||||||
|
foreach($basic_colors as $cname => $chex) {
|
||||||
|
if ($chex==$bnrtextcolor) {
|
||||||
|
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
||||||
|
} else {
|
||||||
|
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\">$cname</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// set form options for add
|
||||||
|
$sectiontitle="<font size=\"+1\"><b>Add New Banner</b></font><br><br>";
|
||||||
|
$formtag="<form method=\"post\" action=\"config.php#banners\">";
|
||||||
|
$bnrname="";
|
||||||
|
$buttontags="
|
||||||
|
<input type=\"submit\" name=\"add_banner\" value=\"Add Banner\">
|
||||||
|
";
|
||||||
|
// set default values
|
||||||
|
$bnrcolor="#000000";
|
||||||
|
$bnrtextcolor="#FFFFFF";
|
||||||
|
$bnrcoloropts="";
|
||||||
|
foreach($basic_colors as $cname => $chex) {
|
||||||
|
if ($chex==$bnrcolor) {
|
||||||
|
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
||||||
|
} else {
|
||||||
|
$bnrcoloropts=$bnrcoloropts . "<option value=\"$chex\">$cname</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$bnrtextcoloropts="";
|
||||||
|
foreach($basic_colors as $cname => $chex) {
|
||||||
|
if ($chex==$bnrtextcolor) {
|
||||||
|
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
||||||
|
} else {
|
||||||
|
$bnrtextcoloropts=$bnrtextcoloropts . "<option value=\"$chex\">$cname</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
$sectiontitle
|
||||||
|
$formtag
|
||||||
|
<table border=\"0\">
|
||||||
|
<tr><td>
|
||||||
|
Banner Name (text displayed in the banner): <input type=\"text\" name=\"bnrname\" size=\"40\" value=\"$bnrname\"><br><br>
|
||||||
|
Banner Color (background color of the banner):
|
||||||
|
<select name=\"bnrcolor\">
|
||||||
|
$bnrcoloropts
|
||||||
|
</select><br><br>
|
||||||
|
Banner Text Color (text color of the banner, different than banner color):
|
||||||
|
<select name=\"bnrtxtcolor\">
|
||||||
|
$bnrtextcoloropts
|
||||||
|
</select><br><br>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
$buttontags
|
||||||
|
</form>
|
||||||
|
<br><hr>
|
||||||
|
";
|
||||||
|
// show the table of entities
|
||||||
|
$existingdata=mysqli_query($drs_db,"select * from banners where bannerid!=1 order by bannerid asc");
|
||||||
|
echo "
|
||||||
|
<b>Existing Banners</b> <font size=\"-1\">Click on the Banner ID to edit.</font><br><br>
|
||||||
|
<table border=\"1\">
|
||||||
|
<tr><th>Banner ID</th><th>Banner</th></tr>
|
||||||
|
";
|
||||||
|
while ($tablerow=mysqli_fetch_assoc($existingdata)) {
|
||||||
|
printf("
|
||||||
|
<tr>
|
||||||
|
<td><a href=\"config.php?edit_banner=1&bnrid=%s#banners\">%s</a></td>
|
||||||
|
<td align=\"center\" bgcolor=\"%s\"><font color=\"%s\">%s</font></td>
|
||||||
|
</tr>",
|
||||||
|
$tablerow["bannerid"],$tablerow["bannerid"],
|
||||||
|
$tablerow["bannercolor"],$tablerow["textcolor"],$tablerow["bannername"]);
|
||||||
|
}
|
||||||
|
echo "</table>";
|
||||||
|
|
||||||
|
echo "
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id=\"miscellaneous\">
|
||||||
|
<form method=\"post\" action=\"config.php#miscellaneous\">
|
||||||
|
";
|
||||||
|
if ($ttlsuppld_err) format_message(1,"Session expiration time cannot be blank.");
|
||||||
|
if ($dirsuppld_err) format_message(1,"Server session file directory cannot be blank.");
|
||||||
|
$curttl=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"session_ttl_days\""))[0];
|
||||||
|
if ($ostype == 'WIN') {
|
||||||
|
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"win_server_session_dir\""))[0];
|
||||||
|
} else {
|
||||||
|
$curssdir=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"unix_server_session_dir\""))[0];
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
<font size=\"+1\"><b>Miscellaneous Configuration Parameters</b></font><br><br><br><br>
|
||||||
|
Session expiration time (users will have to log in again after this long) : <input type=\"text\" name=\"sessttl\" size=\"3\" value=\"$curttl\"> days<br><br>
|
||||||
|
Server session file directory (must be writable by the web server process) : <br><input type=\"text\" name=\"sessdir\" size=\"40\" value=\"$curssdir\"><br><br>
|
||||||
|
Force logout of all users <input type=\"checkbox\" name=\"logoutall\"><br><br><br><br>
|
||||||
|
<input type=\"submit\" name=\"update_misc\" value=\"Update Options\">
|
||||||
|
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
238
distfiles/create.php
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
create.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to writeups.php on change cancel
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:writeups.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['personid'])) $personid=$_SESSION['personid'];
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming[]
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST[] to $incoming[]
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
$create=$incoming['create'];
|
||||||
|
$device=$incoming['device'];
|
||||||
|
$period=$incoming['period'];
|
||||||
|
$period_effective=$incoming['period_effective'];
|
||||||
|
$reported_by=$incoming['reported_by'];
|
||||||
|
$report_date=$incoming['report_date'];
|
||||||
|
$report_time=$incoming['report_time'];
|
||||||
|
$subsystem=$incoming['subsystem'];
|
||||||
|
$discrepancy_text=$incoming['discrepancy_text'];
|
||||||
|
$status=$incoming['status'];
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role=dblookup($drs_db,"persons","id","role",$personid);
|
||||||
|
|
||||||
|
framework("begin","$appname","New Writeup",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//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");
|
||||||
|
if (!$report_date || $report_date=="automatic") $report_date=$today;
|
||||||
|
if (!$report_time || $report_time=="automatic") $report_time=$now;
|
||||||
|
|
||||||
|
if ($create) {
|
||||||
|
// add the entry if create is pressed
|
||||||
|
if ($discrepancy_text && $reported_by && $device && $subsystem && $period) {
|
||||||
|
// sanitize and fix blank date and time
|
||||||
|
$report_date=mysqli_real_escape_string($drs_db,$report_date);
|
||||||
|
$report_time=mysqli_real_escape_string($drs_db,$report_time);
|
||||||
|
if (!$report_date) $report_date=$today;
|
||||||
|
if (!$report_time) $report_time=$now;
|
||||||
|
|
||||||
|
// remove html tags from discrepancy text and sanitize
|
||||||
|
$discrepancy_text=strip_tags($discrepancy_text);
|
||||||
|
$clean_discrepancy_text=mysqli_real_escape_string($drs_db,$discrepancy_text);
|
||||||
|
$clean_reported_by=mysqli_real_escape_string($drs_db,$reported_by);
|
||||||
|
|
||||||
|
// add the record to writeups
|
||||||
|
mysqli_query($drs_db,"insert into writeups(device,period,period_effective,reported_by,report_date,report_time,subsystem,discrepancy_text,status)
|
||||||
|
values (\"$device\",\"$period\",\"$period_effective\",\"$clean_reported_by\",\"$report_date\",\"$report_time\",\"$subsystem\",\"$clean_discrepancy_text\",\"$status\")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
// display the form
|
||||||
|
if ($create) {
|
||||||
|
if ($discrepancy_text && $reported_by) {
|
||||||
|
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) {
|
||||||
|
format_message(1,"You didn't select a device. Please try again.");
|
||||||
|
$preserve=TRUE;
|
||||||
|
}
|
||||||
|
if (!$subsystem) {
|
||||||
|
format_message(1,"You didn't select a subsystem. Please try again.");
|
||||||
|
$preserve=TRUE;
|
||||||
|
}
|
||||||
|
if (!$period) {
|
||||||
|
format_message(1,"You didn't select a period. Please try again.");
|
||||||
|
$preserve=TRUE;
|
||||||
|
}
|
||||||
|
if (!$discrepancy_text) {
|
||||||
|
format_message(1,"You didn't enter any discrepancy text. Please try again.");
|
||||||
|
$preserve=TRUE;
|
||||||
|
}
|
||||||
|
if (!$reported_by) {
|
||||||
|
format_message(1,"You didn't enter your name in the Reported by: block. Please try again.");
|
||||||
|
$preserve=TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$preserve=FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<form method=\"post\" action=\"create.php\">
|
||||||
|
";
|
||||||
|
|
||||||
|
// start writeup entry section
|
||||||
|
if ($status==1) $statusind="<b><font color=\"#FF0000\">OPEN</font></b>";
|
||||||
|
if ($status==2) $statusind="<b><font color=\"#008000\">CLSD</font></b>";
|
||||||
|
if ($status==3) $statusind="<b><font color=\"#FFFF00\">DFRD</font></b>";
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<table border=\"0\" cellpadding=\"5\">
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\">Device<br>
|
||||||
|
<select name=\"device\" id=\"device\">
|
||||||
|
<option value=\"\">Please select...</option>
|
||||||
|
";
|
||||||
|
$trow=mysqli_query($drs_db,"select * from devices where active is true order by id asc");
|
||||||
|
while ($titem=mysqli_fetch_assoc($trow)) {
|
||||||
|
if ($device==$titem["id"] && $preserve) {
|
||||||
|
printf("<option value=\"%s\" selected>%s</option>",$titem["id"],$titem["name"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\">%s</option>",$titem["id"],$titem["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select></td>
|
||||||
|
<td align=\"left\">Subsystem<br>
|
||||||
|
<select name=\"subsystem\" id=\"subsystem\">
|
||||||
|
<option value=\"\">Please select...</option>
|
||||||
|
";
|
||||||
|
$ssrow=mysqli_query($drs_db,"select * from subsystems where active is true order by id asc");
|
||||||
|
while ($ssitem=mysqli_fetch_assoc($ssrow)) {
|
||||||
|
if ($subsystem==$ssitem["id"] && $preserve) {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\">%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select></td><td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\">Period<br>
|
||||||
|
<select name=\"period\" id=\"period\">
|
||||||
|
<option value=\"\">Please select...</option>
|
||||||
|
";
|
||||||
|
$prow=mysqli_query($drs_db,"select * from periods where active is true order by times asc");
|
||||||
|
while ($pitem=mysqli_fetch_assoc($prow)) {
|
||||||
|
if ($period==$pitem["id"] && $preserve) {
|
||||||
|
printf("<option value=\"%s\" title=\"Period %s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$preserve) {
|
||||||
|
$report_date="automatic";
|
||||||
|
$report_time="automatic";
|
||||||
|
$discrepancy_text="";
|
||||||
|
$reported_by="";
|
||||||
|
}
|
||||||
|
|
||||||
|
$effstate=$nefstate="";
|
||||||
|
if ($preserve) {
|
||||||
|
if($period_effective==1) $effstate="checked";
|
||||||
|
if($period_effective==0) $nefstate="checked";
|
||||||
|
} else {
|
||||||
|
$effstate="checked";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "
|
||||||
|
</select></td>
|
||||||
|
<td align=\"left\" >Report Date<br>
|
||||||
|
<input type=\"text\" name=\"report_date\" size=\"10\" maxlength=\"10\" value=\"$report_date\" id=\"singledatepicker\" title=\"Format: YYYY-MM-DD\"></td>
|
||||||
|
<td align=\"left\">Report Time<br>
|
||||||
|
<input type=\"text\" name=\"report_time\" size=\"8\" maxlength=\"8\" value=\"$report_time\" title=\"Format: HH:MM:SS\"></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td></td><td></td><td></td></tr>
|
||||||
|
<tr><td colspan=\"3\">
|
||||||
|
Discrepancy <font size=\"-2\">(required)</font><br>
|
||||||
|
<textarea rows=\"10\" cols=\"80\" name=\"discrepancy_text\" wrap=\"soft\">$discrepancy_text</textarea><br>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Reported by <font size=\"-2\">(required)</font><br>
|
||||||
|
<input type=\"text\" name=\"reported_by\" size=\"30\" value=\"$reported_by\" title=\"Who to contact with questions about this writeup\"></td>
|
||||||
|
<td>Period effective? <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
|
||||||
|
<input type=\"radio\" name=\"period_effective\" value=\"1\" $effstate> Yes
|
||||||
|
<input type=\"radio\" name=\"period_effective\" value=\"0\" $nefstate> No
|
||||||
|
</td>
|
||||||
|
<td align=\"right\" valign=\"bottom\"><input type=\"submit\" name=\"create\" value=\"Submit Writeup\" id=\"createbutton\"></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td></td><td></td><td></td></tr>
|
||||||
|
<td></td><td></td><td align=\"right\" valign=\"bottom\">
|
||||||
|
<input type=\"submit\" name=\"cancel\" value=\"Cancel\" id=\"usercancelbutton\"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<input type=\"hidden\" name=\"status\" value=\"1\">
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
";
|
||||||
|
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
1096
distfiles/dbadmin.php
Normal file
431
distfiles/gpl.php
Normal file
@@ -0,0 +1,431 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
gpl.php
|
||||||
|
OpenMTS Online Maintenance Tracking System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to index.php on cancel button press
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST to $incoming
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
|
||||||
|
|
||||||
|
// define local functions
|
||||||
|
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$sbcolor=P_SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$sbcolor=SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role=dblookup($mts_db,"users","id","role",$userid);
|
||||||
|
|
||||||
|
framework("begin","$appname","GNU General Public License",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//var_dump($incoming);
|
||||||
|
|
||||||
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<center>
|
||||||
|
<pre>
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Library General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The \"Program\", below,
|
||||||
|
refers to any such program or work, and a \"work based on the Program\"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term \"modification\".) Each licensee is addressed as \"you\".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and \"any
|
||||||
|
later version\", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the \"copyright\" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a \"copyright disclaimer\" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Library General
|
||||||
|
Public License instead of this License.
|
||||||
|
|
||||||
|
|
||||||
|
</pre>
|
||||||
|
</center>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
896
distfiles/groups.php
Normal file
@@ -0,0 +1,896 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
groups.php
|
||||||
|
OpenDRS Online Discrepancy Reporting System
|
||||||
|
Copyright (C) 2018 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
include("common.php");
|
||||||
|
|
||||||
|
// redirect to groups.php on cancel button press
|
||||||
|
if ($_REQUEST['cancel']) {
|
||||||
|
header("Cache-Control:no-cache, must-revalidate");
|
||||||
|
header("Pragma:no-cache");
|
||||||
|
header("Location:groups.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// import session variables
|
||||||
|
if (isset($_SESSION['userid'])) $userid=$_SESSION['userid'];
|
||||||
|
|
||||||
|
// import incoming arrays
|
||||||
|
$print=$_REQUEST['print'];
|
||||||
|
if ($print) {
|
||||||
|
// if printer friendly was clicked, values will be passed in serialized
|
||||||
|
// form as "all_parameters" so we need to load those into $incoming
|
||||||
|
$incoming=unserialize($_REQUEST['all_parameters']);
|
||||||
|
} else {
|
||||||
|
// copy $_REQUEST to $incoming
|
||||||
|
$incoming=arrayCopy($_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load variables from incoming array
|
||||||
|
|
||||||
|
$action=$incoming['action'];
|
||||||
|
$save=$incoming['save'];
|
||||||
|
$targets=$incoming['targets'];
|
||||||
|
$group=$incoming['group'];
|
||||||
|
$name=$incoming['name'];
|
||||||
|
$expandgrp=$incoming['expandgrp'];
|
||||||
|
|
||||||
|
$search=$incoming['search'];
|
||||||
|
$s_status=$incoming['s_status'];
|
||||||
|
$s_device=$incoming['s_device'];
|
||||||
|
$s_subsystem=$incoming['s_subsystem'];
|
||||||
|
$s_period=$incoming['s_period'];
|
||||||
|
$s_report_date_start=$incoming['s_report_date_start'];
|
||||||
|
$s_report_date_end=$incoming['s_report_date_end'];
|
||||||
|
$s_report_time_start=$incoming['s_report_time_start'];
|
||||||
|
$s_report_time_end=$incoming['s_report_time_end'];
|
||||||
|
$s_discrepancy_text=$incoming['s_discrepancy_text'];
|
||||||
|
$s_reported_by=$incoming['s_reported_by'];
|
||||||
|
$s_period_effective=$incoming['s_period_effective'];
|
||||||
|
|
||||||
|
$edit_status=$incoming['edit_status'];
|
||||||
|
$edit_action_by=$incoming['edit_action_by'];
|
||||||
|
$edit_action_reason=$incoming['edit_action_reason'];
|
||||||
|
$edit_action_date=$incoming['edit_action_date'];
|
||||||
|
$edit_action_time=$incoming['edit_action_time'];
|
||||||
|
$edit_action_text=$incoming['edit_action_text'];
|
||||||
|
|
||||||
|
// define local functions
|
||||||
|
|
||||||
|
|
||||||
|
// assign variables from constants
|
||||||
|
$appname=APP_NAME;
|
||||||
|
|
||||||
|
if ($print=="Printer Friendly") {
|
||||||
|
$sbcolor=P_SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=P_MENUBG_COLOR;
|
||||||
|
} else {
|
||||||
|
$sbcolor=SIDEBAR_COLOR;
|
||||||
|
$mbgcolor=MENUBG_COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role=dblookup($drs_db,"users","id","role",$userid);
|
||||||
|
|
||||||
|
framework("begin","$appname","Writeup Groups",$print);
|
||||||
|
|
||||||
|
//var_dump($_REQUEST);
|
||||||
|
//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];
|
||||||
|
if (!$s_report_date_start || !validateDate($s_report_date_start)) $s_report_date_start=mysqli_fetch_row(mysqli_query($drs_db,"select date_sub(curdate(),interval 30 day)"))[0];
|
||||||
|
if (!$s_report_date_end || !validateDate($s_report_date_end)) $s_report_date_end=$maxrepdate;
|
||||||
|
if (!$s_report_time_start || !validateTime($s_report_time_start)) $s_report_time_start="00:00:00";
|
||||||
|
if (!$s_report_time_end || !validateTime($s_report_time_end)) $s_report_time_end="23:59:59";
|
||||||
|
if (!$edit_action_date || !validateDate($edit_action_date)) $edit_action_date=$today;
|
||||||
|
if (!$edit_action_time || !validateTime($edit_action_time)) $edit_action_time=$now;
|
||||||
|
|
||||||
|
|
||||||
|
if ($action=="add" && $role && $save) {
|
||||||
|
$fail=false;
|
||||||
|
if (!$group) {
|
||||||
|
// group was not supplied, so create a new one
|
||||||
|
mysqli_query($drs_db,"insert into groups(name) value(\"\")");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
$group=mysqli_insert_id($drs_db);
|
||||||
|
}
|
||||||
|
foreach ($targets as $target) {
|
||||||
|
// 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)");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($action=="remove" && $role && $save) {
|
||||||
|
$fail=false;
|
||||||
|
$writeups=array();
|
||||||
|
$writeups_qry=mysqli_query($drs_db,"select writeupid from links where linkgroup=\"$group\"");
|
||||||
|
while ($writeuprow=mysqli_fetch_row($writeups_qry)) {
|
||||||
|
$writeups[]=$writeuprow[0];
|
||||||
|
}
|
||||||
|
foreach ($writeups as $writeup) {
|
||||||
|
if (!in_array($writeup,$targets)) {
|
||||||
|
// remove writeup from group
|
||||||
|
mysqli_query($drs_db,"delete from links where writeupid=$writeup and linkgroup=$group");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($action=="dissolve" && $role && $save) {
|
||||||
|
$fail=false;
|
||||||
|
// unassign all writeups from a group and delete the group
|
||||||
|
mysqli_query($drs_db,"delete from links where linkgroup=$group");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
mysqli_query($drs_db,"delete from groups where id=$group");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
} elseif ($action=="setname" && $role && $save) {
|
||||||
|
$fail=false;
|
||||||
|
// change the name of a group
|
||||||
|
// remove html tags from group name and sanitize
|
||||||
|
$name=strip_tags($name);
|
||||||
|
$clean_name=mysqli_real_escape_string($drs_db,$name);
|
||||||
|
mysqli_query($drs_db,"update groups set name=\"$clean_name\" where id=\"$group\"");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
} elseif ($action=="takeaction" && $role && $save) {
|
||||||
|
$fail=false;
|
||||||
|
// set the status, action by, reason action date/time and append supplied text to action text
|
||||||
|
// for all ids in group
|
||||||
|
if ($edit_action_text) {
|
||||||
|
// sanitize date and time
|
||||||
|
$edit_action_date=mysqli_real_escape_string($drs_db,$edit_action_date);
|
||||||
|
$edit_action_time=mysqli_real_escape_string($drs_db,$edit_action_time);
|
||||||
|
// remove html tags from action text and sanitize
|
||||||
|
$edit_action_text=strip_tags($edit_action_text);
|
||||||
|
$clean_edit_action_text=mysqli_real_escape_string($drs_db,$edit_action_text);
|
||||||
|
// update the group members
|
||||||
|
$groupmem_qry=mysqli_query($drs_db,"select writeupid from links where linkgroup=\"$group\"");
|
||||||
|
while ($edit_row=mysqli_fetch_row($groupmem_qry)) {
|
||||||
|
$writeup_to_edit=$edit_row[0];
|
||||||
|
$writeup_action_text=dblookup($drs_db,"writeups","id","action_text",$writeup_to_edit);
|
||||||
|
$full_action_text=$writeup_action_text." STATUS CHANGED: ".$clean_edit_action_text;
|
||||||
|
mysqli_query($drs_db,"update writeups set status=\"$edit_status\",action_by=\"$edit_action_by\",action_date=\"$edit_action_date\",action_time=\"$edit_action_time\",action_reason=\"$edit_action_reason\",action_text=\"$full_action_text\" where id=\"$writeup_to_edit\"");
|
||||||
|
$fail=mysqli_error($drs_db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($search) {
|
||||||
|
// strip whitespace from beginning and end of text fields
|
||||||
|
$s_reported_by=trim($s_reported_by);
|
||||||
|
$s_action_text=trim($s_action_text);
|
||||||
|
$s_discrepancy_text=trim($s_discrepancy_text);
|
||||||
|
|
||||||
|
// build the query string
|
||||||
|
$query_string="";
|
||||||
|
// device
|
||||||
|
if ($s_device) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$device_param="Devices:";
|
||||||
|
foreach ($s_device as $dev_val) {
|
||||||
|
$query_string="{$query_string}device=\"{$dev_val}\" or ";
|
||||||
|
$device_dsp=dblookup($drs_db,"devices","id","name",$dev_val);
|
||||||
|
$device_param="{$device_param} {$device_dsp}, ";
|
||||||
|
}
|
||||||
|
$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";
|
||||||
|
$query_string=rtrim($query_string," or ");
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
}
|
||||||
|
// subsystem
|
||||||
|
if ($s_subsystem) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$subsystem_param="Subsystems:";
|
||||||
|
foreach ($s_subsystem as $sub_val) {
|
||||||
|
$query_string="{$query_string}subsystem=\"{$sub_val}\" or ";
|
||||||
|
$subsystem_dsp=dblookup($drs_db,"subsystems","id","name",$sub_val);
|
||||||
|
$subsystem_param="{$subsystem_param} {$subsystem_dsp}, ";
|
||||||
|
}
|
||||||
|
$subsystem_param=rtrim($subsystem_param,", ");
|
||||||
|
$num_subsystems=mysqli_num_rows(mysqli_query($drs_db,"select id from subsystems"));
|
||||||
|
if (count($s_subsystem)==$num_subsystems) $subsystem_param="Subsystems: any";
|
||||||
|
$query_string=rtrim($query_string," or ");
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
}
|
||||||
|
// period
|
||||||
|
if ($s_period) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$period_param="Periods:";
|
||||||
|
foreach ($s_period as $per_val) {
|
||||||
|
$query_string="{$query_string}period=\"{$per_val}\" or ";
|
||||||
|
$period_dsp=$per_val;
|
||||||
|
$period_param="{$period_param} {$period_dsp}, ";
|
||||||
|
}
|
||||||
|
$period_param=rtrim($period_param,", ");
|
||||||
|
$num_periods=mysqli_num_rows(mysqli_query($drs_db,"select id from periods"));
|
||||||
|
if (count($s_period)==$num_periods) $period_param="Periods: any";
|
||||||
|
$query_string=rtrim($query_string," or ");
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
}
|
||||||
|
// period_effective
|
||||||
|
if ($s_period_effective) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$eff_param="Period effective:";
|
||||||
|
foreach ($s_period_effective as $eff_val) {
|
||||||
|
$query_string="{$query_string}period_effective=\"{$eff_val}\" or ";
|
||||||
|
if ($eff_val=="0") $eff_dsp="<font color=\"#FF0000\">NEF</font>";
|
||||||
|
if ($eff_val=="1") $eff_dsp="<font color=\"#00FF00\">EFF</font>";
|
||||||
|
$eff_param="{$eff_param} {$eff_dsp}, ";
|
||||||
|
}
|
||||||
|
$eff_param=rtrim($eff_param,", ");
|
||||||
|
$query_string=rtrim($query_string," or ");
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
}
|
||||||
|
// status
|
||||||
|
if ($s_status) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$status_param="Status:";
|
||||||
|
foreach ($s_status as $stat_val) {
|
||||||
|
$query_string="{$query_string}status=\"{$stat_val}\" or ";
|
||||||
|
if ($stat_val=="1") $stat_dsp="<font color=\"#FF0000\">OPEN</font>";
|
||||||
|
if ($stat_val=="2") $stat_dsp="<font color=\"#00FF00\">CLSD</font>";
|
||||||
|
if ($stat_val=="3") $stat_dsp="<font color=\"#FFFF00\">DFRD</font>";
|
||||||
|
$status_param="{$status_param} {$stat_dsp}, ";
|
||||||
|
}
|
||||||
|
$status_param=rtrim($status_param,", ");
|
||||||
|
$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}\"";
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
$reportdate_param="Report date between {$s_report_date_start} and {$s_report_date_end}";
|
||||||
|
// report time
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$query_string="{$query_string}report_time between \"{$s_report_time_start}\" and \"{$s_report_time_end}\"";
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
$reporttime_param="Report time between {$s_report_time_start} and {$s_report_time_end}";
|
||||||
|
// discrepancy text
|
||||||
|
if ($s_discrepancy_text) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$query_string="{$query_string}discrepancy_text like \"%{$s_discrepancy_text}%\"";
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
$discrepancytext_param="Text in discrepancy: {$s_discrepancy_text}";
|
||||||
|
} else {
|
||||||
|
$discrepancytext_param="Text in discrepancy: any";
|
||||||
|
}
|
||||||
|
// reported by
|
||||||
|
if ($s_reported_by) {
|
||||||
|
$query_string="{$query_string}(";
|
||||||
|
$query_string="{$query_string}reported_by like \"%{$s_reported_by}%\"";
|
||||||
|
$query_string="{$query_string})";
|
||||||
|
$query_string="{$query_string} and ";
|
||||||
|
$repby_param="Text in Reported by: {$s_reported_by}";
|
||||||
|
} else {
|
||||||
|
$repby_param="Text in Reported by: any";
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_string=rtrim($query_string," and ");
|
||||||
|
$query_string="select * from writeups where {$query_string} order by report_date asc";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******** end database manipulation ********
|
||||||
|
|
||||||
|
pagetable("begin");
|
||||||
|
if (!$print) {
|
||||||
|
pageblock("left","begin");
|
||||||
|
sidemenu();
|
||||||
|
pageblock("left","end");
|
||||||
|
}
|
||||||
|
pageblock("right","begin");
|
||||||
|
banner($print);
|
||||||
|
echo "<br>";
|
||||||
|
|
||||||
|
if ($action=="add") {
|
||||||
|
if (count($targets) > 1) {
|
||||||
|
$plural="s";
|
||||||
|
} else {
|
||||||
|
$plural="";
|
||||||
|
}
|
||||||
|
if ($save && !$fail) {
|
||||||
|
format_message(0,"<strong>Writeup$plural successfully added.</strong> <a href=\"groups.php\">Return to Writeup Groups page.</a>");
|
||||||
|
} elseif ($save && $fail) {
|
||||||
|
format_message(2,"<strong>An error was encountered when adding writeup$plural.</strong> The error was \" $fail \"");
|
||||||
|
}
|
||||||
|
if ($save) {
|
||||||
|
// show the group
|
||||||
|
$mode="view";
|
||||||
|
group_table($group,$role,$mode);
|
||||||
|
if ($role) {
|
||||||
|
// show buttons
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"add\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($role){
|
||||||
|
// show mini search with discrepancy data only
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"add\">
|
||||||
|
<b>Search Parameters</b> Enter search terms to find writeups to add to the group.<br>
|
||||||
|
<table border=\"0\" cellpadding=\"5\">
|
||||||
|
<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\">
|
||||||
|
";
|
||||||
|
// Device cell *********************
|
||||||
|
echo "
|
||||||
|
Device<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");
|
||||||
|
while ($ditem=mysqli_fetch_assoc($drow)) {
|
||||||
|
if (!$search || in_array($ditem["id"],$s_device,true)) {
|
||||||
|
printf("<option value=\"%s\" selected>%s</option>",$ditem["id"],$ditem["name"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\">%s</option>",$ditem["id"],$ditem["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select>
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Subsystem cell *******************
|
||||||
|
echo "
|
||||||
|
Subsystem<br>
|
||||||
|
<select name=\"s_subsystem[]\" id=\"ms-subsystem\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||||
|
";
|
||||||
|
$ssrow=mysqli_query($drs_db,"select * from subsystems order by id asc");
|
||||||
|
while ($ssitem=mysqli_fetch_assoc($ssrow)) {
|
||||||
|
if (!$search || in_array($ssitem["id"],$s_subsystem,true)) {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\">%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select>
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Period cell **********************
|
||||||
|
echo "
|
||||||
|
Period<br>
|
||||||
|
<select name=\"s_period[]\" id=\"ms-period\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||||
|
";
|
||||||
|
$prow=mysqli_query($drs_db,"select * from periods order by times asc");
|
||||||
|
while ($pitem=mysqli_fetch_assoc($prow)) {
|
||||||
|
if (!$search || in_array($pitem["id"],$s_period,true)) {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\" title=\"%s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select>
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Report Date cell *****************
|
||||||
|
echo "
|
||||||
|
Report Date Between<br>
|
||||||
|
<input type=\"text\" name=\"s_report_date_start\" size=\"10\" maxlength=\"10\" value=\"$s_report_date_start\" id=\"sdp-report_date\" title=\"Format: YYYY-MM-DD\">
|
||||||
|
and
|
||||||
|
<input type=\"text\" name=\"s_report_date_end\" size=\"10\" maxlength=\"10\" value=\"$s_report_date_end\" id=\"edp-report_date\" title=\"Format: YYYY-MM-DD\">
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
";
|
||||||
|
echo "
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Report Time cell *****************
|
||||||
|
echo "
|
||||||
|
Report Time Between<br>
|
||||||
|
<input type=\"text\" name=\"s_report_time_start\" size=\"8\" maxlength=\"8\" value=\"$s_report_time_start\" title=\"Format: HH:MM:SS\">
|
||||||
|
and
|
||||||
|
<input type=\"text\" name=\"s_report_time_end\" size=\"8\" maxlength=\"8\" value=\"$s_report_time_end\" title=\"Format: HH:MM:SS\">
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr><td></td><td></td><td></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan=\"3\">
|
||||||
|
";
|
||||||
|
// Discrepancy text cell ************
|
||||||
|
echo "
|
||||||
|
Words in Discrepancy<br>
|
||||||
|
<textarea rows=\"5\" cols=\"80\" name=\"s_discrepancy_text\" wrap=\"soft\">$s_discrepancy_text</textarea><br>
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Reported by cell *****************
|
||||||
|
echo "
|
||||||
|
Reported by<br>
|
||||||
|
<input type=\"text\" name=\"s_reported_by\" size=\"30\" value=\"$s_reported_by\">
|
||||||
|
";
|
||||||
|
// **********************************
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
<td align=\"left\">
|
||||||
|
";
|
||||||
|
// Period effective cell ************
|
||||||
|
echo "
|
||||||
|
Sim period effective? <img src=\"icons/question.png\" title=\"If maintenance issues prevented the training objectives from being achieved and you will have to come back and redo the same training, answer Non-effective.
|
||||||
|
Otherwise, answer Effective. \"><br>
|
||||||
|
";
|
||||||
|
if ($search) {
|
||||||
|
$effstate=$nefstate="";
|
||||||
|
if (in_array("1",$s_period_effective,true)) $effstate="selected";
|
||||||
|
if (in_array("0",$s_period_effective,true)) $nefstate="selected";
|
||||||
|
} else {
|
||||||
|
$effstate=$nefstate="selected";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
<select name=\"s_period_effective[]\" id=\"ms-period_effective\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
|
||||||
|
<option value=\"1\" $effstate title=\"Training objectives were achieved\">Effective</option>
|
||||||
|
<option value=\"0\" $nefstate title=\"Training objectives were not achieved\">Non-effective</option>
|
||||||
|
</select>
|
||||||
|
</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%;\">Msn Eff</th>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
while ($tablerow = mysqli_fetch_assoc($writeup_qry)) {
|
||||||
|
// determine effective icon
|
||||||
|
if($tablerow["period_effective"]==1) {
|
||||||
|
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
|
||||||
|
} else {
|
||||||
|
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
$eff_icon
|
||||||
|
);
|
||||||
|
}
|
||||||
|
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>
|
||||||
|
<br><br>
|
||||||
|
If nothing looks appropriate, you can modify the search parameters above and search again or select another menu option.
|
||||||
|
</form>";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<b>No writeups match your search parameters.</b><br><br>
|
||||||
|
You can modify the search parameters above and search again or select another menu option.
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($action=="remove") {
|
||||||
|
if ($save && !$fail) {
|
||||||
|
format_message(0,"<strong>Group successfully modified.</strong> <a href=\"groups.php\">Return to Writeup Groups page.</a>");
|
||||||
|
} elseif ($save && $fail) {
|
||||||
|
format_message(2,"<strong>An error was encountered when modifying group.</strong> The error was \" $fail \"");
|
||||||
|
}
|
||||||
|
if ($role && mysqli_num_rows(mysqli_query($drs_db,"select id from links where linkgroup=$group"))) {
|
||||||
|
// show group table with everything selected
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"remove\">
|
||||||
|
";
|
||||||
|
group_table($group,$role,"select","all");
|
||||||
|
echo "
|
||||||
|
Deselect the writeups you want to remove from this group. <br><br>
|
||||||
|
<b>NOTE:</b> Deselecting them all will dissolve the group.
|
||||||
|
<br><br>
|
||||||
|
<button name=\"save\" value=\"save\" type=\"submit\">Modify this group</button>
|
||||||
|
|
||||||
|
<button name=\"cancel\" value=\"cancel\" type=\"submit\">Cancel</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} elseif ($action=="dissolve") {
|
||||||
|
if ($save && !$fail) {
|
||||||
|
format_message(0,"<strong>Group dissolved.</strong> <a href=\"groups.php\">Return to Writeup Groups page.</a>");
|
||||||
|
} elseif ($save && $fail) {
|
||||||
|
format_message(2,"<strong>An error was encountered when dissolving the group.</strong> The error was \" $fail \"");
|
||||||
|
} else {
|
||||||
|
if ($role) {
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"dissolve\">
|
||||||
|
<b>NOTE:</b> Dissolving this group will unassign its member writeups and remove the group.<br><br>
|
||||||
|
It will not delete any writeups or affect their assignment to other groups.<br><br>
|
||||||
|
<button name=\"save\" value=\"save\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"cancel\" value=\"cancel\" type=\"submit\">Cancel</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
// show the group
|
||||||
|
$mode="view";
|
||||||
|
group_table($group,$role,$mode);
|
||||||
|
if ($role) {
|
||||||
|
// show buttons
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($action=="setname") {
|
||||||
|
if ($save && !$fail) {
|
||||||
|
format_message(0,"<strong>Group name updated.</strong> <a href=\"groups.php\">Return to Writeup Groups page.</a>");
|
||||||
|
} elseif ($save && $fail) {
|
||||||
|
format_message(2,"<strong>An error was encountered when updating the group name.</strong> The error was \" $fail \"");
|
||||||
|
}
|
||||||
|
if ($role) {
|
||||||
|
// get current group name if there is one and show the form
|
||||||
|
$curr_name=dblookup($drs_db,"groups","id","name",$group);
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"setname\">
|
||||||
|
<input type=\"text\" name=\"name\" size=\"60\" value=\"$curr_name\">
|
||||||
|
<button name=\"save\" value=\"save\" type=\"submit\">Update group name</button>
|
||||||
|
|
||||||
|
<button name=\"cancel\" value=\"cancel\" type=\"submit\">Cancel</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
// show the group
|
||||||
|
$mode="view";
|
||||||
|
group_table($group,$role,$mode);
|
||||||
|
if ($role) {
|
||||||
|
// show buttons
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} elseif ($action=="takeaction") {
|
||||||
|
if ($save && !$fail) {
|
||||||
|
format_message(0,"<strong>Group action completed.</strong> <a href=\"groups.php\">Return to Writeup Groups page.</a>");
|
||||||
|
} elseif ($save && $fail) {
|
||||||
|
format_message(2,"<strong>An error was encountered when taking group action.</strong> The error was \" $fail \"");
|
||||||
|
}
|
||||||
|
// show the group
|
||||||
|
$mode="view";
|
||||||
|
group_table($group,$role,$mode);
|
||||||
|
if ($role && ! $save) {
|
||||||
|
// show action form
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<input type=\"hidden\" name=\"action\" value=\"takeaction\">
|
||||||
|
<table border=\"0\" cellpadding=\"5\" width=\"600\">
|
||||||
|
<tr>
|
||||||
|
<td>Status<br>
|
||||||
|
<select name=\"edit_status\" id=\"status\">
|
||||||
|
<option value=\"1\">OPEN</option>
|
||||||
|
<option value=\"2\"selected>CLOSED</option>
|
||||||
|
<option value=\"3\">DEFERRED</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>Action taken by<br>
|
||||||
|
";
|
||||||
|
if ($role==ADMIN) {
|
||||||
|
// allow selection of tech name
|
||||||
|
echo "
|
||||||
|
<select name=\"edit_action_by\" id=\"user\">
|
||||||
|
";
|
||||||
|
$persrow=mysqli_query($drs_db,"select id,firstname,lastname from users where active is true order by lastname asc");
|
||||||
|
while ($persitem=mysqli_fetch_assoc($persrow)) {
|
||||||
|
if ($userid==$persitem["id"]) {
|
||||||
|
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>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
// limit the choice to the tech in question
|
||||||
|
echo "
|
||||||
|
<select name=\"edit_action_by\" id=\"user\">
|
||||||
|
";
|
||||||
|
$persrow=mysqli_query($drs_db,"select id,firstname,lastname from users where active is true order by lastname asc");
|
||||||
|
while ($persitem=mysqli_fetch_assoc($persrow)) {
|
||||||
|
if ($userid==$persitem["id"]) {
|
||||||
|
printf("<option value=\"%s\" selected>%s %s</option>",$persitem["id"],$persitem["firstname"],$persitem["lastname"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
|
<td>Status change reason<br>
|
||||||
|
<select name=\"edit_action_reason\" id=\"reason\">
|
||||||
|
";
|
||||||
|
$reasrow=mysqli_query($drs_db,"select id,text from reasons where active is true order by id asc");
|
||||||
|
if (!$action_reason) echo "<option selected></option>";
|
||||||
|
while ($reasitem=mysqli_fetch_assoc($reasrow)) {
|
||||||
|
if ($action_reason==$reasitem["id"]) {
|
||||||
|
printf("<option value=\"%s\" selected>%s</option>",$reasitem["id"],$reasitem["text"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\">%s</option>",$reasitem["id"],$reasitem["text"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr><td></td><td></td><td></td></tr>
|
||||||
|
<tr><td colspan=\"3\">
|
||||||
|
Action Taken <font size=\"-2\">(required)</font><br>
|
||||||
|
<textarea rows=\"10\" cols=\"80\" name=\"edit_action_text\" wrap=\"soft\"></textarea><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\" >Action Taken Date<br>
|
||||||
|
<input type=\"text\" name=\"edit_action_date\" size=\"10\" maxlength=\"10\" value=\"$today\" id=\"actiondatepicker\" title=\"Format: YYYY-MM-DD\"></td>
|
||||||
|
<td align=\"left\">Action Taken Time<br>
|
||||||
|
<input type=\"text\" name=\"edit_action_time\" size=\"8\" maxlength=\"8\" value=\"$now\" title=\"Format: HH:MM:SS\"></td>
|
||||||
|
<td align=\"right\" valign=\"bottom\"><button type=\"submit\" name=\"save\" value=\"save\">Save action</button></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align=\"left\" valign=\"bottom\">
|
||||||
|
<td></td><td align=\"right\" valign=\"bottom\">
|
||||||
|
<input type=\"submit\" name=\"cancel\" value=\"Cancel Changes\"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($role) {
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Create a new group</button>
|
||||||
|
</form>
|
||||||
|
<hr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
if ($group) {
|
||||||
|
// show only the requested group
|
||||||
|
$mode="view";
|
||||||
|
group_table($group,$role,$mode);
|
||||||
|
if ($role) {
|
||||||
|
// show buttons
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"$group\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "<hr><br>";
|
||||||
|
} else {
|
||||||
|
// show all groups
|
||||||
|
$mode="view";
|
||||||
|
$groups_qry=mysqli_query($drs_db,"select id from groups");
|
||||||
|
if (mysqli_num_rows($groups_qry)) {
|
||||||
|
while ($grouprow=mysqli_fetch_assoc($groups_qry)) {
|
||||||
|
if ($expandgrp == $grouprow['id']) {
|
||||||
|
group_table($grouprow['id'],$role,$mode,"none",$expandgrp);
|
||||||
|
if ($role) {
|
||||||
|
// show buttons
|
||||||
|
echo "
|
||||||
|
<form method=post action=\"groups.php\">
|
||||||
|
<input type=\"hidden\" name=\"group\" value=\"{$grouprow['id']}\">
|
||||||
|
<button name=\"action\" value=\"add\" type=\"submit\">Add writeups to this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"remove\" type=\"submit\">Remove writeups from this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"dissolve\" type=\"submit\">Dissolve this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"setname\" type=\"submit\">Set name for this group</button>
|
||||||
|
|
||||||
|
<button name=\"action\" value=\"takeaction\" type=\"submit\">Take group action</button>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<a href=\"groups.php?expandgrp={$grouprow['id']}\" style=\"text-decoration:none\">
|
||||||
|
<img src=\"icons/plus-white.png\" alt=\"Expand group\">
|
||||||
|
</a>
|
||||||
|
";
|
||||||
|
$groupname=dblookup($drs_db,"groups","id","name",$grouprow['id']);
|
||||||
|
if ($groupname == "") {
|
||||||
|
echo "<b>Group ID:</b> {$grouprow['id']}";
|
||||||
|
} else {
|
||||||
|
echo "<b>Group Name:</b> $groupname";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "<br><br>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<br>No writeup groups were found.<br><br><br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo "<br>";
|
||||||
|
banner($print);
|
||||||
|
pageblock("right","end");
|
||||||
|
pagetable("end");
|
||||||
|
|
||||||
|
framework("end","","",$print);
|
||||||
|
|
||||||
|
?>
|
||||||
BIN
distfiles/icons/block.png
Normal file
|
After Width: | Height: | Size: 630 B |
BIN
distfiles/icons/calendar.gif
Normal file
|
After Width: | Height: | Size: 258 B |
BIN
distfiles/icons/chain--arrow.png
Normal file
|
After Width: | Height: | Size: 584 B |
BIN
distfiles/icons/chain--plus.png
Normal file
|
After Width: | Height: | Size: 586 B |
BIN
distfiles/icons/control-180.png
Normal file
|
After Width: | Height: | Size: 458 B |
BIN
distfiles/icons/control-double-180.png
Normal file
|
After Width: | Height: | Size: 551 B |
BIN
distfiles/icons/control-double.png
Normal file
|
After Width: | Height: | Size: 564 B |
BIN
distfiles/icons/control.png
Normal file
|
After Width: | Height: | Size: 470 B |
BIN
distfiles/icons/cross.png
Normal file
|
After Width: | Height: | Size: 544 B |
BIN
distfiles/icons/exclamation-red.png
Normal file
|
After Width: | Height: | Size: 696 B |
BIN
distfiles/icons/magnifier--arrow.png
Normal file
|
After Width: | Height: | Size: 811 B |
BIN
distfiles/icons/minus-button.png
Normal file
|
After Width: | Height: | Size: 479 B |
BIN
distfiles/icons/minus-white.png
Normal file
|
After Width: | Height: | Size: 682 B |
BIN
distfiles/icons/node-magnifier.png
Normal file
|
After Width: | Height: | Size: 811 B |
BIN
distfiles/icons/node.png
Normal file
|
After Width: | Height: | Size: 548 B |
BIN
distfiles/icons/notebook--pencil.png
Normal file
|
After Width: | Height: | Size: 757 B |
BIN
distfiles/icons/plus-button.png
Normal file
|
After Width: | Height: | Size: 583 B |
BIN
distfiles/icons/plus-white.png
Normal file
|
After Width: | Height: | Size: 703 B |
BIN
distfiles/icons/plus.png
Normal file
|
After Width: | Height: | Size: 521 B |
BIN
distfiles/icons/question-white.png
Normal file
|
After Width: | Height: | Size: 761 B |
BIN
distfiles/icons/question.png
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
distfiles/icons/sym-dash.png
Normal file
|
After Width: | Height: | Size: 562 B |
BIN
distfiles/icons/sym-diag.png
Normal file
|
After Width: | Height: | Size: 592 B |
BIN
distfiles/icons/sym-x.png
Normal file
|
After Width: | Height: | Size: 481 B |
BIN
distfiles/icons/tick.png
Normal file
|
After Width: | Height: | Size: 634 B |
BIN
distfiles/images/Kamiyamane.png
Normal file
|
After Width: | Height: | Size: 10 KiB |