diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 4e33ce4e0..f52716c2d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,23 +1,43 @@ -You should only file an issue if you found a bug. Feature and enhancement requests, general discussions and support questions should occur in one of the following areas: +**THIS FORUM IS FOR BUG REPORTS ONLY** + +Do not post feature or enhancement requests, general discussions or support questions here. + +Feature and enhancement requests, general discussions, and support questions should occur in one of the following areas: - The [ZoneMinder-Chat Slack channel](https://zoneminder-chat.herokuapp.com/) - The [ZoneMinder Forum](https://forums.zoneminder.com/) -**Do not post feature or enhancement requests, general discussions or support questions here.** - Docker related issues should be posted here: https://github.com/ZoneMinder/zmdockerfiles -Make sure you are running the latest version of ZoneMinder before reporting an issue. +In order to submit a bug report, please populate the fields below. This is required. -**ZoneMinder Version (`zmaudit.pl -v`):** +**Describe Your Environment** +- Version of ZoneMinder [release version, development version, or commit] +- How you installed ZoneMinder [e.g. PPA, RPMFusion, from-source, etc] +- Full name and version of OS -**Are you using a development snapshot / git checkout? If so, what is the latest commit? (`git rev-parse HEAD`):** +**If the issue concerns a camera** +- Make and Model +- frame rate +- resolution +- ZoneMinder Source Type: -**Linux Distribution and Version (`cat /etc/os-release` or `cat /etc/redhat-release`):** +**Describe the bug** +A clear and concise description of what the bug is. -**If the issue concerns a camera, provide the make, model, frame rate, resolution and ZoneMinder Source Type:** +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error -**Relevant log lines:** +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Debug Logs** ``` -log lines here + + + ``` diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 000000000..543a2c160 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,21 @@ +# Configuration for welcome - https://github.com/behaviorbot/welcome + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome + +# Comment to be posted to on first time issues +newIssueWelcomeComment: > + Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template! + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome + +# Comment to be posted to on PRs from first time contributors in your repository +#newPRWelcomeComment: > +# Thanks for opening this pull request! Please check out our contributing guidelines. + +# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge + +# Comment to be posted to on pull requests merged by a first time user +#firstPRMergeComment: > +# Congrats on merging your first pull request! We here at behaviorbot are proud of you! + +# It is recommend to include as many gifs and emojis as possible diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 000000000..7e40c036f --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,13 @@ +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an Issue is closed for lack of response +daysUntilClose: 7 +# Label requiring a response +responseRequiredLabel: more-information-needed +# Comment to post when closing an Issue for lack of response. Set to `false` to disable +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. With only the + information that is currently in the issue, we don't have enough information + to take action. Please reach out if you have or find the answers we need so + that we can investigate further. diff --git a/.github/support.yml b/.github/support.yml new file mode 100644 index 000000000..fc61e151e --- /dev/null +++ b/.github/support.yml @@ -0,0 +1,27 @@ +# Configuration for support-requests - https://github.com/dessant/support-requests + +# Label used to mark issues as support requests +supportLabel: support + +# Comment to post on issues marked as support requests, `{issue-author}` is an +# optional placeholder. Set to `false` to disable +supportComment: > + :wave: @{issue-author}, we use the issue tracker exclusively for bug reports. + However, this issue appears to be a support request, a feature request, or + attempts to ask a question. + + Please use our support channels to get help with or discuss this project: + - The [ZoneMinder-Chat Slack channel](https://zoneminder-chat.herokuapp.com/) + - The [ZoneMinder Forum](https://forums.zoneminder.com/) + +# Close issues marked as support requests +close: true + +# Lock issues marked as support requests +lock: true + +# Assign `off-topic` as the reason for locking. Set to `false` to disable +setLockReason: true + +# Repository to extend settings from +# _extends: repo diff --git a/.travis.yml b/.travis.yml index 1ae0988d5..d46e0fc85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,7 @@ env: - OS=el DIST=7 - OS=fedora DIST=27 DOCKER_REPO=knnniggett/packpack - OS=fedora DIST=28 DOCKER_REPO=knnniggett/packpack + - OS=fedora DIST=29 DOCKER_REPO=knnniggett/packpack - OS=ubuntu DIST=trusty - OS=ubuntu DIST=xenial - OS=ubuntu DIST=trusty ARCH=i386 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d070c6d3..9646ffc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,8 @@ mark_as_advanced( ZM_PATH_ARP ZM_CONFIG_DIR ZM_CONFIG_SUBDIR - ZM_SYSTEMD) + ZM_SYSTEMD + ZM_MANPAGE_DEST_PREFIX) set(ZM_RUNDIR "/var/run/zm" CACHE PATH "Location of transient process files, default: /var/run/zm") @@ -161,9 +162,6 @@ set(ZM_WEB_GROUP "" CACHE STRING Leave empty to be the same as the web user") set(ZM_DIR_EVENTS "${ZM_CONTENTDIR}/events" CACHE PATH "Location where events are recorded to, default: ZM_CONTENTDIR/events") -set(ZM_DIR_IMAGES "${ZM_CONTENTDIR}/images" CACHE PATH - "Location where images, not directly associated with events, - are recorded to, default: ZM_CONTENTDIR/images") set(ZM_DIR_SOUNDS "sounds" CACHE PATH "Location to look for optional sound files, default: sounds") set(ZM_PATH_ZMS "/cgi-bin/nph-zms" CACHE PATH @@ -185,8 +183,6 @@ set(ZM_MYSQL_ENGINE "InnoDB" CACHE STRING set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF") -set(ZM_NO_FFMPEG "OFF" CACHE BOOL - "Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF") set(ZM_NO_LIBVLC "OFF" CACHE BOOL "Set to ON to skip libvlc checks and force building ZM without libvlc. default: OFF") set(ZM_NO_CURL "OFF" CACHE BOOL @@ -210,6 +206,10 @@ set(ZM_TARGET_DISTRO "" CACHE STRING "Build ZoneMinder for a specific distribution. Currently, valid names are: fc27, fc26, el7, OS13, FreeBSD") set(ZM_SYSTEMD "OFF" CACHE BOOL "Set to ON to force building ZM with systemd support. default: OFF") +set(ZM_MANPAGE_DEST_PREFIX "share/man" CACHE PATH + "Relative path used to install ZoneMinder's Man pages into a + non-standard folder. Most Linux users will not need to change this. + BSD users may need to set this.") # Reassign some variables if a target distro has been specified if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc")) @@ -222,7 +222,6 @@ if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc")) set(ZM_WEBDIR "/usr/share/zoneminder/www") set(ZM_CGIDIR "/usr/libexec/zoneminder/cgi-bin") set(ZM_DIR_EVENTS "/var/lib/zoneminder/events") - set(ZM_DIR_IMAGES "/var/lib/zoneminder/images") set(ZM_PATH_ZMS "/cgi-bin-zm/nph-zms") elseif(ZM_TARGET_DISTRO STREQUAL "OS13") set(ZM_RUNDIR "/var/run/zoneminder") @@ -513,123 +512,137 @@ endif(MP4V2_LIBRARIES) set(PATH_FFMPEG "") set(OPT_FFMPEG "no") -# Do not check for ffmpeg if ZM_NO_FFMPEG is on -if(NOT ZM_NO_FFMPEG) - # avformat (using find_library and find_path) - find_library(AVFORMAT_LIBRARIES avformat) - if(AVFORMAT_LIBRARIES) - set(HAVE_LIBAVFORMAT 1) - list(APPEND ZM_BIN_LIBS "${AVFORMAT_LIBRARIES}") - find_path(AVFORMAT_INCLUDE_DIR "libavformat/avformat.h" /usr/include/ffmpeg) - if(AVFORMAT_INCLUDE_DIR) - include_directories("${AVFORMAT_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVFORMAT_INCLUDE_DIR}") - endif(AVFORMAT_INCLUDE_DIR) - mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) - check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) - set(optlibsfound "${optlibsfound} AVFormat") - else(AVFORMAT_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVFormat") - endif(AVFORMAT_LIBRARIES) +# avformat (using find_library and find_path) +find_library(AVFORMAT_LIBRARIES avformat) +if(AVFORMAT_LIBRARIES) + set(HAVE_LIBAVFORMAT 1) + list(APPEND ZM_BIN_LIBS "${AVFORMAT_LIBRARIES}") + find_path(AVFORMAT_INCLUDE_DIR "libavformat/avformat.h" /usr/include/ffmpeg) + if(AVFORMAT_INCLUDE_DIR) + include_directories("${AVFORMAT_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVFORMAT_INCLUDE_DIR}") + endif(AVFORMAT_INCLUDE_DIR) + mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) + check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) + set(optlibsfound "${optlibsfound} AVFormat") +else(AVFORMAT_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVFormat") +endif(AVFORMAT_LIBRARIES) - # avcodec (using find_library and find_path) - find_library(AVCODEC_LIBRARIES avcodec) - if(AVCODEC_LIBRARIES) - set(HAVE_LIBAVCODEC 1) - list(APPEND ZM_BIN_LIBS "${AVCODEC_LIBRARIES}") - find_path(AVCODEC_INCLUDE_DIR "libavcodec/avcodec.h" /usr/include/ffmpeg) - if(AVCODEC_INCLUDE_DIR) - include_directories("${AVCODEC_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVCODEC_INCLUDE_DIR}") - endif(AVCODEC_INCLUDE_DIR) - mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) - check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) - set(optlibsfound "${optlibsfound} AVCodec") - else(AVCODEC_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVCodec") - endif(AVCODEC_LIBRARIES) +# avcodec (using find_library and find_path) +find_library(AVCODEC_LIBRARIES avcodec) +if(AVCODEC_LIBRARIES) + set(HAVE_LIBAVCODEC 1) + list(APPEND ZM_BIN_LIBS "${AVCODEC_LIBRARIES}") + find_path(AVCODEC_INCLUDE_DIR "libavcodec/avcodec.h" /usr/include/ffmpeg) + if(AVCODEC_INCLUDE_DIR) + include_directories("${AVCODEC_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVCODEC_INCLUDE_DIR}") + endif(AVCODEC_INCLUDE_DIR) + mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) + check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) + set(optlibsfound "${optlibsfound} AVCodec") +else(AVCODEC_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVCodec") +endif(AVCODEC_LIBRARIES) - # avdevice (using find_library and find_path) - find_library(AVDEVICE_LIBRARIES avdevice) - if(AVDEVICE_LIBRARIES) - set(HAVE_LIBAVDEVICE 1) - list(APPEND ZM_BIN_LIBS "${AVDEVICE_LIBRARIES}") - find_path(AVDEVICE_INCLUDE_DIR "libavdevice/avdevice.h" /usr/include/ffmpeg) - if(AVDEVICE_INCLUDE_DIR) - include_directories("${AVDEVICE_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVDEVICE_INCLUDE_DIR}") - endif(AVDEVICE_INCLUDE_DIR) - mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) - check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) - set(optlibsfound "${optlibsfound} AVDevice") - else(AVDEVICE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVDevice") - endif(AVDEVICE_LIBRARIES) +# avdevice (using find_library and find_path) +find_library(AVDEVICE_LIBRARIES avdevice) +if(AVDEVICE_LIBRARIES) + set(HAVE_LIBAVDEVICE 1) + list(APPEND ZM_BIN_LIBS "${AVDEVICE_LIBRARIES}") + find_path(AVDEVICE_INCLUDE_DIR "libavdevice/avdevice.h" /usr/include/ffmpeg) + if(AVDEVICE_INCLUDE_DIR) + include_directories("${AVDEVICE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVDEVICE_INCLUDE_DIR}") + endif(AVDEVICE_INCLUDE_DIR) + mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) + check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) + set(optlibsfound "${optlibsfound} AVDevice") +else(AVDEVICE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVDevice") +endif(AVDEVICE_LIBRARIES) - # avutil (using find_library and find_path) - find_library(AVUTIL_LIBRARIES avutil) - if(AVUTIL_LIBRARIES) - set(HAVE_LIBAVUTIL 1) - list(APPEND ZM_BIN_LIBS "${AVUTIL_LIBRARIES}") - find_path(AVUTIL_INCLUDE_DIR "libavutil/avutil.h" /usr/include/ffmpeg) - if(AVUTIL_INCLUDE_DIR) - include_directories("${AVUTIL_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVUTIL_INCLUDE_DIR}") - endif(AVUTIL_INCLUDE_DIR) - mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) - check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) - check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) - check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) - set(optlibsfound "${optlibsfound} AVUtil") - else(AVUTIL_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVUtil") - endif(AVUTIL_LIBRARIES) +# avutil (using find_library and find_path) +find_library(AVUTIL_LIBRARIES avutil) +if(AVUTIL_LIBRARIES) + set(HAVE_LIBAVUTIL 1) + list(APPEND ZM_BIN_LIBS "${AVUTIL_LIBRARIES}") + find_path(AVUTIL_INCLUDE_DIR "libavutil/avutil.h" /usr/include/ffmpeg) + if(AVUTIL_INCLUDE_DIR) + include_directories("${AVUTIL_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVUTIL_INCLUDE_DIR}") + endif(AVUTIL_INCLUDE_DIR) + mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) + check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) + check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) + check_include_file("libavutil/hwcontext.h" HAVE_LIBAVUTIL_HWCONTEXT_H) + set(optlibsfound "${optlibsfound} AVUtil") +else(AVUTIL_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVUtil") +endif(AVUTIL_LIBRARIES) - # swscale (using find_library and find_path) - find_library(SWSCALE_LIBRARIES swscale) - if(SWSCALE_LIBRARIES) - set(HAVE_LIBSWSCALE 1) - list(APPEND ZM_BIN_LIBS "${SWSCALE_LIBRARIES}") - find_path(SWSCALE_INCLUDE_DIR "libswscale/swscale.h" /usr/include/ffmpeg) - if(SWSCALE_INCLUDE_DIR) - include_directories("${SWSCALE_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${SWSCALE_INCLUDE_DIR}") - endif(SWSCALE_INCLUDE_DIR) - mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) - check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) - set(optlibsfound "${optlibsfound} SWScale") - else(SWSCALE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} SWScale") - endif(SWSCALE_LIBRARIES) +# swscale (using find_library and find_path) +find_library(SWSCALE_LIBRARIES swscale) +if(SWSCALE_LIBRARIES) + set(HAVE_LIBSWSCALE 1) + list(APPEND ZM_BIN_LIBS "${SWSCALE_LIBRARIES}") + find_path(SWSCALE_INCLUDE_DIR "libswscale/swscale.h" /usr/include/ffmpeg) + if(SWSCALE_INCLUDE_DIR) + include_directories("${SWSCALE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${SWSCALE_INCLUDE_DIR}") + endif(SWSCALE_INCLUDE_DIR) + mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) + check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) + set(optlibsfound "${optlibsfound} SWScale") +else(SWSCALE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} SWScale") +endif(SWSCALE_LIBRARIES) - # rescale (using find_library and find_path) - find_library(AVRESAMPLE_LIBRARIES avresample) - if(AVRESAMPLE_LIBRARIES) - set(HAVE_LIBAVRESAMPLE 1) - list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}") - find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg) - if(AVRESAMPLE_INCLUDE_DIR) - include_directories("${AVRESAMPLE_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}") - endif(AVRESAMPLE_INCLUDE_DIR) - mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR) - check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H) - set(optlibsfound "${optlibsfound} AVResample") - else(AVRESAMPLE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVResample") - endif(AVRESAMPLE_LIBRARIES) +# SWresample (using find_library and find_path) +find_library(SWRESAMPLE_LIBRARIES swresample) +if(SWRESAMPLE_LIBRARIES) + set(HAVE_LIBSWRESAMPLE 1) + list(APPEND ZM_BIN_LIBS "${SWRESAMPLE_LIBRARIES}") + find_path(SWRESAMPLE_INCLUDE_DIR "libswresample/swresample.h" /usr/include/ffmpeg) + if(SWRESAMPLE_INCLUDE_DIR) + include_directories("${SWRESAMPLE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${SWRESAMPLE_INCLUDE_DIR}") + endif(SWRESAMPLE_INCLUDE_DIR) + mark_as_advanced(FORCE SWRESAMPLE_LIBRARIES SWRESAMPLE_INCLUDE_DIR) + check_include_file("libswresample/swresample.h" HAVE_LIBSWRESAMPLE_SWRESAMPLE_H) + set(optlibsfound "${optlibsfound} SWResample") +else(SWRESAMPLE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} SWResample") - # Find the path to the ffmpeg executable - find_program(FFMPEG_EXECUTABLE - NAMES ffmpeg avconv - PATH_SUFFIXES ffmpeg) - if(FFMPEG_EXECUTABLE) - set(PATH_FFMPEG "${FFMPEG_EXECUTABLE}") - set(OPT_FFMPEG "yes") - mark_as_advanced(FFMPEG_EXECUTABLE) - endif(FFMPEG_EXECUTABLE) + # AVresample (using find_library and find_path) + find_library(AVRESAMPLE_LIBRARIES avresample) + if(AVRESAMPLE_LIBRARIES) + set(HAVE_LIBAVRESAMPLE 1) + list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}") + find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg) + if(AVRESAMPLE_INCLUDE_DIR) + include_directories("${AVRESAMPLE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}") + endif(AVRESAMPLE_INCLUDE_DIR) + mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR) + check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H) + set(optlibsfound "${optlibsfound} AVResample") + else(AVRESAMPLE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVResample") + endif(AVRESAMPLE_LIBRARIES) -endif(NOT ZM_NO_FFMPEG) +endif(SWRESAMPLE_LIBRARIES) + +# Find the path to the ffmpeg executable +find_program(FFMPEG_EXECUTABLE + NAMES ffmpeg avconv + PATH_SUFFIXES ffmpeg) +if(FFMPEG_EXECUTABLE) + set(PATH_FFMPEG "${FFMPEG_EXECUTABLE}") + set(OPT_FFMPEG "yes") + mark_as_advanced(FFMPEG_EXECUTABLE) +endif(FFMPEG_EXECUTABLE) # Do not check for libvlc if ZM_NO_LIBVLC is on if(NOT ZM_NO_LIBVLC) diff --git a/INSTALL b/INSTALL index 666105c40..ecf7b909a 100644 --- a/INSTALL +++ b/INSTALL @@ -51,7 +51,6 @@ Possible configuration options: ZM_WEB_USER The user apache or the local web server runs on. Leave empty for automatic detection. If that fails, you can use this variable to force ZM_WEB_GROUP The group apache or the local web server runs on, Leave empty to be the same as the web user ZM_DIR_EVENTS Location where events are recorded to, default: ZM_CONTENTDIR/events - ZM_DIR_IMAGES Location where images, not directly associated with events, are recorded to, default: ZM_CONTENTDIR/images ZM_DIR_SOUNDS Location to look for optional sound files, default: sounds ZM_PATH_ZMS Web url to zms streaming server, default: /cgi-bin/nph-zms Advanced: @@ -62,7 +61,6 @@ Advanced: ZM_EXTRA_LIBS A list of optional libraries, separated by semicolons, e.g. ssl;theora ZM_MYSQL_ENGINE MySQL engine to use with database, default: InnoDB ZM_NO_MMAP Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF - ZM_NO_FFMPEG Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF ZM_NO_X10 Set to ON to build ZoneMinder without X10 support. default: OFF ZM_PERL_MM_PARMS By default, ZoneMinder's Perl modules are installed into the Vendor folders, as defined by your installation of Perl. You can change that here. Consult Perl's MakeMaker documentation for a definition of acceptable parameters. If you set this to something that causes the modules to be installed outside Perl's normal serach path, then you will also need to set ZM_PERL_SEARCH_PATH accordingly. default: "INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1" ZM_PERL_SEARCH_PATH Use to add a folder to your Perl's search path. This will need to be set in cases where ZM_PERL_MM_PARMS has been modified such that ZoneMinder's Perl modules are installed outside Perl's default search path. default: "" @@ -130,8 +128,8 @@ cmake -C zm_conf.cmake [extra options] . 2) Run "make" to compile ZoneMinder 3) Run "make install" (as root, or use sudo) to install ZoneMinder to your system. -4) Depending on your configuration: If the DIR_EVENTS and DIR_IMAGES options are set to default (pointing to web directory/events and web directory/images), You will need to update the symlinks in the web directory to the correct folders. e.g. web directory/events should point to the real events directory, and likewise for the images directory. -You can use the zmlinkcontent.sh script for this. For example, if /var/lib/zoneminder is the folder that contains the "images" and "events" directories, you can use: +4) Depending on your configuration: If DIR_EVENTS is set to default, You will need to update the symlinks in the web directory to the correct folders. e.g. web directory/events should point to the real events directory. +You can use the zmlinkcontent.sh script for this. For example, if /var/lib/zoneminder is the folder that contains the "events" directory, you can use: ./zmlinkcontent.sh /var/lib/zoneminder By default, the content directory for new installations is /var/lib/zoneminder. This can be overridden in cmake with the ZM_CONTENTDIR option. e.g. cmake -DZM_CONTENTDIR="/some/big/storage/zm" . diff --git a/README.md b/README.md index 94774364c..b8e3f34fd 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Lastly, if you desire to build a development snapshot from the master branch, it Please visit our [ReadtheDocs site](https://zoneminder.readthedocs.org/en/stable/installationguide/index.html) for distro specific instructions. ### Package Maintainers -Many of the ZoneMinder configration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source. +Many of the ZoneMinder configuration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source. -For example, let's say I have created a new ZoneMinder package that contains the cambozola javascript file. However, by default cambozola support is turned off. To fix that, add this to the pacakging script: +For example, let's say I have created a new ZoneMinder package that contains the cambozola javascript file. However, by default cambozola support is turned off. To fix that, add this to the packaging script: ```bash ./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes ``` diff --git a/cmake/Modules/Pod2Man.cmake b/cmake/Modules/Pod2Man.cmake index 6804fab53..734be239b 100644 --- a/cmake/Modules/Pod2Man.cmake +++ b/cmake/Modules/Pod2Man.cmake @@ -21,7 +21,7 @@ # To use it, include this file in CMakeLists.txt and # invoke POD2MAN(
) -MACRO(POD2MAN PODFILE MANFILE SECTION) +MACRO(POD2MAN PODFILE MANFILE SECTION MANPAGE_DEST_PREFIX) FIND_PROGRAM(POD2MAN pod2man) FIND_PROGRAM(GZIP gzip) @@ -58,9 +58,9 @@ MACRO(POD2MAN PODFILE MANFILE SECTION) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${MANFILE}.${SECTION}.gz - DESTINATION share/man/man${SECTION} + DESTINATION ${MANPAGE_DEST_PREFIX}/man${SECTION} ) -ENDMACRO(POD2MAN PODFILE MANFILE SECTION) +ENDMACRO(POD2MAN PODFILE MANFILE SECTION MANPAGE_DEST_PREFIX) MACRO(ADD_MANPAGE_TARGET) # It is not possible add a dependency to target 'install' diff --git a/conf.d/01-system-paths.conf.in b/conf.d/01-system-paths.conf.in index e97433ba2..e1aaf0bef 100644 --- a/conf.d/01-system-paths.conf.in +++ b/conf.d/01-system-paths.conf.in @@ -16,11 +16,6 @@ # The web account user must have full read/write permission to this folder. ZM_DIR_EVENTS=@ZM_DIR_EVENTS@ -# Full path to the folder images, not directly associated with events, -# are recorded to. -# The web account user must have full read/write permission to this folder. -ZM_DIR_IMAGES=@ZM_DIR_IMAGES@ - # Foldername under the webroot where ZoneMinder looks for optional sound files # to play when an alarm is detected. ZM_DIR_SOUNDS=@ZM_DIR_SOUNDS@ diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 91c34163d..26d31dd2f 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -496,7 +496,6 @@ CREATE TABLE `Monitors` ( `TrackDelay` smallint(5) unsigned, `ReturnLocation` tinyint(3) NOT NULL default '-1', `ReturnDelay` smallint(5) unsigned, - `DefaultView` enum('Events','Control') NOT NULL default 'Events', `DefaultRate` smallint(5) unsigned NOT NULL default '100', `DefaultScale` smallint(5) unsigned NOT NULL default '100', `SignalCheckPoints` INT UNSIGNED NOT NULL default '0', @@ -556,7 +555,12 @@ INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1'); DROP TABLE IF EXISTS `Servers`; CREATE TABLE `Servers` ( `Id` int(10) unsigned NOT NULL auto_increment, + `Protocol` TEXT, `Hostname` TEXT, + `Port` INTEGER UNSIGNED, + `PathToIndex` TEXT, + `PathToZMS` TEXT, + `PathToApi` TEXT, `Name` varchar(64) NOT NULL default '', `State_Id` int(10) unsigned, `Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown', diff --git a/db/zm_update-1.31.47.sql b/db/zm_update-1.31.47.sql index 155fb29cc..714afd133 100644 --- a/db/zm_update-1.31.47.sql +++ b/db/zm_update-1.31.47.sql @@ -1,2 +1 @@ ALTER TABLE Frames MODIFY COLUMN EventId bigint unsigned NOT NULL; - diff --git a/db/zm_update-1.32.3.sql b/db/zm_update-1.32.3.sql index fe38baede..6c3e2c47f 100644 --- a/db/zm_update-1.32.3.sql +++ b/db/zm_update-1.32.3.sql @@ -2,8 +2,361 @@ -- This updates a 1.32.2 database to 1.32.3 -- +delimiter // +DROP TRIGGER IF EXISTS Events_Hour_delete_trigger// +CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour +FOR EACH ROW BEGIN + UPDATE Monitors SET + HourEvents = COALESCE(HourEvents,1)-1, + HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; +END; +// + +DROP TRIGGER IF EXISTS Events_Hour_update_trigger// + +CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour +FOR EACH ROW + BEGIN + declare diff BIGINT default 0; + + set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0); + IF ( diff ) THEN + IF ( NEW.MonitorID != OLD.MonitorID ) THEN + UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId; + UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId; + ELSE + UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId; + END IF; + END IF; + END; +// +DELIMITER ; + +delimiter // +DROP TRIGGER IF EXISTS Events_Day_delete_trigger// +CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day +FOR EACH ROW BEGIN + UPDATE Monitors SET + DayEvents = COALESCE(DayEvents,1)-1, + DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; +END; +// + +DROP TRIGGER IF EXISTS Events_Day_update_trigger; +CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day +FOR EACH ROW + BEGIN + declare diff BIGINT default 0; + + set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0); + IF ( diff ) THEN + IF ( NEW.MonitorID != OLD.MonitorID ) THEN + UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId; + UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId; + ELSE + UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId; + END IF; + END IF; + END; + // + + +DROP TRIGGER IF EXISTS Events_Week_delete_trigger// +CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week +FOR EACH ROW BEGIN + UPDATE Monitors SET + WeekEvents = COALESCE(WeekEvents,1)-1, + WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; +END; +// + +DROP TRIGGER IF EXISTS Events_Week_update_trigger; +CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week +FOR EACH ROW + BEGIN + declare diff BIGINT default 0; + + set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0); + IF ( diff ) THEN + IF ( NEW.MonitorID != OLD.MonitorID ) THEN + UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId; + UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId; + ELSE + UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId; + END IF; + END IF; + END; + // + +DROP TRIGGER IF EXISTS Events_Month_delete_trigger// +CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month +FOR EACH ROW BEGIN + UPDATE Monitors SET + MonthEvents = COALESCE(MonthEvents,1)-1, + MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; +END; +// + +DROP TRIGGER IF EXISTS Events_Month_update_trigger; +CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month +FOR EACH ROW + BEGIN + declare diff BIGINT default 0; + + set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0); + IF ( diff ) THEN + IF ( NEW.MonitorID != OLD.MonitorID ) THEN + UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace) WHERE Monitors.Id=OLD.MonitorId; + UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+COALESCE(NEW.DiskSpace) WHERE Monitors.Id=NEW.MonitorId; + ELSE + UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId; + END IF; + END IF; + END; + // + +drop procedure if exists update_storage_stats// + +drop trigger if exists event_update_trigger// + +CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events +FOR EACH ROW +BEGIN + declare diff BIGINT default 0; + + set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0); + IF ( NEW.StorageId = OLD.StorageID ) THEN + IF ( diff ) THEN + UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + diff WHERE Id = OLD.StorageId; + END IF; + ELSE + IF ( NEW.DiskSpace ) THEN + UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Id = NEW.StorageId; + END IF; + IF ( OLD.DiskSpace ) THEN + UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - OLD.DiskSpace WHERE Id = OLD.StorageId; + END IF; + END IF; + + UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + + IF ( NEW.Archived != OLD.Archived ) THEN + IF ( NEW.Archived ) THEN + INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace); + UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId; + ELSEIF ( OLD.Archived ) THEN + DELETE FROM Events_Archived WHERE EventId=OLD.Id; + UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId; + ELSE + IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN + UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + UPDATE Monitors SET + ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) + WHERE Id=OLD.MonitorId; + END IF; + END IF; + ELSEIF ( NEW.Archived AND diff ) THEN + UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id; + END IF; + + IF ( diff ) THEN + UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId; + END IF; + +END; + +// + +delimiter ; + +DROP TRIGGER IF EXISTS event_insert_trigger; + +delimiter // +/* The assumption is that when an Event is inserted, it has no size yet, so don't bother updating the DiskSpace, just the count. + * The DiskSpace will get update in the Event Update Trigger + */ +CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events +FOR EACH ROW + BEGIN + + INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0); + UPDATE Monitors SET + HourEvents = COALESCE(HourEvents,0)+1, + DayEvents = COALESCE(DayEvents,0)+1, + WeekEvents = COALESCE(WeekEvents,0)+1, + MonthEvents = COALESCE(MonthEvents,0)+1, + TotalEvents = COALESCE(TotalEvents,0)+1 + WHERE Id=NEW.MonitorId; +END; +// + +DROP TRIGGER IF EXISTS event_delete_trigger// + +CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events +FOR EACH ROW +BEGIN + IF ( OLD.DiskSpace ) THEN + UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - CAST(OLD.DiskSpace AS SIGNED) WHERE Id = OLD.StorageId; + END IF; + DELETE FROM Events_Hour WHERE EventId=OLD.Id; + DELETE FROM Events_Day WHERE EventId=OLD.Id; + DELETE FROM Events_Week WHERE EventId=OLD.Id; + DELETE FROM Events_Month WHERE EventId=OLD.Id; + IF ( OLD.Archived ) THEN + DELETE FROM Events_Archived WHERE EventId=OLD.Id; + UPDATE Monitors SET + ArchivedEvents = COALESCE(ArchivedEvents,1) - 1, + ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0), + TotalEvents = COALESCE(TotalEvents,1) - 1, + TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; + ELSE + UPDATE Monitors SET + TotalEvents = COALESCE(TotalEvents,1)-1, + TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) + WHERE Id=OLD.MonitorId; + END IF; +END; + +// + +DROP TRIGGER IF EXISTS Zone_Insert_Trigger// +CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones +FOR EACH ROW + BEGIN + UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID; + END +// +DROP TRIGGER IF EXISTS Zone_Delete_Trigger// +CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones +FOR EACH ROW + BEGIN + UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID; + END +// + +DELIMITER ; + +REPLACE INTO Events_Day SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 day); +REPLACE INTO Events_Week SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 week); +REPLACE INTO Events_Month SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 month); +REPLACE INTO Events_Archived SELECT Id,MonitorId,DiskSpace FROM Events WHERE Archived=1; + +UPDATE Monitors INNER JOIN ( + SELECT MonitorId, + COUNT(Id) AS TotalEvents, + SUM(DiskSpace) AS TotalEventDiskSpace, + SUM(IF(Archived,1,0)) AS ArchivedEvents, + SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents, + SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace + FROM Events GROUP BY MonitorId + ) AS E ON E.MonitorId=Monitors.Id SET + Monitors.TotalEvents = E.TotalEvents, + Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace, + Monitors.ArchivedEvents = E.ArchivedEvents, + Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace, + Monitors.HourEvents = E.HourEvents, + Monitors.HourEventDiskSpace = E.HourEventDiskSpace, + Monitors.DayEvents = E.DayEvents, + Monitors.DayEventDiskSpace = E.DayEventDiskSpace, + Monitors.WeekEvents = E.WeekEvents, + Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace, + Monitors.MonthEvents = E.MonthEvents, + Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace; + -- --- Add some additional monitor preset values +-- Add Protocol column to Storage -- -INSERT INTO MonitorPresets VALUES (NULL,'D-link DCS-930L, 640x480, mjpeg','Remote','http',0,0,'http','simple','',80,'/mjpeg.cgi',NULL,640,480,3,NULL,0,NULL,NULL,NULL,100,100); +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'Protocol' + ) > 0, +"SELECT 'Column Protocol already exists in Servers'", +"ALTER TABLE Servers ADD `Protocol` TEXT AFTER `Id`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add PathToIndex column to Storage +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'PathToIndex' + ) > 0, +"SELECT 'Column PathToIndex already exists in Servers'", +"ALTER TABLE Servers ADD `PathToIndex` TEXT AFTER `Hostname`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add PathToZMS column to Storage +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'PathToZMS' + ) > 0, +"SELECT 'Column PathToZMS already exists in Servers'", +"ALTER TABLE Servers ADD `PathToZMS` TEXT AFTER `PathToIndex`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add PathToApi column to Storage +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'PathToApi' + ) > 0, +"SELECT 'Column PathToApi already exists in Servers'", +"ALTER TABLE Servers ADD `PathToApi` TEXT AFTER `PathToZMS`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +-- +-- Add Port column to Storage +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Servers' + AND column_name = 'Port' + ) > 0, +"SELECT 'Column Port already exists in Servers'", +"ALTER TABLE Servers ADD `Port` INTEGER UNSIGNED AFTER `Hostname`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; diff --git a/db/zm_update-1.33.0.sql b/db/zm_update-1.33.0.sql new file mode 100644 index 000000000..cc7a257c7 --- /dev/null +++ b/db/zm_update-1.33.0.sql @@ -0,0 +1,21 @@ +-- +-- This updates a 1.32.3 database to 1.33.0 +-- +-- +-- Remove DefaultView from Monitors table. +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'DefaultView' + ) > 0, +"ALTER TABLE Monitors DROP COLUMN DefaultView", +"SELECT 'Column DefaultView no longer exists in Monitors'" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + diff --git a/distros/debian/rules b/distros/debian/rules index fe725c2d0..6185838e0 100755 --- a/distros/debian/rules +++ b/distros/debian/rules @@ -24,7 +24,6 @@ override_dh_auto_configure: -DZM_CONFIG_SUBDIR="/etc/zm/conf.d" \ -DZM_CONFIG_DIR="/etc/zm" \ -DZM_DIR_EVENTS="/var/cache/zoneminder/events" \ - -DZM_DIR_IMAGES="/var/cache/zoneminder/images" \ -DZM_PATH_ZMS="/zm/cgi-bin/nph-zms" override_dh_auto_install: diff --git a/distros/redhat/CMakeLists.txt b/distros/redhat/CMakeLists.txt index d940942c1..f1a1bc75b 100644 --- a/distros/redhat/CMakeLists.txt +++ b/distros/redhat/CMakeLists.txt @@ -1,5 +1,10 @@ # CMakeLists.txt for the Redhat Target Distros. +# +# General strategy is to configure and install all files specific to Apache and Nginx +# Then let the rpm specfile sort them into the appropriate sub-package +# + # Display a message to show the RHEL build options are being processed. if(ZM_TARGET_DISTRO MATCHES "^el") message([STATUS] "Starting RHEL Build Options" ...) @@ -9,39 +14,62 @@ else(ZM_TARGET_DISTRO MATCHES "^el") message([WARNING] "Unknown Build Option Detected" ...) endif(ZM_TARGET_DISTRO MATCHES "^el") -if((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx")) - message([FATAL_ERROR] "Experimental Nginx support is currently only supported on Fedora" ...) -endif((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx")) +# +# CONFIGURE STAGE +# -# Configure the zoneminder service files -configure_file(systemd/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY) -if(ZM_WEB_USER STREQUAL "nginx") - configure_file(nginx/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY) - configure_file(nginx/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY) - configure_file(nginx/zoneminder.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.tmpfiles @ONLY) - configure_file(nginx/zoneminder.php-fpm.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.php-fpm.conf @ONLY) - configure_file(nginx/README.Fedora ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY) -else(ZM_WEB_USER STREQUAL "nginx") - configure_file(systemd/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY) - configure_file(apache/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY) - configure_file(systemd/zoneminder.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.tmpfiles @ONLY) - if( ZM_TARGET_DISTRO MATCHES "^fc") - configure_file(readme/README.Fedora ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY) - else( ZM_TARGET_DISTRO MATCHES "^fc") - configure_file(readme/README.Redhat7 ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY) - endif( ZM_TARGET_DISTRO MATCHES "^fc") -endif(ZM_WEB_USER STREQUAL "nginx") +# Configure the common zoneminder files +configure_file(common/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY) +configure_file(common/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY) +file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events temp) -# Create several empty folders -file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events images temp) +# Configure the Apache zoneminder files +configure_file(httpd/zm-httpd.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zm-httpd.conf @ONLY) +configure_file(httpd/zoneminder.httpd.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.httpd.conf @ONLY) +configure_file(httpd/zoneminder.httpd.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.httpd.tmpfiles.conf @ONLY) +configure_file(httpd/com.zoneminder.systemctl.rules.httpd.in ${CMAKE_CURRENT_SOURCE_DIR}/com.zoneminder.systemctl.rules.httpd @ONLY) + +# Configure the Nginx zoneminder files +configure_file(nginx/zm-nginx.conf ${CMAKE_CURRENT_SOURCE_DIR}/zm-nginx.conf COPYONLY) +configure_file(nginx/zoneminder.nginx.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.nginx.conf @ONLY) +configure_file(nginx/redirect.nginx.conf ${CMAKE_CURRENT_SOURCE_DIR}/redirect.nginx.conf COPYONLY) +configure_file(nginx/zoneminder.nginx.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.nginx.tmpfiles.conf @ONLY) +configure_file(nginx/zm-web-user.conf ${CMAKE_CURRENT_SOURCE_DIR}/zm-web-user.conf COPYONLY) +configure_file(nginx/zoneminder.php-fpm.conf ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.php-fpm.conf COPYONLY) +configure_file(nginx/com.zoneminder.systemctl.rules.nginx ${CMAKE_CURRENT_SOURCE_DIR}/com.zoneminder.systemctl.rules.nginx COPYONLY) + +# +# INSTALLATION STAGE +# + + +# Install the common zoneminder files +install(FILES zoneminder.logrotate DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) -# Install the empty folders install(DIRECTORY sock swap DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(DIRECTORY zoneminder DESTINATION /var/log DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(DIRECTORY zoneminder DESTINATION /var/run DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(DIRECTORY zoneminder DESTINATION /var/cache DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) -install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY events temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +# Install the Apache zoneminder files +install(FILES zm-httpd.conf DESTINATION /usr/lib/systemd/system/zoneminder.service.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.httpd.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.httpd.tmpfiles.conf DESTINATION /usr/lib/tmpfiles.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES com.zoneminder.systemctl.rules.httpd DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + +# Install the Nginx zoneminder files +install(FILES zm-nginx.conf DESTINATION /usr/lib/systemd/system/zoneminder.service.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.nginx.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES redirect.nginx.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.nginx.tmpfiles.conf DESTINATION /usr/lib/tmpfiles.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES com.zoneminder.systemctl.rules.nginx DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zm-web-user.conf DESTINATION /etc/zm/conf.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.php-fpm.conf DESTINATION /etc/php-fpm.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + +# Miscellaneous # Symlink the cake php temp folder to the ZoneMinder temp folder install(CODE "execute_process(COMMAND ln -sf ../../../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/api/app/tmp\")") @@ -50,16 +78,5 @@ install(CODE "execute_process(COMMAND ln -sf ../../../../../../var/lib/zoneminde install(CODE "execute_process(COMMAND ln -sf ../../java/cambozola.jar \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/cambozola.jar\")") # Install auxiliary files -install(FILES misc/redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - -# Install zoneminder service files -install(FILES zoneminder.logrotate DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) -install(FILES zoneminder.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -if(ZM_WEB_USER STREQUAL "nginx") - install(FILES zoneminder.php-fpm.conf DESTINATION /etc/php-fpm.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME zoneminder.conf) -endif(ZM_WEB_USER STREQUAL "nginx") - -install(FILES zoneminder.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) -install(FILES zoneminder.tmpfiles DESTINATION /usr/lib/tmpfiles.d RENAME zoneminder.conf PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES common/redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/distros/redhat/misc/redalert.wav b/distros/redhat/common/redalert.wav similarity index 100% rename from distros/redhat/misc/redalert.wav rename to distros/redhat/common/redalert.wav diff --git a/distros/redhat/common/zoneminder.logrotate.in b/distros/redhat/common/zoneminder.logrotate.in new file mode 100644 index 000000000..210a84c07 --- /dev/null +++ b/distros/redhat/common/zoneminder.logrotate.in @@ -0,0 +1,12 @@ +@ZM_LOGDIR@/*.log { + missingok + notifempty + sharedscripts + delaycompress + compress + postrotate + @BINDIR@/zmpkg.pl logrot > /dev/null 2>/dev/null || true + endscript + daily + rotate 7 +} diff --git a/distros/redhat/systemd/zoneminder.service.in b/distros/redhat/common/zoneminder.service.in similarity index 76% rename from distros/redhat/systemd/zoneminder.service.in rename to distros/redhat/common/zoneminder.service.in index 68918ab9e..8551a60e2 100644 --- a/distros/redhat/systemd/zoneminder.service.in +++ b/distros/redhat/common/zoneminder.service.in @@ -1,13 +1,12 @@ # ZoneMinder systemd unit file for RedHat distros and clones +# See drop-in folder for additional config directives [Unit] Description=ZoneMinder CCTV recording and security system -After=network.target mariadb.service httpd.service -Requires=mariadb.service httpd.service +After=network.target mariadb.service +Requires=mariadb.service [Service] -User=@WEB_USER@ -Group=@WEB_GROUP@ Type=forking ExecStart=@BINDIR@/zmpkg.pl start ExecReload=@BINDIR@/zmpkg.pl restart diff --git a/distros/redhat/httpd/com.zoneminder.systemctl.rules.httpd.in b/distros/redhat/httpd/com.zoneminder.systemctl.rules.httpd.in new file mode 100644 index 000000000..d101dad69 --- /dev/null +++ b/distros/redhat/httpd/com.zoneminder.systemctl.rules.httpd.in @@ -0,0 +1,7 @@ +polkit.addRule(function(action, subject) { + if (action.id == "com.zoneminder.policykit.pkexec.run-zmsystemctl" && + subject.user != "@WEB_USER@") { + return polkit.Result.NO; + } + +}); diff --git a/distros/redhat/httpd/zm-httpd.conf.in b/distros/redhat/httpd/zm-httpd.conf.in new file mode 100644 index 000000000..1a00d8d9b --- /dev/null +++ b/distros/redhat/httpd/zm-httpd.conf.in @@ -0,0 +1,8 @@ +# Additional config directives for ZoneMinder with Apache web server + +[Unit] +After=httpd.service + +[Service] +User=@WEB_USER@ +Group=@WEB_GROUP@ diff --git a/distros/redhat/apache/zoneminder.conf.in b/distros/redhat/httpd/zoneminder.httpd.conf.in similarity index 100% rename from distros/redhat/apache/zoneminder.conf.in rename to distros/redhat/httpd/zoneminder.httpd.conf.in diff --git a/distros/redhat/systemd/zoneminder.tmpfiles.in b/distros/redhat/httpd/zoneminder.httpd.tmpfiles.in similarity index 79% rename from distros/redhat/systemd/zoneminder.tmpfiles.in rename to distros/redhat/httpd/zoneminder.httpd.tmpfiles.in index 21e6119fe..b403fb24d 100644 --- a/distros/redhat/systemd/zoneminder.tmpfiles.in +++ b/distros/redhat/httpd/zoneminder.httpd.tmpfiles.in @@ -2,4 +2,4 @@ D @ZM_TMPDIR@ 0755 @WEB_USER@ @WEB_GROUP@ D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@ D @ZM_CACHEDIR@ 0755 @WEB_USER@ @WEB_GROUP@ d @ZM_DIR_EVENTS@ 0755 @WEB_USER@ @WEB_GROUP@ -D @ZM_DIR_IMAGES@ 0755 @WEB_USER@ @WEB_GROUP@ + diff --git a/distros/redhat/misc/local_zoneminder.te b/distros/redhat/misc/local_zoneminder.te deleted file mode 100644 index c49505785..000000000 --- a/distros/redhat/misc/local_zoneminder.te +++ /dev/null @@ -1,125 +0,0 @@ -module local_zoneminder 1.2; - -require { - type afs_ka_port_t; - type netsupport_port_t; - type port_t; - type presence_port_t; - type postfix_master_t; - type postfix_qmgr_t; - type postfix_pickup_t; - type httpd_t; - type var_lib_t; - type ionixnetmon_port_t; - type glance_port_t; - type mmcc_port_t; - type postfix_master_t; - type commplex_port_t; - type syslogd_port_t; - type dcc_port_t; - type sip_port_t; - type amqp_port_t; - type condor_port_t; - type afs_fs_port_t; - type nodejs_debug_port_t; - type httpd_var_lib_t; - type websm_port_t; - type afs_pt_port_t; - type postfix_qmgr_t; - type git_port_t; - type ipp_port_t; - type aol_port_t; - type unconfined_t; - type kernel_t; - type init_t; - type auditd_t; - type mysqld_t; - type httpd_log_t; - type syslogd_t; - type httpd_t; - type initrc_state_t; - type initrc_t; - type var_lib_t; - type udev_t; - type mysqld_safe_t; - type sshd_t; - type crond_t; - type getty_t; - type httpd_var_lib_t; - type initrc_var_run_t; - type tmpfs_t; - type dhcpc_t; - type v4l_device_t; - type file_t; - class sock_file { write create unlink }; - class unix_stream_socket { read connectto }; - class lnk_file { write create getattr read lock unlink }; - class dir {search getattr }; - class udp_socket name_bind; - class file { write getattr read lock unlink open }; - class shm { unix_read unix_write associate read write getattr }; - class chr_file getattr; -} - -#============= httpd_t ============== -allow httpd_t auditd_t:dir { search getattr }; -allow httpd_t auditd_t:file { read getattr open }; -allow httpd_t crond_t:dir { search getattr }; -allow httpd_t crond_t:file { read getattr open }; -allow httpd_t dhcpc_t:dir { search getattr }; -allow httpd_t dhcpc_t:file { read getattr open }; -allow httpd_t getty_t:dir { search getattr }; -allow httpd_t getty_t:file { read getattr open }; -allow httpd_t httpd_log_t:file write; -allow httpd_t httpd_var_lib_t:lnk_file { write getattr read lock unlink }; -allow httpd_t init_t:dir { search getattr }; -allow httpd_t init_t:file { read getattr open }; -#!!!! The source type 'httpd_t' can write to a 'file' of the following types: -#squirrelmail_spool_t, mirrormanager_var_run_t, dirsrvadmin_config_t, httpd_lock_t, httpd_tmp_t, dirsrv_config_t, dirsrvadmin_tmp_t, httpd_cache_t, httpd_tmpfs_t, httpd_squirrelmail_t, dirsrv_var_run_t, dirsrv_var_log_t, httpd_var_lib_t, httpd_var_run_t, zarafa_var_lib_t, httpd_prewikka_rw_content_t, httpd_mediawiki_rw_content_t, httpd_squid_rw_content_t, passenger_var_run_t, httpd_smokeping_cgi_rw_content_t, httpd_openshift_rw_content_t, httpd_dirsrvadmin_rw_content_t, httpd_w3c_validator_rw_content_t, httpd_collectd_rw_content_t, cluster_var_lib_t, cluster_var_run_t, httpd_user_rw_content_t, httpd_awstats_rw_content_t, httpdcontent, root_t, httpd_cobbler_rw_content_t, httpd_munin_rw_content_t, cluster_conf_t, httpd_bugzilla_rw_content_t, passenger_tmp_t, httpd_cvs_rw_content_t, httpd_git_rw_content_t, httpd_sys_rw_content_t, httpd_sys_rw_content_t, httpd_nagios_rw_content_t, httpd_apcupsd_cgi_rw_content_t, httpd_nutups_cgi_rw_content_t, httpd_dspam_rw_content_t - -allow httpd_t initrc_state_t:file { read write getattr unlink open }; -allow httpd_t initrc_t:unix_stream_socket connectto; -allow httpd_t initrc_t:shm { unix_read unix_write associate read write getattr }; -allow httpd_t initrc_var_run_t:file { write read lock open }; -allow httpd_t kernel_t:dir { search getattr }; -allow httpd_t kernel_t:file { read getattr open }; -allow httpd_t mysqld_safe_t:dir { search getattr }; -allow httpd_t mysqld_safe_t:file { read getattr open }; -allow httpd_t mysqld_t:dir { search getattr }; -allow httpd_t mysqld_t:file { read getattr open }; -allow httpd_t sshd_t:dir { search getattr }; -allow httpd_t sshd_t:file { read getattr open }; -allow httpd_t syslogd_t:dir { search getattr }; -allow httpd_t syslogd_t:file { read getattr open }; -allow httpd_t tmpfs_t:sock_file write; -allow httpd_t udev_t:dir { search getattr }; -allow httpd_t udev_t:file { read getattr open }; -allow httpd_t unconfined_t:dir { search getattr }; -allow httpd_t unconfined_t:file { read getattr open }; -allow httpd_t var_lib_t:lnk_file { write getattr read lock unlink }; -allow httpd_t var_lib_t:sock_file { write unlink }; -allow httpd_t v4l_device_t:chr_file getattr; -allow httpd_t afs_fs_port_t:udp_socket name_bind; -allow httpd_t afs_ka_port_t:udp_socket name_bind; -allow httpd_t afs_pt_port_t:udp_socket name_bind; -allow httpd_t amqp_port_t:udp_socket name_bind; -allow httpd_t aol_port_t:udp_socket name_bind; -allow httpd_t commplex_port_t:udp_socket name_bind; -allow httpd_t condor_port_t:udp_socket name_bind; -allow httpd_t dcc_port_t:udp_socket name_bind; -allow httpd_t git_port_t:udp_socket name_bind; -allow httpd_t glance_port_t:udp_socket name_bind; -allow httpd_t httpd_var_lib_t:lnk_file create; -allow httpd_t ionixnetmon_port_t:udp_socket name_bind; -allow httpd_t ipp_port_t:udp_socket name_bind; -allow httpd_t mmcc_port_t:udp_socket name_bind; -allow httpd_t netsupport_port_t:udp_socket name_bind; -allow httpd_t nodejs_debug_port_t:udp_socket name_bind; -allow httpd_t port_t:udp_socket name_bind; -allow httpd_t postfix_master_t:dir { search getattr }; -allow httpd_t postfix_master_t:file { read getattr open }; -allow httpd_t postfix_pickup_t:dir { search getattr }; -allow httpd_t postfix_pickup_t:file { read getattr open }; -allow httpd_t postfix_qmgr_t:dir { search getattr }; -allow httpd_t postfix_qmgr_t:file { read getattr open }; -allow httpd_t presence_port_t:udp_socket name_bind; diff --git a/distros/redhat/nginx/README.Fedora b/distros/redhat/nginx/README.Fedora deleted file mode 100644 index 0a5168231..000000000 --- a/distros/redhat/nginx/README.Fedora +++ /dev/null @@ -1,165 +0,0 @@ -What's New -========== - -1. This is an *experimental* build of zoneminder which uses the - nginx web server. - -2. The Apache ScriptAlias has been changed from "/cgi-bin/zm/zms" to - "/cgi-bin-zm/zms". This has been to done to avoid this bug: - https://bugzilla.redhat.com/show_bug.cgi?id=973067 - - IMPORTANT: You must manually inspect the value for PATH_ZMS under Options - and verify it is set to "/cgi-bin-zm/nph-zms". Failure to do so will result - in a broken system. You have been warned. - -3. Due to the active state of the ZoneMinder project, we now recommend granting - ALL permission to the ZoneMinder mysql account. This change must be done - manually before ZoneMinder will run. See the installation steps below. - -4. This package uses the HTTPS protocol by default to access the web portal. - Requests using HTTP will auto-redirect to HTTPS. See README.https for - more information. - -5. This package ships with the new ZoneMinder API enabled. - -New installs -============ - -1. This package supports either community-mysql-server or mariadb-server with - mariadb being the preferred choice. Unless you are already using MariaDB or - Mysql server, you need to ensure that the server is configured to start - during boot and properly secured by running: - - sudo dnf install mariadb-server - sudo systemctl enable mariadb - sudo systemctl start mariadb.service - mysql_secure_installation - -2. Assuming the database is local and using the password for the root account - set during the previous step, you will need to create the ZoneMinder - database and configure a database account for ZoneMinder to use: - - mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql - mysql -uroot -p -e "grant all on zm.* to \ - 'zmuser'@localhost identified by 'zmpass';" - mysqladmin -uroot -p reload - - The database account credentials, zmuser/zmpass, are arbitrary. Set them to - anything that suits your environment. - -3. If you have chosen to change the zoneminder database account credentials to - something other than zmuser/zmpass, you must now edit /etc/zm/zm.conf. - Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous - step. - - This version of zoneminder no longer requires you to make a similar change - to the credentials in /usr/share/zoneminder/www/api/app/Config/database.php - This now happens dynamically. Do *not* make any changes to this file. - -4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local - timezone. PHP will complain loudly if this is not set, or if it is set - incorrectly, and these complaints will show up in the zoneminder logging - system as errors. - - If you are not sure of the proper timezone specification to use, look at - http://php.net/date.timezone - -5. Disable SELinux - - We currently do not have the resources to create and maintain an accurate - SELinux policy for ZoneMinder on Fedora. We will gladly accept pull - reqeusts from anyone who wishes to do the work. In the meantime, SELinux - will need to be disabled or put into permissive mode. - - To immediately disbale SELinux for the current seesion, issue the following - from the command line: - - sudo setenforce 0 - - To permanently disable SELinux, edit /etc/selinux/config and change the - SELINUX line from "enforcing" to "disabled". This change will take - effect after a reboot. - -6. This package comes preconfigured for HTTPS using the default self signed - certificate on your system. We recommend you keep this configuration. - - If this does not meet your needs, then read README.https to - learn about alternatives. - -7. Edit /etc/sysconfig/fcgiwrap and set DAEMON_PROCS to the maximum number of - simulatneous streams the server should support. Generally, a good minimum - value for this equals the total number of cameras you expect to view at the - same time. - -8. Now start the web server: - - sudo systemctl enable nginx - sudo systemctl start nginx - -9. Now start zoneminder: - - sudo systemctl enable zoneminder - sudo systemctl start zoneminder - -10.The Fedora repos have a ZoneMinder package available, but it does not - support ffmpeg or libvlc, which many modern IP cameras require. Most users - will want to prevent the ZoneMinder package in the Fedora repos from - overwriting the ZoneMinder package in zmrepo, during a future dnf update. To - prevent that from happening you must edit /etc/yum.repos.d/fedora.repo - and /etc/yum.repos.d/fedora-updates.repo. Add the line "exclude=zoneminder*" - without the quotes under the [fedora] and [fedora-updates] blocks, - respectively. - -Upgrades -======== - -1. Verify /etc/zm/zm.conf. - - If zm.conf was manually edited before running the upgrade, the installation - may not overwrite it. In this case, it will create the file - /etc/zm/zm.conf.rpmnew. - - For example, this will happen if you are using database account credentials - other than zmuser/zmpass. - - Compare /etc/zm/zm.conf to /etc/zm/zm.conf.rpmnew. Verify that zm.conf - contains any new config settings that may be in zm.conf.rpmnew. - - This version of zoneminder no longer requires you to make a similar change - to the credentials in /usr/share/zoneminder/www/api/app/Config/database.php - This now happens dynamically. Do *not* make any changes to this file. - -2. Verify permissions of the zmuser account. - - Over time, the database account permissions required for normal operation - have increased. Verify the zmuser database account has been granted all - permission to the ZoneMinder database: - - mysql -uroot -p -e "show grants for zmuser@localhost;" - - See step 2 of the Installation section to add missing permissions. - -3. Verify the ZoneMinder Apache configuration file in the folder - /etc/httpd/conf.d. You will have a file called "zoneminder.conf" and there - may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file - exists, inspect it and merge anything new in that file with zoneminder.conf. - Verify the SSL REquirements meet your needs. Read README.https if necessary. - -4. Upgrade the database before starting ZoneMinder. - - Most upgrades can be performed by executing the following command: - - sudo zmupdate.pl - - Recent versions of ZoneMinder don't require any parameters added to the - zmupdate command. However, if ZoneMinder complains, you may need to call - zmupdate in the following manner: - - sudo zmupdate.pl --user=root --pass= --version= - -5. Now restart nginx and php-fpm then start and zoneminder: - - sudo systemctl restart nginx - sudo systemctl restart php-fpm - sudo systemctl start zoneminder - diff --git a/distros/redhat/nginx/com.zoneminder.systemctl.rules.nginx b/distros/redhat/nginx/com.zoneminder.systemctl.rules.nginx new file mode 100644 index 000000000..8eaa78d5c --- /dev/null +++ b/distros/redhat/nginx/com.zoneminder.systemctl.rules.nginx @@ -0,0 +1,7 @@ +polkit.addRule(function(action, subject) { + if (action.id == "com.zoneminder.policykit.pkexec.run-zmsystemctl" && + subject.user != "nginx") { + return polkit.Result.NO; + } + +}); diff --git a/distros/redhat/nginx/redirect.nginx.conf b/distros/redhat/nginx/redirect.nginx.conf new file mode 100644 index 000000000..67ef08124 --- /dev/null +++ b/distros/redhat/nginx/redirect.nginx.conf @@ -0,0 +1,2 @@ +# Auto redirect to https +return 301 https://$host$request_uri; diff --git a/distros/redhat/nginx/zm-nginx.conf b/distros/redhat/nginx/zm-nginx.conf new file mode 100644 index 000000000..5f0319b17 --- /dev/null +++ b/distros/redhat/nginx/zm-nginx.conf @@ -0,0 +1,9 @@ +# Additional config directives for ZoneMinder with Nginx web server + +[Unit] +After=nginx.service php-fpm.service fcgiwrap.service +Requires=php-fpm.service fcgiwrap@nginx.service + +[Service] +User=nginx +Group=nginx diff --git a/distros/redhat/nginx/zm-web-user.conf b/distros/redhat/nginx/zm-web-user.conf new file mode 100644 index 000000000..3146679fd --- /dev/null +++ b/distros/redhat/nginx/zm-web-user.conf @@ -0,0 +1,3 @@ +ZM_WEB_USER=nginx +ZM_WEB_GROUP=nginx + diff --git a/distros/redhat/nginx/zoneminder.conf.in b/distros/redhat/nginx/zoneminder.conf.in deleted file mode 100644 index b8ffd816a..000000000 --- a/distros/redhat/nginx/zoneminder.conf.in +++ /dev/null @@ -1,49 +0,0 @@ -listen 443 ssl; -listen [::]:443 ssl; - -ssl_certificate "/etc/pki/tls/certs/localhost.crt"; -ssl_certificate_key "/etc/pki/tls/private/localhost.key"; -ssl_session_cache shared:SSL:1m; -ssl_session_timeout 10m; -ssl_ciphers PROFILE=SYSTEM; -ssl_prefer_server_ciphers on; - -# Auto-redirect HTTP requests to HTTPS -if ($scheme != "https") { - rewrite ^/?(zm)(.*)$ https://$host/$1$2 permanent; -} - -location /cgi-bin-zm { - gzip off; - alias "@ZM_CGIDIR@"; - - include /etc/nginx/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $request_filename; - fastcgi_pass unix:/run/fcgiwrap.sock; -} - -location /zm { - gzip off; - alias "@ZM_WEBDIR@"; - index index.php; - - location ~ \.php$ { - if (!-f $request_filename) { return 404; } - expires epoch; - include /etc/nginx/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $request_filename; - fastcgi_index index.php; - fastcgi_pass unix:/run/php-fpm/www.sock; - } - - location ~ \.(jpg|jpeg|gif|png|ico)$ { - access_log off; - expires 33d; - } - - location /zm/api/ { - alias "@ZM_WEBDIR@"; - rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last; - } -} - diff --git a/distros/redhat/nginx/zoneminder.nginx.conf.in b/distros/redhat/nginx/zoneminder.nginx.conf.in new file mode 100644 index 000000000..2976a83b2 --- /dev/null +++ b/distros/redhat/nginx/zoneminder.nginx.conf.in @@ -0,0 +1,57 @@ +server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + server_name = localhost $hostname; + + ssl_certificate "/etc/pki/tls/certs/localhost.crt"; + ssl_certificate_key "/etc/pki/tls/private/localhost.key"; + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 10m; + ssl_ciphers PROFILE=SYSTEM; + ssl_prefer_server_ciphers on; + + # Auto redirect to server/zm when no url suffix was given + location = / { + return 301 zm; + } + + location /cgi-bin-zm { + gzip off; + alias "@ZM_CGIDIR@"; + + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass unix:/run/fcgiwrap/fcgiwrap-nginx.sock; + } + + location /zm/cache { + alias "@ZM_CACHEDIR@"; + } + + location /zm { + gzip off; + alias "@ZM_WEBDIR@"; + index index.php; + + location ~ \.php$ { + try_files $uri =404; + expires epoch; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_index index.php; + fastcgi_pass unix:/run/php-fpm/www.sock; + } + + location ~ \.(jpg|jpeg|gif|png|ico)$ { + access_log off; + expires 33d; + } + + location /zm/api/ { + alias "@ZM_WEBDIR@"; + rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last; + } + } + +} + diff --git a/distros/redhat/nginx/zoneminder.nginx.tmpfiles.in b/distros/redhat/nginx/zoneminder.nginx.tmpfiles.in new file mode 100644 index 000000000..502b817d8 --- /dev/null +++ b/distros/redhat/nginx/zoneminder.nginx.tmpfiles.in @@ -0,0 +1,5 @@ +D @ZM_TMPDIR@ 0755 nginx nginx +D @ZM_SOCKDIR@ 0755 nginx nginx +D @ZM_CACHEDIR@ 0755 nginx nginx +d @ZM_DIR_EVENTS@ 0755 nginx nginx + diff --git a/distros/redhat/nginx/zoneminder.php-fpm.conf b/distros/redhat/nginx/zoneminder.php-fpm.conf new file mode 100644 index 000000000..cd60a5120 --- /dev/null +++ b/distros/redhat/nginx/zoneminder.php-fpm.conf @@ -0,0 +1,14 @@ +; This config file is needed when using ZoneMinder with web servers other +; than Apache. You can ignore this file if you are using Apache web server. +; Change the user and group of the default pool to the web server account +[www] + +user = nginx +group = nginx + +; These parameters are typically a tradoff between performance and memory +; consumption. See the contents of www.conf for details. + +pm = ondemand +pm.max_children = 50 +pm.process_idle_timeout = 10s diff --git a/distros/redhat/nginx/zoneminder.php-fpm.conf.in b/distros/redhat/nginx/zoneminder.php-fpm.conf.in deleted file mode 100644 index 26e8c62cf..000000000 --- a/distros/redhat/nginx/zoneminder.php-fpm.conf.in +++ /dev/null @@ -1,10 +0,0 @@ -# Change the user and group of the default pool to the web server account -[www] - -user = @WEB_USER@ -group = @WEB_GROUP@ - -# Uncomment these on machines with little memory -#pm = ondemand -#pm.max_children = 10 -#pm.process_idle_timeout = 10s diff --git a/distros/redhat/nginx/zoneminder.service.in b/distros/redhat/nginx/zoneminder.service.in deleted file mode 100644 index 7e2e36585..000000000 --- a/distros/redhat/nginx/zoneminder.service.in +++ /dev/null @@ -1,22 +0,0 @@ -# ZoneMinder systemd unit file for Fedora -# Replace mariadb with community-mysql if using mysql service instead of mariadb - -[Unit] -Description=ZoneMinder CCTV recording and security system -After=network.target mariadb.service nginx.service php-fpm.service fcgiwrap.service -Requires=mariadb.service nginx.service php-fpm.service fcgiwrap.service - -[Service] -User=@WEB_USER@ -Group=@WEB_GROUP@ -Type=forking -ExecStart=@BINDIR@/zmpkg.pl start -ExecReload=@BINDIR@/zmpkg.pl restart -ExecStop=@BINDIR@/zmpkg.pl stop -PIDFile=@ZM_RUNDIR@/zm.pid -Environment=TZ=/etc/localtime -RuntimeDirectory=zoneminder -RuntimeDirectoryMode=0755 - -[Install] -WantedBy=multi-user.target diff --git a/distros/redhat/nginx/zoneminder.tmpfiles.in b/distros/redhat/nginx/zoneminder.tmpfiles.in deleted file mode 100644 index 8040a7877..000000000 --- a/distros/redhat/nginx/zoneminder.tmpfiles.in +++ /dev/null @@ -1,5 +0,0 @@ -D @ZM_TMPDIR@ 0755 @WEB_USER@ @WEB_GROUP@ -D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@ -D /var/lib/php/session 770 root @WEB_GROUP@ -D /var/lib/php/wsdlcache 770 root @WEB_GROUP@ - diff --git a/distros/redhat/readme/README b/distros/redhat/readme/README new file mode 100644 index 000000000..0b3e4bb9c --- /dev/null +++ b/distros/redhat/readme/README @@ -0,0 +1,36 @@ +What's New +========== + +1. See the ZoneMinder release notes for a list of new features: + https://github.com/ZoneMinder/zoneminder/releases + +2. The contents of the ZoneMinder Apache config file have changed. In + addition, this ZoneMinder package now requires you to manually symlink the + ZoneMinder Apache config file. See new install step 6 and upgrade step 3 + in the appropriate README for details. + +3. This package has been split into sub-packages to allow compatibility with + other web servers. Here is a breakdown of the available packages: + + zoneminder - Meta-package installs zoneminder-common and zoneminder-httpd + This exists soley for backwards compatibility. + zoneminder-common - Common files that do not differ based on the web server + zoneminder-httpd - Files needed for compatibility with the Apache web server + zoneminder-nginx - Files needed for compatibility with the Nginx web server + + You can switch between different subpackages with dnf/yum. Be advised that, + switching between httpd <-> nginx requires manaully changing ownership of + all event folders and the php session folder after the change. + +4. If you have installed ZoneMinder from the FedBerry repositories, this build + of ZoneMinder has support for Raspberry Pi hardware acceleration when using + ffmpeg. Unforunately, there is a problem with the same hardware acceleration + when using libvlc. Consequently, libvlc support in this build of ZoneMinder + has been disabled until the problem is resolved. See the following bug + report for details: https://trac.videolan.org/vlc/ticket/18594 + +5. Continue on to the next README that corresponds to the chosen webserver: + + README.httpd - Follow these steps when using Apache + README.nginx - Follow these steps when using Nginx + diff --git a/distros/redhat/readme/README.Fedora b/distros/redhat/readme/README.httpd similarity index 89% rename from distros/redhat/readme/README.Fedora rename to distros/redhat/readme/README.httpd index 9c5061e28..5301850df 100644 --- a/distros/redhat/readme/README.Fedora +++ b/distros/redhat/readme/README.httpd @@ -1,17 +1,8 @@ -What's New -========== - -1. See the ZoneMinder release notes for a list of new features: - https://github.com/ZoneMinder/zoneminder/releases - -2. The contents of the ZoneMinder Apache config file have changed. In - addition, this ZoneMinder package now requires you to manually symlink the - ZoneMinder Apache config file. See new install step 6 and upgrade step 3 - below for details. - New installs ============ +NOTE: EL7 users should replace "dnf" with "yum" in the instructions below. + 1. Unless you are already using MariaDB server, you need to ensure that the server is configured to start during boot and properly secured by running: @@ -77,14 +68,14 @@ New installs Inspect the web server configuration file and verify it meets your needs: - /etc/zm/www/zoneminder.conf + /etc/zm/www/zoneminder.httpd.conf If you are running other web enabled services then you may need to edit this file to suite. See README.https to learn about other alternatives. When in doubt, proceed with the default: - sudo ln -s /etc/zm/www/zoneminder.conf /etc/httpd/conf.d/ + sudo ln -sf /etc/zm/www/zoneminder.httpd.conf /etc/httpd/conf.d/ sudo dnf install mod_ssl 7. Now start the web server: @@ -146,15 +137,18 @@ Upgrades See step 2 of the Installation section to add missing permissions. 3. Verify the ZoneMinder Apache configuration file in the folder - /etc/zm/www. You will have a file called "zoneminder.conf" and there - may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file + /etc/zm/www. You will have a file called "zoneminder.httpd.conf" and there + may also be one or more files with "rpmnew" extenstion. If the rpmnew file exists, inspect it and merge anything new in that file with zoneminder.conf. - Verify the SSL REquirements meet your needs. Read README.https if necessary. + Verify the SSL Requirements meet your needs. Read README.https if necessary. The contents of this file must be merged into your Apache configuration. See step 6 of the installation section if you have not already done this during a previous upgrade. + IMPORTANT: Failure to complete this step properly will result in a mostly + empty or significantly corrupted web console post-upgrade. + 4. Upgrade the database before starting ZoneMinder. Most upgrades can be performed by executing the following command: diff --git a/distros/redhat/readme/README.https b/distros/redhat/readme/README.https index 4b02aaa0d..620588bf9 100644 --- a/distros/redhat/readme/README.https +++ b/distros/redhat/readme/README.https @@ -20,7 +20,8 @@ experience. to do this: https://wiki.centos.org/HowTos/Https . Additionally, Googling "centos certificate" reveals many articles on the subject. -3. You can turn off HTTPS entirely by simply commenting out the SSLRequireSSL - directives found in /etc/httpd/conf.d/zoneminder.conf. You should also - comment out the HTTP -> HTTPS Rewrite rule. +3. When using Apache, you can turn off HTTPS entirely by simply commenting + out the SSLRequireSSL directives found in + /etc/zm/www/zoneminder.apache.conf. You should also comment out the + HTTP -> HTTPS Rewrite rule. diff --git a/distros/redhat/readme/README.Redhat7 b/distros/redhat/readme/README.nginx similarity index 77% rename from distros/redhat/readme/README.Redhat7 rename to distros/redhat/readme/README.nginx index c78d02042..cca4e72c2 100644 --- a/distros/redhat/readme/README.Redhat7 +++ b/distros/redhat/readme/README.nginx @@ -1,28 +1,17 @@ -What's New -========== - -1. See the ZoneMinder release notes for a list of new features: - https://github.com/ZoneMinder/zoneminder/releases - -2. The contents of the ZoneMinder Apache config file have changed. In - addition, this ZoneMinder package now requires you to manually symlink the - ZoneMinder Apache config file. See new install step 6 and upgrade step 3 - below for details. - New installs ============ 1. Unless you are already using MariaDB server, you need to ensure that the server is configured to start during boot and properly secured by running: - sudo yum install mariadb-server + sudo dnf install mariadb-server sudo systemctl enable mariadb sudo systemctl start mariadb.service mysql_secure_installation -2. Using the password for the root account set during the previous step, you - will need to create the ZoneMinder database and configure a database - account for ZoneMinder to use: +2. Assuming the database is local and using the password for the root account + set during the previous step, you will need to create the ZoneMinder + database and configure a database account for ZoneMinder to use: mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql mysql -uroot -p -e "grant all on zm.* to \ @@ -42,8 +31,8 @@ New installs Once the file has been saved, set proper file & ownership permissions on it: - sudo chown root:apache *.conf - sudo chmod 640 *.conf + sudo chown root:nginx *.conf + sudo chmod 640 *.conf 4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local timezone. PHP will complain loudly if this is not set, or if it is set @@ -56,7 +45,7 @@ New installs 5. Disable SELinux We currently do not have the resources to create and maintain an accurate - SELinux policy for ZoneMinder on CentOS 7. We will gladly accept pull + SELinux policy for ZoneMinder on Fedora. We will gladly accept pull reqeusts from anyone who wishes to do the work. In the meantime, SELinux will need to be disabled or put into permissive mode. @@ -72,8 +61,7 @@ New installs 6. Configure the web server This package uses the HTTPS protocol by default to access the web portal, - using the default self signed certificate on your system. Requests using - HTTP will auto-redirect to HTTPS. + using the default self signed certificate on your system. Inspect the web server configuration file and verify it meets your needs: @@ -82,22 +70,30 @@ New installs If you are running other web enabled services then you may need to edit this file to suite. See README.https to learn about other alternatives. + If you wish http requests to auto-redirect to https requests, then link or + copy /etc/zm/www/redirect.nginx.conf into /etc/nginx/default.d folder. + When in doubt, proceed with the default: - sudo ln -s /etc/zm/www/zoneminder.conf /etc/httpd/conf.d/ - sudo yum install mod_ssl + sudo ln -sf /etc/zm/www/zoneminder.nginx.conf /etc/nginx/conf.d/ + sudo ln -sf /etc/zm/www/redirect.nginx.conf /etc/nginx/default.d/ -7. Now start the web server: +7. Edit /etc/sysconfig/fcgiwrap and set DAEMON_PROCS to the maximum number of + simulatneous streams the server should support. Generally, a good minimum + value for this equals the total number of cameras you expect to view at the + same time. - sudo systemctl enable httpd - sudo systemctl start httpd +8. Now start the web server: -8. Now start zoneminder: + sudo systemctl enable nginx + sudo systemctl start nginx + +9. Now start zoneminder: sudo systemctl enable zoneminder sudo systemctl start zoneminder -9. Optionally configure the firewall +10. Optionally configure the firewall All Redhat distros ship with the firewall enabled. That means you will not be able to access the ZoneMinder web console from a remote machine until @@ -117,7 +113,7 @@ New installs security requirements and how you use the system. It is up to you to verify these commands are sufficient. -10. Access the ZoneMinder web console +11. Access the ZoneMinder web console You may now access the ZoneMinder web console from your web browser using an appropriate url. Here are some examples: @@ -144,14 +140,14 @@ Upgrades mysql -uroot -p -e "show grants for zmuser@localhost;" See step 2 of the Installation section to add missing permissions. - -3. Verify the ZoneMinder Apache configuration file in the folder + +3. Verify the ZoneMinder Nginx configuration file in the folder /etc/zm/www. You will have a file called "zoneminder.conf" and there - may also be a file called "zoneminder.conf.rpmnew". If an rpmnew file + may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file exists, inspect it and merge anything new in that file with zoneminder.conf. Verify the SSL REquirements meet your needs. Read README.https if necessary. - The contents of this file must be merged into your Apache configuration. + The contents of this file must be merged into your Nginx configuration. See step 6 of the installation section if you have not already done this during a previous upgrade. @@ -167,9 +163,9 @@ Upgrades sudo zmupdate.pl --user=root --pass= --version= -5. Now restart the web server then start zoneminder: +5. Now restart nginx and php-fpm then start zoneminder: - sudo systemctl restart httpd + sudo systemctl restart nginx + sudo systemctl restart php-fpm sudo systemctl start zoneminder - diff --git a/distros/redhat/systemd/zoneminder.logrotate.in b/distros/redhat/systemd/zoneminder.logrotate.in deleted file mode 100644 index b4919eb5e..000000000 --- a/distros/redhat/systemd/zoneminder.logrotate.in +++ /dev/null @@ -1,8 +0,0 @@ -@ZM_LOGDIR@/*.log { - missingok - notifempty - sharedscripts - postrotate - @BINDIR@/zmpkg.pl logrot 2> /dev/null > /dev/null || : - endscript -} diff --git a/distros/redhat/zoneminder.spec b/distros/redhat/zoneminder.spec index de1d408ea..8f30d6fee 100644 --- a/distros/redhat/zoneminder.spec +++ b/distros/redhat/zoneminder.spec @@ -1,3 +1,4 @@ +# Leaving this to allow one to build zoneminder-http subpackage using arbitrary user account %global zmuid_final apache %global zmgid_final apache @@ -7,10 +8,6 @@ # CakePHP-Enum-Behavior is configured as a git submodule %global ceb_version 1.0-zm -%if "%{zmuid_final}" == "nginx" -%global with_nginx 1 -%endif - %global sslcert %{_sysconfdir}/pki/tls/certs/localhost.crt %global sslkey %{_sysconfdir}/pki/tls/private/localhost.key @@ -22,10 +19,11 @@ %global with_apcu_bc 1 %endif +# The default for everything but el7 these days %global _hardened_build 1 Name: zoneminder -Version: 1.32.2 +Version: 1.33.0 Release: 1%{?dist} Summary: A camera monitoring and analysis tool Group: System Environment/Daemons @@ -44,7 +42,7 @@ BuildRequires: systemd-devel BuildRequires: mariadb-devel BuildRequires: perl-podlators BuildRequires: polkit-devel -BuildRequires: cmake >= 2.8.7 +BuildRequires: cmake3 BuildRequires: gnutls-devel BuildRequires: bzip2-devel BuildRequires: pcre-devel @@ -74,6 +72,7 @@ BuildRequires: vlc-devel BuildRequires: libcurl-devel BuildRequires: libv4l-devel BuildRequires: desktop-file-utils +BuildRequires: gzip # ZoneMinder looks for and records the location of the ffmpeg binary during build BuildRequires: ffmpeg @@ -83,11 +82,25 @@ BuildRequires: ffmpeg-devel BuildRequires: libmp4v2-devel BuildRequires: x264-devel -%{?with_nginx:Requires: nginx} -%{?with_nginx:Requires: fcgiwrap} -%{?with_nginx:Requires: php-fpm} -%{!?with_nginx:Requires: httpd} -%{!?with_nginx:Requires: php} +# Allow existing user base to seamlessly transition to sub-packages +Requires: %{name}-common%{?_isa} = %{version}-%{release} +Requires: %{name}-httpd%{?_isa} = %{version}-%{release} + +%description +ZoneMinder is a set of applications which is intended to provide a complete +solution allowing you to capture, analyze, record and monitor any cameras you +have attached to a Linux based machine. It is designed to run on kernels which +support the Video For Linux (V4L) interface and has been tested with cameras +attached to BTTV cards, various USB cameras and IP network cameras. It is +designed to support as many cameras as you can attach to your computer without +too much degradation of performance. + +This is a meta package for backwards compatibility with the existing +ZoneMinder user base. + +%package common +Summary: Common files for ZoneMinder, not tied to a specific web server + Requires: php-mysqli Requires: php-common Requires: php-gd @@ -112,16 +125,12 @@ Requires: perl(Net::FTP) Requires: perl(LWP::Protocol::https) Requires: ca-certificates Requires: zip - -Requires(post): systemd -Requires(post): systemd-sysv -Requires(preun): systemd -Requires(postun): systemd +%{?systemd_requires} Requires(post): %{_bindir}/gpasswd -Requires(post): %{_bindir}/less +Requires(post): %{_bindir}/chown -%description +%description common ZoneMinder is a set of applications which is intended to provide a complete solution allowing you to capture, analyze, record and monitor any cameras you have attached to a Linux based machine. It is designed to run on kernels which @@ -130,15 +139,57 @@ attached to BTTV cards, various USB cameras and IP network cameras. It is designed to support as many cameras as you can attach to your computer without too much degradation of performance. +This is a meta-package that exists solely to allow the existing user base to +seamlessly transition to sub-packages. + +%package httpd +Summary: ZoneMinder configuration for Apache web server +Requires: %{name}-common%{?_isa} = %{version}-%{release} +Requires: httpd +Requires: php + +Conflicts: %{name}-nginx + +%description httpd +ZoneMinder is a set of applications which is intended to provide a complete +solution allowing you to capture, analyze, record and monitor any cameras you +have attached to a Linux based machine. It is designed to run on kernels which +support the Video For Linux (V4L) interface and has been tested with cameras +attached to BTTV cards, various USB cameras and IP network cameras. It is +designed to support as many cameras as you can attach to your computer without +too much degradation of performance. + +This sub-package contains configuration specific to Apache web server + +%package nginx +Summary: ZoneMinder configuration for Nginx web server +Requires: %{name}-common%{?_isa} = %{version}-%{release} +Requires: nginx +Requires: php-fpm +Requires: fcgiwrap + +Conflicts: %{name}-httpd + +%description nginx +ZoneMinder is a set of applications which is intended to provide a complete +solution allowing you to capture, analyze, record and monitor any cameras you +have attached to a Linux based machine. It is designed to run on kernels which +support the Video For Linux (V4L) interface and has been tested with cameras +attached to BTTV cards, various USB cameras and IP network cameras. It is +designed to support as many cameras as you can attach to your computer without +too much degradation of performance. + +This sub-package contains support for ZoneMinder with the Nginx web server + %prep -%autosetup -p 1 -a 1 -n ZoneMinder-%{version} -%{__rm} -rf ./web/api/app/Plugin/Crud -%{__mv} -f crud-%{crud_version} ./web/api/app/Plugin/Crud +%autosetup -p 1 -a 1 +rm -rf ./web/api/app/Plugin/Crud +mv -f crud-%{crud_version} ./web/api/app/Plugin/Crud # The all powerful autosetup macro does not work after the second source tarball -%{__gzip} -dc %{_sourcedir}/cakephp-enum-behavior-%{ceb_version}.tar.gz | tar -xvvf - -%{__rm} -rf ./web/api/app/Plugin/CakePHP-Enum-Behavior -%{__mv} -f CakePHP-Enum-Behavior-%{ceb_version} ./web/api/app/Plugin/CakePHP-Enum-Behavior +gzip -dc %{_sourcedir}/cakephp-enum-behavior-%{ceb_version}.tar.gz | tar -xvvf - +rm -rf ./web/api/app/Plugin/CakePHP-Enum-Behavior +mv -f CakePHP-Enum-Behavior-%{ceb_version} ./web/api/app/Plugin/CakePHP-Enum-Behavior # Change the following default values ./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes @@ -149,9 +200,9 @@ too much degradation of performance. ./utils/zmeditconfigdata.sh ZM_OPT_FAST_DELETE no %build -%cmake \ +%cmake3 \ -DZM_WEB_USER="%{zmuid_final}" \ - -DZM_WEB_GROUP="%{zmuid_final}" \ + -DZM_WEB_GROUP="%{zmgid_final}" \ -DZM_TARGET_DISTRO="%{zmtargetdistro}" \ . @@ -173,10 +224,13 @@ find %{buildroot} \( -name .htaccess -or -name .editorconfig -or -name .packlist find %{buildroot}%{_datadir}/zoneminder/www/api \( -name cake -or -name cake.php \) -type f -exec sed -i 's\^#!/usr/bin/env bash$\#!%{_buildshell}\' {} \; -exec %{__chmod} 755 {} \; # Use the system cacert file rather then the one bundled with CakePHP -%{__rm} -f %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem -%{__ln_s} ../../../../../../../..%{_sysconfdir}/pki/tls/certs/ca-bundle.crt %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem +rm -f %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem +ln -s ../../../../../../../..%{_sysconfdir}/pki/tls/certs/ca-bundle.crt %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem -%post +# Handle the polkit file differently for web server agnostic support (see post) +rm -f %{buildroot}%{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules + +%post common # Initial installation if [ $1 -eq 1 ] ; then %systemd_post %{name}.service @@ -184,28 +238,48 @@ fi # Upgrade from a previous version of zoneminder if [ $1 -eq 2 ] ; then - # Add any new PTZ control configurations to the database (will not overwrite) %{_bindir}/zmcamtool.pl --import >/dev/null 2>&1 || : # Freshen the database %{_bindir}/zmupdate.pl -f >/dev/null 2>&1 || : - - # We can't run this automatically when new sql account permissions need to - # be manually added first - # Run zmupdate non-interactively - # zmupdate.pl --nointeractive fi +# Warn the end user to read the README file +echo -e "\nVERY IMPORTANT: Before starting ZoneMinder, you must read the README file\nto finish the installation or upgrade!" +echo -e "\nThe README file is located here: %{_pkgdocdir}-common/README\n" + +%post httpd +# For the case of changing from nginx <-> httpd, files in these folders must change ownership if they exist +%{_bindir}/chown -R %{zmuid_final}:%{zmgid_final} %{_sharedstatedir}/php/session/* >/dev/null 2>&1 || : +%{_bindir}/chown -R %{zmuid_final}:%{zmgid_final} %{_localstatedir}/log/zoneminder/* >/dev/null 2>&1 || : + +ln -sf %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.httpd %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules +# backwards compatibility +ln -sf %{_sysconfdir}/zm/www/zoneminder.httpd.conf %{_sysconfdir}/zm/www/zoneminder.conf + # Allow zoneminder access to local video sources, serial ports, and x10 %{_bindir}/gpasswd -a %{zmuid_final} video >/dev/null 2>&1 || : %{_bindir}/gpasswd -a %{zmuid_final} dialout >/dev/null 2>&1 || : -# Warn the end user to read the README file -echo -e "\nVERY IMPORTANT: Before starting ZoneMinder, you must read the README file\nto finish the installation or upgrade!" -echo -e "\nThe README file is located here: %{_pkgdocdir}/README\n" +%post nginx + +# Php package owns the session folder and sets group ownership to apache account +# We could override the folder permission, but adding nginx to the apache group works better +%{_bindir}/gpasswd -a nginx apache >/dev/null 2>&1 || : + +# For the case of changing from httpd <-> nginx, files in these folders must change ownership if they exist +%{_bindir}/chown -R nginx:nginx %{_sharedstatedir}/php/session/* >/dev/null 2>&1 || : +%{_bindir}/chown -R nginx:nginx %{_localstatedir}/log/zoneminder/* >/dev/null 2>&1 || : + +ln -sf %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.nginx %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules +# backwards compatibility +ln -sf %{_sysconfdir}/zm/www/zoneminder.nginx.conf %{_sysconfdir}/zm/www/zoneminder.conf + +# Allow zoneminder access to local video sources, serial ports, and x10 +%{_bindir}/gpasswd -a nginx video >/dev/null 2>&1 || : +%{_bindir}/gpasswd -a nginx dialout >/dev/null 2>&1 || : -%if 0%{?with_nginx} # Nginx does not create an SSL certificate like the apache package does so lets do that here if [ -f %{sslkey} -o -f %{sslcert} ]; then exit 0 @@ -231,7 +305,6 @@ SomeOrganizationalUnit ${FQDN} root@${FQDN} EOF -%endif %preun %systemd_preun %{name}.service @@ -239,19 +312,12 @@ EOF %postun %systemd_postun_with_restart %{name}.service -%triggerun -- zoneminder < 1.25.0-4 -# Save the current service runlevel info -# User must manually run systemd-sysv-convert --apply zoneminder -# to migrate them to systemd targets -%{_bindir}/systemd-sysv-convert --save zoneminder >/dev/null 2>&1 ||: - -# Run these because the SysV package being removed won't do them -/sbin/chkconfig --del zoneminder >/dev/null 2>&1 || : -/bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || : - %files +# nothing + +%files common %license COPYING -%doc AUTHORS README.md distros/redhat/readme/README distros/redhat/readme/README.https +%doc AUTHORS README.md distros/redhat/readme/README distros/redhat/readme/README.httpd distros/redhat/readme/README.nginx distros/redhat/readme/README.https # We want these two folders to have "normal" read permission # compared to the folder contents @@ -261,21 +327,11 @@ EOF # Config folder contents contain sensitive info # and should not be readable by normal users %{_sysconfdir}/zm/conf.d/README -%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf -%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/*.conf -%ghost %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/zmcustom.conf -%config(noreplace) %attr(644,root,root) /etc/zm/www/zoneminder.conf %config(noreplace) %{_sysconfdir}/logrotate.d/zoneminder -%if 0%{?with_nginx} -%config(noreplace) %{_sysconfdir}/php-fpm.d/zoneminder.conf -%endif - -%{_tmpfilesdir}/zoneminder.conf %{_unitdir}/zoneminder.service %{_datadir}/polkit-1/actions/com.zoneminder.systemctl.policy -%{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules %{_bindir}/zmsystemctl.pl %{_bindir}/zma @@ -306,20 +362,64 @@ EOF %{_libexecdir}/zoneminder/ %{_datadir}/zoneminder/ -%{_datadir}/applications/*%{name}.desktop +%{_datadir}/applications/*zoneminder.desktop +%files httpd +%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf +%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/0*.conf +%ghost %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/zmcustom.conf +%config(noreplace) %{_sysconfdir}/zm/www/zoneminder.httpd.conf +%ghost %{_sysconfdir}/zm/www/zoneminder.conf +%config(noreplace) %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.httpd +%ghost %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules + +%{_unitdir}/zoneminder.service.d/zm-httpd.conf +%{_tmpfilesdir}/zoneminder.httpd.tmpfiles.conf %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/events -%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/images %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/sock %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/swap %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/temp %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/cache/zoneminder %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/log/zoneminder %dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/spool/zoneminder-upload -%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/run/zoneminder + +%files nginx +%config(noreplace) %attr(640,root,nginx) %{_sysconfdir}/zm/zm.conf +%config(noreplace) %attr(640,root,nginx) %{_sysconfdir}/zm/conf.d/*.conf +%ghost %attr(640,root,nginx) %{_sysconfdir}/zm/conf.d/zmcustom.conf +%config(noreplace) %{_sysconfdir}/zm/www/zoneminder.nginx.conf +%config(noreplace) %{_sysconfdir}/zm/www/redirect.nginx.conf +%ghost %{_sysconfdir}/zm/www/zoneminder.conf +%config(noreplace) %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.nginx +%ghost %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules + +%config(noreplace) %{_sysconfdir}/php-fpm.d/zoneminder.php-fpm.conf + + +%{_unitdir}/zoneminder.service.d/zm-nginx.conf +%{_tmpfilesdir}/zoneminder.nginx.tmpfiles.conf +%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder +%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/events +%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/sock +%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/swap +%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/temp +%dir %attr(755,nginx,nginx) %{_localstatedir}/cache/zoneminder +%dir %attr(755,nginx,nginx) %{_localstatedir}/log/zoneminder +%dir %attr(755,nginx,nginx) %{_localstatedir}/spool/zoneminder-upload %changelog +* Tue Dec 11 2018 Andrew Bauer - 1.33.0-1 +- Bump tp 1.33.0 Development + +* Sat Dec 08 2018 Andrew Bauer - 1.32.3-1 +- 1.32.3 Release +- Break into sub-packages + +* Tue Nov 13 2018 Antonio Trande - 1.32.2-2 +- Rebuild for ffmpeg-3.4.5 on el7 +- Use CMake3 + * Sat Oct 13 2018 Andrew Bauer - 1.32.2-1 - 1.32.2 release - Bug fix release diff --git a/distros/ubuntu1204/rules b/distros/ubuntu1204/rules index f971e9cc3..20dd303f8 100755 --- a/distros/ubuntu1204/rules +++ b/distros/ubuntu1204/rules @@ -27,7 +27,6 @@ override_dh_auto_configure: -DZM_CGIDIR="/usr/lib/zoneminder/cgi-bin" \ -DZM_CACHEDIR="/var/cache/zoneminder/cache" \ -DZM_DIR_EVENTS="/var/cache/zoneminder/events" \ - -DZM_DIR_IMAGES="/var/cache/zoneminder/images" \ -DZM_PATH_ZMS="/zm/cgi-bin/nph-zms" override_dh_clean: diff --git a/distros/ubuntu1504_cmake_split_packages/rules b/distros/ubuntu1504_cmake_split_packages/rules index 0eca4b511..f6169c495 100755 --- a/distros/ubuntu1504_cmake_split_packages/rules +++ b/distros/ubuntu1504_cmake_split_packages/rules @@ -64,7 +64,6 @@ override_dh_auto_configure: -DZM_CONFIG_SUBDIR="/etc/zm/conf.d" \ -DZM_CONFIG_DIR="/etc/zm" \ -DZM_DIR_EVENTS="/var/cache/zoneminder/events" \ - -DZM_DIR_IMAGES="/var/cache/zoneminder/images" \ -DZM_PATH_ZMS="/zm/cgi-bin/nph-zms" override_dh_auto_test: diff --git a/distros/ubuntu1604/control b/distros/ubuntu1604/control index d4fe74e79..d91fd4f53 100644 --- a/distros/ubuntu1604/control +++ b/distros/ubuntu1604/control @@ -3,13 +3,14 @@ Section: net Priority: optional Maintainer: Dmitry Smirnov Uploaders: Vagrant Cascadian -Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree +Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree, dh-systemd, dh-apache2 ,cmake ,libx264-dev, libmp4v2-dev ,libavdevice-dev (>= 6:10~) ,libavcodec-dev (>= 6:10~) ,libavformat-dev (>= 6:10~) ,libavutil-dev (>= 6:10~) + ,libswresample-dev ,libswscale-dev (>= 6:10~) ,ffmpeg | libav-tools ,net-tools @@ -41,7 +42,9 @@ Package: zoneminder Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,javascript-common - ,libmp4v2-2, libx264-142|libx264-148|libx264-152, libswscale-ffmpeg3|libswscale4|libswscale3 + ,libmp4v2-2, libx264-142|libx264-148|libx264-152 + ,libswscale-ffmpeg3|libswscale4|libswscale3|libswscale5 + ,libswresample2|libswresample3|libswresample24 ,ffmpeg | libav-tools ,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl ,libdbd-mysql-perl diff --git a/distros/ubuntu1604/rules b/distros/ubuntu1604/rules index f0808a8e1..98b9ac0a2 100755 --- a/distros/ubuntu1604/rules +++ b/distros/ubuntu1604/rules @@ -27,7 +27,6 @@ override_dh_auto_configure: -DZM_CGIDIR="/usr/lib/zoneminder/cgi-bin" \ -DZM_CACHEDIR="/var/cache/zoneminder/cache" \ -DZM_DIR_EVENTS="/var/cache/zoneminder/events" \ - -DZM_DIR_IMAGES="/var/cache/zoneminder/images" \ -DZM_PATH_ZMS="/zm/cgi-bin/nph-zms" override_dh_clean: diff --git a/docs/api.rst b/docs/api.rst index a6d0cc9aa..2f90b7fdf 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -5,7 +5,6 @@ This document will provide an overview of ZoneMinder's API. This is work in prog Overview ^^^^^^^^ - In an effort to further 'open up' ZoneMinder, an API was needed. This will allow quick integration with and development of ZoneMinder. @@ -13,6 +12,78 @@ The API is built in CakePHP and lives under the ``/api`` directory. It provides a RESTful service and supports CRUD (create, retrieve, update, delete) functions for Monitors, Events, Frames, Zones and Config. +Streaming Interface +^^^^^^^^^^^^^^^^^^^ +Developers working on their application often ask if there is an "API" to receive live streams, or recorded event streams. +It is possible to stream both live and recorded streams. This isn't strictly an "API" per-se (that is, it is not integrated +into the Cake PHP based API layer discussed here) and also why we've used the term "Interface" instead of an "API". + +Live Streams +~~~~~~~~~~~~~~ +What you need to know is that if you want to display "live streams", ZoneMinder sends you streaming JPEG images (MJPEG) +which can easily be rendered in a browser using an ``img src`` tag. + +For example: + +:: + + + +will display a live feed from monitor id 1, scaled down by 50% in quality and resized to 640x480px. + +* This assumes ``/zm/cgi-bin`` is your CGI_BIN path. Change it to what is correct in your system +* The "auth" token you see above is required if you use ZoneMinder authentication. To understand how to get the auth token, please read the "Login, Logout & API security" section below. +* The "connkey" parameter is essentially a random number which uniquely identifies a stream. If you don't specify a connkey, ZM will generate its own. It is recommended to generate a connkey because you can then use it to "control" the stream (pause/resume etc.) +* Instead of dealing with the "auth" token, you can also use ``&user=username&pass=password`` where "username" and "password" are your ZoneMinder username and password respectively. Note that this is not recommended because you are transmitting them in a URL and even if you use HTTPS, they may show up in web server logs. + + +PTZ on live streams +------------------- +PTZ commands are pretty cryptic in ZoneMinder. This is not meant to be an exhaustive guide, but just something to whet your appetite: + + +Lets assume you have a monitor, with ID=6. Let's further assume you want to pan it left. + +You'd need to send a: +``POST`` command to ``https://yourserver/zm/index.php`` with the following data payload in the command (NOT in the URL) + +``view=request&request=control&id=6&control=moveConLeft&xge=30&yge=30`` + +Obviously, if you are using authentication, you need to be logged in for this to work. + +Like I said, at this stage, this is only meant to get you started. Explore the ZoneMinder code and use "Inspect source" as you use PTZ commands in the ZoneMinder source code. +`control_functions.php `__ is a great place to start. + + +Pre-recorded (past event) streams +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Similar to live playback, if you have chosen to store events in JPEG mode, you can play it back using: + +:: + + + + +* This assumes ``/zm/cgi-bin`` is your CGI_BIN path. Change it to what is correct in your system +* This will playback event 293820, starting from frame 1 as an MJPEG stream +* Like before, you can add more parameters like ``scale`` etc. +* auth and connkey have the same meaning as before, and yes, you can replace auth by ``&user=usename&pass=password`` as before and the same security concerns cited above apply. + +If instead, you have chosen to use the MP4 (Video) storage mode for events, you can directly play back the saved video file: + +:: + + + +* This will play back the video recording for event 294690 + +What other parameters are supported? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The best way to answer this question is to play with ZoneMinder console. Open a browser, play back live or recorded feed, and do an "Inspect Source" to see what parameters +are generated. Change and observe. + + Enabling API ^^^^^^^^^^^^ A default ZoneMinder installs with APIs enabled. You can explictly enable/disable the APIs @@ -132,6 +203,22 @@ Return a list of all monitors curl http://server/zm/api/monitors.json +It is worthwhile to note that starting ZM 1.32.3 and beyond, this API also returns a ``Monitor_Status`` object per monitor. It looks like this: + +:: + + "Monitor_Status": { + "MonitorId": "2", + "Status": "Connected", + "CaptureFPS": "1.67", + "AnalysisFPS": "1.67", + "CaptureBandwidth": "52095" + } + + +If you don't see this in your API, you are running an older version of ZM. This gives you a very convenient way to check monitor status without calling the ``daemonCheck`` API described later. + + Retrieve monitor 1 ^^^^^^^^^^^^^^^^^^^ @@ -148,6 +235,13 @@ This API changes monitor 1 to Modect and Enabled :: curl -XPOST http://server/zm/api/monitors/1.json -d "Monitor[Function]=Modect&Monitor[Enabled]=1" + +Get Daemon Status of Monitor 1 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:: + + curl http://server/zm/api/monitors/daemonStatus/id:1/daemon:zmc.json Add a monitor ^^^^^^^^^^^^^^ @@ -384,11 +478,13 @@ Create a Zone &Zone[MaxBlobs]=\ &Zone[OverloadFrames]=0" -PTZ Control APIs -^^^^^^^^^^^^^^^^ +PTZ Control Meta-Data APIs +^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTZ controls associated with a monitor are stored in the Controls table and not the Monitors table inside ZM. What that means is when you get the details of a Monitor, you will only know if it is controllable (isControllable:true) and the control ID. To be able to retrieve PTZ information related to that Control ID, you need to use the controls API +Note that these APIs only retrieve control data related to PTZ. They don't actually move the camera. See the "PTZ on live streams" section to move the camera. + This returns all the control definitions: :: @@ -406,7 +502,97 @@ ZM APIs have various APIs that help you in determining host (aka ZM) daemon stat :: - curl -XGET http://server/zm/api/host/daemonCheck.json # 1 = ZM running 0=not running curl -XGET http://server/zm/api/host/getLoad.json # returns current load of ZM - curl -XGET http://server/zm/api/host/getDiskPercent.json # returns in GB (not percentage), disk usage per monitor (that is, space taken to store various event related information,images etc. per monitor) + + # Note that ZM 1.32.3 onwards has the same information in Monitors.json which is more reliable and works for multi-server too. + curl -XGET http://server/zm/api/host/daemonCheck.json # 1 = ZM running 0=not running + + # The API below uses "du" to calculate disk space. We no longer recommend you use it if you have many events. Use the Storage APIs instead, described later + curl -XGET http://server/zm/api/host/getDiskPercent.json # returns in GB (not percentage), disk usage per monitor (that is,space taken to store various event related information,images etc. per monitor) + + +Storage and Server APIs +^^^^^^^^^^^^^^^^^^^^^^^ + +ZoneMinder introduced many new options that allowed you to configure multiserver/multistorage configurations. While a part of this was available in previous versions, a lot of rework was done as part of ZM 1.31 and 1.32. As part of that work, a lot of new and useful APIs were added. Some of these are part of ZM 1.32 and others will be part of ZM 1.32.3 (of course, if you build from master, you can access them right away, or wait till a stable release is out. + + + +This returns storage data for my single server install. If you are using multi-storage, you'll see many such "Storage" entries, one for each storage defined: + +:: + + curl http://server/zm/api/storage.json + +Returns: + +:: + + { + "storage": [ + { + "Storage": { + "Id": "0", + "Path": "\/var\/cache\/zoneminder\/events", + "Name": "Default", + "Type": "local", + "Url": null, + "DiskSpace": "364705447651", + "Scheme": "Medium", + "ServerId": null, + "DoDelete": true + } + } + ] + } + + + +"DiskSpace" is the disk used in bytes. While this doesn't return disk space data as rich as ``/host/getDiskPercent``, it is much more efficient. + +Similarly, + +:: + + curl http://server/zm/api/servers.json + +Returns: + +:: + + { + "servers": [ + { + "Server": { + "Id": "1", + "Name": "server1", + "Hostname": "server1.mydomain.com", + "State_Id": null, + "Status": "Running", + "CpuLoad": "0.9", + "TotalMem": "6186237952", + "FreeMem": "156102656", + "TotalSwap": "536866816", + "FreeSwap": "525697024", + "zmstats": false, + "zmaudit": false, + "zmtrigger": false + } + } + ] + } + +This only works if you have a multiserver setup in place. If you don't it will return an empty array. + + +Further Reading +^^^^^^^^^^^^^^^^ +As described earlier, treat this document as an "introduction" to the important parts of the API and streaming interfaces. +There are several details that haven't yet been documented. Till they are, here are some resources: + +* zmNinja, the open source mobile app for ZoneMinder is 100% based on ZM APIs. Explore its `source code `__ to see how things work. +* Launch up ZM console in a browser, and do an "Inspect source". See how images are being rendered. Go to the networks tab of the inspect source console and look at network requests that are made when you pause/play/forward streams. +* If you still can't find an answer, post your question in the `forums `__ (not the github repo). + + diff --git a/docs/faq.rst b/docs/faq.rst index 7735ff38f..a703fd065 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -311,7 +311,7 @@ There are a number of specific reasons why processor loads can be high either by The main causes are. - * Using a video palette other than greyscale or RGB24. This can cause a relatively minor performace hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference. + * Using a video palette other than greyscale or RGB24. This can cause a relatively minor performance hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference. * Big image sizes. A image of 640x480 requires at least four times the processing of a 320x240 image. Experiment with different sizes to see what effect it may have. Sometimes a large image is just two interlaced smaller frames so has no real benefit anyway. This is especially true for analog cameras/cards as image height over 320 (NTSC) or 352 PAL) are invariably interlaced. * Capture frame rates. Unless there's a compelling reason in your case there is often little benefit in running cameras at 25fps when 5-10fps would often get you results just as good. Try changing your monitor settings to limit your cameras to lower frame rates. You can still configure ZM to ignore these limits and capture as fast as possible when motion is detected. * Run function. Obviously running in Record or Mocord modes or in Modect with lots of events generates a lot of DB and file activity and so CPU and load will increase. diff --git a/docs/installationguide/dedicateddrive.rst b/docs/installationguide/dedicateddrive.rst index f0dfadc28..6a7367b8b 100644 --- a/docs/installationguide/dedicateddrive.rst +++ b/docs/installationguide/dedicateddrive.rst @@ -31,7 +31,6 @@ Add the following content to the file and save your changes: :: ZM_DIR_EVENTS=/full/path/to/the/events/folder - ZM_DIR_IMAGES=/full/path/to/the/images/folder **Step 5:** Start ZoneMinder and inspect the ZoneMinder log files for errors. :: diff --git a/docs/installationguide/redhat.rst b/docs/installationguide/redhat.rst index 12d9ed769..71b4f5278 100644 --- a/docs/installationguide/redhat.rst +++ b/docs/installationguide/redhat.rst @@ -197,7 +197,7 @@ If you have previsouly cloned the ZoneMinder git repo and wish to update it to t :: - cd ~\ZoneMinder + cd ~/ZoneMinder git pull origin master Get the crud submodule tarball: @@ -210,14 +210,14 @@ At this point, you can make changes to the source code. Depending on what you wa :: - cd ~\ZoneMinder + cd ~/ZoneMinder git checkout -b mynewbranch Again, depending on what you want to do with those changes, you may want to commit your changes: :: - cd ~\ZoneMinder + cd ~/ZoneMinder git add . git commit @@ -231,7 +231,7 @@ Scroll down until you see the Version field. Note the value, which will be in th :: - cd ~\ZoneMinder + cd ~/ZoneMinder git archive --prefix=ZoneMinder-1.31.1/ -o ~/rpmbuild/SOURCES/zoneminder-1.31.1.tar.gz HEAD Replace "1.31.1" with the Version shown in the rpm specfile. @@ -240,7 +240,7 @@ From the root of the local ZoneMinder git repo, execute the following: :: - cd ~\ZoneMinder + cd ~/ZoneMinder rpmbuild -bs --nodeps distros/redhat/zoneminder.spec This step will create a source rpm and it will tell you where it was saved. For example: diff --git a/docs/installationguide/ubuntu.rst b/docs/installationguide/ubuntu.rst index 3df065264..6c686d7ed 100644 --- a/docs/installationguide/ubuntu.rst +++ b/docs/installationguide/ubuntu.rst @@ -49,7 +49,7 @@ guide you with a quick search. add-apt-repository ppa:iconnor/zoneminder-1.32 - If you are on trusty, you may want to add both, as there are some packages for dependencies included in the old ppa. + If you are on Trusty or Xenial, you may want to add both, as there are some packages for dependencies included in the old ppa. Update repo and upgrade. @@ -138,9 +138,9 @@ Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content :: - a2enconf zoneminder a2enmod cgi a2enmod rewrite + a2enconf zoneminder You may also want to enable to following modules to improve caching performance diff --git a/docs/userguide/definemonitor.rst b/docs/userguide/definemonitor.rst index bf12a1bc5..7641cb751 100644 --- a/docs/userguide/definemonitor.rst +++ b/docs/userguide/definemonitor.rst @@ -58,7 +58,7 @@ Maximum FPS Alarm Maximum FPS If you have specified a Maximum FPS it may be that you don’t want this limitation to apply when your monitor is recording motion or other event. This setting allows you to override the Maximum FPS value if this circumstance occurs. As with the Maximum FPS setting leaving this blank implies no limit so if you have set a maximum fps in the previous option then when an alarm occurs this limit would be ignored and ZoneMinder would capture as fast as possible for the duration of the alarm, returning to the limited value after the alarm has concluded. Equally you could set this to the same, or higher (or even lower) value than Maximum FPS for more precise control over the capture rate in the event of an alarm. - **IMPORTANT:** This field is subject to the same limitations as the Maxium FPS field. Ignoring these limitations will produce undesriable results. + **IMPORTANT:** This field is subject to the same limitations as the Maximum FPS field. Ignoring these limitations will produce undesriable results. Reference Image Blend %ge Each analysed image in ZoneMinder is a composite of previous images and is formed by applying the current image as a certain percentage of the previous reference image. Thus, if we entered the value of 10 here, each image’s part in the reference image will diminish by a factor of 0.9 each time round. So a typical reference image will be 10% the previous image, 9% the one before that and then 8.1%, 7.2%, 6.5% and so on of the rest of the way. An image will effectively vanish around 25 images later than when it was added. This blend value is what is specified here and if higher will make slower progressing events less detectable as the reference image would change more quickly. Similarly events will be deemed to be over much sooner as the reference image adapts to the new images more quickly. In signal processing terms the higher this value the steeper the event attack and decay of the signal. It depends on your particular requirements what the appropriate value would be for you but start with 10 here and adjust it (usually down) later if necessary. @@ -164,6 +164,29 @@ Height (pixels) Web Site Refresh If the website in question has static content, optionally enter a time period in seconds for ZoneMinder to refresh the content. +Storage Tab +----------- + +The storage section allows for each monitor to configure if and how video and audio are recorded. + +Save JPEGs + Records video in individual JPEG frames. Storing JPEG frames requires more storage space than h264 but it allows to view an event anytime while it is being recorded. + + * Disabled – video is not recorded as JPEG frames. If this setting is selected, then "Video Writer" should be enabled otherwise there is no video recording at all. + * Frames only – video is recorded in individual JPEG frames. + * Analysis images only (if available) – video is recorded in invidual JPEG frames with an overlay of the motion detection analysis information. Note that this overlay remains permanently visible in the frames. + * Frames + Analysis images (if available) – video is recorded twice, once as normal individual JPEG frames and once in invidual JPEG frames with analysis information overlaid. + +Video Writer + Records video in real video format. It provides much better compression results than saving JPEGs, thus longer video history can be stored. + + * Disabled – video is not recorded in video format. If this setting is selected, then "Save JPEGs" should be enabled otherwise there is no video recording at all. + * X264 Encode – the video or picture frames received from the camera are transcoded into h264 and stored as a video. This option is useful if the camera cannot natively stream h264. + * H264 Camera Passthrough – this option assumes that the camera is already sending an h264 stream. Video will be recorded as is, without any post-processing in zoneminder. Video characteristics such as bitrate, encoding mode, etc. should be set directly in the camera. + +Recording Audio + Check the box labeled "Whether to store the audio stream when saving an event." in order to save audio (if available) when events are recorded. + Timestamp Tab ------------- @@ -182,7 +205,8 @@ Warm-up Frames Pre/Post Event Image Buffer These options determine how many frames from before and after an event should be preserved with it. This allows you to view what happened immediately prior and subsequent to the event. A value of 10 for both of these will get you started but if you get a lot of short events and would prefer them to run together to form fewer longer ones then increase the Post Event buffer size. The pre-event buffer is a true buffer and should not really exceed half the ring buffer size. However the post-event buffer is just a count that is applied to captured frames and so can be managed more flexibly. You should also bear in mind the frame rate of the camera when choosing these values. For instance a network camera capturing at 1FPS will give you 10 seconds before and after each event if you chose 10 here. This may well be too much and pad out events more than necessary. However a fast video card may capture at 25FPS and you will want to ensure that this setting enables you to view a reasonable time frame pre and post event. Stream Replay Image Buffer - This option ... + The number of frames buffered to allow pausing and rewinding of the stream when live viewing a monitor. A value of 0 disables the feature. + Frames are buffered to ZM_PATH_SWAP. If this path points to a physical drive, a lot of IO will be caused during live view / montage. If you experience high system load in those situations, either disable the feature or use a RAM drive for ZM_PATH_SWAP. Alarm Frame Count This option allows you to specify how many consecutive alarm frames must occur before an alarm event is generated. The usual, and default, value is 1 which implies that any alarm frame will cause or participate in an event. You can enter any value up to 16 here to eliminate bogus events caused perhaps by screen flickers or other transients. Values over 3 or 4 are unlikely to be useful however. Please note that if you have statistics recording enabled then currently statistics are not recorded for the first ‘Alarm Frame Count’-1 frames of an event. So if you set this value to 5 then the first 4 frames will be missing statistics whereas the more usual value of 1 will ensure that all alarm frames have statistics recorded. diff --git a/docs/userguide/definezone.rst b/docs/userguide/definezone.rst index cf33f44c9..97f42f864 100644 --- a/docs/userguide/definezone.rst +++ b/docs/userguide/definezone.rst @@ -29,7 +29,7 @@ Type Triggers an alarm when motion is detected within it, as long as no alarms have already been triggered in an Active zone. This is the most specialized of the zone types. For instance in the camera covering my garden I keep watch for a hedgehog that visits most nights and scoffs the food out of my cats bowls. By creating a sensitive Exclusive zone in that area I can ensure that a hedgehog alarm will only trigger if there is activity in that small area. If something much bigger occurs, like someone walking by it will trigger a regular alarm and not one from the Exclusive zone. Thus I can ensure I get alarms for big events and also special small events but not the noise in between. * Preclusive - This zone type is relatively recent. It is called a Preclusive zone because if it is triggered it actually precludes an alarm being generated for that image frame. So motion or other changes that occur in a Preclusive zone will have the effect of ensuring that no alarm occurs at all. The application for this zone type is primarily as a shortcut for detecting general large-scale lighting or other changes. Generally this may be achieved by limiting the maximum number of alarm pixels or other measure in an Active zone. However in some cases that zone may cover an area where the area of variable illumination occurs in different places as the sun and/or shadows move and it thus may be difficult to come up with general values. Additionally, if the sun comes out rapidly then although the initial change may be ignored in this way as the reference image catches up an alarm may ultimately be triggered as the image becomes less different. Using one or more Preclusive zones offers a different approach. Preclusive zones are designed to be fairly small, even just a few pixels across, with quite low alarm thresholds. They should be situated in areas of the image that are less likely to have motion occur such as high on a wall or in a corner. Should a general illumination change occur they would be triggered at least as early as any Active zones and prevent any other zones from generating an alarm. Obviously careful placement is required to ensure that they do not cancel any genuine alarms or that they are not so close together that any motion just hops from one Preclusive zone to another. Preclusive zones may also be used to reduce processing time by situating one over an Active zone. The Preclusive zone is processed first; if it is small, and is triggered, the rest of the zone/image will not be processed. + This zone type is relatively recent. It is called a Preclusive zone because if it is triggered it actually precludes an alarm being generated for that image frame. So motion or other changes that occur in a Preclusive zone will have the effect of ensuring that no alarm occurs at all. The application for this zone type is primarily as a shortcut for detecting general large-scale lighting or other changes. Generally this may be achieved by limiting the maximum number of alarm pixels or other measure in an Active zone. However in some cases that zone may cover an area where the area of variable illumination occurs in different places as the sun and/or shadows move and it thus may be difficult to come up with general values. Additionally, if the sun comes out rapidly then although the initial change may be ignored in this way as the reference image catches up an alarm may ultimately be triggered as the image becomes less different. Using one or more Preclusive zones offers a different approach. Preclusive zones are designed to be fairly small, even just a few pixels across, with quite low alarm thresholds. They should be situated in areas of the image that are less likely to have motion occur such as high on a wall or in a corner. Should a general illumination change occur they would be triggered at least as early as any Active zones and prevent any other zones from generating an alarm. Obviously careful placement is required to ensure that they do not cancel any genuine alarms or that they are not so close together that any motion just hops from one Preclusive zone to another. Preclusive zones may also be used to reduce processing time by situating one over an Active zone. The Preclusive zone is processed first; if it is small, and is triggered, the rest of the zone/image will not be processed. See Extend Alarm Frame Count below for a way to hold the preclusive zone active for an extended period. * Inactive Suppresses the detection of motion within it. This can be layered on top of any other zone type, preventing motion within the Inactive zone from being effective for any other zone type. Use inactive zones to cover areas in which nothing notable will ever happen or where you get false alarms that don't relate to what you are trying to monitor. Inactive zones may be overlaid on other zones to blank out areas, and are processed first (with the exception of Privacy zones, see below). As a general practice, you should try and make zones abut each other instead of overlapping to avoid repeated duplicate processing of the same area. @@ -104,6 +104,9 @@ Overload Frame Ignore Count * Number of Blobs > Max Blobs The idea is that after a change like a light going on that is considered too big to count as an alarm, it could take a couple of frames for things to settle down again. +Extend Alarm Frame Count + This field applies to Preclusive Zones only. Placing a value in this field holds the Preclusive zone active for the specified number of frames after the initial triggering event. This is useful in cases where a sudden change in light level triggers the Preclusive zone, but the zone needs to be held active for a few frames as the camera itself adjusts to that change in light level. + Other information ----------------- Refer to `this `__ user contributed Zone guide for additional information will illustrations if you are new to zones and need more help. diff --git a/docs/userguide/introduction.rst b/docs/userguide/introduction.rst index 8da67a5e9..2d9985eb1 100644 --- a/docs/userguide/introduction.rst +++ b/docs/userguide/introduction.rst @@ -1,15 +1,14 @@ Introduction ============ -Welcome to ZoneMinder, the all-in-one Linux GPL'd security camera solution. +Welcome to ZoneMinder, the all-in-one security camera solution for Linux with GPL License. -Most commercial "security systems" are designed as a monitoring system that also records. Recording quality can vary from bad to unusable, locating the relevant video can range from challenging to impractical, and exporting can often only be done with the manual present. ZoneMinder was designed primarily to record, and allow easy searches and exporting. Recordings are of the best possible quality, easy to filter and find, and simple to export using any system with a web browser. It also monitors. +Commercial "security systems" are often designed as a monitoring system with little attention to recording quality. In such a system, locating and exporting relevant video can be challenging and often requires extensive human intervention. ZoneMinder was designed to provide the best possible record quality while allowing easy searching, filtering and exporting of security footage. -ZoneMinder is designed around a series of independent components that only function when necessary limiting any wasted resource and maximising the efficiency of your machine. A fairly ancient Pentium II PC should be able to track one camera per device at up to 25 frames per second with this dropping by half approximately for each additional camera on the same device. Additional cameras on other devices do not interact so can maintain this frame rate. Even monitoring several cameras still will not overload the CPU as frame processing is designed to synchronise with capture and not stall it. +ZoneMinder is designed around a series of independent components that only function when necessary, limiting any wasted resource and maximising the efficiency of your machine. An outdated Pentium II PC can have multiple recording devices connected to it, and it is able to track one camera per device at up to 25 frames per second, which drops by approximately half for each additional camera on the same device. Additional cameras on devices that do not interact with other devices can maintain the 25 frame rate per second. Monitoring several cameras will not overload the CPU as frame processing is designed to synchronise with capture. -As well as being fast ZoneMinder is designed to be friendly and even more than that, actually useful. As well as the fast video interface core it also comes with a user friendly and comprehensive PHP based web interface allowing you to control and monitor your cameras from home, at work, on the road, or even a web enabled cell phone. It supports variable web capabilities based on available bandwidth. The web interface also allows you to view events that your cameras have captured and archive them or review them time and again, or delete the ones you no longer wish to keep. The web pages directly interact with the core daemons ensuring full co-operation at all times. ZoneMinder can even be installed as a system service ensuring it is right there if your computer has to reboot for any reason. +A fast video interface core, a user-friendly and comprehensive PHP based web interface allows ZoneMinder to be efficient, friendly and most importantly useful. You can control and monitor your cameras from home, at work, on the road, or a web-enabled cell phone. It supports variable web capabilities based on available bandwidth. The web interface also allows you to view events that your cameras have captured, which can be archived, reviewed or deleted. The web application directly interacts with the core daemons ensuring full co-operation at all times. ZoneMinder can also be installed as a system service to reboot a system remotely. -The core of ZoneMinder is the capture and analysis of images and there is a highly configurable set of parameters that allow you to ensure that you can eliminate false positives whilst ensuring that anything you don't want to miss will be captured and saved. ZoneMinder allows you to define a set of 'zones' for each camera of varying sensitivity and functionality. This allows you to eliminate regions that you don't wish to track or define areas that will alarm if various thresholds are exceeded in conjunction with other zones. - -ZoneMinder is free, but if you do find it useful then please feel free to visit http://www.zoneminder.com/donate.html and help to fund future improvements to ZoneMinder. +The core of ZoneMinder is the capture and analysis of images and a highly configurable set of parameters that eliminate false positives whilst ensuring minimum loss of footage. For example, you can define a set of 'zones' for each camera of varying sensitivity and functionality. This eliminates zones that you don't wish to track or define areas that will alarm if various thresholds are exceeded in conjunction with other zones. +ZoneMinder is free under GPL License, but if you do find it useful, then please feel free to visit http://www.zoneminder.com/donate.html and help us fund our future improvements. diff --git a/docs/userguide/options/options_images.rst b/docs/userguide/options/options_images.rst index 3e8598425..1b17d8336 100644 --- a/docs/userguide/options/options_images.rst +++ b/docs/userguide/options/options_images.rst @@ -23,7 +23,7 @@ MPEG_LIVE_FORMAT - When using MPEG mode ZoneMinder can output live video. Howeve MPEG_REPLAY_FORMAT - When using MPEG mode ZoneMinder can replay events in encoded video format. However what formats are handled by the browser varies greatly between machines. This option allows you to specify a video format using a file extension format, so you would just enter the extension of the file type you would like and the rest is determined from that. The default of 'asf' works well under Windows with Windows Media Player and 'mpg', or 'avi' etc should work under Linux. If you know any more then please let me know! If this option is left blank then live streams will revert to being in motion jpeg format -RAND_STREAM - Some browsers can cache the streams used by ZoneMinder. In order to prevent his a harmless random string can be appended to the url to make each invocation of the stream appear unique. +RAND_STREAM - Some browsers can cache the streams used by ZoneMinder. In order to prevent this a harmless random string can be appended to the url to make each invocation of the stream appear unique. OPT_CAMBOZOLA - Cambozola is a handy low fat cheese flavoured Java applet that ZoneMinder uses to view image streams on browsers such as Internet Explorer that don't natively support this format. If you use this browser it is highly recommended to install this from http://www.charliemouse.com/code/cambozola/ however if it is not installed still images at a lower refresh rate can still be viewed. diff --git a/docs/userguide/options/options_paths.rst b/docs/userguide/options/options_paths.rst index 024998194..1d4911f70 100644 --- a/docs/userguide/options/options_paths.rst +++ b/docs/userguide/options/options_paths.rst @@ -7,8 +7,6 @@ ZM_DIR_EVENTS - This is the path to the events directory where all the event ima USE_DEEP_STORAGE - Traditionally ZoneMinder stores all events for a monitor in one directory for that monitor. This is simple and efficient except when you have very large amounts of events. Some filesystems are unable to store more than 32k files in one directory and even without this limitation, large numbers of files in a directory can slow creation and deletion of files. This option allows you to select an alternate method of storing events by year/month/day/hour/min/second which has the effect of separating events out into more directories, resulting in less per directory, and also making it easier to manually navigate to any events that may have happened at a particular time or date. -DIR_IMAGES - ZoneMinder generates a myriad of images, mostly of which are associated with events. For those that aren't this is where they go. CAUTION: The directory you specify here cannot be outside the web root. This is a common mistake. Most users should never change this value. If you intend to save images to a second disk or network share, then you should mount the drive or share directly to the ZoneMinder images folder or follow the instructions in the ZoneMinder Wiki titled Using a dedicated Hard Drive. - DIR_SOUNDS - ZoneMinder can optionally play a sound file when an alarm is detected. This indicates where to look for this file. CAUTION: The directory you specify here cannot be outside the web root. Most users should never change this value. PATH_ZMS - The ZoneMinder streaming server is required to send streamed images to your browser. It will be installed into the cgi-bin path given at configuration time. This option determines what the web path to the server is rather than the local path on your machine. Ordinarily the streaming server runs in parser-header mode however if you experience problems with streaming you can change this to non-parsed-header (nph) mode by changing 'zms' to 'nph-zms'. diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index 3f92bd5da..990b8ce06 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -2,6 +2,7 @@ # Create files from the .in files configure_file(apache.conf.in "${CMAKE_CURRENT_BINARY_DIR}/apache.conf" @ONLY) +configure_file(nginx.conf.in "${CMAKE_CURRENT_BINARY_DIR}/nginx.conf" @ONLY) configure_file(logrotate.conf.in "${CMAKE_CURRENT_BINARY_DIR}/logrotate.conf" @ONLY) configure_file(syslog.conf.in "${CMAKE_CURRENT_BINARY_DIR}/syslog.conf" @ONLY) configure_file(com.zoneminder.systemctl.policy.in "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.policy" @ONLY) diff --git a/misc/nginx.conf.in b/misc/nginx.conf.in new file mode 100644 index 000000000..47dc3ce68 --- /dev/null +++ b/misc/nginx.conf.in @@ -0,0 +1,61 @@ +# +# PLEASE NOTE THAT THIS FILE IS INTENDED FOR GUIDANCE ONLY AND MAY NOT BE APPROPRIATE FOR YOUR DISTRIBUTION +# + +server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + server_name = localhost $hostname; + + ssl_certificate "/etc/pki/tls/certs/localhost.crt"; + ssl_certificate_key "/etc/pki/tls/private/localhost.key"; + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 10m; + ssl_ciphers PROFILE=SYSTEM; + ssl_prefer_server_ciphers on; + + # Auto redirect to server/zm when no url suffix was given + location = / { + return 301 zm; + } + + location /cgi-bin-zm { + gzip off; + alias "@ZM_CGIDIR@"; + + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass unix:/run/fcgiwrap.sock; + } + + location /zm/cache { + alias "@ZM_CACHEDIR@"; + } + + location /zm { + gzip off; + alias "@ZM_WEBDIR@"; + index index.php; + + location ~ \.php$ { + try_files $uri =404; + expires epoch; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_index index.php; + fastcgi_pass unix:/run/php-fpm/www.sock; + } + + location ~ \.(jpg|jpeg|gif|png|ico)$ { + access_log off; + expires 33d; + } + + location /zm/api/ { + alias "@ZM_WEBDIR@"; + rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last; + } + } + +} + diff --git a/onvif/proxy/lib/ONVIF/Device/Interfaces/Device/DevicePort.pm b/onvif/proxy/lib/ONVIF/Device/Interfaces/Device/DevicePort.pm index 35f259f31..c3c488ba1 100644 --- a/onvif/proxy/lib/ONVIF/Device/Interfaces/Device/DevicePort.pm +++ b/onvif/proxy/lib/ONVIF/Device/Interfaces/Device/DevicePort.pm @@ -25,15 +25,13 @@ sub GetServices { soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServices', style => 'document', body => { - - - 'use' => 'literal', + use => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( ONVIF::Device::Elements::GetServices )], }, header => { - + }, headerfault => { @@ -50,9 +48,7 @@ sub GetServiceCapabilities { soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServiceCapabilities', style => 'document', body => { - - - 'use' => 'literal', + use => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/', encodingStyle => '', parts => [qw( ONVIF::Device::Elements::GetServiceCapabilities )], @@ -3059,7 +3055,7 @@ Returns a L object. @@ -3069,7 +3065,7 @@ Returns a L object. @@ -3085,7 +3081,7 @@ Returns a L object. diff --git a/onvif/proxy/lib/ONVIF/PTZ/Interfaces/PTZ/PTZPort.pm b/onvif/proxy/lib/ONVIF/PTZ/Interfaces/PTZ/PTZPort.pm index 8d42d439e..d1c5faa29 100644 --- a/onvif/proxy/lib/ONVIF/PTZ/Interfaces/PTZ/PTZPort.pm +++ b/onvif/proxy/lib/ONVIF/PTZ/Interfaces/PTZ/PTZPort.pm @@ -830,7 +830,7 @@ Returns a L object. diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index f1bfa2ed1..3ecded8db 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -31,7 +31,7 @@ configure_file(zm.in "${CMAKE_CURRENT_BINARY_DIR}/zm" @ONLY) file(GLOB perlscripts "*.pl") FOREACH(PERLSCRIPT ${perlscripts}) get_filename_component(PERLSCRIPTNAME ${PERLSCRIPT} NAME) - POD2MAN(${PERLSCRIPT} zoneminder-${PERLSCRIPTNAME} 8) + POD2MAN(${PERLSCRIPT} zoneminder-${PERLSCRIPTNAME} 8 ${ZM_MANPAGE_DEST_PREFIX}) ENDFOREACH(PERLSCRIPT ${perlscripts}) # Install the perl scripts diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in index d48747703..92085b07b 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Config.pm.in @@ -309,6 +309,8 @@ saving configuration is a convenient way to ensure that the configuration held in the database corresponds with the most recent definitions and that all components are using the same set of configuration. +=back + =head2 EXPORT None by default. diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index eac13cb75..846a62f82 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -659,7 +659,7 @@ our @options = ( description => 'Add a random string to prevent caching of streams', help => q` Some browsers can cache the streams used by ZoneMinder. In - order to prevent his a harmless random string can be appended + order to prevent this a harmless random string can be appended to the url to make each invocation of the stream appear unique. `, type => $types{boolean}, @@ -1202,6 +1202,20 @@ our @options = ( category => 'logging', }, { + name => 'ZM_LOG_FFMPEG', + default => 'yes', + description => 'Log FFMPEG messages', + help => q` + When enabled (default is on), this option will log FFMPEG messages. + FFMPEG messages can be useful when debugging streaming issues. However, + depending on your distro and FFMPEG version, this may also result in + more logs than you'd typically like to see. If all your streams are working + well, you may choose to turn this off. + `, + type => $types{boolean}, + category => 'logging', + }, +{ name => 'ZM_LOG_DEBUG', default => 'no', description => 'Switch debugging on', diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/IPCAMIOS.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/IPCAMIOS.pm index 8465ee472..ec3bbfc70 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/IPCAMIOS.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/IPCAMIOS.pm @@ -16,7 +16,7 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # ========================================================================== # diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/Reolink.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/Reolink.pm index 370d463c3..7a2f72fc6 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/Reolink.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/Reolink.pm @@ -16,7 +16,7 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # ========================================================================== # diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm index b1fca1d16..173c0033c 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm @@ -41,17 +41,18 @@ our @ISA = qw(Exporter ZoneMinder::Base); # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( - 'functions' => [ qw( + functions => [ qw( zmDbConnect zmDbDisconnect zmDbGetMonitors zmDbGetMonitor zmDbGetMonitorAndControl + zmDbDo ) ] ); push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } ); our @EXPORT = qw(); @@ -66,8 +67,6 @@ our $VERSION = $ZoneMinder::Base::VERSION; use ZoneMinder::Logger qw(:all); use ZoneMinder::Config qw(:all); -use Carp; - our $dbh = undef; sub zmDbConnect { @@ -93,7 +92,7 @@ sub zmDbConnect { my $sslOptions = ''; if ( $Config{ZM_DB_SSL_CA_CERT} ) { - $sslOptions = ';'.join(';', + $sslOptions = join(';','', 'mysql_ssl=1', 'mysql_ssl_ca_file='.$Config{ZM_DB_SSL_CA_CERT}, 'mysql_ssl_client_key='.$Config{ZM_DB_SSL_CLIENT_KEY}, @@ -102,8 +101,9 @@ sub zmDbConnect { } eval { - $dbh = DBI->connect( 'DBI:mysql:database='.$Config{ZM_DB_NAME} - .$socket . $sslOptions . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '') + $dbh = DBI->connect( + 'DBI:mysql:database='.$Config{ZM_DB_NAME} + .$socket . $sslOptions . ($options?join(';', '', map { $_.'='.$$options{$_} } keys %{$options} ) : '') , $Config{ZM_DB_USER} , $Config{ZM_DB_PASS} ); @@ -125,7 +125,7 @@ sub zmDbConnect { sub zmDbDisconnect { if ( defined( $dbh ) ) { - $dbh->disconnect(); + $dbh->disconnect() or Error('Error disconnecting db? ' . $dbh->errstr()); $dbh = undef; } } @@ -141,7 +141,7 @@ sub zmDbGetMonitors { zmDbConnect(); my $function = shift || DB_MON_ALL; - my $sql = "select * from Monitors"; + my $sql = 'SELECT * FROM Monitors'; if ( $function ) { if ( $function == DB_MON_CAPT ) { @@ -156,26 +156,38 @@ sub zmDbGetMonitors { $sql .= " where Function = 'Nodect'"; } } - my $sth = $dbh->prepare_cached( $sql ) - or croak( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute() - or croak( "Can't execute '$sql': ".$sth->errstr() ); + my $sth = $dbh->prepare_cached( $sql ); + if ( ! $sth ) { + Error("Can't prepare '$sql': ".$dbh->errstr()); + return undef; + } + my $res = $sth->execute(); + if ( ! $res ) { + Error("Can't execute '$sql': ".$sth->errstr()); + return undef; + } my @monitors; while( my $monitor = $sth->fetchrow_hashref() ) { push( @monitors, $monitor ); } $sth->finish(); - return( \@monitors ); + return \@monitors; } sub zmSQLExecute { my $sql = shift; - - my $sth = $dbh->prepare_cached( $sql ) - or croak( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( @_ ) - or croak( "Can't execute '$sql': ".$sth->errstr() ); + + my $sth = $dbh->prepare_cached( $sql ); + if ( ! $sth ) { + Error("Can't prepare '$sql': ".$dbh->errstr()); + return undef; + } + my $res = $sth->execute( @_ ); + if ( ! $res ) { + Error("Can't execute '$sql': ".$sth->errstr()); + return undef; + } return 1; } @@ -185,17 +197,22 @@ sub zmDbGetMonitor { my $id = shift; if ( !defined($id) ) { - croak("Undefined id in zmDbgetMonitor"); + Error('Undefined id in zmDbgetMonitor'); return undef ; } my $sql = 'SELECT * FROM Monitors WHERE Id = ?'; - my $sth = $dbh->prepare_cached($sql) - or croak("Can't prepare '$sql': ".$dbh->errstr()); - my $res = $sth->execute($id) - or croak("Can't execute '$sql': ".$sth->errstr()); + my $sth = $dbh->prepare_cached($sql); + if ( !$sth ) { + Error("Can't prepare '$sql': ".$dbh->errstr()); + return undef; + } + my $res = $sth->execute($id); + if ( !$res ) { + Error("Can't execute '$sql': ".$sth->errstr()); + return undef; + } my $monitor = $sth->fetchrow_hashref(); - return $monitor; } @@ -204,25 +221,28 @@ sub zmDbGetMonitorAndControl { my $id = shift; - return( undef ) if ( !defined($id) ); + return undef if !defined($id); - my $sql = "SELECT C.*,M.*,C.Protocol + my $sql = 'SELECT C.*,M.*,C.Protocol FROM Monitors as M INNER JOIN Controls as C on (M.ControlId = C.Id) - WHERE M.Id = ?" + WHERE M.Id = ?' ; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $id ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + my $sth = $dbh->prepare_cached($sql); + if ( !$sth ) { + Error("Can't prepare '$sql': ".$dbh->errstr()); + return undef; + } + my $res = $sth->execute( $id ); + if ( !$res ) { + Error("Can't execute '$sql': ".$sth->errstr()); + return undef; + } my $monitor = $sth->fetchrow_hashref(); - - return( $monitor ); + return $monitor; } sub start_transaction { - #my ( $caller, undef, $line ) = caller; -#$openprint::log->debug("Called start_transaction from $caller : $line"); my $d = shift; $d = $dbh if ! $d; my $ac = $d->{AutoCommit}; @@ -231,20 +251,29 @@ sub start_transaction { } # end sub start_transaction sub end_transaction { - #my ( $caller, undef, $line ) = caller; - #$openprint::log->debug("Called end_transaction from $caller : $line"); my ( $d, $ac ) = @_; if ( ! defined $ac ) { Error("Undefined ac"); } $d = $dbh if ! $d; if ( $ac ) { - #$log->debug("Committing"); $d->commit(); } # end if $d->{AutoCommit} = $ac; } # end sub end_transaction +# Basic execution of $dbh->do but with some pretty logging of the sql on error. +# Returns 1 on success, 0 on error +sub zmDbDo { + my $sql = shift; + if ( ! $dbh->do($sql, undef, @_) ) { + $sql =~ s/\?/'%s'/; + Error(sprintf("Failed $sql :", @_).$dbh->errstr()); + return 0; + } + return 1; +} + 1; __END__ @@ -266,6 +295,7 @@ zmDbDisconnect zmDbGetMonitors zmDbGetMonitor zmDbGetMonitorAndControl +zmDbDo =head1 AUTHOR diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index d52c9829e..5916f8cdb 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -70,6 +70,7 @@ $serial = $primary_key = 'Id'; Frames AlarmFrames DefaultVideo + SaveJPEGs TotScore AvgScore MaxScore @@ -83,6 +84,7 @@ $serial = $primary_key = 'Id'; StateId Orientation DiskSpace + Scheme ); use POSIX; @@ -168,6 +170,8 @@ sub Path { sub Scheme { my $self = shift; + $$self{Scheme} = shift if @_; + if ( ! $$self{Scheme} ) { if ( $$self{RelativePath} ) { if ( $$self{RelativePath} =~ /^\d+\/\d{4}\-\d{2}\-\d{2}\/\d+$/ ) { @@ -316,11 +320,11 @@ sub GenerateVideo { my $file_size = 'S'.$size; push( @file_parts, $file_size ); } - my $video_file = "$video_name-".$file_parts[0]."-".$file_parts[1].".$format"; + my $video_file = join('-', $video_name, $file_parts[0], $file_parts[1] ).'.'.$format; if ( $overwrite || !-s $video_file ) { - Info( "Creating video file $video_file for event $self->{Id}\n" ); + Info("Creating video file $video_file for event $self->{Id}"); - my $frame_rate = sprintf( "%.2f", $self->{Frames}/$self->{FullLength} ); + my $frame_rate = sprintf('%.2f', $self->{Frames}/$self->{FullLength}); if ( $rate ) { if ( $rate != 1.0 ) { $frame_rate *= $rate; @@ -351,19 +355,19 @@ sub GenerateVideo { .$Config{ZM_FFMPEG_OUTPUT_OPTIONS} ." '$video_file' > ffmpeg.log 2>&1" ; - Debug( $command."\n" ); + Debug($command); my $output = qx($command); my $status = $? >> 8; if ( $status ) { - Error( "Unable to generate video, check $event_path/ffmpeg.log for details"); + Error("Unable to generate video, check $event_path/ffmpeg.log for details"); return; } - Info( "Finished $video_file\n" ); + Info("Finished $video_file"); return $event_path.'/'.$video_file; } else { - Info( "Video file $video_file already exists for event $self->{Id}\n" ); + Info("Video file $video_file already exists for event $self->{Id}"); return $event_path.'/'.$video_file; } return; @@ -371,57 +375,49 @@ sub GenerateVideo { sub delete { my $event = $_[0]; - if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) { - my ( $caller, undef, $line ) = caller; - Warning("Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime} from $caller:$line\n"); - return; - } - if ( ! -e $event->Storage()->Path() ) { - Warning("Not deleting event because storage path doesn't exist"); - return; - } - Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n"); - $ZoneMinder::Database::dbh->ping(); - $ZoneMinder::Database::dbh->begin_work(); - #$event->lock_and_load(); + my $in_zmaudit = ( $0 =~ 'zmaudit.pl$'); - { - my $sql = 'DELETE FROM Frames WHERE EventId=?'; - my $sth = $ZoneMinder::Database::dbh->prepare_cached($sql) - or Error( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() ); - my $res = $sth->execute($event->{Id}) - or Error( "Can't execute '$sql': ".$sth->errstr() ); - $sth->finish(); + if ( ! $in_zmaudit ) { + if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) { + # zmfilter shouldn't delete anything in an odd situation. zmaudit will though. + my ( $caller, undef, $line ) = caller; + Warning("$0 Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:". + (defined($event->{StartTime})?$event->{StartTime}:'undef')." from $caller:$line"); + return; + } + if ( !($event->Storage()->Path() and -e $event->Storage()->Path()) ) { + Warning('Not deleting event because storage path doesn\'t exist'); + return; + } + } + + if ( $$event{Id} ) { + # Need to have an event Id if we are to delete from the db. + Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}"); + $ZoneMinder::Database::dbh->ping(); + + $ZoneMinder::Database::dbh->begin_work(); + #$event->lock_and_load(); + + ZoneMinder::Database::zmDbDo('DELETE FROM Frames WHERE EventId=?', $$event{Id}); + if ( $ZoneMinder::Database::dbh->errstr() ) { + $ZoneMinder::Database::dbh->commit(); + return; + } + ZoneMinder::Database::zmDbDo('DELETE FROM Stats WHERE EventId=?', $$event{Id}); if ( $ZoneMinder::Database::dbh->errstr() ) { $ZoneMinder::Database::dbh->commit(); return; } - $sql = 'DELETE FROM Stats WHERE EventId=?'; - $sth = $ZoneMinder::Database::dbh->prepare_cached($sql) - or Error("Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr()); - $res = $sth->execute($event->{Id}) - or Error("Can't execute '$sql': ".$sth->errstr()); - $sth->finish(); - if ( $ZoneMinder::Database::dbh->errstr() ) { - $ZoneMinder::Database::dbh->commit(); - return; - } + # Do it individually to avoid locking up the table for new events + ZoneMinder::Database::zmDbDo('DELETE FROM Events WHERE Id=?', $$event{Id}); + $ZoneMinder::Database::dbh->commit(); } -# Do it individually to avoid locking up the table for new events - { - my $sql = 'DELETE FROM Events WHERE Id=?'; - my $sth = $ZoneMinder::Database::dbh->prepare_cached($sql) - or Error("Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr()); - my $res = $sth->execute($event->{Id}) - or Error("Can't execute '$sql': ".$sth->errstr()); - $sth->finish(); - } - $ZoneMinder::Database::dbh->commit(); - if ( (! $Config{ZM_OPT_FAST_DELETE}) and $event->Storage()->DoDelete() ) { - $event->delete_files( ); + if ( ( $in_zmaudit or (!$Config{ZM_OPT_FAST_DELETE})) and $event->Storage()->DoDelete() ) { + $event->delete_files(); } else { Debug('Not deleting event files from '.$event->Path().' for speed.'); } @@ -430,11 +426,11 @@ sub delete { sub delete_files { my $event = shift; - my $Storage = @_ ? $_[0] : new ZoneMinder::Storage( $$event{StorageId} ); + my $Storage = @_ ? $_[0] : new ZoneMinder::Storage($$event{StorageId}); my $storage_path = $Storage->Path(); if ( ! $storage_path ) { - Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId} "); + Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId}"); return; } @@ -466,14 +462,14 @@ sub delete_files { if ( $bucket->delete_key($event_path) ) { $deleted = 1; } else { - Error("Failed to delete from S3:".$s3->err . ": " . $s3->errstr); + Error('Failed to delete from S3:'.$s3->err . ': ' . $s3->errstr); } }; Error($@) if $@; } - if ( ! $deleted ) { + if ( !$deleted ) { my $command = "/bin/rm -rf $storage_path/$event_path"; - ZoneMinder::General::executeShellCommand( $command ); + ZoneMinder::General::executeShellCommand($command); } } @@ -482,7 +478,7 @@ sub delete_files { Debug("Deleting link for Event $$event{Id} from $storage_path/$link_path."); if ( $link_path ) { ( $link_path ) = ( $link_path =~ /^(.*)$/ ); # De-taint - unlink($storage_path.'/'.$link_path) or Error( "Unable to unlink '$storage_path/$link_path': $!" ); + unlink($storage_path.'/'.$link_path) or Error("Unable to unlink '$storage_path/$link_path': $!"); } } } # end sub delete_files @@ -502,7 +498,7 @@ sub check_for_in_filesystem { if ( $path ) { if ( -e $path ) { my @files = glob "$path/*"; - Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files"); + Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . ' files'); return 1 if @files; } else { Warning("Path not found for Event $_[0]{Id} at $path"); @@ -573,7 +569,7 @@ sub MoveTo { if ( $$OldStorage{Id} != $$self{StorageId} ) { $ZoneMinder::Database::dbh->commit(); - return "Old Storage path changed, Event has moved somewhere else."; + return 'Old Storage path changed, Event has moved somewhere else.'; } $$self{Storage} = $NewStorage; @@ -617,11 +613,11 @@ Debug("Files to move @files"); Debug("Moving file $file to $NewPath"); my $size = -s $file; if ( ! $size ) { - Info("Not moving file with 0 size"); + Info('Not moving file with 0 size'); } my $file_contents = File::Slurp::read_file($file); if ( ! $file_contents ) { - die "Loaded empty file, but it had a size. Giving up"; + die 'Loaded empty file, but it had a size. Giving up'; } my $filename = $event_path.'/'.File::Basename::basename($file); @@ -629,7 +625,7 @@ Debug("Files to move @files"); die "Unable to add key for $filename"; } my $duration = time - $starttime; - Debug("PUT to S3 " . Number::Bytes::Human::format_bytes($size) . " in $duration seconds = " . Number::Bytes::Human::format_bytes($duration?$size/$duration:$size) . '/sec'); + Debug('PUT to S3 ' . Number::Bytes::Human::format_bytes($size) . " in $duration seconds = " . Number::Bytes::Human::format_bytes($duration?$size/$duration:$size) . '/sec'); } # end foreach file. $moved = 1; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/General.pm b/scripts/ZoneMinder/lib/ZoneMinder/General.pm index 900a8985f..d16c248d5 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/General.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/General.pm @@ -1,27 +1,3 @@ -# ========================================================================== -# -# ZoneMinder General Utility Module, $Date$, $Revision$ -# Copyright (C) 2001-2008 Philip Coombes -# -# 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. -# -# ========================================================================== -# -# This module contains the common definitions and functions used by the rest -# of the ZoneMinder scripts -# package ZoneMinder::General; use 5.006; @@ -42,7 +18,7 @@ our @ISA = qw(Exporter ZoneMinder::Base); # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( - 'functions' => [ qw( + functions => [ qw( executeShellCommand getCmdFormat runCommand @@ -56,7 +32,7 @@ our %EXPORT_TAGS = ( ); push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } ); our @EXPORT = qw(); @@ -80,74 +56,74 @@ sub executeShellCommand { my $output = qx( $command ); my $status = $? >> 8; if ( $status || logDebugging() ) { - Debug( "Command: $command\n" ); + Debug("Command: $command"); chomp( $output ); - Debug( "Output: $output\n" ); + Debug("Output: $output"); } - return( $status ); + return $status; } sub getCmdFormat { - Debug( "Testing valid shell syntax\n" ); + Debug("Testing valid shell syntax"); my ( $name ) = getpwuid( $> ); if ( $name eq $Config{ZM_WEB_USER} ) { - Debug( "Running as '$name', su commands not needed\n" ); - return( "" ); + Debug("Running as '$name', su commands not needed"); + return ''; } - my $null_command = "true"; + my $null_command = 'true'; - my $prefix = "sudo -u ".$Config{ZM_WEB_USER}." "; - my $suffix = ""; + my $prefix = 'sudo -u '.$Config{ZM_WEB_USER}.' '; + my $suffix = ''; my $command = $prefix.$null_command.$suffix; - Debug( "Testing \"$command\"\n" ); + Debug("Testing \"$command\""); my $output = qx($command 2>&1); my $status = $? >> 8; $output //= $!; if ( !$status ) { - Debug( "Test ok, using format \"$prefix$suffix\"\n" ); + Debug("Test ok, using format \"$prefix$suffix\""); return( $prefix, $suffix ); } else { chomp( $output ); - Debug( "Test failed, '$output'\n" ); + Debug("Test failed, '$output'"); - $prefix = "su ".$Config{ZM_WEB_USER}." --shell=/bin/sh --command='"; - $suffix = "'"; + $prefix = 'su '.$Config{ZM_WEB_USER}.q` --shell=/bin/sh --command='`; + $suffix = q`'`; $command = $prefix.$null_command.$suffix; - Debug( "Testing \"$command\"\n" ); + Debug("Testing \"$command\""); my $output = qx($command 2>&1); my $status = $? >> 8; $output //= $!; if ( !$status ) { - Debug( "Test ok, using format \"$prefix$suffix\"\n" ); + Debug("Test ok, using format \"$prefix$suffix\""); return( $prefix, $suffix ); } else { - chomp( $output ); - Debug( "Test failed, '$output'\n" ); + chomp($output); + Debug("Test failed, '$output'"); $prefix = "su ".$Config{ZM_WEB_USER}." -c '"; $suffix = "'"; $command = $prefix.$null_command.$suffix; - Debug( "Testing \"$command\"\n" ); + Debug("Testing \"$command\""); $output = qx($command 2>&1); $status = $? >> 8; $output //= $!; if ( !$status ) { - Debug( "Test ok, using format \"$prefix$suffix\"\n" ); + Debug("Test ok, using format \"$prefix$suffix\""); return( $prefix, $suffix ); } else { - chomp( $output ); - Debug( "Test failed, '$output'\n" ); + chomp($output); + Debug("Test failed, '$output'"); } } } - Error( "Unable to find valid 'su' syntax\n" ); - exit( -1 ); -} + Error("Unable to find valid 'su' syntax"); + exit -1; +} # end sub getCmdFormat our $testedShellSyntax = 0; our ( $cmdPrefix, $cmdSuffix ); @@ -161,23 +137,23 @@ sub runCommand { } my $command = shift; - $command = $Config{ZM_PATH_BIN}."/".$command; + $command = $Config{ZM_PATH_BIN}.'/'.$command; if ( $cmdPrefix ) { $command = $cmdPrefix.$command.$cmdSuffix; } - Debug( "Command: $command\n" ); + Debug("Command: $command"); my $output = qx($command); my $status = $? >> 8; - chomp( $output ); + chomp($output); if ( $status || logDebugging() ) { if ( $status ) { - Error( "Unable to run \"$command\", output is \"$output\", status is $status\n" ); + Error("Unable to run \"$command\", output is \"$output\", status is $status"); } else { - Debug( "Output: $output\n" ); + Debug("Output: $output"); } } - return( $output ); -} + return $output; +} # end sub runCommand sub createEventPath { my $event = shift; @@ -210,7 +186,7 @@ sub _checkProcessOwner { $_setFileOwner = 0; } } - return( $_setFileOwner ); + return $_setFileOwner; } sub setFileOwner { @@ -219,7 +195,7 @@ sub setFileOwner { if ( _checkProcessOwner() ) { chown( $_ownerUid, $_ownerGid, $file ) or Fatal( "Can't change ownership of file '$file' to '" - .$Config{ZM_WEB_USER}.":".$Config{ZM_WEB_GROUP}."': $!" + .$Config{ZM_WEB_USER}.':'.$Config{ZM_WEB_GROUP}."': $!" ); } } @@ -234,13 +210,13 @@ sub _checkForImageInfo { }; $_hasImageInfo = $@?0:1; } - return( $_hasImageInfo ); + return $_hasImageInfo; } sub createEvent { my $event = shift; - Debug( "Creating event" ); + Debug('Creating event'); #print( Dumper( $event )."\n" ); _checkForImageInfo(); @@ -561,38 +537,33 @@ __END__ =head1 NAME -ZoneMinder::Database - Perl extension for blah blah blah +ZoneMinder::General - Utility Functions for ZoneMinder =head1 SYNOPSIS -use ZoneMinder::Database; +use ZoneMinder::General; blah blah blah =head1 DESCRIPTION -Stub documentation for ZoneMinder, created by h2xs. It looks like the -author of the extension was negligent enough to leave the stub -unedited. - -Blah blah blah. +This module contains the common definitions and functions used by the rest +of the ZoneMinder scripts =head2 EXPORT -None by default. + functions => [ qw( + executeShellCommand + getCmdFormat + runCommand + setFileOwner + createEventPath + createEvent + makePath + jsonEncode + jsonDecode + ) ] - -=head1 SEE ALSO - -Mention other useful documentation such as the documentation of -related modules or operating system documentation (such as man pages - in UNIX), or any relevant external documentation such as RFCs or -standards. - -If you have a mailing list set up for your module, mention it here. - -If you have a web site set up for your module, mention it here. - =head1 AUTHOR Philip Coombes, Ephilip.coombes@zoneminder.comE @@ -601,9 +572,18 @@ Philip Coombes, Ephilip.coombes@zoneminder.comE Copyright (C) 2001-2008 Philip Coombes -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself, either Perl version 5.8.3 or, -at your option, any later version of Perl 5 you may have available. +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. =cut diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm index 3caa6af4a..eb7a8824d 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm @@ -310,7 +310,7 @@ sub reinitialise { # Bit of a nasty hack to reopen connections to log files and the DB my $syslogLevel = $this->syslogLevel(); - $this->syslogLevel( NOLOG ); + $this->syslogLevel(NOLOG); $this->syslogLevel($syslogLevel) if $syslogLevel > NOLOG; my $logfileLevel = $this->fileLevel(); @@ -321,11 +321,10 @@ sub reinitialise { $this->databaseLevel(NOLOG); $this->databaseLevel($databaseLevel) if $databaseLevel > NOLOG; - my $screenLevel = $this->termLevel(); + $this->{hasTerm} = -t STDERR; + my $termLevel = $this->termLevel(); $this->termLevel(NOLOG); - $this->termLevel($screenLevel) if $screenLevel > NOLOG; - - $this->{sth} = undef; + $this->termLevel($termLevel) if $termLevel > NOLOG; } # Prevents undefined logging levels @@ -439,16 +438,13 @@ sub databaseLevel { my $databaseLevel = shift; if ( defined($databaseLevel) ) { $databaseLevel = $this->limit($databaseLevel); - if ( $this->{databaseLevel} != $databaseLevel ) { - if ( ( $databaseLevel > NOLOG ) and ( $this->{databaseLevel} <= NOLOG ) ) { - if ( !$this->{dbh} ) { - $this->{dbh} = ZoneMinder::Database::zmDbConnect(); - } - } elsif ( $databaseLevel <= NOLOG && $this->{databaseLevel} > NOLOG ) { - undef($this->{dbh}); - } - $this->{databaseLevel} = $databaseLevel; + if ( $databaseLevel > NOLOG ) { + $this->{dbh} = ZoneMinder::Database::zmDbConnect(); + } else { + undef($this->{dbh}); } + $this->{sth} = undef; + $this->{databaseLevel} = $databaseLevel; } return $this->{databaseLevel}; } @@ -558,12 +554,12 @@ sub logPrint { } if ( $level <= $this->{databaseLevel} ) { - if ( ! ( $this->{dbh} and $this->{dbh}->ping() ) ) { + if ( ! ( $ZoneMinder::Database::dbh and $ZoneMinder::Database::dbh->ping() ) ) { $this->{sth} = undef; # Turn this off because zDbConnect will do logging calls. my $oldlevel = $this->{databaseLevel}; $this->{databaseLevel} = NOLOG; - if ( ! ( $this->{dbh} = ZoneMinder::Database::zmDbConnect() ) ) { + if ( ! ZoneMinder::Database::zmDbConnect() ) { #print(STDERR "Can't log to database: "); return; } @@ -571,10 +567,10 @@ sub logPrint { } my $sql = 'INSERT INTO Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, NULL )'; - $this->{sth} = $this->{dbh}->prepare_cached($sql) if ! $this->{sth}; + $this->{sth} = $ZoneMinder::Database::dbh->prepare_cached($sql) if ! $this->{sth}; if ( !$this->{sth} ) { $this->{databaseLevel} = NOLOG; - Error("Can't prepare log entry '$sql': ".$this->{dbh}->errstr()); + Error("Can't prepare log entry '$sql': ".$ZoneMinder::Database::dbh->errstr()); return; } @@ -590,7 +586,7 @@ sub logPrint { ); if ( !$res ) { $this->{databaseLevel} = NOLOG; - Error("Can't execute log entry '$sql': ".$this->{dbh}->errstr()); + Error("Can't execute log entry '$sql': ".$ZoneMinder::Database::dbh->errstr()); } } # end if doing db logging } # end if level < effectivelevel @@ -705,7 +701,7 @@ sub Fatal( @ ) { $SIG{TERM}(); } # I think if we don't disconnect we will leave sockets around in TIME_WAIT - zmDbDisconnect(); + ZoneMinder::Database::zmDbDisconnect(); exit(-1); } diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 2529c8786..c04a66c42 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -161,7 +161,6 @@ our $mem_data = { format => { type=>'uint8', seq=>$mem_seq++ }, imagesize => { type=>'uint32', seq=>$mem_seq++ }, epadding1 => { type=>'uint32', seq=>$mem_seq++ }, - epadding2 => { type=>'uint32', seq=>$mem_seq++ }, startup_time => { type=>'time_t64', seq=>$mem_seq++ }, last_write_time => { type=>'time_t64', seq=>$mem_seq++ }, last_read_time => { type=>'time_t64', seq=>$mem_seq++ }, @@ -247,11 +246,12 @@ sub zmMemInit { sub zmMemVerify { my $monitor = shift; - if ( !zmMemAttach( $monitor, $mem_size ) ) { - return( undef ); + + if ( !zmMemAttach($monitor, $mem_size) ) { + return undef; } - my $sd_size = zmMemRead( $monitor, 'shared_data:size', 1 ); + my $sd_size = zmMemRead($monitor, 'shared_data:size', 1); if ( $sd_size != $mem_data->{shared_data}->{size} ) { if ( $sd_size ) { Error( "Shared data size conflict in shared_data for monitor " @@ -269,9 +269,9 @@ sub zmMemVerify { .", got ".$sd_size ); } - return( undef ); + return undef; } - my $td_size = zmMemRead( $monitor, 'trigger_data:size', 1 ); + my $td_size = zmMemRead($monitor, 'trigger_data:size', 1); if ( $td_size != $mem_data->{trigger_data}->{size} ) { if ( $td_size ) { Error( "Shared data size conflict in trigger_data for monitor " @@ -290,14 +290,17 @@ sub zmMemVerify { .$td_size ); } - return( undef ); + return undef; } - if ( !zmMemRead($monitor, 'shared_data:valid',1) ) { - Error( "Shared data not valid for monitor $$monitor{Id}" ); - return( undef ); + my $valid = zmMemRead($monitor, 'shared_data:valid',1); + if ( !$valid ) { + Error("Shared data not valid for monitor $$monitor{Id}"); + return undef; + } else { + Debug("Shared data appears vaild for monitor $$monitor{Id}: $valid"); } - return( !undef ); + return !undef; } sub zmMemRead { @@ -813,7 +816,7 @@ shared_data The general mapped memory section size The size, in bytes, of this section valid Flag indicating whether this section has been initialised active Flag indicating whether this monitor is active (enabled/disabled) -signal Flag indicating whether this monitor is reciving a valid signal +signal Flag indicating whether this monitor is receiving a valid signal state The current monitor state, see the STATE constants below last_write_index The last index, in the image buffer, that an image has been saved to last_read_index The last index, in the image buffer, that an image has been analysed from diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm index d782c6c9a..b9a8b6a1c 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm @@ -75,55 +75,50 @@ sub zmMemKey { sub zmMemAttach { my ( $monitor, $size ) = @_; - if ( ! $size ) { - Error( "No size passed to zmMemAttach for monitor $$monitor{Id}\n" ); + + if ( !$size ) { + Error("No size passed to zmMemAttach for monitor $$monitor{Id}"); return undef; } - if ( !defined($monitor->{MMapAddr}) ) { - - my $mmap_file = $Config{ZM_PATH_MAP}.'/zm.mmap.'.$monitor->{Id}; - if ( ! -e $mmap_file ) { - Error( sprintf( "Memory map file '%s' does not exist. zmc might not be running." - , $mmap_file - ) - ); - return undef; - } - my $mmap_file_size = -s $mmap_file; - - if ( $mmap_file_size < $size ) { - Error( sprintf( "Memory map file '%s' should have been %d but was instead %d" - , $mmap_file - , $size - , $mmap_file_size - ) - ); - return undef; - } - my $MMAP; - if ( !open( $MMAP, '+<', $mmap_file ) ) { - Error( sprintf( "Can't open memory map file '%s': $!", $mmap_file ) ); - return undef; - } - my $mmap = undef; - my $mmap_addr = mmap( $mmap, $size, PROT_READ|PROT_WRITE, MAP_SHARED, $MMAP ); - if ( !$mmap_addr || !$mmap ) { - Error( sprintf( "Can't mmap to file '%s': $!\n", $mmap_file ) ); - close( $MMAP ); - return undef; - } - $monitor->{MMapHandle} = $MMAP; - $monitor->{MMapAddr} = $mmap_addr; - $monitor->{MMap} = \$mmap; + if ( defined($monitor->{MMapAddr}) ) { + Debug("zmMemAttach already attached at $monitor->{MMapAddr}"); + return !undef; } + + my $mmap_file = $Config{ZM_PATH_MAP}.'/zm.mmap.'.$monitor->{Id}; + if ( ! -e $mmap_file ) { + Error("Memory map file '$mmap_file' does not exist. zmc might not be running."); + return undef; + } + my $mmap_file_size = -s $mmap_file; + + if ( $mmap_file_size < $size ) { + Error("Memory map file '$mmap_file' should have been $size but was instead $mmap_file_size"); + return undef; + } + my $MMAP; + if ( !open($MMAP, '+<', $mmap_file) ) { + Error("Can't open memory map file '$mmap_file': $!"); + return undef; + } + my $mmap = undef; + my $mmap_addr = mmap($mmap, $size, PROT_READ|PROT_WRITE, MAP_SHARED, $MMAP); + if ( !$mmap_addr || !$mmap ) { + Error("Can't mmap to file '$mmap_file': $!"); + close($MMAP); + return undef; + } + $monitor->{MMapHandle} = $MMAP; + $monitor->{MMapAddr} = $mmap_addr; + $monitor->{MMap} = \$mmap; return !undef; -} +} # end sub zmMemAttach sub zmMemDetach { my $monitor = shift; if ( $monitor->{MMap} ) { - if ( ! munmap( ${$monitor->{MMap}} ) ) { + if ( ! munmap(${$monitor->{MMap}}) ) { Warn( "Unable to munmap for monitor $$monitor{Id}\n"); } delete $monitor->{MMap}; @@ -132,7 +127,7 @@ sub zmMemDetach { delete $monitor->{MMapAddr}; } if ( $monitor->{MMapHandle} ) { - close( $monitor->{MMapHandle} ); + close($monitor->{MMapHandle}); delete $monitor->{MMapHandle}; } } @@ -144,13 +139,10 @@ sub zmMemGet { my $mmap = $monitor->{MMap}; if ( !$mmap || !$$mmap ) { - Error( sprintf( "Can't read from mapped memory for monitor '%d', gone away?" - , $monitor->{Id} - ) - ); + Error("Can't read from mapped memory for monitor '$$monitor{Id}', gone away?"); return undef; } - my $data = substr( $$mmap, $offset, $size ); + my $data = substr($$mmap, $offset, $size); return $data; } @@ -162,23 +154,20 @@ sub zmMemPut { my $mmap = $monitor->{MMap}; if ( !$mmap || !$$mmap ) { - Error( sprintf( "Can't write mapped memory for monitor '%d', gone away?" - , $monitor->{Id} - ) - ); - return( undef ); + Error("Can't write mapped memory for monitor '$$monitor{Id}', gone away?"); + return undef; } - substr( $$mmap, $offset, $size ) = $data; - return( !undef ); + substr($$mmap, $offset, $size) = $data; + return !undef; } sub zmMemClean { - Debug( "Removing memory map files\n" ); + Debug("Removing memory map files"); my $mapPath = $Config{ZM_PATH_MAP}.'/zm.mmap.*'; foreach my $mapFile( glob( $mapPath ) ) { ( $mapFile ) = $mapFile =~ /^(.+)$/; - Debug( "Removing memory map file '$mapFile'\n" ); - unlink( $mapFile ); + Debug("Removing memory map file '$mapFile'"); + unlink($mapFile); } } diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm index 8c28028a0..f779255b2 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm @@ -456,7 +456,7 @@ sub transform { sub to_string { my $type = ref($_[0]); my $fields = eval '\%'.$type.'::fields'; - return $type . ': '. join(' ' , map { $_[0]{$_} ? "$_ => $_[0]{$_}" : () } keys %$fields ); + return $type . ': '. join(' ' , map { $_[0]{$_} ? "$_ => $_[0]{$_}" : () } sort { $a cmp $b } keys %$fields ); } 1; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Storage.pm b/scripts/ZoneMinder/lib/ZoneMinder/Storage.pm index 134752594..1f7c1b9fe 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Storage.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Storage.pm @@ -15,7 +15,7 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # ========================================================================== # diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index 495fdc031..10917a729 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -48,7 +48,6 @@ use Time::HiRes qw/gettimeofday/; use Getopt::Long; use autouse 'Pod::Usage'=>qw(pod2usage); -use constant IMAGE_PATH => $Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_IMAGES}; use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|) ? $Config{ZM_DIR_EVENTS} : ($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS}) @@ -144,7 +143,8 @@ require ZoneMinder::Event; my $max_image_age = 6/24; # 6 hours my $max_swap_age = 24/24; # 24 hours -my $image_path = IMAGE_PATH; +# images now live under the event path +my $image_path = EVENT_PATH; my $loop = 1; my $cleaned = 0; @@ -384,7 +384,7 @@ MAIN: while( $loop ) { Debug("Checking for Medium Scheme Events under $$Storage{Path}/$monitor_dir"); { my @event_dirs = glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*"); - Debug(qq`glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*") returned ` . scalar @event_dirs . " entries." ); + Debug(qq`glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*") returned ` . scalar @event_dirs . ' entries.' ); foreach my $event_dir ( @event_dirs ) { if ( ! -d $event_dir ) { Debug( "$event_dir is not a dir. Skipping" ); @@ -403,6 +403,7 @@ MAIN: while( $loop ) { $$Event{RelativePath} = $event_dir; $Event->MonitorId( $monitor_dir ); $Event->StorageId( $Storage->Id() ); + $Event->StartTime( POSIX::strftime('%Y-%m-%d %H:%M:%S', gmtime(time_of_youngest_file($$Event{Path})) ) ); } # end foreach event } @@ -428,7 +429,7 @@ MAIN: while( $loop ) { } # end foreach event chdir( $Storage->Path() ); } # if USE_DEEP_STORAGE - Debug( 'Got '.int(keys(%$fs_events))." filesystem events for monitor $monitor_dir\n" ); + Debug( 'Got '.int(keys(%$fs_events))." filesystem events for monitor $monitor_dir" ); delete_empty_subdirs($$Storage{Path}.'/'.$monitor_dir); } # end foreach monitor @@ -446,13 +447,19 @@ MAIN: while( $loop ) { next; } my @event_ids = keys %$fs_events; - Debug("Have " .scalar @event_ids . " events for monitor $monitor_id"); + Debug('Have ' .scalar @event_ids . " events for monitor $monitor_id"); foreach my $fs_event_id ( sort { $a <=> $b } keys %$fs_events ) { my $Event = $fs_events->{$fs_event_id}; if ( ! defined( $db_events->{$fs_event_id} ) ) { + # Long running zmaudits can find events that were created after we loaded all db events. + # So do a secondary lookup + if ( ZoneMinder::Event->find_one(Id=>$fs_event_id) ) { + Debug("$$Event{Id} found in secondary lookup."); + next; + } my $age = $Event->age(); if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { @@ -490,7 +497,11 @@ MAIN: while( $loop ) { } } } # end foreach Storage Area - redo MAIN if ( $cleaned ); + + if ( $cleaned ) { + Debug("Events were deleted, starting again."); + redo MAIN; + } $cleaned = 0; my $deleteMonitorSql = 'DELETE LOW_PRIORITY FROM Monitors WHERE Id = ?'; @@ -508,68 +519,88 @@ MAIN: while( $loop ) { # Foreach database monitor and it's list of events. while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) { + Debug("Checking db events for monitor $db_monitor"); + if ( ! $db_events ) { + Debug("Skipping db events for $db_monitor because there are none"); + next; + } # If we found the monitor in the file system - if ( my $fs_events = $fs_monitors->{$db_monitor} ) { - next if ! $db_events; + my $fs_events = $fs_monitors->{$db_monitor}; - while ( my ( $db_event, $age ) = each( %$db_events ) ) { - if ( ! defined( $fs_events->{$db_event} ) ) { - my $Event = ZoneMinder::Event->find_one( Id=>$db_event ); - if ( ! $Event ) { - Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing."); - next; + while ( my ( $db_event, $age ) = each( %$db_events ) ) { + if ( ! ($fs_events and defined( $fs_events->{$db_event} ) ) ) { + Debug("Don't have an fs event for $db_event"); + my $Event = ZoneMinder::Event->find_one( Id=>$db_event ); + if ( ! $Event ) { + Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing."); + next; + } + Debug("Event $db_event is not in fs. Should have been at ".$Event->Path()); + if ( $Event->Archived() ) { + Warning("Event $$Event{Id} is Archived. Taking no further action on it."); + next; + } + if ( ! $Event->StartTime() ) { + Info("Event $$Event{Id} has no start time."); + if ( confirm() ) { + $Event->delete(); + $cleaned = 1; } - Debug("Event $db_event is not in fs. Should have been at ".$Event->Path()); - if ( $Event->Archived() ) { - Warning("Event $$Event{Id} is Archived. Taking no further action on it."); - next; - } - if ( ! $Event->StartTime() ) { - Info("Event $$Event{Id} has no start time. deleting it."); + next; + } + if ( ! $Event->EndTime() ) { + if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { + Info("Event $$Event{Id} has no end time and is $age seconds old. deleting it."); if ( confirm() ) { $Event->delete(); $cleaned = 1; } next; - } - if ( ! $Event->EndTime() ) { - if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { - Info("Event $$Event{Id} has no end time and is $age seconds old. deleting it."); - if ( confirm() ) { - $Event->delete(); - $cleaned = 1; - } - next; - } } - if ( $Event->check_for_in_filesystem() ) { - Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() ); - } else { - if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { - aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting' ); - if ( confirm() ) { - $Event->delete(); - $cleaned = 1; - } - } else { - aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" ); + } + if ( $Event->check_for_in_filesystem() ) { + Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() ); + } else { + if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { + aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting' ); + if ( confirm() ) { + $Event->delete(); + $cleaned = 1; } - } # end if exists in filesystem - } # end if ! in fs_events - } # foreach db_event - #} else { - #my $Monitor = new ZoneMinder::Monitor( $db_monitor ); - #my $Storage = $Monitor->Storage(); - #aud_print( "Database monitor '$db_monitor' does not exist in filesystem, should have been at ".$Storage->Path().'/'.$Monitor->Id()."\n" ); -#if ( confirm() ) -#{ -# We don't actually do this in case it's new -#my $res = $deleteMonitorSth->execute( $db_monitor ) -# or Fatal( "Can't execute: ".$deleteMonitorSth->errstr() ); -#$cleaned = 1; -#} - } + } else { + aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" ); + } + } # end if exists in filesystem + } else { + Debug("Found fs event for $db_event, $age at " . $$fs_events{$db_event}->Path()); + my $Event = new ZoneMinder::Event( $db_event ); + if ( ! $Event->check_for_in_filesystem() ) { + Warning("Not found at " . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path() ); + Warning($Event->to_string()); + Warning($$fs_events{$db_event}->to_string()); + if ( $$fs_events{$db_event}->Scheme() ne $Event->Scheme() ) { + Info("Updating scheme on event $$Event{Id} from $$Event{Scheme} to $$fs_events{$db_event}{Scheme}"); + $Event->Scheme($$fs_events{$db_event}->Scheme()); + } + if ( $$fs_events{$db_event}->StorageId() != $Event->StorageId() ) { + Info("Updating storage area on event $$Event{Id} from $$Event{StorageId} to $$fs_events{$db_event}{StorageId}"); + $Event->StorageId($$fs_events{$db_event}->StorageId()); + } + if ( $$fs_events{$db_event}->StartTime() ne $Event->StartTime() ) { + Info("Updating StartTime on event $$Event{Id} from $$Event{StartTime} to $$fs_events{$db_event}{StartTime}"); + if ( $$Event{Scheme} eq 'Deep' ) { + $Event->StartTime($$fs_events{$db_event}->StartTime()); + } else { + $Event->StartTime($$fs_events{$db_event}->StartTime()); + } + $Event->save(); + } + + $Event->save(); + } + } # end if ! in fs_events + } # foreach db_event } # end foreach db_monitor if ( $cleaned ) { Debug("Have done some cleaning, restarting."); @@ -954,7 +985,7 @@ sub delete_empty_directories { return; } my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR ); - Debug("delete_empty_directories $_[0] has " . @contents .' entries:' . ( @contents <= 2 ? join(',',@contents) : '' )); + #Debug("delete_empty_directories $_[0] has " . @contents .' entries:' . ( @contents <= 2 ? join(',',@contents) : '' )); my @dirs = map { -d $_[0].'/'.$_ ? $_ : () } @contents; if ( @dirs ) { Debug("Have " . @dirs . " dirs"); @@ -975,6 +1006,25 @@ sub delete_empty_directories { } } # end sub delete_empty_directories +sub time_of_youngest_file { + my $dir = shift; + + if ( ! opendir(DIR, $dir) ) { + Error("Can't open directory '$dir': $!"); + return; + } + my $youngest = (stat($dir))[9]; + Debug("stat of $dir is $youngest"); + foreach my $file ( readdir( DIR ) ) { + next if $file =~ /^\./; + $_ = (stat($dir))[9]; + $youngest = $_ if $_ and ( $_ < $youngest ); + #Debug("stat of $dir is $_ < $youngest"); + } + Debug("stat of $dir is $youngest"); + return $youngest; +} # end sub time_of_youngest_file + 1; __END__ diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index ac83fa6d6..67bbc294b 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -257,6 +257,8 @@ sub run { } my $fd = 0; + + # This also closes dbh and CLIENT and SERVER while( $fd < POSIX::sysconf(&POSIX::_SC_OPEN_MAX) ) { POSIX::close($fd++); } @@ -300,16 +302,17 @@ sub run { if ( $Config{ZM_SERVER_ID} ) { if ( ! ( $secs_count % 60 ) ) { - Debug("Connecting"); while ( (!$zm_terminate) and !($dbh and $dbh->ping()) ) { Warning("Not connected to db ($dbh)".($dbh?' ping('.$dbh->ping().')':''). ($DBI::errstr?" errstr($DBI::errstr)":'').' Reconnecting'); $dbh = zmDbConnect(); } + last if $zm_terminate; + my @cpuload = CpuLoad(); Debug("Updating Server record @cpuload"); if ( ! defined $dbh->do(q{UPDATE Servers SET Status=?,CpuLoad=?,TotalMem=?,FreeMem=?,TotalSwap=?,FreeSwap=? WHERE Id=?}, undef, 'Running', $cpuload[0], &totalmem, &freemem, &totalswap, &freeswap, $Config{ZM_SERVER_ID} ) ) { - Error("Failed Updating status of Server record for Id=$Config{ZM_SERVER_ID}".$dbh->errstr()); + Error("Failed Updating status of Server record for Id=$Config{ZM_SERVER_ID} :".$dbh->errstr()); } } $secs_count += 1; @@ -375,7 +378,7 @@ sub run { } # end while dPrint(ZoneMinder::Logger::INFO, 'Server exiting at ' - .strftime( '%y/%m/%d %H:%M:%S', localtime() ) + .strftime('%y/%m/%d %H:%M:%S', localtime()) ."\n" ); if ( $Config{ZM_SERVER_ID} ) { @@ -438,7 +441,7 @@ sub start { $dbh = zmDbConnect(1); # This logReinit is required. Not sure why. - #logReinit(); + logReinit(); $process->{pid} = $cpid; $process->{started} = time(); @@ -709,7 +712,7 @@ sub reaper { $process->{delay} = $Config{ZM_MAX_RESTART_DELAY}; } } - Debug("Delay for $$process{command} is now $$process{delay}"); + #Debug("Delay for $$process{command} is now $$process{delay}"); } else { delete $cmd_hash{$$process{command}}; } diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index f9029016a..3f7e720c3 100644 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -576,7 +576,8 @@ sub uploadArchFile { $host .= ':'.$Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT}; Info('Uploading to '.$host.' using SFTP'); my %sftpOptions = ( - host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER} + host=>$Config{ZM_UPLOAD_HOST}, + user=>$Config{ZM_UPLOAD_USER}, ($Config{ZM_UPLOAD_PASS} ? (password=>$Config{ZM_UPLOAD_PASS}) : ()), ($Config{ZM_UPLOAD_PORT} ? (port=>$Config{ZM_UPLOAD_PORT}) : ()), ($Config{ZM_UPLOAD_TIMEOUT} ? (timeout=>$Config{ZM_UPLOAD_TIMEOUT}) : ()), diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index b29235f65..167943952 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -54,35 +54,35 @@ if ( $command eq 'version' ) { my $state; my $dbh = zmDbConnect(); -Info("Command: $command"); -if ( !$command || $command !~ /^(?:start|stop|restart|status|logrot|version)$/ ) { - if ( $command ) { -# Check to see if it's a valid run state - my $sql = 'SELECT * FROM States WHERE Name=?'; - my $sth = $dbh->prepare_cached($sql) - or Fatal("Can't prepare '$sql': ".$dbh->errstr()); - my $res = $sth->execute($command) - or Fatal("Can't execute: ".$sth->errstr()); - if ( $state = $sth->fetchrow_hashref() ) { - #$state->{Name} = $command; - $state->{Definitions} = []; - foreach( split(',', $state->{Definition}) ) { - my ( $id, $function, $enabled ) = split(':', $_); - push( @{$state->{Definitions}}, - { Id=>$id, Function=>$function, Enabled=>$enabled } - ); - } - $store_state = $command; # PP - Remember the name that was passed to search in DB - $command = 'state'; - } else { - $command = undef; +Debug("Command: $command"); +if ( $command and ( $command !~ /^(?:start|stop|restart|status|logrot|version)$/ ) ) { + # Check to see if it's a valid run state + my $sql = 'SELECT * FROM States WHERE Name=?'; + my $sth = $dbh->prepare_cached($sql) + or Fatal("Can't prepare '$sql': ".$dbh->errstr()); + my $res = $sth->execute($command) + or Fatal("Can't execute: ".$sth->errstr()); + if ( $state = $sth->fetchrow_hashref() ) { + #$state->{Name} = $command; + $state->{Definitions} = []; + foreach( split(',', $state->{Definition}) ) { + my ( $id, $function, $enabled ) = split(':', $_); + push( @{$state->{Definitions}}, + { Id=>$id, Function=>$function, Enabled=>$enabled } + ); } + $store_state = $command; # PP - Remember the name that was passed to search in DB + $command = 'state'; + } else { + $command = undef; } - if ( !$command ) { - pod2usage(-exitstatus => -1); - } + $sth->finish(); } # end if not one of the usual commands +if ( !$command ) { + pod2usage(-exitstatus => -1); +} + # PP - Sane state check Debug("StartisActiveSSantiyCheck"); isActiveSanityCheck(); @@ -314,18 +314,14 @@ sub isActiveSanityCheck { if ( $sth->rows != 1 ) { # PP - no row, or too many rows. Either case is an error - Info( 'Fixing States table - either no default state or duplicate default states' ); - $sql = "DELETE FROM States WHERE Name='default'"; - $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - $res = $sth->execute() - or Fatal( "Can't execute: ".$sth->errstr() ); - $sql = q`"INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');`; - $sth = $dbh->prepare_cached($sql) - or Fatal("Can't prepare '$sql': ".$dbh->errstr()); - $res = $sth->execute() - or Fatal("Can't execute: ".$sth->errstr()); - } + Info('Fixing States table - either no default state or duplicate default states'); + if ( $sth->rows ) { + $dbh->do(q`DELETE FROM States WHERE Name='default'`) or Fatal("Can't execute: ".$dbh->errstr()); + } + $dbh->do(q`INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');`) + or Fatal("Can't execute: ".$dbh->errstr()); + } + $sth->finish(); # PP - Now make sure no two states have IsActive=1 $sql = 'SELECT Name FROM States WHERE IsActive = 1'; @@ -337,22 +333,17 @@ sub isActiveSanityCheck { if ( $sth->rows != 1 ) { Info('Fixing States table so only one run state is active'); resetStates(); - $sql = q`UPDATE States SET IsActive=1 WHERE Name='default'`; - $sth = $dbh->prepare_cached($sql) - or Fatal("Can't prepare '$sql': ".$dbh->errstr()); - $res = $sth->execute() - or Fatal("Can't execute: ".$sth->errstr()); + $dbh->do(q`UPDATE States SET IsActive=1 WHERE Name='default'`) + or Fatal("Can't execute: ".$dbh->errstr()); } + $sth->finish(); } # end sub isActiveSanityCheck # PP - zeroes out isActive for all states sub resetStates { $dbh = zmDbConnect() if ! $dbh; - my $sql = 'UPDATE States SET IsActive=0'; - my $sth = $dbh->prepare_cached($sql) - or Fatal("Can't prepare '$sql': ".$dbh->errstr()); - my $res = $sth->execute() - or Fatal("Can't execute: ".$sth->errstr()); + $dbh->do('UPDATE States SET IsActive=0') + or Fatal("Can't execute: ".$dbh->errstr()); } sub systemdRunning { @@ -400,7 +391,7 @@ zmpkg.pl - ZoneMinder Package Control Script =head1 SYNOPSIS -zmpkg.pl {start|stop|restart|status|logrot|'state'|version} +zmpkg.pl {start|stop|restart|status|logrot|state|version} =head1 DESCRIPTION diff --git a/scripts/zmstats.pl.in b/scripts/zmstats.pl.in index 25bccfebc..410459158 100644 --- a/scripts/zmstats.pl.in +++ b/scripts/zmstats.pl.in @@ -1,39 +1,4 @@ #!/usr/bin/perl -wT -# -# ========================================================================== -# -# ZoneMinder WatchDog Script, $Date$, $Revision$ -# Copyright (C) 2001-2008 Philip Coombes -# -# 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. -# -# ========================================================================== - -=head1 NAME - -zmwatch.pl - ZoneMinder Stats Updating Script - -=head1 SYNOPSIS - -zmstats.pl - -=head1 DESCRIPTION - -This does background updating various stats in the db like event counts, diskspace, etc. - -=cut use strict; use bytes; @@ -66,8 +31,8 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; logInit(); logSetSignal(); -Info( "Stats Daemon starting in ".START_DELAY." seconds\n" ); -sleep( START_DELAY ); +Info("Stats Daemon starting in ".START_DELAY." seconds"); +sleep(START_DELAY); my $dbh = zmDbConnect(); @@ -88,7 +53,43 @@ while( 1 ) { sleep($Config{ZM_STATS_UPDATE_INTERVAL}); } # end while (1) -Info( "Stats Daemon exiting\n" ); +Info("Stats Daemon exiting"); exit(); 1; __END__ + +# +# ========================================================================== +# +# ZoneMinder WatchDog Script, $Date$, $Revision$ +# Copyright (C) 2001-2008 Philip Coombes +# +# 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. +# +# ========================================================================== + +=head1 NAME + +zmstats.pl - ZoneMinder Stats Updating Script + +=head1 SYNOPSIS + +zmstats.pl + +=head1 DESCRIPTION + +This does background updating various stats in the db like event counts, diskspace, etc. + +=cut diff --git a/scripts/zmtrigger.pl.in b/scripts/zmtrigger.pl.in index b16e1cdd4..8e1257db9 100644 --- a/scripts/zmtrigger.pl.in +++ b/scripts/zmtrigger.pl.in @@ -311,7 +311,7 @@ while( 1 ) { # zmDbConnect will ping and reconnect if neccessary $dbh = zmDbConnect(); } # end while ( 1 ) -Info( "Trigger daemon exiting" ); +Info('Trigger daemon exiting'); exit; sub loadMonitor { @@ -327,7 +327,7 @@ sub loadMonitor { } sub loadMonitors { - Debug( "Loading monitors" ); + Debug('Loading monitors'); $monitor_reload_time = time(); my %new_monitors = (); @@ -362,25 +362,25 @@ sub handleMessage { my $monitor = $monitors{$id}; if ( !$monitor ) { - Warning( "Can't find monitor '$id' for message '$message'" ); + Warning("Can't find monitor '$id' for message '$message'"); return; } - Debug( "Found monitor for id '$id'" ); + Debug("Found monitor for id '$id'"); - next if ( !zmMemVerify( $monitor ) ); + next if ( !zmMemVerify($monitor) ); - Debug( "Handling action '$action'" ); + Debug("Handling action '$action'"); if ( $action =~ /^(enable|disable)(?:\+(\d+))?$/ ) { my $state = $1; my $delay = $2; if ( $state eq 'enable' ) { - zmMonitorEnable( $monitor ); + zmMonitorEnable($monitor); } else { - zmMonitorDisable( $monitor ); + zmMonitorDisable($monitor); } # Force a reload $monitor_reload_time = 0; - Info( "Set monitor to $state" ); + Info("Set monitor to $state"); if ( $delay ) { my $action_text = $id.'|'.( ($state eq 'enable') ? 'disable' @@ -395,9 +395,9 @@ sub handleMessage { my $delay = $2; my $trigger_data; if ( $trigger eq 'on' ) { - zmTriggerEventOn( $monitor, $score, $cause, $text ); - zmTriggerShowtext( $monitor, $showtext ) if defined($showtext); - Info( "Trigger '$trigger' '$cause'" ); + zmTriggerEventOn($monitor, $score, $cause, $text); + zmTriggerShowtext($monitor, $showtext) if defined($showtext); + Info("Trigger '$trigger' '$cause'"); if ( $delay ) { my $action_text = $id.'|cancel'; handleDelay($delay, $connection, $action_text); @@ -407,29 +407,29 @@ sub handleMessage { my $action_text = $id.'|off|0|'.$cause.'|'.$text; handleDelay($delay, $connection, $action_text); } else { - my $last_event = zmGetLastEvent( $monitor ); - zmTriggerEventOff( $monitor ); - zmTriggerShowtext( $monitor, $showtext ) if defined($showtext); - Info( "Trigger '$trigger'" ); + my $last_event = zmGetLastEvent($monitor); + zmTriggerEventOff($monitor); + zmTriggerShowtext($monitor, $showtext) if defined($showtext); + Info("Trigger '$trigger'"); # Wait til it's finished - while( zmInAlarm( $monitor ) - && ($last_event == zmGetLastEvent( $monitor )) + while( zmInAlarm($monitor) + && ($last_event == zmGetLastEvent($monitor)) ) { # Tenth of a second - usleep( 100000 ); + usleep(100000); } - zmTriggerEventCancel( $monitor ); + zmTriggerEventCancel($monitor); } } # end if trigger is on or off } elsif( $action eq 'cancel' ) { - zmTriggerEventCancel( $monitor ); - zmTriggerShowtext( $monitor, $showtext ) if defined($showtext); - Info( "Cancelled event" ); + zmTriggerEventCancel($monitor); + zmTriggerShowtext($monitor, $showtext) if defined($showtext); + Info('Cancelled event'); } elsif( $action eq 'show' ) { zmTriggerShowtext( $monitor, $showtext ); - Info( "Updated show text to '$showtext'" ); + Info("Updated show text to '$showtext'"); } else { - Error( "Unrecognised action '$action' in message '$message'" ); + Error("Unrecognised action '$action' in message '$message'"); } } # end sub handleMessage @@ -444,8 +444,9 @@ sub handleDelay { $action_array = $actions{$action_time} = []; } push( @$action_array, { connection=>$connection, message=>$action_text } ); - Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)" ); + Debug("Added timed event '$action_text', expires at $action_time (+$delay secs)"); } + 1; __END__ @@ -520,13 +521,13 @@ B|B|B|B|B|B =back -Note that multiple messages can be sent at once and should be LF or CRLF -delimited. This script is not necessarily intended to be a solution in -itself, but is intended to be used as 'glue' to help ZoneMinder interface -with other systems. It will almost certainly require some customisation -before you can make any use of it. If all you want to do is generate alarms -from external sources then using the ZoneMinder::SharedMem perl module is -likely to be easier. + Note that multiple messages can be sent at once and should be LF or CRLF + delimited. This script is not necessarily intended to be a solution in + itself, but is intended to be used as 'glue' to help ZoneMinder interface + with other systems. It will almost certainly require some customisation + before you can make any use of it. If all you want to do is generate alarms + from external sources then using the ZoneMinder::SharedMem perl module is + likely to be easier. =head1 EXAMPLES diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index 45d45851a..8517e0277 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -353,8 +353,8 @@ if ( $version ) { $version = $detaint_version; if ( ZM_VERSION eq $version ) { - print( "\nDatabase already at version $version, update aborted.\n\n" ); - exit( 0 ); + print("\nDatabase already at version $version, update skipped.\n\n"); + exit(0); } print( "\nInitiating database upgrade to version ".ZM_VERSION." from version $version\n" ); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a87abe955..309a2c05f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS}) # Generate man files for the binaries destined for the bin folder FOREACH(CBINARY zma zmc zmu) - POD2MAN(${CMAKE_CURRENT_SOURCE_DIR}/${CBINARY}.cpp zoneminder-${CBINARY} 8) + POD2MAN(${CMAKE_CURRENT_SOURCE_DIR}/${CBINARY}.cpp zoneminder-${CBINARY} 8 ${ZM_MANPAGE_DEST_PREFIX}) ENDFOREACH(CBINARY zma zmc zmu) install(TARGETS zmc zma zmu RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/zm.h b/src/zm.h index 092561378..ad0f89584 100644 --- a/src/zm.h +++ b/src/zm.h @@ -17,9 +17,6 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -#if !defined(PATH_MAX) -#define PATH_MAX 1024 -#endif #ifndef ZM_H #define ZM_H diff --git a/src/zm_comms.h b/src/zm_comms.h index 133c0d19f..e93951a85 100644 --- a/src/zm_comms.h +++ b/src/zm_comms.h @@ -20,6 +20,7 @@ #ifndef ZM_COMMS_H #define ZM_COMMS_H +#include "zm_logger.h" #include "zm_exception.h" #include diff --git a/src/zm_config.cpp b/src/zm_config.cpp index 6d63be98b..f9e11e59b 100644 --- a/src/zm_config.cpp +++ b/src/zm_config.cpp @@ -176,8 +176,6 @@ void process_configfile( char* configFile) { staticConfig.SERVER_ID = atoi(val_ptr); else if ( strcasecmp( name_ptr, "ZM_DIR_EVENTS" ) == 0 ) staticConfig.DIR_EVENTS = std::string(val_ptr); - else if ( strcasecmp( name_ptr, "ZM_DIR_IMAGES" ) == 0 ) - staticConfig.DIR_IMAGES = std::string(val_ptr); else if ( strcasecmp( name_ptr, "ZM_DIR_SOUNDS" ) == 0 ) staticConfig.DIR_SOUNDS = std::string(val_ptr); else if ( strcasecmp( name_ptr, "ZM_DIR_EXPORTS" ) == 0 ) diff --git a/src/zm_config.h.in b/src/zm_config.h.in index f321095df..9831677f0 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -20,9 +20,11 @@ #ifndef ZM_CONFIG_H #define ZM_CONFIG_H +#if !defined(PATH_MAX) +#define PATH_MAX 1024 +#endif #include "config.h" #include "zm_config_defines.h" -#include "zm.h" #include @@ -74,7 +76,6 @@ struct StaticConfig { std::string SERVER_NAME; unsigned int SERVER_ID; std::string DIR_EVENTS; - std::string DIR_IMAGES; std::string DIR_SOUNDS; std::string DIR_EXPORTS; std::string PATH_ZMS; diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 8d3108b31..6b244a005 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -117,6 +117,7 @@ Event::Event( alarm_frames = 0; tot_score = 0; max_score = 0; + alarm_frame_written = false; char id_file[PATH_MAX]; @@ -174,7 +175,7 @@ Event::Event( Error("Can't mkdir %s: %s", path, strerror(errno)); } } else { - path_ptr += snprintf(path, sizeof(path), "/%" PRIu64, id); + path_ptr += snprintf(path_ptr, sizeof(path), "/%" PRIu64, id); if ( mkdir(path, 0755) ) { if ( errno != EEXIST ) Error("Can't mkdir %s: %s", path, strerror(errno)); @@ -251,11 +252,12 @@ Event::~Event() { id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec); db_mutex.lock(); if ( mysql_query(&dbconn, sql) ) { + db_mutex.unlock(); Error("Can't insert frame: %s", mysql_error(&dbconn)); } else { + db_mutex.unlock(); Debug(1,"Success writing last frame"); } - db_mutex.unlock(); } snprintf(sql, sizeof(sql), @@ -263,8 +265,8 @@ Event::~Event() { monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, video_name, id ); db_mutex.lock(); while ( mysql_query(&dbconn, sql) && !zm_terminate ) { - Error("Can't update event: %s reason: %s", sql, mysql_error(&dbconn)); db_mutex.unlock(); + Error("Can't update event: %s reason: %s", sql, mysql_error(&dbconn)); sleep(1); db_mutex.lock(); } @@ -527,6 +529,13 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a snprintf(snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path); WriteFrameImage(image, timestamp, snapshot_file); } + // The first frame with a score will be the frame that alarmed the event + if (!alarm_frame_written && score > 0) { + alarm_frame_written = true; + char alarm_file[PATH_MAX]; + snprintf(alarm_file, sizeof(alarm_file), "%s/alarm.jpg", path); + WriteFrameImage(image, timestamp, alarm_file); + } } if ( videowriter != NULL ) { Debug(3, "Writing video"); diff --git a/src/zm_event.h b/src/zm_event.h index 1e55ae593..7c38764bc 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -82,6 +82,7 @@ class Event { bool videoEvent; int frames; int alarm_frames; + bool alarm_frame_written; unsigned int tot_score; unsigned int max_score; char path[PATH_MAX]; diff --git a/src/zm_exception.h b/src/zm_exception.h index 83d1ecab1..a02653b88 100644 --- a/src/zm_exception.h +++ b/src/zm_exception.h @@ -20,8 +20,6 @@ #ifndef ZM_EXCEPTION_H #define ZM_EXCEPTION_H -#include "zm.h" - #include class Exception diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 79a1d8b26..eb95e3659 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -24,14 +24,59 @@ #if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE +void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs ) { + Logger *log = Logger::fetch(); + int log_level = 0; + if ( level == AV_LOG_QUIET ) { // -8 + log_level = Logger::NOLOG; + } else if ( level == AV_LOG_PANIC ) { //0 + log_level = Logger::PANIC; + } else if ( level == AV_LOG_FATAL ) { // 8 + log_level = Logger::FATAL; + } else if ( level == AV_LOG_ERROR ) { // 16 + log_level = Logger::WARNING; // ffmpeg outputs a lot of errors that don't really affect anything. + //log_level = Logger::ERROR; + } else if ( level == AV_LOG_WARNING ) { //24 + log_level = Logger::INFO; + //log_level = Logger::WARNING; + } else if ( level == AV_LOG_INFO ) { //32 + log_level = Logger::DEBUG1; + //log_level = Logger::INFO; + } else if ( level == AV_LOG_VERBOSE ) { //40 + log_level = Logger::DEBUG2; + } else if ( level == AV_LOG_DEBUG ) { //48 + log_level = Logger::DEBUG3; +#ifdef AV_LOG_TRACE + } else if ( level == AV_LOG_TRACE ) { + log_level = Logger::DEBUG8; +#endif +#ifdef AV_LOG_MAX_OFFSET + } else if ( level == AV_LOG_MAX_OFFSET ) { + log_level = Logger::DEBUG9; +#endif + } else { + Error("Unknown log level %d", level); + } + + if ( log ) { + char logString[8192]; + vsnprintf(logString, sizeof(logString)-1, fmt, vargs); + log->logPrint(false, __FILE__, __LINE__, log_level, logString); + } +} + void FFMPEGInit() { static bool bInit = false; if ( !bInit ) { - //if ( logDebugging() ) - //av_log_set_level( AV_LOG_DEBUG ); - //else + if ( logDebugging() ) + av_log_set_level( AV_LOG_DEBUG ); + else av_log_set_level( AV_LOG_QUIET ); + if ( config.log_ffmpeg ) + av_log_set_callback(log_libav_callback); + else + Info("Not enabling ffmpeg logs, as LOG_FFMPEG is disabled in options"); av_register_all(); avformat_network_init(); bInit = true; diff --git a/src/zm_image.cpp b/src/zm_image.cpp index ea7ad446b..491ae8470 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1094,8 +1094,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int jpeg_read_header( cinfo, TRUE ); - if ( cinfo->num_components != 1 && cinfo->num_components != 3 ) - { + if ( cinfo->num_components != 1 && cinfo->num_components != 3 ) { Error( "Unexpected colours when reading jpeg image: %d", colours ); jpeg_abort_decompress( cinfo ); return( false ); @@ -1110,8 +1109,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int new_width = cinfo->image_width; new_height = cinfo->image_height; - if ( width != new_width || height != new_height ) - { + if ( width != new_width || height != new_height ) { Debug(9,"Image dimensions differ. Old: %ux%u New: %ux%u",width,height,new_width,new_height); } @@ -1173,7 +1171,7 @@ cinfo->out_color_space = JCS_RGB; } break; } - } + } // end switch if(WriteBuffer(new_width, new_height, new_colours, new_subpixelorder) == NULL) { Error("Failed requesting writeable buffer for reading JPEG image."); @@ -1185,21 +1183,18 @@ cinfo->out_color_space = JCS_RGB; JSAMPROW row_pointer; /* pointer to a single row */ int row_stride = width * colours; /* physical row width in buffer */ - while ( cinfo->output_scanline < cinfo->output_height ) - { + while ( cinfo->output_scanline < cinfo->output_height ) { row_pointer = &buffer[cinfo->output_scanline * row_stride]; jpeg_read_scanlines( cinfo, &row_pointer, 1 ); } jpeg_finish_decompress( cinfo ); - return( true ); + return true; } -bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override ) const -{ - if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 ) - { +bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override ) const { + if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 ) { Image temp_image( *this ); temp_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); return( temp_image.EncodeJpeg( outbuffer, outbuffer_size, quality_override ) ); @@ -1209,8 +1204,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over struct jpeg_compress_struct *cinfo = encodejpg_ccinfo[quality]; - if ( !cinfo ) - { + if ( !cinfo ) { cinfo = encodejpg_ccinfo[quality] = new jpeg_compress_struct; cinfo->err = jpeg_std_error( &jpg_err.pub ); jpg_err.pub.error_exit = zm_jpeg_error_exit; @@ -1276,7 +1270,7 @@ cinfo->out_color_space = JCS_RGB; } break; } - } + } // end switch jpeg_set_defaults( cinfo ); jpeg_set_quality( cinfo, quality, FALSE ); @@ -1286,44 +1280,38 @@ cinfo->out_color_space = JCS_RGB; JSAMPROW row_pointer; /* pointer to a single row */ int row_stride = cinfo->image_width * colours; /* physical row width in buffer */ - while ( cinfo->next_scanline < cinfo->image_height ) - { + while ( cinfo->next_scanline < cinfo->image_height ) { row_pointer = &buffer[cinfo->next_scanline * row_stride]; jpeg_write_scanlines( cinfo, &row_pointer, 1 ); } jpeg_finish_compress( cinfo ); - return( true ); + return true; } #if HAVE_ZLIB_H -bool Image::Unzip( const Bytef *inbuffer, unsigned long inbuffer_size ) -{ +bool Image::Unzip( const Bytef *inbuffer, unsigned long inbuffer_size ) { unsigned long zip_size = size; int result = uncompress( buffer, &zip_size, inbuffer, inbuffer_size ); - if ( result != Z_OK ) - { - Error( "Unzip failed, result = %d", result ); - return( false ); + if ( result != Z_OK ) { + Error("Unzip failed, result = %d", result); + return false; } - if ( zip_size != (unsigned int)size ) - { - Error( "Unzip failed, size mismatch, expected %d bytes, got %ld", size, zip_size ); - return( false ); + if ( zip_size != (unsigned int)size ) { + Error("Unzip failed, size mismatch, expected %d bytes, got %ld", size, zip_size); + return false; } - return( true ); + return true; } -bool Image::Zip( Bytef *outbuffer, unsigned long *outbuffer_size, int compression_level ) const -{ +bool Image::Zip( Bytef *outbuffer, unsigned long *outbuffer_size, int compression_level ) const { int result = compress2( outbuffer, outbuffer_size, buffer, size, compression_level ); - if ( result != Z_OK ) - { - Error( "Zip failed, result = %d", result ); - return( false ); + if ( result != Z_OK ) { + Error("Zip failed, result = %d", result); + return false; } - return( true ); + return true; } #endif // HAVE_ZLIB_H @@ -1337,11 +1325,11 @@ bool Image::Crop( unsigned int lo_x, unsigned int lo_y, unsigned int hi_x, unsig } if ( hi_x > (width-1) || ( hi_y > (height-1) ) ) { Error( "Attempting to crop outside image, %d,%d -> %d,%d not in %d,%d", lo_x, lo_y, hi_x, hi_y, width-1, height-1 ); - return( false ); + return false; } if ( new_width == width && new_height == height ) { - return( true ); + return true; } unsigned int new_size = new_width*new_height*colours; @@ -1356,24 +1344,22 @@ bool Image::Crop( unsigned int lo_x, unsigned int lo_y, unsigned int hi_x, unsig AssignDirect(new_width, new_height, colours, subpixelorder, new_buffer, new_size, ZM_BUFTYPE_ZM); - return( true ); + return true; } -bool Image::Crop( const Box &limits ) -{ - return( Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ) ); +bool Image::Crop( const Box &limits ) { + return Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ); } /* Far from complete */ /* Need to implement all possible of overlays possible */ -void Image::Overlay( const Image &image ) -{ - if ( !(width == image.width && height == image.height) ) - { - Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); +void Image::Overlay( const Image &image ) { + if ( !(width == image.width && height == image.height) ) { + Panic("Attempt to overlay different sized images, expected %dx%d, got %dx%d", + width, height, image.width, image.height); } - if( colours == image.colours && subpixelorder != image.subpixelorder ) { + if ( colours == image.colours && subpixelorder != image.subpixelorder ) { Warning("Attempt to overlay images of same format but with different subpixel order."); } @@ -1383,10 +1369,8 @@ void Image::Overlay( const Image &image ) const uint8_t* psrc = image.buffer; uint8_t* pdest = buffer; - while( pdest < max_ptr ) - { - if ( *psrc ) - { + while( pdest < max_ptr ) { + if ( *psrc ) { *pdest = *psrc; } pdest++; @@ -1401,10 +1385,8 @@ void Image::Overlay( const Image &image ) const uint8_t* psrc = image.buffer; uint8_t* pdest = buffer; - while( pdest < max_ptr ) - { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { + while( pdest < max_ptr ) { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) { RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); @@ -1421,11 +1403,10 @@ void Image::Overlay( const Image &image ) const Rgb* prsrc = (Rgb*)image.buffer; Rgb* prdest = (Rgb*)buffer; - if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + if ( subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA ) { /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ while (prdest < max_ptr) { - if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) - { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) { *prdest = *prsrc; } prdest++; @@ -1434,8 +1415,7 @@ void Image::Overlay( const Image &image ) } else { /* ABGR\ARGB subpixel order - Alpha byte is first */ while (prdest < max_ptr) { - if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) - { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) { *prdest = *prsrc; } prdest++; @@ -1449,10 +1429,8 @@ void Image::Overlay( const Image &image ) const uint8_t* psrc = image.buffer; uint8_t* pdest = buffer; - while( pdest < max_ptr ) - { - if ( *psrc ) - { + while( pdest < max_ptr ) { + if ( *psrc ) { RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc; } pdest += 3; @@ -1465,10 +1443,8 @@ void Image::Overlay( const Image &image ) const uint8_t* psrc = image.buffer; uint8_t* pdest = buffer; - while( pdest < max_ptr ) - { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { + while( pdest < max_ptr ) { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) { RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); @@ -1487,11 +1463,10 @@ void Image::Overlay( const Image &image ) Rgb* prdest = (Rgb*)buffer; const uint8_t* psrc = image.buffer; - if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + if ( subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA ) { /* RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( *psrc ) - { + while ( prdest < max_ptr ) { + if ( *psrc ) { RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc; } prdest++; @@ -1499,9 +1474,8 @@ void Image::Overlay( const Image &image ) } } else { /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( *psrc ) - { + while ( prdest < max_ptr ) { + if ( *psrc ) { RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc; } prdest++; @@ -1519,11 +1493,10 @@ void Image::Overlay( const Image &image ) Rgb* prdest = (Rgb*)buffer; const Rgb* prsrc = (Rgb*)image.buffer; - if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + if ( image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA ) { /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) - { + while ( prdest < max_ptr ) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) { *prdest = *prsrc; } prdest++; @@ -1531,9 +1504,8 @@ void Image::Overlay( const Image &image ) } } else { /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) - { + while ( prdest < max_ptr ) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) { *prdest = *prsrc; } prdest++; @@ -1545,61 +1517,49 @@ void Image::Overlay( const Image &image ) } /* RGB32 compatible: complete */ -void Image::Overlay( const Image &image, unsigned int x, unsigned int y ) -{ - if ( !(width < image.width || height < image.height) ) - { - Panic( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height ); +void Image::Overlay( const Image &image, unsigned int x, unsigned int y ) { + if ( !(width < image.width || height < image.height) ) { + Panic("Attempt to overlay image too big for destination, %dx%d > %dx%d", + image.width, image.height, width, height ); } - if ( !(width < (x+image.width) || height < (y+image.height)) ) - { - Panic( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height ); + if ( !(width < (x+image.width) || height < (y+image.height)) ) { + Panic("Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", + image.width, image.height, x, y, width, height ); } - if ( !(colours == image.colours) ) - { - Panic( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours ); + if ( !(colours == image.colours) ) { + Panic("Attempt to partial overlay differently coloured images, expected %d, got %d", + colours, image.colours); } unsigned int lo_x = x; unsigned int lo_y = y; unsigned int hi_x = (x+image.width)-1; unsigned int hi_y = (y+image.height-1); - if ( colours == ZM_COLOUR_GRAY8 ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { const uint8_t *psrc = image.buffer; - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { uint8_t *pdest = &buffer[(y*width)+lo_x]; - for ( unsigned int x = lo_x; x <= hi_x; x++ ) - { + for ( unsigned int x = lo_x; x <= hi_x; x++ ) { *pdest++ = *psrc++; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { const uint8_t *psrc = image.buffer; - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { uint8_t *pdest = &buffer[colours*((y*width)+lo_x)]; - for ( unsigned int x = lo_x; x <= hi_x; x++ ) - { + for ( unsigned int x = lo_x; x <= hi_x; x++ ) { *pdest++ = *psrc++; *pdest++ = *psrc++; *pdest++ = *psrc++; } } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { const Rgb *psrc = (Rgb*)(image.buffer); - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { Rgb *pdest = (Rgb*)&buffer[((y*width)+lo_x)<<2]; - for ( unsigned int x = lo_x; x <= hi_x; x++ ) - { + for ( unsigned int x = lo_x; x <= hi_x; x++ ) { *pdest++ = *psrc++; } } @@ -1609,8 +1569,7 @@ void Image::Overlay( const Image &image, unsigned int x, unsigned int y ) } -void Image::Blend( const Image &image, int transparency ) -{ +void Image::Blend( const Image &image, int transparency ) { #ifdef ZM_IMAGE_PROFILING struct timespec start,end,diff; unsigned long long executetime; @@ -1618,12 +1577,16 @@ void Image::Blend( const Image &image, int transparency ) #endif uint8_t* new_buffer; - if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) - { - Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); + if ( !( + width == image.width && height == image.height + && colours == image.colours + && subpixelorder == image.subpixelorder + ) ) { + Panic("Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", + width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } - if(transparency <= 0) + if ( transparency <= 0 ) return; new_buffer = AllocBuffer(size); @@ -1644,7 +1607,7 @@ void Image::Blend( const Image &image, int transparency ) Debug(5, "Blend: %u colours blended in %llu nanoseconds, %lu million colours/s\n",size,executetime,milpixels); #endif - AssignDirect( width, height, colours, subpixelorder, new_buffer, size, ZM_BUFTYPE_ZM); + AssignDirect(width, height, colours, subpixelorder, new_buffer, size, ZM_BUFTYPE_ZM); } Image *Image::Merge( unsigned int n_images, Image *images[] ) { @@ -1655,7 +1618,8 @@ Image *Image::Merge( unsigned int n_images, Image *images[] ) { unsigned int colours = images[0]->colours; for ( unsigned int i = 1; i < n_images; i++ ) { if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) ) { - Panic( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); + Panic("Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", + width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); } } @@ -1683,7 +1647,8 @@ Image *Image::Merge( unsigned int n_images, Image *images[], double weight ) { unsigned int colours = images[0]->colours; for ( unsigned int i = 1; i < n_images; i++ ) { if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) ) { - Panic( "Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); + Panic("Attempt to merge different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", + width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); } } @@ -1703,8 +1668,7 @@ Image *Image::Merge( unsigned int n_images, Image *images[], double weight ) { return result; } -Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb threshold, const Rgb ref_colour ) -{ +Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb threshold, const Rgb ref_colour ) { if ( n_images == 1 ) return new Image(*images[0]); unsigned int width = images[0]->width; @@ -1712,7 +1676,8 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres unsigned int colours = images[0]->colours; for ( unsigned int i = 1; i < n_images; i++ ) { if ( !(width == images[i]->width && height == images[i]->height && colours == images[i]->colours) ) { - Panic( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); + Panic( "Attempt to highlight different sized images, expected %dx%dx%d, got %dx%dx%d, for image %d", + width, height, colours, images[i]->width, images[i]->height, images[i]->colours, i ); } } @@ -1738,26 +1703,25 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres pdest += 3; } } - return( result ); + return result; } /* New function to allow buffer re-using instead of allocationg memory for the delta image every time */ -void Image::Delta( const Image &image, Image* targetimage) const -{ +void Image::Delta( const Image &image, Image* targetimage) const { #ifdef ZM_IMAGE_PROFILING struct timespec start,end,diff; unsigned long long executetime; unsigned long milpixels; #endif - if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) - { - Panic( "Attempt to get delta of different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder); + if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { + Panic( "Attempt to get delta of different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", + width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder); } uint8_t *pdiff = targetimage->WriteBuffer(width, height, ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE); - if(pdiff == NULL) { + if ( pdiff == NULL ) { Panic("Failed requesting writeable buffer for storing the delta image"); } @@ -1847,34 +1811,24 @@ void Image::MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour unsigned char *ptr = &buffer[0]; unsigned int i = 0; - for ( unsigned int y = 0; y < height; y++ ) - { - if ( colours == ZM_COLOUR_GRAY8 ) - { - for ( unsigned int x = 0; x < width; x++, ptr++ ) - { + for ( unsigned int y = 0; y < height; y++ ) { + if ( colours == ZM_COLOUR_GRAY8 ) { + for ( unsigned int x = 0; x < width; x++, ptr++ ) { if ( p_bitmask[i] ) *ptr = pixel_bw_col; i++; } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for ( unsigned int x = 0; x < width; x++, ptr += colours ) - { - if ( p_bitmask[i] ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for ( unsigned int x = 0; x < width; x++, ptr += colours ) { + if ( p_bitmask[i] ) { RED_PTR_RGBA(ptr) = pixel_r_col; GREEN_PTR_RGBA(ptr) = pixel_g_col; BLUE_PTR_RGBA(ptr) = pixel_b_col; } i++; } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { - for ( unsigned int x = 0; x < width; x++, ptr += colours ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { + for ( unsigned int x = 0; x < width; x++, ptr += colours ) { Rgb *temp_ptr = (Rgb*)ptr; if ( p_bitmask[i] ) *temp_ptr = pixel_rgb_col; @@ -1884,8 +1838,7 @@ void Image::MaskPrivacy( const unsigned char *p_bitmask, const Rgb pixel_colour Panic("MaskPrivacy called with unexpected colours: %d", colours); return; } - - } + } // end foreach y } /* RGB32 compatible: complete */ @@ -1917,8 +1870,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int if (size == 2) zm_text_bitmask = 0x8000; - while ( (index < text_len) && (line_len = strcspn( line, "\n" )) ) - { + while ( (index < text_len) && (line_len = strcspn( line, "\n" )) ) { unsigned int line_width = line_len * ZM_CHAR_WIDTH * size; @@ -1948,62 +1900,46 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int if ( hi_line_y > height ) hi_line_y = height; - if ( colours == ZM_COLOUR_GRAY8 ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *ptr = &buffer[(lo_line_y*width)+lo_line_x]; - for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += width ) - { + for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += width ) { unsigned char *temp_ptr = ptr; - for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) - { + for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { int f; if (size == 2) f = bigfontdata[(line[c] * ZM_CHAR_HEIGHT * size) + r]; else f = fontdata[(line[c] * ZM_CHAR_HEIGHT) + r]; - for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr++ ) - { - if ( f & (zm_text_bitmask >> i) ) - { + for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr++ ) { + if ( f & (zm_text_bitmask >> i) ) { if ( !fg_trans ) *temp_ptr = fg_bw_col; - } - else if ( !bg_trans ) - { + } else if ( !bg_trans ) { *temp_ptr = bg_bw_col; } } } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { unsigned int wc = width * colours; unsigned char *ptr = &buffer[((lo_line_y*width)+lo_line_x)*colours]; - for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += wc ) - { + for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += wc ) { unsigned char *temp_ptr = ptr; - for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) - { + for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { int f; if (size == 2) f = bigfontdata[(line[c] * ZM_CHAR_HEIGHT * size) + r]; else f = fontdata[(line[c] * ZM_CHAR_HEIGHT) + r]; - for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr += colours ) - { - if ( f & (zm_text_bitmask >> i) ) - { - if ( !fg_trans ) - { + for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr += colours ) { + if ( f & (zm_text_bitmask >> i) ) { + if ( !fg_trans ) { RED_PTR_RGBA(temp_ptr) = fg_r_col; GREEN_PTR_RGBA(temp_ptr) = fg_g_col; BLUE_PTR_RGBA(temp_ptr) = fg_b_col; } - } - else if ( !bg_trans ) - { + } else if ( !bg_trans ) { RED_PTR_RGBA(temp_ptr) = bg_r_col; GREEN_PTR_RGBA(temp_ptr) = bg_g_col; BLUE_PTR_RGBA(temp_ptr) = bg_b_col; @@ -2011,33 +1947,24 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int } } } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { unsigned int wc = width * colours; uint8_t *ptr = &buffer[((lo_line_y*width)+lo_line_x)<<2]; - for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += wc ) - { + for ( unsigned int y = lo_line_y, r = 0; y < hi_line_y && r < (ZM_CHAR_HEIGHT * size); y++, r++, ptr += wc ) { Rgb* temp_ptr = (Rgb*)ptr; - for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) - { + for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { int f; if (size == 2) f = bigfontdata[(line[c] * ZM_CHAR_HEIGHT * size) + r]; else f = fontdata[(line[c] * ZM_CHAR_HEIGHT) + r]; - for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr++ ) - { - if ( f & (zm_text_bitmask >> i) ) - { - if ( !fg_trans ) - { + for ( unsigned int i = 0; i < (ZM_CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr++ ) { + if ( f & (zm_text_bitmask >> i) ) { + if ( !fg_trans ) { *temp_ptr = fg_rgb_col; } - } - else if ( !bg_trans ) - { + } else if ( !bg_trans ) { *temp_ptr = bg_rgb_col; } } @@ -2050,8 +1977,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int } index += line_len; - while ( text[index] == '\n' ) - { + while ( text[index] == '\n' ) { index++; } line = text+index; @@ -2072,8 +1998,7 @@ void Image::Timestamp( const char *label, const time_t when, const Coord &coord, } /* RGB32 compatible: complete */ -void Image::Colourise(const unsigned int p_reqcolours, const unsigned int p_reqsubpixelorder) -{ +void Image::Colourise(const unsigned int p_reqcolours, const unsigned int p_reqsubpixelorder) { Debug(9, "Colourise: Req colours: %u Req subpixel order: %u Current colours: %u Current subpixel order: %u",p_reqcolours,p_reqsubpixelorder,colours,subpixelorder); if ( colours != ZM_COLOUR_GRAY8) { @@ -2090,9 +2015,9 @@ void Image::Colourise(const unsigned int p_reqcolours, const unsigned int p_reqs Rgb subpixel; Rgb newpixel; - if ( p_reqsubpixelorder == ZM_SUBPIX_ORDER_ABGR || p_reqsubpixelorder == ZM_SUBPIX_ORDER_ARGB) { + if ( p_reqsubpixelorder == ZM_SUBPIX_ORDER_ABGR || p_reqsubpixelorder == ZM_SUBPIX_ORDER_ARGB ) { /* ARGB\ABGR subpixel order. alpha byte is first (mem+0), so we need to shift the pixel left in the end */ - for(unsigned int i=0;iLo().Y():0; unsigned int hi_x = limits?limits->Hi().X():width-1; unsigned int hi_y = limits?limits->Hi().Y():height-1; - if ( colours == ZM_COLOUR_GRAY8 ) - { - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { unsigned char *p = &buffer[(y*width)+lo_x]; - for ( unsigned int x = lo_x; x <= hi_x; x++, p++) - { + for ( unsigned int x = lo_x; x <= hi_x; x++, p++) { *p = colour; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { unsigned char *p = &buffer[colours*((y*width)+lo_x)]; - for ( unsigned int x = lo_x; x <= hi_x; x++, p += 3) - { + for ( unsigned int x = lo_x; x <= hi_x; x++, p += 3) { RED_PTR_RGBA(p) = RED_VAL_RGBA(colour); GREEN_PTR_RGBA(p) = GREEN_VAL_RGBA(colour); BLUE_PTR_RGBA(p) = BLUE_VAL_RGBA(colour); } } - } - else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ - { - for ( unsigned int y = lo_y; y <= (unsigned int)hi_y; y++ ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ { + for ( unsigned int y = lo_y; y <= (unsigned int)hi_y; y++ ) { Rgb *p = (Rgb*)&buffer[((y*width)+lo_x)<<2]; - for ( unsigned int x = lo_x; x <= (unsigned int)hi_x; x++, p++) - { + for ( unsigned int x = lo_x; x <= (unsigned int)hi_x; x++, p++) { /* Fast, copies the entire pixel in a single pass */ *p = colour; } @@ -2245,15 +2153,13 @@ void Image::Fill( Rgb colour, const Box *limits ) } /* RGB32 compatible: complete */ -void Image::Fill( Rgb colour, int density, const Box *limits ) -{ +void Image::Fill( Rgb colour, int density, const Box *limits ) { /* Allow the faster version to be used if density is not used (density=1) */ - if(density <= 1) + if ( density <= 1 ) return Fill(colour,limits); - if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) - { - Panic( "Attempt to fill image with unexpected colours %d", colours ); + if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) { + Panic("Attempt to fill image with unexpected colours %d", colours); } /* Convert the colour's RGBA subpixel order into the image's subpixel order */ @@ -2263,25 +2169,18 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) unsigned int lo_y = limits?limits->Lo().Y():0; unsigned int hi_x = limits?limits->Hi().X():width-1; unsigned int hi_y = limits?limits->Hi().Y():height-1; - if ( colours == ZM_COLOUR_GRAY8 ) - { - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { unsigned char *p = &buffer[(y*width)+lo_x]; - for ( unsigned int x = lo_x; x <= hi_x; x++, p++) - { + for ( unsigned int x = lo_x; x <= hi_x; x++, p++) { if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) *p = colour; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { unsigned char *p = &buffer[colours*((y*width)+lo_x)]; - for ( unsigned int x = lo_x; x <= hi_x; x++, p += 3) - { + for ( unsigned int x = lo_x; x <= hi_x; x++, p += 3) { if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) { RED_PTR_RGBA(p) = RED_VAL_RGBA(colour); GREEN_PTR_RGBA(p) = GREEN_VAL_RGBA(colour); @@ -2289,38 +2188,30 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) } } } - } - else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ - { - for ( unsigned int y = lo_y; y <= hi_y; y++ ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) { Rgb* p = (Rgb*)&buffer[((y*width)+lo_x)<<2]; - for ( unsigned int x = lo_x; x <= hi_x; x++, p++) - { + for ( unsigned int x = lo_x; x <= hi_x; x++, p++) { if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) /* Fast, copies the entire pixel in a single pass */ *p = colour; } } } - } /* RGB32 compatible: complete */ -void Image::Outline( Rgb colour, const Polygon &polygon ) -{ - if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) - { - Panic( "Attempt to outline image with unexpected colours %d", colours ); +void Image::Outline( Rgb colour, const Polygon &polygon ) { + if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) { + Panic("Attempt to outline image with unexpected colours %d", colours); } /* Convert the colour's RGBA subpixel order into the image's subpixel order */ colour = rgb_convert(colour,subpixelorder); int n_coords = polygon.getNumCoords(); - for ( int j = 0, i = n_coords-1; j < n_coords; i = j++ ) - { + for ( int j = 0, i = n_coords-1; j < n_coords; i = j++ ) { const Coord &p1 = polygon.getCoord( i ); const Coord &p2 = polygon.getCoord( j ); @@ -2335,8 +2226,7 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) double grad; //Debug( 9, "dx: %.2lf, dy: %.2lf", dx, dy ); - if ( fabs(dx) <= fabs(dy) ) - { + if ( fabs(dx) <= fabs(dy) ) { //Debug( 9, "dx <= dy" ); if ( y1 != y2 ) grad = dx/dy; @@ -2346,35 +2236,25 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) double x; int y, yinc = (y1 dy" ); if ( x1 != x2 ) grad = dy/dx; @@ -2385,42 +2265,31 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) double y; int x, xinc = (x1= Logger::DEBUG9 ) - { - for ( int i = 0; i < n_global_edges; i++ ) - { + if ( logLevel() >= Logger::DEBUG9 ) { + for ( int i = 0; i < n_global_edges; i++ ) { Debug( 9, "%d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", i, global_edges[i].min_y, global_edges[i].max_y, global_edges[i].min_x, global_edges[i]._1_m ); } } @@ -2468,60 +2334,46 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon ) int n_active_edges = 0; Edge active_edges[n_global_edges]; int y = global_edges[0].min_y; - do - { - for ( int i = 0; i < n_global_edges; i++ ) - { - if ( global_edges[i].min_y == y ) - { - Debug( 9, "Moving global edge" ); + do { + for ( int i = 0; i < n_global_edges; i++ ) { + if ( global_edges[i].min_y == y ) { + Debug(9, "Moving global edge"); active_edges[n_active_edges++] = global_edges[i]; - if ( i < (n_global_edges-1) ) - { + if ( i < (n_global_edges-1) ) { //memcpy( &global_edges[i], &global_edges[i+1], sizeof(*global_edges)*(n_global_edges-i) ); memmove( &global_edges[i], &global_edges[i+1], sizeof(*global_edges)*(n_global_edges-i) ); i--; } n_global_edges--; - } - else - { + } else { break; } } qsort( active_edges, n_active_edges, sizeof(*active_edges), Edge::CompareX ); #ifndef ZM_DBG_OFF - if ( logLevel() >= Logger::DEBUG9 ) - { - for ( int i = 0; i < n_active_edges; i++ ) - { + if ( logLevel() >= Logger::DEBUG9 ) { + for ( int i = 0; i < n_active_edges; i++ ) { Debug( 9, "%d - %d: min_y: %d, max_y:%d, min_x:%.2f, 1/m:%.2f", y, i, active_edges[i].min_y, active_edges[i].max_y, active_edges[i].min_x, active_edges[i]._1_m ); } } #endif - if ( !(y%density) ) - { + if ( !(y%density) ) { //Debug( 9, "%d", y ); - for ( int i = 0; i < n_active_edges; ) - { + for ( int i = 0; i < n_active_edges; ) { int lo_x = int(round(active_edges[i++].min_x)); int hi_x = int(round(active_edges[i++].min_x)); - if( colours == ZM_COLOUR_GRAY8 ) { + if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *p = &buffer[(y*width)+lo_x]; - for ( int x = lo_x; x <= hi_x; x++, p++) - { - if ( !(x%density) ) - { + for ( int x = lo_x; x <= hi_x; x++, p++) { + if ( !(x%density) ) { //Debug( 9, " %d", x ); *p = colour; } } - } else if( colours == ZM_COLOUR_RGB24 ) { + } else if ( colours == ZM_COLOUR_RGB24 ) { unsigned char *p = &buffer[colours*((y*width)+lo_x)]; - for ( int x = lo_x; x <= hi_x; x++, p += 3) - { - if ( !(x%density) ) - { + for ( int x = lo_x; x <= hi_x; x++, p += 3) { + if ( !(x%density) ) { RED_PTR_RGBA(p) = RED_VAL_RGBA(colour); GREEN_PTR_RGBA(p) = GREEN_VAL_RGBA(colour); BLUE_PTR_RGBA(p) = BLUE_VAL_RGBA(colour); @@ -2529,10 +2381,8 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon ) } } else if( colours == ZM_COLOUR_RGB32 ) { Rgb *p = (Rgb*)&buffer[((y*width)+lo_x)<<2]; - for ( int x = lo_x; x <= hi_x; x++, p++) - { - if ( !(x%density) ) - { + for ( int x = lo_x; x <= hi_x; x++, p++) { + if ( !(x%density) ) { /* Fast, copies the entire pixel in a single pass */ *p = colour; } @@ -2541,43 +2391,35 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon ) } } y++; - for ( int i = n_active_edges-1; i >= 0; i-- ) - { - if ( y >= active_edges[i].max_y ) // Or >= as per sheets - { + for ( int i = n_active_edges-1; i >= 0; i-- ) { + if ( y >= active_edges[i].max_y ) { + // Or >= as per sheets Debug( 9, "Deleting active_edge" ); - if ( i < (n_active_edges-1) ) - { + if ( i < (n_active_edges-1) ) { //memcpy( &active_edges[i], &active_edges[i+1], sizeof(*active_edges)*(n_active_edges-i) ); memmove( &active_edges[i], &active_edges[i+1], sizeof(*active_edges)*(n_active_edges-i) ); } n_active_edges--; - } - else - { + } else { active_edges[i].min_x += active_edges[i]._1_m; } } } while ( n_global_edges || n_active_edges ); } -void Image::Fill( Rgb colour, const Polygon &polygon ) -{ +void Image::Fill( Rgb colour, const Polygon &polygon ) { Fill( colour, 1, polygon ); } /* RGB32 compatible: complete */ -void Image::Rotate( int angle ) -{ +void Image::Rotate( int angle ) { angle %= 360; - if ( !angle ) - { + if ( !angle ) { return; } - if ( angle%90 ) - { + if ( angle%90 ) { return; } @@ -2708,39 +2550,28 @@ void Image::Flip( bool leftright ) { unsigned char *d_ptr = flip_buffer; unsigned char *max_d_ptr = flip_buffer + size; - if ( colours == ZM_COLOUR_GRAY8 ) - { - while( d_ptr < max_d_ptr ) - { - for ( unsigned int j = 0; j < width; j++ ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + while( d_ptr < max_d_ptr ) { + for ( unsigned int j = 0; j < width; j++ ) { s_ptr--; *d_ptr++ = *s_ptr; } s_ptr += line_bytes2; } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { Rgb* s_rptr = (Rgb*)s_ptr; Rgb* d_rptr = (Rgb*)flip_buffer; Rgb* max_d_rptr = (Rgb*)max_d_ptr; - while( d_rptr < max_d_rptr ) - { - for ( unsigned int j = 0; j < width; j++ ) - { + while( d_rptr < max_d_rptr ) { + for ( unsigned int j = 0; j < width; j++ ) { s_rptr--; *d_rptr++ = *s_rptr; } s_rptr += width * 2; } - } - else /* Assume RGB24 */ - { - while( d_ptr < max_d_ptr ) - { - for ( unsigned int j = 0; j < width; j++ ) - { + } else /* Assume RGB24 */ { + while( d_ptr < max_d_ptr ) { + for ( unsigned int j = 0; j < width; j++ ) { s_ptr -= 3; *d_ptr++ = *s_ptr; *d_ptr++ = *(s_ptr+1); @@ -2749,15 +2580,12 @@ void Image::Flip( bool leftright ) { s_ptr += line_bytes2; } } - } - else - { + } else { // Vertical flip, top to bottom unsigned char *s_ptr = buffer+(height*line_bytes); unsigned char *d_ptr = flip_buffer; - while( s_ptr > buffer ) - { + while( s_ptr > buffer ) { s_ptr -= line_bytes; memcpy( d_ptr, s_ptr, line_bytes ); d_ptr += line_bytes; @@ -2768,15 +2596,12 @@ void Image::Flip( bool leftright ) { } -void Image::Scale( unsigned int factor ) -{ - if ( !factor ) - { +void Image::Scale( unsigned int factor ) { + if ( !factor ) { Error( "Bogus scale factor %d found", factor ); return; } - if ( factor == ZM_SCALE_BASE ) - { + if ( factor == ZM_SCALE_BASE ) { return; } @@ -2787,8 +2612,7 @@ void Image::Scale( unsigned int factor ) uint8_t* scale_buffer = AllocBuffer(scale_buffer_size); - if ( factor > ZM_SCALE_BASE ) - { + if ( factor > ZM_SCALE_BASE ) { unsigned char *pd = scale_buffer; unsigned int wc = width*colours; unsigned int nwc = new_width*colours; @@ -2796,20 +2620,16 @@ void Image::Scale( unsigned int factor ) unsigned int last_h_index = 0; unsigned int last_w_index = 0; unsigned int h_index; - for ( unsigned int y = 0; y < height; y++ ) - { + for ( unsigned int y = 0; y < height; y++ ) { unsigned char *ps = &buffer[y*wc]; unsigned int w_count = ZM_SCALE_BASE/2; unsigned int w_index; last_w_index = 0; - for ( unsigned int x = 0; x < width; x++ ) - { + for ( unsigned int x = 0; x < width; x++ ) { w_count += factor; w_index = w_count/ZM_SCALE_BASE; - for (unsigned int f = last_w_index; f < w_index; f++ ) - { - for ( unsigned int c = 0; c < colours; c++ ) - { + for (unsigned int f = last_w_index; f < w_index; f++ ) { + for ( unsigned int c = 0; c < colours; c++ ) { *pd++ = *(ps+c); } } @@ -2818,8 +2638,7 @@ void Image::Scale( unsigned int factor ) } h_count += factor; h_index = h_count/ZM_SCALE_BASE; - for ( unsigned int f = last_h_index+1; f < h_index; f++ ) - { + for ( unsigned int f = last_h_index+1; f < h_index; f++ ) { memcpy( pd, pd-nwc, nwc ); pd += nwc; } @@ -2827,9 +2646,7 @@ void Image::Scale( unsigned int factor ) } new_width = last_w_index; new_height = last_h_index; - } - else - { + } else { unsigned char *pd = scale_buffer; unsigned int wc = width*colours; unsigned int xstart = factor/2; @@ -2838,31 +2655,24 @@ void Image::Scale( unsigned int factor ) unsigned int last_h_index = 0; unsigned int last_w_index = 0; unsigned int h_index; - for ( unsigned int y = 0; y < (unsigned int)height; y++ ) - { + for ( unsigned int y = 0; y < (unsigned int)height; y++ ) { h_count += factor; h_index = h_count/ZM_SCALE_BASE; - if ( h_index > last_h_index ) - { + if ( h_index > last_h_index ) { unsigned int w_count = xstart; unsigned int w_index; last_w_index = 0; unsigned char *ps = &buffer[y*wc]; - for ( unsigned int x = 0; x < (unsigned int)width; x++ ) - { + for ( unsigned int x = 0; x < (unsigned int)width; x++ ) { w_count += factor; w_index = w_count/ZM_SCALE_BASE; - if ( w_index > last_w_index ) - { - for ( unsigned int c = 0; c < colours; c++ ) - { + if ( w_index > last_w_index ) { + for ( unsigned int c = 0; c < colours; c++ ) { *pd++ = *ps++; } - } - else - { + } else { ps += colours; } last_w_index = w_index; @@ -2878,29 +2688,23 @@ void Image::Scale( unsigned int factor ) } -void Image::Deinterlace_Discard() -{ +void Image::Deinterlace_Discard() { /* Simple deinterlacing. Copy the even lines into the odd lines */ - if ( colours == ZM_COLOUR_GRAY8 ) - { + if ( colours == ZM_COLOUR_GRAY8 ) { const uint8_t *psrc; uint8_t *pdest; - for (unsigned int y = 0; y < (unsigned int)height; y += 2) - { + for (unsigned int y = 0; y < (unsigned int)height; y += 2) { psrc = buffer + (y * width); pdest = buffer + ((y+1) * width); for (unsigned int x = 0; x < (unsigned int)width; x++) { *pdest++ = *psrc++; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { const uint8_t *psrc; uint8_t *pdest; - for (unsigned int y = 0; y < (unsigned int)height; y += 2) - { + for (unsigned int y = 0; y < (unsigned int)height; y += 2) { psrc = buffer + ((y * width) * 3); pdest = buffer + (((y+1) * width) * 3); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -2909,13 +2713,10 @@ void Image::Deinterlace_Discard() *pdest++ = *psrc++; } } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { const Rgb *psrc; Rgb *pdest; - for (unsigned int y = 0; y < (unsigned int)height; y += 2) - { + for (unsigned int y = 0; y < (unsigned int)height; y += 2) { psrc = (Rgb*)(buffer + ((y * width) << 2)); pdest = (Rgb*)(buffer + (((y+1) * width) << 2)); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -2928,17 +2729,14 @@ void Image::Deinterlace_Discard() } -void Image::Deinterlace_Linear() -{ +void Image::Deinterlace_Linear() { /* Simple deinterlacing. The odd lines are average of the line above and line below */ const uint8_t *pbelow, *pabove; uint8_t *pcurrent; - if ( colours == ZM_COLOUR_GRAY8 ) - { - for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) { pabove = buffer + ((y-1) * width); pbelow = buffer + ((y+1) * width); pcurrent = buffer + (y * width); @@ -2952,11 +2750,8 @@ void Image::Deinterlace_Linear() for (unsigned int x = 0; x < (unsigned int)width; x++) { *pcurrent++ = *pabove++; } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) { pabove = buffer + (((y-1) * width) * 3); pbelow = buffer + (((y+1) * width) * 3); pcurrent = buffer + ((y * width) * 3); @@ -2974,11 +2769,8 @@ void Image::Deinterlace_Linear() *pcurrent++ = *pabove++; *pcurrent++ = *pabove++; } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { - for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { + for (unsigned int y = 1; y < (unsigned int)(height-1); y += 2) { pabove = buffer + (((y-1) * width) << 2); pbelow = buffer + (((y+1) * width) << 2); pcurrent = buffer + ((y * width) << 2); @@ -3004,16 +2796,13 @@ void Image::Deinterlace_Linear() } -void Image::Deinterlace_Blend() -{ +void Image::Deinterlace_Blend() { /* Simple deinterlacing. Blend the fields together. 50% blend */ uint8_t *pabove, *pcurrent; - if ( colours == ZM_COLOUR_GRAY8 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + ((y-1) * width); pcurrent = buffer + (y * width); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3021,11 +2810,8 @@ void Image::Deinterlace_Blend() *pcurrent++ = *pabove++; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + (((y-1) * width) * 3); pcurrent = buffer + ((y * width) * 3); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3037,11 +2823,8 @@ void Image::Deinterlace_Blend() *pcurrent++ = *pabove++; } } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + (((y-1) * width) << 2); pcurrent = buffer + ((y * width) << 2); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3061,8 +2844,7 @@ void Image::Deinterlace_Blend() } -void Image::Deinterlace_Blend_CustomRatio(int divider) -{ +void Image::Deinterlace_Blend_CustomRatio(int divider) { /* Simple deinterlacing. Blend the fields together at a custom ratio. */ /* 1 = 50% blending */ /* 2 = 25% blending */ @@ -3076,10 +2858,8 @@ void Image::Deinterlace_Blend_CustomRatio(int divider) Error("Deinterlace called with invalid blend ratio"); } - if ( colours == ZM_COLOUR_GRAY8 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + if ( colours == ZM_COLOUR_GRAY8 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + ((y-1) * width); pcurrent = buffer + (y * width); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3089,11 +2869,8 @@ void Image::Deinterlace_Blend_CustomRatio(int divider) *pabove++ = subpix2; } } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + } else if ( colours == ZM_COLOUR_RGB24 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + (((y-1) * width) * 3); pcurrent = buffer + ((y * width) * 3); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3111,11 +2888,8 @@ void Image::Deinterlace_Blend_CustomRatio(int divider) *pabove++ = subpix2; } } - } - else if ( colours == ZM_COLOUR_RGB32 ) - { - for (unsigned int y = 1; y < (unsigned int)height; y += 2) - { + } else if ( colours == ZM_COLOUR_RGB32 ) { + for (unsigned int y = 1; y < (unsigned int)height; y += 2) { pabove = buffer + (((y-1) * width) << 2); pcurrent = buffer + ((y * width) << 2); for (unsigned int x = 0; x < (unsigned int)width; x++) { @@ -3203,25 +2977,25 @@ void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, u static uint32_t clearmask = 0; static double current_blendpercent = 0.0; - if(current_blendpercent != blendpercent) { + if ( current_blendpercent != blendpercent ) { /* Attempt to match the blending percent to one of the possible values */ - if(blendpercent < 2.34375) { + if ( blendpercent < 2.34375 ) { // 1.5625% blending divider = 6; clearmask = 0x03030303; - } else if(blendpercent < 4.6875) { + } else if ( blendpercent < 4.6875 ) { // 3.125% blending divider = 5; clearmask = 0x07070707; - } else if(blendpercent < 9.375) { + } else if ( blendpercent < 9.375 ) { // 6.25% blending divider = 4; clearmask = 0x0F0F0F0F; - } else if(blendpercent < 18.75) { + } else if ( blendpercent < 18.75 ) { // 12.5% blending divider = 3; clearmask = 0x1F1F1F1F; - } else if(blendpercent < 37.5) { + } else if ( blendpercent < 37.5 ) { // 25% blending divider = 2; clearmask = 0x3F3F3F3F; @@ -3267,21 +3041,21 @@ __attribute__((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* static double current_blendpercent = 0.0; const uint8_t* const max_ptr = result + count; - if(current_blendpercent != blendpercent) { + if ( current_blendpercent != blendpercent ) { /* Attempt to match the blending percent to one of the possible values */ - if(blendpercent < 2.34375) { + if ( blendpercent < 2.34375 ) { // 1.5625% blending divider = 6; - } else if(blendpercent < 4.6875) { + } else if ( blendpercent < 4.6875 ) { // 3.125% blending divider = 5; - } else if(blendpercent < 9.375) { + } else if ( blendpercent < 9.375 ) { // 6.25% blending divider = 4; - } else if(blendpercent < 18.75) { + } else if ( blendpercent < 18.75 ) { // 12.5% blending divider = 3; - } else if(blendpercent < 37.5) { + } else if ( blendpercent < 37.5 ) { // 25% blending divider = 2; } else { @@ -3291,8 +3065,7 @@ __attribute__((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* current_blendpercent = blendpercent; } - - while(result < max_ptr) { + while ( result < max_ptr ) { result[0] = ((col2[0] - col1[0])>>divider) + col1[0]; result[1] = ((col2[1] - col1[1])>>divider) + col1[1]; result[2] = ((col2[2] - col1[2])>>divider) + col1[2]; @@ -3490,9 +3263,8 @@ __attribute__((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col double opacity = 1.0 - divide; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while ( result < max_ptr ) { *result++ = (*col1++ * opacity) + (*col2++ * divide); - } } @@ -4692,8 +4464,7 @@ __attribute__((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8 /************************************************* DEINTERLACE FUNCTIONS *************************************************/ /* Grayscale */ -__attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const uint8_t* const max_ptr = col1 + (width*(height-1)); const uint8_t *max_ptr2; @@ -4703,8 +4474,7 @@ __attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8 pabove = col1; pnabove = col2; pbelow = col1 + (width*2); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + width; while(pcurrent < max_ptr2) { if((unsigned int)((abs(*pnabove - *pabove) + abs(*pncurrent - *pcurrent)) >> 1) >= threshold) { @@ -4721,7 +4491,6 @@ __attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8 pabove += width; pnabove += width; pbelow += width; - } /* Special case for the last line */ @@ -4738,8 +4507,7 @@ __attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8 } /* RGB */ -__attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*3; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -4752,8 +4520,7 @@ __attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t pabove = col1; pnabove = col2; pbelow = col1 + ((width*2)*3); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { r = abs(pnabove[0] - pabove[0]); @@ -4780,7 +4547,6 @@ __attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t pabove += row_width; pnabove += row_width; pbelow += row_width; - } /* Special case for the last line */ @@ -4807,8 +4573,7 @@ __attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t } /* BGR */ -__attribute__((noinline)) void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*3; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -4821,8 +4586,7 @@ __attribute__((noinline)) void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t pabove = col1; pnabove = col2; pbelow = col1 + ((width*2)*3); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { b = abs(pnabove[0] - pabove[0]); @@ -4876,8 +4640,7 @@ __attribute__((noinline)) void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t } /* RGBA */ -__attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -4890,8 +4653,7 @@ __attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_ pabove = col1; pnabove = col2; pbelow = col1 + (row_width*2); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { r = abs(pnabove[0] - pabove[0]); @@ -4918,7 +4680,6 @@ __attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_ pabove += row_width; pnabove += row_width; pbelow += row_width; - } /* Special case for the last line */ @@ -4945,8 +4706,7 @@ __attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_ } /* BGRA */ -__attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -4959,8 +4719,7 @@ __attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_ pabove = col1; pnabove = col2; pbelow = col1 + (row_width*2); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { b = abs(pnabove[0] - pabove[0]); @@ -4987,7 +4746,6 @@ __attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_ pabove += row_width; pnabove += row_width; pbelow += row_width; - } /* Special case for the last line */ @@ -5014,8 +4772,7 @@ __attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_ } /* ARGB */ -__attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -5028,8 +4785,7 @@ __attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_ pabove = col1; pnabove = col2; pbelow = col1 + (row_width*2); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { r = abs(pnabove[1] - pabove[1]); @@ -5056,7 +4812,6 @@ __attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_ pabove += row_width; pnabove += row_width; pbelow += row_width; - } /* Special case for the last line */ @@ -5083,8 +4838,7 @@ __attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_ } /* ABGR */ -__attribute__((noinline)) void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) -{ +__attribute__((noinline)) void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; const uint8_t* const max_ptr = col1 + (row_width * (height-1)); @@ -5097,8 +4851,7 @@ __attribute__((noinline)) void std_deinterlace_4field_abgr(uint8_t* col1, uint8_ pabove = col1; pnabove = col2; pbelow = col1 + (row_width*2); - while(pcurrent < max_ptr) - { + while(pcurrent < max_ptr) { max_ptr2 = pcurrent + row_width; while(pcurrent < max_ptr2) { b = abs(pnabove[1] - pabove[1]); diff --git a/src/zm_image.h b/src/zm_image.h index dafd067f1..66e7ef32e 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -274,6 +274,7 @@ void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); + void neon32_armv7_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void neon32_armv7_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void neon32_armv7_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 736d36377..c34f6ba41 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -444,6 +444,7 @@ void Logger::closeSyslog() { void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) { if ( level > mEffectiveLevel ) return; + log_mutex.lock(); char timeString[64]; char logString[8192]; va_list argPtr; @@ -579,8 +580,10 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co abort(); exit(-1); } + log_mutex.unlock(); } + void logInit(const char *name, const Logger::Options &options) { if ( !Logger::smInstance ) Logger::smInstance = new Logger(); diff --git a/src/zm_logger.h b/src/zm_logger.h index 8e2ab6c9d..f65c5ec31 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -30,6 +30,8 @@ #endif // HAVE_SYS_SYSCALL_H #include +#include "zm_thread.h" + class Logger { public: enum { @@ -82,6 +84,8 @@ private: static bool smInitialised; static Logger *smInstance; + RecursiveMutex log_mutex; + static StringMap smCodes; static IntMap smSyslogPriorities; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 2e1e55691..3e4aff2a4 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -483,9 +483,14 @@ Monitor::Monitor( event = 0; - Debug( 1, "Monitor %s has function %d", name, function ); - Debug( 1, "Monitor %s LBF = '%s', LBX = %d, LBY = %d, LBS = %d", name, label_format, label_coord.X(), label_coord.Y(), label_size ); - Debug( 1, "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d, ARBP = %d, FM = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion ); + Debug(1, "Monitor %s has function %d,\n" + "label format = '%s', label X = %d, label Y = %d, label size = %d,\n" + "image buffer count = %d, warmup count = %d, pre-event count = %d, post-event count = %d, alarm frame count = %d,\n" + "fps report interval = %d, ref blend percentage = %d, alarm ref blend percentage = %d, track motion = %d", + name, function, + label_format, label_coord.X(), label_coord.Y(), label_size, + image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, + fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion ); //Set video recording flag for event start constructor and easy reference in code videoRecording = ((GetOptVideoWriter() == H264PASSTHROUGH) && camera->SupportsNativeVideo()); @@ -494,7 +499,6 @@ Monitor::Monitor( linked_monitors = 0; if ( purpose == ANALYSIS ) { -Debug(2,"last_write_index(%d), last_write_time(%d)", shared_data->last_write_index, shared_data->last_write_time ); while( ( shared_data->last_write_index == (unsigned int)image_buffer_count ) && @@ -502,80 +506,81 @@ Debug(2,"last_write_index(%d), last_write_time(%d)", shared_data->last_write_ind && ( !zm_terminate ) ) { - Debug(1, "Waiting for capture daemon"); + Debug(1, "Waiting for capture daemon last_write_index(%d), last_write_time(%d)", + shared_data->last_write_index, shared_data->last_write_time ); sleep(1); } ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[shared_data->last_write_index].image->Buffer(), camera->ImageSize()); adaptive_skip = true; - ReloadLinkedMonitors( p_linked_monitors ); - } + ReloadLinkedMonitors(p_linked_monitors); + } // end if purpose == ANALYSIS } // Monitor::Monitor - bool Monitor::connect() { Debug(3, "Connecting to monitor. Purpose is %d", purpose ); #if ZM_MEM_MAPPED - snprintf( mem_file, sizeof(mem_file), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id ); - map_fd = open( mem_file, O_RDWR|O_CREAT, (mode_t)0600 ); + snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id); + map_fd = open(mem_file, O_RDWR|O_CREAT, (mode_t)0600); if ( map_fd < 0 ) { - Fatal( "Can't open memory map file %s, probably not enough space free: %s", mem_file, strerror(errno) ); + Fatal("Can't open memory map file %s, probably not enough space free: %s", mem_file, strerror(errno)); } else { - Debug(3, "Success opening mmap file at (%s)", mem_file ); + Debug(3, "Success opening mmap file at (%s)", mem_file); } struct stat map_stat; - if ( fstat( map_fd, &map_stat ) < 0 ) - Fatal( "Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file, strerror(errno) ); + if ( fstat(map_fd, &map_stat) < 0 ) + Fatal("Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file, strerror(errno)); if ( map_stat.st_size != mem_size ) { if ( purpose == CAPTURE ) { // Allocate the size - if ( ftruncate( map_fd, mem_size ) < 0 ) { - Fatal( "Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno) ); + if ( ftruncate(map_fd, mem_size) < 0 ) { + Fatal("Can't extend memory map file %s to %d bytes: %s", mem_file, mem_size, strerror(errno)); } } else if ( map_stat.st_size == 0 ) { - Error( "Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size ); + Error("Got empty memory map file size %ld, is the zmc process for this monitor running?", map_stat.st_size, mem_size); + close(map_fd); + map_fd = -1; return false; } else { - Error( "Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size ); + Error("Got unexpected memory map file size %ld, expected %d", map_stat.st_size, mem_size); + close(map_fd); + map_fd = -1; return false; } } - Debug(3, "MMap file size is %ld", map_stat.st_size ); + Debug(3, "MMap file size is %ld", map_stat.st_size); #ifdef MAP_LOCKED - mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0 ); + mem_ptr = (unsigned char *)mmap(NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0); if ( mem_ptr == MAP_FAILED ) { if ( errno == EAGAIN ) { - Debug( 1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size ); - + Debug(1, "Unable to map file %s (%d bytes) to locked memory, trying unlocked", mem_file, mem_size); #endif - mem_ptr = (unsigned char *)mmap( NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0 ); - Debug( 1, "Mapped file %s (%d bytes) to unlocked memory", mem_file, mem_size ); + mem_ptr = (unsigned char *)mmap(NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0); + Debug(1, "Mapped file %s (%d bytes) to unlocked memory", mem_file, mem_size); #ifdef MAP_LOCKED } else { - Error( "Unable to map file %s (%d bytes) to locked memory (%s)", mem_file, mem_size , strerror(errno) ); + Error("Unable to map file %s (%d bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno)); } } #endif if ( mem_ptr == MAP_FAILED ) - Fatal( "Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno ); + Fatal("Can't map file %s (%d bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno); if ( mem_ptr == NULL ) { - Error( "mmap gave a null address:" ); + Error("mmap gave a null address:"); } else { - Debug(3, "mmapped to %p", mem_ptr ); + Debug(3, "mmapped to %p", mem_ptr); } #else // ZM_MEM_MAPPED - shm_id = shmget( (config.shm_key&0xffff0000)|id, mem_size, IPC_CREAT|0700 ); + shm_id = shmget((config.shm_key&0xffff0000)|id, mem_size, IPC_CREAT|0700); if ( shm_id < 0 ) { - Error( "Can't shmget, probably not enough shared memory space free: %s", strerror(errno)); - exit( -1 ); + Fatal("Can't shmget, probably not enough shared memory space free: %s", strerror(errno)); } mem_ptr = (unsigned char *)shmat( shm_id, 0, 0 ); if ( mem_ptr < (void *)0 ) { - Error( "Can't shmat: %s", strerror(errno)); - exit( -1 ); + Fatal("Can't shmat: %s", strerror(errno)); } #endif // ZM_MEM_MAPPED shared_data = (SharedData *)mem_ptr; @@ -584,13 +589,12 @@ bool Monitor::connect() { struct timeval *shared_timestamps = (struct timeval *)((char *)video_store_data + sizeof(VideoStoreData)); unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); - if ( ((unsigned long)shared_images % 64) != 0 ) { /* Align images buffer to nearest 64 byte boundary */ Debug(3,"Aligning shared memory images to the next 64 byte boundary"); shared_images = (uint8_t*)((unsigned long)shared_images + (64 - ((unsigned long)shared_images % 64))); } - Debug(3, "Allocating %d image buffers", image_buffer_count ); + Debug(3, "Allocating %d image buffers", image_buffer_count); image_buffer = new Snapshot[image_buffer_count]; for ( int i = 0; i < image_buffer_count; i++ ) { image_buffer[i].timestamp = &(shared_timestamps[i]); @@ -615,17 +619,24 @@ bool Monitor::connect() { *pre_event_buffer[i].timestamp = {0,0}; pre_event_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder()); } - } + } // end if max_analysis_fps timestamps = new struct timeval *[pre_event_count]; images = new Image *[pre_event_count]; last_signal = shared_data->signal; - } + } // end if purpose == ANALYSIS Debug(3, "Success connecting"); return true; -} +} // end Monitor::connect Monitor::~Monitor() { + if ( n_linked_monitors ) { + for( int i = 0; i < n_linked_monitors; i++ ) { + delete linked_monitors[i]; + } + delete[] linked_monitors; + linked_monitors = 0; + } if ( timestamps ) { delete[] timestamps; timestamps = 0; @@ -688,31 +699,29 @@ Monitor::~Monitor() { } #if ZM_MEM_MAPPED - if ( msync( mem_ptr, mem_size, MS_SYNC ) < 0 ) - Error( "Can't msync: %s", strerror(errno) ); - if ( munmap( mem_ptr, mem_size ) < 0 ) - Fatal( "Can't munmap: %s", strerror(errno) ); + if ( msync(mem_ptr, mem_size, MS_SYNC) < 0 ) + Error("Can't msync: %s", strerror(errno)); + if ( munmap(mem_ptr, mem_size) < 0 ) + Fatal("Can't munmap: %s", strerror(errno)); close( map_fd ); if ( purpose == CAPTURE ) { // How about we store this in the object on instantiation so that we don't have to do this again. char mmap_path[PATH_MAX] = ""; - snprintf( mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id ); + snprintf(mmap_path, sizeof(mmap_path), "%s/zm.mmap.%d", staticConfig.PATH_MAP.c_str(), id); - if ( unlink( mmap_path ) < 0 ) { - Warning( "Can't unlink '%s': %s", mmap_path, strerror(errno) ); + if ( unlink(mmap_path) < 0 ) { + Warning("Can't unlink '%s': %s", mmap_path, strerror(errno)); } } #else // ZM_MEM_MAPPED struct shmid_ds shm_data; - if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) { - Error( "Can't shmctl: %s", strerror(errno) ); - exit( -1 ); + if ( shmctl(shm_id, IPC_STAT, &shm_data) < 0 ) { + Fatal("Can't shmctl: %s", strerror(errno)); } if ( shm_data.shm_nattch <= 1 ) { - if ( shmctl( shm_id, IPC_RMID, 0 ) < 0 ) { - Error( "Can't shmctl: %s", strerror(errno) ); - exit( -1 ); + if ( shmctl(shm_id, IPC_RMID, 0) < 0 ) { + Fatal("Can't shmctl: %s", strerror(errno)); } } #endif // ZM_MEM_MAPPED @@ -749,7 +758,7 @@ void Monitor::AddPrivacyBitmask( Zone *p_zones[] ) { } Monitor::State Monitor::GetState() const { - return( (State)shared_data->state ); + return (State)shared_data->state; } int Monitor::GetImage( int index, int scale ) { @@ -1906,15 +1915,15 @@ void Monitor::ReloadLinkedMonitors(const char *p_linked_monitors) { static char sql[ZM_SQL_SML_BUFSIZ]; snprintf(sql, sizeof(sql), "select Id, Name from Monitors where Id = %d and Function != 'None' and Function != 'Monitor' and Enabled = 1", link_ids[i] ); if ( mysql_query(&dbconn, sql) ) { - Error("Can't run query: %s", mysql_error(&dbconn)); db_mutex.unlock(); + Error("Can't run query: %s", mysql_error(&dbconn)); continue; } MYSQL_RES *result = mysql_store_result(&dbconn); if ( !result ) { - Error("Can't use query result: %s", mysql_error(&dbconn)); db_mutex.unlock(); + Error("Can't use query result: %s", mysql_error(&dbconn)); continue; } db_mutex.unlock(); @@ -2110,6 +2119,7 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) { Camera *camera = 0; if ( type == "Local" ) { +#if ZM_HAS_V4L int extras = (deinterlacing>>24)&0xff; camera = new LocalCamera( @@ -2132,6 +2142,9 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) { record_audio, extras ); +#else + Fatal("ZoneMinder not built with Local Camera support"); +#endif } else if ( type == "Remote" ) { if ( protocol == "http" ) { camera = new RemoteCameraHttp( @@ -2475,8 +2488,13 @@ int Monitor::Capture() { fps = new_fps; db_mutex.lock(); static char sql[ZM_SQL_SML_BUFSIZ]; + // The reason we update the Status as well is because if mysql restarts, the Monitor_Status table is lost, + // and nothing else will update the status until zmc restarts. Since we are successfully capturing we can + // assume that we are connected snprintf(sql, sizeof(sql), - "INSERT INTO Monitor_Status (MonitorId,CaptureFPS,CaptureBandwidth) VALUES (%d, %.2lf,%u) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf, CaptureBandwidth=%u", + "INSERT INTO Monitor_Status (MonitorId,CaptureFPS,CaptureBandwidth,Status) " + "VALUES (%d, %.2lf, %u, 'Connected') ON DUPLICATE KEY UPDATE " + "CaptureFPS = %.2lf, CaptureBandwidth=%u, Status='Connected'", id, fps, new_capture_bandwidth, fps, new_capture_bandwidth); if ( mysql_query(&dbconn, sql) ) { Error("Can't run query: %s", mysql_error(&dbconn)); @@ -2628,7 +2646,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z } else { // check if end of alarm if (old_zone_alarmed) { - Debug(3, "Preclusive Zone %s alarm Ends. Prevíous score: %d", zone->Label(), old_zone_score); + Debug(3, "Preclusive Zone %s alarm Ends. Previous score: %d", zone->Label(), old_zone_score); if (old_zone_score > 0) { zone->SetExtendAlarmCount(zone->GetExtendAlarmFrames()); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index b98f5953f..d7be9555e 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -127,24 +127,25 @@ protected: uint8_t format; /* +55 */ uint32_t imagesize; /* +56 */ uint32_t epadding1; /* +60 */ - uint32_t epadding2; /* +64 */ /* ** This keeps 32bit time_t and 64bit time_t identical and compatible as long as time is before 2038. ** Shared memory layout should be identical for both 32bit and 64bit and is multiples of 16. + ** Because startup_time is 64bit it may be aligned to a 64bit boundary. So it's offset SHOULD be a multiple + ** of 8. Add or delete epadding's to achieve this. */ - union { /* +68 */ + union { /* +64 */ time_t startup_time; /* When the zmc process started. zmwatch uses this to see how long the process has been running without getting any images */ uint64_t extrapad1; }; - union { /* +76 */ + union { /* +72 */ time_t last_write_time; uint64_t extrapad2; }; - union { /* +84 */ + union { /* +80 */ time_t last_read_time; uint64_t extrapad3; }; - uint8_t control_state[256]; /* +92 */ + uint8_t control_state[256]; /* +88 */ char alarm_cause[256]; diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index 897859435..703328e2e 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -388,7 +388,7 @@ int RtspThread::run() { std::string trackUrl = mUrl; std::string controlUrl; - _AVCODECID codecId; + _AVCODECID codecId = AV_CODEC_ID_NONE; if ( mFormatContext->nb_streams >= 1 ) { for ( unsigned int i = 0; i < mFormatContext->nb_streams; i++ ) { diff --git a/src/zm_signal.cpp b/src/zm_signal.cpp index 034ff7d66..e13bfdc9c 100644 --- a/src/zm_signal.cpp +++ b/src/zm_signal.cpp @@ -31,13 +31,15 @@ bool zm_terminate = false; RETSIGTYPE zm_hup_handler(int signal) { - Info("Got signal %d (%s), reloading", signal, strsignal(signal)); + // Shouldn't do complex things in signal handlers, logging is complex and can block due to mutexes. + //Info("Got signal %d (%s), reloading", signal, strsignal(signal)); zm_reload = true; } RETSIGTYPE zm_term_handler(int signal) { - Info("Got signal %d (%s), exiting", signal, strsignal(signal)); + // Shouldn't do complex things in signal handlers, logging is complex and can block due to mutexes. + //Info("Got signal %d (%s), exiting", signal, strsignal(signal)); zm_terminate = true; } diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 7ab844d78..461a6d74d 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -325,7 +325,7 @@ void StreamBase::openComms() { strncpy(loc_addr.sun_path, loc_sock_path, sizeof(loc_addr.sun_path)); loc_addr.sun_family = AF_UNIX; Debug(3, "Binding to %s", loc_sock_path); - if ( bind(sd, (struct sockaddr *)&loc_addr, strlen(loc_addr.sun_path)+sizeof(loc_addr.sun_family)+1) < 0 ) { + if ( ::bind(sd, (struct sockaddr *)&loc_addr, strlen(loc_addr.sun_path)+sizeof(loc_addr.sun_family)+1) < 0 ) { Fatal("Can't bind: %s", strerror(errno)); } diff --git a/src/zm_thread.h b/src/zm_thread.h index 0c41a93a5..8cdfb892c 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -20,9 +20,12 @@ #ifndef ZM_THREAD_H #define ZM_THREAD_H +class RecursiveMutex; + + +#include "zm_config.h" #include #include -#include #ifdef HAVE_SYS_SYSCALL_H #include #endif // HAVE_SYS_SYSCALL_H diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index a1c52353c..cb7bac722 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -205,7 +205,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, audio_out_stream = NULL; in_frame = NULL; out_frame = NULL; -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE) resample_ctx = NULL; #endif @@ -220,7 +220,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, audio_in_ctx = audio_in_stream->codec; #endif - if (audio_in_ctx->codec_id != AV_CODEC_ID_AAC) { + if ( audio_in_ctx->codec_id != AV_CODEC_ID_AAC ) { static char error_buffer[256]; avcodec_string(error_buffer, sizeof(error_buffer), audio_in_ctx, 0); Debug(2, "Got something other than AAC (%s)", error_buffer); @@ -238,45 +238,42 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, avformat_new_stream(oc, (AVCodec *)audio_in_ctx->codec); #endif if ( !audio_out_stream ) { - Error("Unable to create audio out stream\n"); + Error("Unable to create audio out stream"); audio_out_stream = NULL; } else { - Debug(2, "setting parameters"); - #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) audio_out_ctx = avcodec_alloc_context3(audio_out_codec); // Copy params from instream to ctx ret = avcodec_parameters_to_context(audio_out_ctx, audio_in_stream->codecpar); - if (ret < 0) { - Error("Unable to copy audio params to ctx %s\n", + if ( ret < 0 ) { + Error("Unable to copy audio params to ctx %s", av_make_error_string(ret).c_str()); } ret = avcodec_parameters_from_context(audio_out_stream->codecpar, audio_out_ctx); - if (ret < 0) { - Error("Unable to copy audio params to stream %s\n", + if ( ret < 0 ) { + Error("Unable to copy audio params to stream %s", av_make_error_string(ret).c_str()); } - if (!audio_out_ctx->codec_tag) { + if ( !audio_out_ctx->codec_tag ) { audio_out_ctx->codec_tag = av_codec_get_tag( oc->oformat->codec_tag, audio_in_ctx->codec_id); Debug(2, "Setting audio codec tag to %d", audio_out_ctx->codec_tag); } - #else audio_out_ctx = audio_out_stream->codec; ret = avcodec_copy_context(audio_out_ctx, audio_in_ctx); audio_out_ctx->codec_tag = 0; #endif - if (ret < 0) { - Error("Unable to copy audio ctx %s\n", + if ( ret < 0 ) { + Error("Unable to copy audio ctx %s", av_make_error_string(ret).c_str()); audio_out_stream = NULL; } else { - if (audio_out_ctx->channels > 1) { + if ( audio_out_ctx->channels > 1 ) { Warning("Audio isn't mono, changing it."); audio_out_ctx->channels = 1; } else { @@ -286,8 +283,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, } // end if audio_out_stream } // end if is AAC - if (audio_out_stream) { - if (oc->oformat->flags & AVFMT_GLOBALHEADER) { + if ( audio_out_stream ) { + if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) { #if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0) audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; #else @@ -297,7 +294,6 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, } } // end if audio_in_stream - video_last_pts = 0; video_last_dts = 0; audio_last_pts = 0; @@ -310,12 +306,11 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, bool VideoStore::open() { /* open the out file, if needed */ - if (!(out_format->flags & AVFMT_NOFILE)) { + if ( !(out_format->flags & AVFMT_NOFILE) ) { ret = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, NULL, NULL); - if (ret < 0) { + if ( ret < 0 ) { Error("Could not open out file '%s': %s\n", filename, av_make_error_string(ret).c_str()); - return false; } } @@ -339,9 +334,9 @@ bool VideoStore::open() { } else if (av_dict_count(opts) != 0) { Warning("some options not set\n"); } - if (opts) av_dict_free(&opts); - if (ret < 0) { - Error("Error occurred when writing out file header to %s: %s\n", + if ( opts ) av_dict_free(&opts); + if ( ret < 0 ) { + Error("Error occurred when writing out file header to %s: %s", filename, av_make_error_string(ret).c_str()); /* free the stream */ avio_closep(&oc->pb); @@ -469,10 +464,16 @@ VideoStore::~VideoStore() { avcodec_free_context(&audio_out_ctx); #endif audio_out_ctx = NULL; -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBAVRESAMPLE) || defined(HAVE_LIBSWRESAMPLE) if ( resample_ctx ) { +#if defined(HAVE_LIBSWRESAMPLE) + swr_free(&resample_ctx); +#else +#if defined(HAVE_LIBAVRESAMPLE) avresample_close(resample_ctx); avresample_free(&resample_ctx); +#endif +#endif } if ( in_frame ) { av_frame_free(&in_frame); @@ -494,7 +495,12 @@ VideoStore::~VideoStore() { } // VideoStore::~VideoStore() bool VideoStore::setup_resampler() { -#ifdef HAVE_LIBAVRESAMPLE +#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE) + Error( + "Not built with resample library. " + "Cannot do audio conversion to AAC"); + return false; +#else #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) // Newer ffmpeg wants to keep everything separate... so have to lookup our own @@ -502,17 +508,16 @@ bool VideoStore::setup_resampler() { audio_in_codec = avcodec_find_decoder(audio_in_stream->codecpar->codec_id); #else - audio_in_codec = - avcodec_find_decoder(audio_in_ctx->codec_id); + audio_in_codec = avcodec_find_decoder(audio_in_ctx->codec_id); #endif ret = avcodec_open2(audio_in_ctx, audio_in_codec, NULL); - if (ret < 0) { + if ( ret < 0 ) { Error("Can't open in codec!"); return false; } audio_out_codec = avcodec_find_encoder(AV_CODEC_ID_AAC); - if (!audio_out_codec) { + if ( !audio_out_codec ) { Error("Could not find codec for AAC"); return false; } @@ -521,23 +526,25 @@ bool VideoStore::setup_resampler() { #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) // audio_out_ctx = audio_out_stream->codec; audio_out_ctx = avcodec_alloc_context3(audio_out_codec); - - if (!audio_out_ctx) { - Error("could not allocate codec ctx for AAC\n"); + if ( !audio_out_ctx ) { + Error("could not allocate codec ctx for AAC"); audio_out_stream = NULL; return false; } Debug(2, "Have audio_out_ctx"); // Now copy them to the out stream - audio_out_stream = avformat_new_stream(oc, NULL); + audio_out_stream = avformat_new_stream(oc, audio_out_codec); #else audio_out_stream = avformat_new_stream(oc, NULL); audio_out_ctx = audio_out_stream->codec; #endif + // Some formats (i.e. WAV) do not produce the proper channel layout + if ( audio_in_ctx->channel_layout == 0 ) + audio_in_ctx->channel_layout = av_get_channel_layout("mono"); /* put sample parameters */ - audio_out_ctx->bit_rate = audio_in_ctx->bit_rate; + audio_out_ctx->bit_rate = audio_in_ctx->bit_rate <= 96000 ? audio_in_ctx->bit_rate : 96000; audio_out_ctx->sample_rate = audio_in_ctx->sample_rate; audio_out_ctx->channels = audio_in_ctx->channels; audio_out_ctx->channel_layout = audio_in_ctx->channel_layout; @@ -546,29 +553,35 @@ bool VideoStore::setup_resampler() { #else audio_out_ctx->refcounted_frames = 1; #endif + if ( ! audio_out_ctx->channel_layout ) { + Debug(3, "Correcting channel layout from (%d) to (%d)", + audio_out_ctx->channel_layout, + av_get_default_channel_layout(audio_out_ctx->channels) + ); + audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels); + } - if (audio_out_codec->supported_samplerates) { + if ( audio_out_codec->supported_samplerates ) { int found = 0; - for (unsigned int i = 0; audio_out_codec->supported_samplerates[i]; - i++) { - if (audio_out_ctx->sample_rate == - audio_out_codec->supported_samplerates[i]) { + for ( unsigned int i = 0; audio_out_codec->supported_samplerates[i]; i++) { + if ( audio_out_ctx->sample_rate == + audio_out_codec->supported_samplerates[i] ) { found = 1; break; } } - if (found) { + if ( found ) { Debug(3, "Sample rate is good"); } else { audio_out_ctx->sample_rate = audio_out_codec->supported_samplerates[0]; - Debug(1, "Sampel rate is no good, setting to (%d)", + Debug(1, "Sample rate is no good, setting to (%d)", audio_out_codec->supported_samplerates[0]); } } /* check that the encoder supports s16 pcm in */ - if (!check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt)) { + if ( !check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt) ) { Debug(3, "Encoder does not support sample format %s, setting to FLTP", av_get_sample_fmt_name(audio_out_ctx->sample_fmt)); audio_out_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP; @@ -577,16 +590,6 @@ bool VideoStore::setup_resampler() { audio_out_ctx->time_base = (AVRational){1, audio_out_ctx->sample_rate}; - -#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) - ret = avcodec_parameters_from_context(audio_out_stream->codecpar, - audio_out_ctx); - if (ret < 0) { - Error("Could not initialize stream parameteres"); - return false; - } -#endif - AVDictionary *opts = NULL; if ( (ret = av_dict_set(&opts, "strict", "experimental", 0)) < 0 ) { Error("Couldn't set experimental"); @@ -601,6 +604,15 @@ bool VideoStore::setup_resampler() { return false; } +#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + ret = avcodec_parameters_from_context( + audio_out_stream->codecpar, audio_out_ctx); + if ( ret < 0 ) { + Error("Could not initialize stream parameteres"); + return false; + } +#endif + Debug(1, "Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) " "layout(%d) frame_size(%d)", @@ -609,84 +621,76 @@ bool VideoStore::setup_resampler() { audio_out_ctx->channel_layout, audio_out_ctx->frame_size); /** Create a new frame to store the audio samples. */ - if (!(in_frame = zm_av_frame_alloc())) { + if ( !(in_frame = zm_av_frame_alloc()) ) { Error("Could not allocate in frame"); return false; } /** Create a new frame to store the audio samples. */ - if (!(out_frame = zm_av_frame_alloc())) { + if ( !(out_frame = zm_av_frame_alloc()) ) { Error("Could not allocate out frame"); av_frame_free(&in_frame); return false; } +#if defined(HAVE_LIBSWRESAMPLE) + resample_ctx = swr_alloc_set_opts(NULL, + av_get_default_channel_layout(audio_out_ctx->channels), + audio_out_ctx->sample_fmt, + audio_out_ctx->sample_rate, + av_get_default_channel_layout(audio_in_ctx->channels), + audio_in_ctx->sample_fmt, + audio_in_ctx->sample_rate, + 0, NULL); + if ( !resample_ctx ) { + Error("Could not allocate resample context"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); + return false; + } + if ( (ret = swr_init(resample_ctx)) < 0 ) { + Error("Could not open resampler"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); + swr_free(&resample_ctx); + return false; + } +#else +#if defined(HAVE_LIBAVRESAMPLE) // Setup the audio resampler resample_ctx = avresample_alloc_context(); - if (!resample_ctx) { - Error("Could not allocate resample ctx\n"); + if ( !resample_ctx ) { + Error("Could not allocate resample ctx"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); return false; } - // Some formats (i.e. WAV) do not produce the proper channel layout - if (audio_in_ctx->channel_layout == 0) { - uint64_t layout = av_get_channel_layout("mono"); - av_opt_set_int(resample_ctx, "in_channel_layout", - av_get_channel_layout("mono"), 0); - Debug(1, "Bad channel layout. Need to set it to mono (%d).", layout); - } else { - av_opt_set_int(resample_ctx, "in_channel_layout", - audio_in_ctx->channel_layout, 0); - } - + av_opt_set_int(resample_ctx, "in_channel_layout", + audio_in_ctx->channel_layout, 0); av_opt_set_int(resample_ctx, "in_sample_fmt", - audio_in_ctx->sample_fmt, 0); + audio_in_ctx->sample_fmt, 0); av_opt_set_int(resample_ctx, "in_sample_rate", - audio_in_ctx->sample_rate, 0); - av_opt_set_int(resample_ctx, "in_channels", audio_in_ctx->channels, - 0); - // av_opt_set_int( resample_ctx, "out_channel_layout", - // audio_out_ctx->channel_layout, 0); + audio_in_ctx->sample_rate, 0); + av_opt_set_int(resample_ctx, "in_channels", + audio_in_ctx->channels, 0); av_opt_set_int(resample_ctx, "out_channel_layout", - av_get_channel_layout("mono"), 0); + audio_in_ctx->channel_layout, 0); av_opt_set_int(resample_ctx, "out_sample_fmt", - audio_out_ctx->sample_fmt, 0); + audio_out_ctx->sample_fmt, 0); av_opt_set_int(resample_ctx, "out_sample_rate", - audio_out_ctx->sample_rate, 0); + audio_out_ctx->sample_rate, 0); av_opt_set_int(resample_ctx, "out_channels", - audio_out_ctx->channels, 0); + audio_out_ctx->channels, 0); ret = avresample_open(resample_ctx); - if (ret < 0) { - Error("Could not open resample ctx\n"); + if ( ret < 0 ) { + Error("Could not open resample ctx"); return false; + } else { + Debug(2, "Success opening resampler"); } - -#if 0 - /** - * Allocate as many pointers as there are audio channels. - * Each pointer will later point to the audio samples of the corresponding - * channels (although it may be NULL for interleaved formats). - */ - if (!( converted_in_samples = reinterpret_castcalloc( audio_out_ctx->channels, sizeof(*converted_in_samples))) ) { - Error("Could not allocate converted in sample pointers\n"); - return; - } - /** - * Allocate memory for the samples of all channels in one consecutive - * block for convenience. - */ - if ( (ret = av_samples_alloc( &converted_in_samples, NULL, - audio_out_ctx->channels, - audio_out_ctx->frame_size, - audio_out_ctx->sample_fmt, 0)) < 0 ) { - Error("Could not allocate converted in samples (error '%s')\n", - av_make_error_string(ret).c_str()); - - av_freep(converted_in_samples); - free(converted_in_samples); - return; - } +#endif #endif out_frame->nb_samples = audio_out_ctx->frame_size; @@ -696,30 +700,28 @@ bool VideoStore::setup_resampler() { // The codec gives us the frame size, in samples, we calculate the size of the // samples buffer in bytes unsigned int audioSampleBuffer_size = av_samples_get_buffer_size( - NULL, audio_out_ctx->channels, audio_out_ctx->frame_size, + NULL, audio_out_ctx->channels, + audio_out_ctx->frame_size, audio_out_ctx->sample_fmt, 0); converted_in_samples = (uint8_t *)av_malloc(audioSampleBuffer_size); - if (!converted_in_samples) { - Error("Could not allocate converted in sample pointers\n"); + if ( !converted_in_samples ) { + Error("Could not allocate converted in sample pointers"); return false; + } else { + Debug(2, "Frame Size %d, sample buffer size %d", audio_out_ctx->frame_size, audioSampleBuffer_size); } // Setup the data pointers in the AVFrame - if (avcodec_fill_audio_frame(out_frame, audio_out_ctx->channels, + if ( avcodec_fill_audio_frame(out_frame, audio_out_ctx->channels, audio_out_ctx->sample_fmt, (const uint8_t *)converted_in_samples, audioSampleBuffer_size, 0) < 0) { - Error("Could not allocate converted in sample pointers\n"); + Error("Could not allocate converted in sample pointers"); return false; } return true; -#else - Error( - "Not built with libavresample library. Cannot do audio conversion to " - "AAC"); - return false; #endif } // end bool VideoStore::setup_resampler() @@ -879,9 +881,9 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { if ( audio_out_codec ) { Debug(3, "Have audio codec"); -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE) -#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) ret = avcodec_send_packet(audio_in_ctx, ipkt); if ( ret < 0 ) { Error("avcodec_send_packet fail %s", av_make_error_string(ret).c_str()); @@ -898,7 +900,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { "layout(%d)", in_frame->nb_samples, in_frame->format, in_frame->sample_rate, in_frame->channel_layout); -#else + #else /** * Decode the audio frame stored in the packet. * The in audio stream decoder is used to do this. @@ -906,47 +908,60 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { * to flush it. */ int data_present; - if ((ret = avcodec_decode_audio4(audio_in_ctx, in_frame, - &data_present, ipkt)) < 0) { - Error("Could not decode frame (error '%s')\n", + if ( (ret = avcodec_decode_audio4( + audio_in_ctx, in_frame, &data_present, ipkt)) < 0 ) { + Error("Could not decode frame (error '%s')", av_make_error_string(ret).c_str()); dumpPacket(ipkt); av_frame_free(&in_frame); return 0; } - if (!data_present) { + if ( !data_present ) { Debug(2, "Not ready to transcode a frame yet."); return 0; } -#endif + #endif int frame_size = out_frame->nb_samples; // Resample the in into the audioSampleBuffer until we proceed the whole // decoded data - if ((ret = - avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data, - 0, in_frame->nb_samples)) < 0) { - Error("Could not resample frame (error '%s')\n", + Debug(2, "Converting %d to %d samples", in_frame->nb_samples, out_frame->nb_samples); + if ( + #if defined(HAVE_LIBSWRESAMPLE) + (ret = swr_convert(resample_ctx, + out_frame->data, frame_size, + (const uint8_t**)in_frame->data, + in_frame->nb_samples)) + #else + #if defined(HAVE_LIBAVRESAMPLE) + (ret = avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data, + 0, in_frame->nb_samples)) + #endif + #endif + < 0) { + Error("Could not resample frame (error '%s')", av_make_error_string(ret).c_str()); av_frame_unref(in_frame); return 0; } av_frame_unref(in_frame); + #if defined(HAVE_LIBAVRESAMPLE) int samples_available = avresample_available(resample_ctx); - if (samples_available < frame_size) { + if ( samples_available < frame_size ) { Debug(1, "Not enough samples yet (%d)", samples_available); return 0; } Debug(3, "Output_frame samples (%d)", out_frame->nb_samples); // Read a frame audio data from the resample fifo - if (avresample_read(resample_ctx, out_frame->data, frame_size) != + if ( avresample_read(resample_ctx, out_frame->data, frame_size) != frame_size) { - Warning("Error reading resampled audio: "); + Warning("Error reading resampled audio:"); return 0; } + #endif Debug(2, "Frame: samples(%d), format(%d), sample_rate(%d), channel layout(%d)", out_frame->nb_samples, out_frame->format, @@ -955,7 +970,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { av_init_packet(&opkt); Debug(5, "after init packet"); -#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) if ((ret = avcodec_send_frame(audio_out_ctx, out_frame)) < 0) { Error("Could not send frame (error '%s')", av_make_error_string(ret).c_str()); @@ -979,7 +994,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { // av_frame_unref( out_frame ); return 0; } -#else + #else if ((ret = avcodec_encode_audio2(audio_out_ctx, &opkt, out_frame, &data_present)) < 0) { Error("Could not encode frame (error '%s')", @@ -992,8 +1007,9 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { zm_av_packet_unref(&opkt); return 0; } -#endif - + #endif +#else + Error("Have audio codec but no resampler?!"); #endif } else { av_init_packet(&opkt); diff --git a/src/zm_videostore.h b/src/zm_videostore.h index 282d96da7..bc7cd8417 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -3,8 +3,12 @@ #include "zm_ffmpeg.h" extern "C" { -#ifdef HAVE_LIBAVRESAMPLE -#include "libavresample/avresample.h" +#ifdef HAVE_LIBSWRESAMPLE + #include "libswresample/swresample.h" +#else + #ifdef HAVE_LIBAVRESAMPLE + #include "libavresample/avresample.h" + #endif #endif } @@ -38,8 +42,12 @@ private: // The following are used when encoding the audio stream to AAC AVCodec *audio_out_codec; AVCodecContext *audio_out_ctx; +#ifdef HAVE_LIBSWRESAMPLE + SwrContext *resample_ctx; +#else #ifdef HAVE_LIBAVRESAMPLE AVAudioResampleContext* resample_ctx; +#endif #endif uint8_t *converted_in_samples; diff --git a/src/zmu.cpp b/src/zmu.cpp index dd38cb0c0..af6cb603d 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -463,10 +463,10 @@ int main(int argc, char *argv[]) { } // end if auth if ( mon_id > 0 ) { - fprintf(stderr,"Monitor %d\n", mon_id); + //fprintf(stderr,"Monitor %d\n", mon_id); Monitor *monitor = Monitor::Load(mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY); if ( monitor ) { - fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name()); + //fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name()); if ( verbose ) { printf("Monitor %d(%s)\n", monitor->Id(), monitor->Name()); } @@ -479,9 +479,9 @@ int main(int argc, char *argv[]) { bool have_output = false; if ( function & ZMU_STATE ) { Monitor::State state = monitor->GetState(); - if ( verbose ) + if ( verbose ) { printf("Current state: %s\n", state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle")); - else { + } else { if ( have_output ) printf("%c", separator); printf("%d", state); have_output = true; @@ -560,6 +560,11 @@ int main(int argc, char *argv[]) { if ( verbose ) printf( "Forcing alarm on\n" ); monitor->ForceAlarmOn( config.forced_alarm_score, "Forced Web" ); + while ( monitor->GetState() != Monitor::ALARM ) { + // Wait for monitor to notice. + usleep(1000); + } + printf( "Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId() ); } if ( function & ZMU_NOALARM ) { if ( verbose ) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 71f1ec460..a87c03379 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -76,7 +76,7 @@ fi; if [ "$DISTROS" == "" ]; then if [ "$RELEASE" != "" ]; then - DISTROS="xenial,bionic,trusty" + DISTROS="xenial,bionic,cosmic,disco,trusty" else DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; fi; diff --git a/version b/version index c78d39b8e..7aa332e41 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.32.2 +1.33.0 diff --git a/web/ajax/log.php b/web/ajax/log.php index f0703f871..fca79fda4 100644 --- a/web/ajax/log.php +++ b/web/ajax/log.php @@ -164,14 +164,23 @@ switch ( $_REQUEST['task'] ) { $where = array(); $values = array(); if ( $minTime ) { - preg_match('/(.+)(\.\d+)/', $minTime, $matches); - $minTime = strtotime($matches[1]).$matches[2]; + Logger::Debug("MinTime: $minTime"); + if ( preg_match('/(.+)(\.\d+)/', $minTime, $matches) ) { + # This handles sub second precision + $minTime = strtotime($matches[1]).$matches[2]; + Logger::Debug("MinTime: $minTime"); + } else { + $minTime = strtotime($minTime); + } $where[] = 'TimeKey >= ?'; $values[] = $minTime; } if ( $maxTime ) { - preg_match('/(.+)(\.\d+)/', $maxTime, $matches); - $maxTime = strtotime($matches[1]).$matches[2]; + if ( preg_match('/(.+)(\.\d+)/', $maxTime, $matches) ) { + $maxTime = strtotime($matches[1]).$matches[2]; + } else { + $maxTime = strtotime($maxTime); + } $where[] = 'TimeKey <= ?'; $values[] = $maxTime; } @@ -209,8 +218,15 @@ switch ( $_REQUEST['task'] ) { } $exportKey = substr(md5(rand()),0,8); $exportFile = "zm-log.$exportExt"; - $exportPath = ZM_PATH_SWAP."/zm-log-$exportKey.$exportExt"; - if ( !($exportFP = fopen( $exportPath, "w" )) ) + if ( ! file_exists(ZM_DIR_EXPORTS) ) { + Logger::Debug('Creating ' . ZM_DIR_EXPORTS); + if ( ! mkdir(ZM_DIR_EXPORTS) ) { + Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'"); + } + } + $exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt"; + Logger::Debug("Exporting to $exportPath"); + if ( !($exportFP = fopen($exportPath, 'w')) ) Fatal("Unable to open log export file $exportPath"); $logs = array(); foreach ( dbFetchAll($sql, NULL, $values) as $log ) { @@ -218,6 +234,8 @@ switch ( $_REQUEST['task'] ) { $log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : ''; $logs[] = $log; } + Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values)); + switch( $format ) { case 'text' : { @@ -390,7 +408,7 @@ switch ( $_REQUEST['task'] ) { } $exportFile = "zm-log.$exportExt"; - $exportPath = ZM_PATH_SWAP."/zm-log-$exportKey.$exportExt"; + $exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt"; header('Pragma: public'); header('Expires: 0'); diff --git a/web/ajax/zone.php b/web/ajax/zone.php index bfa77a922..12a68f681 100644 --- a/web/ajax/zone.php +++ b/web/ajax/zone.php @@ -9,37 +9,6 @@ elseif ( !isset($_REQUEST['zid']) ) ajaxError( 'No zone id(s) supplied' ); } -if ( canView( 'Monitors' ) ) -{ - switch ( $_REQUEST['action'] ) - { - case "zoneImage" : - { - $wd = getcwd(); - chdir( ZM_DIR_IMAGES ); - $hiColor = '0x00ff00'; - - $command = getZmuCommand( " -m ".$_REQUEST['mid']." -z" ); - if ( !isset($_REQUEST['zid']) ) - $_REQUEST['zid'] = 0; - $command .= "'".$_REQUEST['zid'].' '.$hiColor.' '.$_REQUEST['coords']."'"; - $status = exec( escapeshellcmd($command) ); - chdir( $wd ); - - $monitor = dbFetchOne( 'SELECT * FROM Monitors WHERE Id = ?', NULL, array($_REQUEST['mid']) ); - $points = coordsToPoints( $_REQUEST['coords'] ); - - ajaxResponse( array( - 'zoneImage' => ZM_DIR_IMAGES.'/Zones'.$monitor['Id'].'.jpg?'.time(), - 'selfIntersecting' => isSelfIntersecting( $points ), - 'area' => getPolyArea( $points ) - ) ); - - break; - } - } -} - ajaxError( 'Unrecognised action or insufficient permissions' ); ?> diff --git a/web/api/app/Config/core.php.default b/web/api/app/Config/core.php.default index 39a51690c..64f439420 100644 --- a/web/api/app/Config/core.php.default +++ b/web/api/app/Config/core.php.default @@ -50,7 +50,7 @@ */ Configure::write('Error', array( 'handler' => 'ErrorHandler::handleError', - 'level' => E_ALL & ~E_DEPRECATED, + 'level' => E_ALL & ~E_DEPRECATED & ~E_NOTICE, 'trace' => true )); diff --git a/web/api/app/Controller/Component/ImageComponent.php b/web/api/app/Controller/Component/ImageComponent.php index fc967a2de..2033e0d8c 100644 --- a/web/api/app/Controller/Component/ImageComponent.php +++ b/web/api/app/Controller/Component/ImageComponent.php @@ -7,12 +7,10 @@ class ImageComponent extends Component { $captImage = sprintf( "%0".$config['ZM_EVENT_IMAGE_DIGITS']."d-capture.jpg", $frame['Frame']['FrameId'] ); $captPath = $eventPath.'/'.$captImage; - $thumbCaptPath = $config['ZM_DIR_IMAGES'].'/'.$event['Event']['Id'].'-'.$captImage; $analImage = sprintf( "%0".$config['ZM_EVENT_IMAGE_DIGITS']."d-analyse.jpg", $frame['Frame']['FrameId'] ); $analPath = $eventPath.'/'.$analImage; $analFile = $config['ZM_DIR_EVENTS']."/".$analPath; - $thumbAnalPath = $config['ZM_DIR_IMAGES'].'/'.$event['Event']['Id'].'-'.$analImage; $alarmFrame = $frame['Frame']['Type']=='Alarm'; @@ -31,8 +29,8 @@ class ImageComponent extends Component { $fraction = sprintf( "%.3f", $scale/100 ); $scale = (int)round( $scale ); - $thumbCaptPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbCaptPath ); - $thumbAnalPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbAnalPath ); + $thumbCaptPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $captPath ); + $thumbAnalPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $analPath ); if ( $isAnalImage ) { diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 1d9456cc4..cf8ca8f37 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -318,7 +318,6 @@ class EventsController extends AppController { 'ZM_WEB_LIST_THUMB_WIDTH', 'ZM_WEB_LIST_THUMB_HEIGHT', 'ZM_EVENT_IMAGE_DIGITS', - 'ZM_DIR_IMAGES', $thumbs, 'ZM_DIR_EVENTS' ) diff --git a/web/api/app/Controller/GroupsController.php b/web/api/app/Controller/GroupsController.php index 7859f492e..6f0a88300 100644 --- a/web/api/app/Controller/GroupsController.php +++ b/web/api/app/Controller/GroupsController.php @@ -16,8 +16,10 @@ class GroupsController extends AppController { public function beforeFilter() { parent::beforeFilter(); - $canView = $this->Session->Read('groupsPermission'); - if ( $canView == 'None' ) { + global $user; + # We already tested for auth in appController, so we just need to test for specific permission + $canView = (!$user) || ($user['Groups'] != 'None'); + if ( !$canView ) { throw new UnauthorizedException(__('Insufficient Privileges')); return; } @@ -63,16 +65,23 @@ class GroupsController extends AppController { * @return void */ public function add() { - if ($this->request->is('post')) { + if ( $this->request->is('post') ) { - if ($this->Session->Read('groupPermission') != 'Edit') { - throw new UnauthorizedException(__('Insufficient privileges')); + global $user; + # We already tested for auth in appController, + # so we just need to test for specific permission + $canEdit = (!$user) || ($user['Groups'] == 'Edit'); + if ( !$canEdit ) { + throw new UnauthorizedException(__('Insufficient Privileges')); return; - } + } $this->Group->create(); - if ($this->Group->save($this->request->data)) { - return $this->flash(__('The group has been saved.'), array('action' => 'index')); + if ( $this->Group->save($this->request->data) ) { + return $this->flash( + __('The group has been saved.'), + array('action' => 'index') + ); } } $monitors = $this->Group->Monitor->find('list'); @@ -86,17 +95,24 @@ class GroupsController extends AppController { * @param string $id * @return void */ - public function edit($id = null) { - if (!$this->Group->exists($id)) { + public function edit( $id = null ) { + if ( !$this->Group->exists($id) ) { throw new NotFoundException(__('Invalid group')); } if ( $this->request->is(array('post', 'put'))) { - if ( $this->Session->Read('groupPermission') != 'Edit' ) { - throw new UnauthorizedException(__('Insufficient privileges')); + global $user; + # We already tested for auth in appController, + # so we just need to test for specific permission + $canEdit = (!$user) || ($user['Groups'] == 'Edit'); + if ( !$canEdit ) { + throw new UnauthorizedException(__('Insufficient Privileges')); return; } - if ($this->Group->save($this->request->data)) { - return $this->flash(__('The group has been saved.'), array('action' => 'index')); + if ( $this->Group->save($this->request->data) ) { + return $this->flash( + __('The group has been saved.'), + array('action' => 'index') + ); } else { $message = 'Error'; } @@ -108,7 +124,7 @@ class GroupsController extends AppController { $this->set(array( 'message' => $message, 'monitors'=> $monitors, - '_serialize' => array('message',) + '_serialize' => array('message') )); } @@ -121,19 +137,30 @@ class GroupsController extends AppController { */ public function delete($id = null) { $this->Group->id = $id; - if (!$this->Group->exists()) { + if ( !$this->Group->exists() ) { throw new NotFoundException(__('Invalid group')); } $this->request->allowMethod('post', 'delete'); - if ( $this->Session->Read('groupPermission') != 'Edit' ) { - throw new UnauthorizedException(__('Insufficient privileges')); - return; - } - if ($this->Group->delete()) { - return $this->flash(__('The group has been deleted.'), array('action' => 'index')); + global $user; + # We already tested for auth in appController, + # so we just need to test for specific permission + $canEdit = (!$user) || ($user['Groups'] == 'Edit'); + if ( !$canEdit ) { + throw new UnauthorizedException(__('Insufficient Privileges')); + return; + } + + if ( $this->Group->delete() ) { + return $this->flash( + __('The group has been deleted.'), + array('action' => 'index') + ); } else { - return $this->flash(__('The group could not be deleted. Please, try again.'), array('action' => 'index')); + return $this->flash( + __('The group could not be deleted. Please, try again.'), + array('action' => 'index') + ); } } // end function delete } // end class GroupController diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index f0df3797e..ce101c73d 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -65,18 +65,18 @@ class HostController extends AppController { $isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value']; if ( $isZmAuth ) { + // In future, we may want to completely move to AUTH_HASH_LOGINS and return &auth= for all cases require_once "../../../includes/auth.php"; # in the event we directly call getCredentials.json $this->Session->read('user'); # this is needed for command line/curl to recognize a session $zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value']; if ( $zmAuthRelay == 'hashed' ) { - $zmAuthHashIps= $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value']; - $credentials = 'auth='.generateAuthHash($zmAuthHashIps); - } else if ( $zmAuthRelay == 'plain' ) { + $zmAuthHashIps = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value']; + // make sure auth is regenerated each time we call this API + $credentials = 'auth='.generateAuthHash($zmAuthHashIps,true); + } else { // user will need to append the store password here $credentials = 'user='.$this->Session->read('user.Username').'&pass='; $appendPassword = 1; - } else if ( $zmAuthRelay == 'none' ) { - $credentials = 'user='.$this->Session->read('user.Username'); } } return array($credentials, $appendPassword); diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index 5ce4bb476..185a06c84 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -207,8 +207,10 @@ class MonitorsController extends AppController { if ( !$this->Monitor->exists() ) { throw new NotFoundException(__('Invalid monitor')); } - if ( $this->Session->Read('systemPermission') != 'Edit' ) { - throw new UnauthorizedException(__('Insufficient privileges')); + global $user; + $canEdit = (!$user) || ($user['System'] == 'Edit'); + if ( !$canEdit ) { + throw new UnauthorizedException(__('Insufficient privileges')); return; } $this->request->allowMethod('post', 'delete'); diff --git a/web/api/app/Controller/StatesController.php b/web/api/app/Controller/StatesController.php index 29201d2c1..b96efe0aa 100644 --- a/web/api/app/Controller/StatesController.php +++ b/web/api/app/Controller/StatesController.php @@ -59,8 +59,9 @@ public function add() { if ($this->request->is('post')) { - if ($this->Session->Read('systemPermission') != 'Edit') - { + global $user; + $canEdit = (!$user) || ($user['System'] == 'Edit'); + if ( !$canEdit ) { throw new UnauthorizedException(__('Insufficient privileges')); return; } diff --git a/web/api/app/Controller/StorageController.php b/web/api/app/Controller/StorageController.php index 325dea4dd..16791788c 100644 --- a/web/api/app/Controller/StorageController.php +++ b/web/api/app/Controller/StorageController.php @@ -31,7 +31,7 @@ class StorageController extends AppController { * @return void */ public function index() { - $this->Storage->recursive = 0; + $this->Storage->recursive = -1; $options = ''; $storage_areas = $this->Storage->find('all',$options); diff --git a/web/api/app/Controller/ZonesController.php b/web/api/app/Controller/ZonesController.php index 74a87f353..4d6564443 100644 --- a/web/api/app/Controller/ZonesController.php +++ b/web/api/app/Controller/ZonesController.php @@ -137,33 +137,4 @@ class ZonesController extends AppController { return $this->flash(__('The zone could not be deleted. Please, try again.'), array('action' => 'index')); } } - - public function createZoneImage($id = null) { - $this->loadModel('Monitor'); - $this->Monitor->id = $id; - if ( !$this->Monitor->exists() ) { - throw new NotFoundException(__('Invalid zone')); - } - - $this->loadModel('Config'); - $zm_dir_images = $this->Config->find('list', array( - 'conditions' => array('Name' => 'ZM_DIR_IMAGES'), - 'fields' => array('Name', 'Value') - )); - - $zm_dir_images = $zm_dir_images['ZM_DIR_IMAGES']; - $zm_path_web = Configure::read('ZM_PATH_WEB'); - $zm_path_bin = Configure::read('ZM_PATH_BIN'); - $images_path = "$zm_path_web/$zm_dir_images"; - - chdir($images_path); - - $command = escapeshellcmd("$zm_path_bin/zmu -z -m $id"); - system($command, $status); - - $this->set(array( - 'status' => $status, - '_serialize' => array('status') - )); - } } // end class diff --git a/web/api/app/Model/Event.php b/web/api/app/Model/Event.php index a59393d9a..14dbd377e 100644 --- a/web/api/app/Model/Event.php +++ b/web/api/app/Model/Event.php @@ -100,7 +100,7 @@ class Event extends AppModel { ), ); - public function Relative_Path($event) { + public function Relative_Path($event) { $event_path = ''; if ( $event['Scheme'] == 'Deep' ) { diff --git a/web/api/app/Model/Group.php b/web/api/app/Model/Group.php index e27460424..108f9b9c7 100644 --- a/web/api/app/Model/Group.php +++ b/web/api/app/Model/Group.php @@ -38,8 +38,8 @@ class Group extends AppModel { */ public $validate = array( 'Name' => array( - 'notEmpty' => array( - 'rule' => array('notEmpty'))), + 'notBlank' => array( + 'rule' => array('notBlank'))), 'Id' => array( 'numeric' => array( 'rule' => array('numeric'), diff --git a/web/api/app/Model/Monitor.php b/web/api/app/Model/Monitor.php index 5c0f62641..2e6584794 100644 --- a/web/api/app/Model/Monitor.php +++ b/web/api/app/Model/Monitor.php @@ -116,8 +116,15 @@ class Monitor extends AppModel { 'OutputCodec' => array('h264','mjpeg','mpeg1','mpeg2'), 'OutputContainer' => array('auto','mp4','mkv'), 'DefaultView' => array('Events','Control'), - 'Status' => array('Unknown','NotRunning','Running','NoSignal','Signal'), + #'Status' => array('Unknown','NotRunning','Running','NoSignal','Signal'), ) ); + public $hasOne = array( + 'Monitor_Status' => array( + 'className' => 'Monitor_Status', + 'foreignKey' => 'MonitorId', + 'joinTable' => 'Monitor_Status', + ) + ); } diff --git a/web/api/app/Model/Monitor_Status.php b/web/api/app/Model/Monitor_Status.php new file mode 100644 index 000000000..40f4aa2c2 --- /dev/null +++ b/web/api/app/Model/Monitor_Status.php @@ -0,0 +1,59 @@ + array( + 'numeric' => array( + 'rule' => array('numeric'), + //'message' => 'Your custom message here', + //'allowEmpty' => false, + //'required' => false, + //'last' => false, // Stop validation after this rule + //'on' => 'create', // Limit validation to 'create' or 'update' operations + ), + ), + ); + + public $actsAs = array( + 'CakePHP-Enum-Behavior.Enum' => array( + 'Status' => array('Unknown','NotRunning','Running','NoSignal','Signal'), + ) + ); + + //The Associations below have been created with all possible keys, those that are not needed can be removed +} diff --git a/web/api/lib/Cake/Network/CakeResponse.php b/web/api/lib/Cake/Network/CakeResponse.php index 21dfd7b2e..982398e87 100644 --- a/web/api/lib/Cake/Network/CakeResponse.php +++ b/web/api/lib/Cake/Network/CakeResponse.php @@ -1168,6 +1168,9 @@ class CakeResponse { if ($modifiedSince) { $timeMatches = strtotime($this->modified()) === strtotime($modifiedSince); } + if (!isset($etagMatches, $timeMatches)) { + return false; + } $checks = compact('etagMatches', 'timeMatches'); if (empty($checks)) { return false; diff --git a/web/includes/Event.php b/web/includes/Event.php index 1852bb8b0..a4f389aca 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -198,32 +198,34 @@ class Event { public function getStreamSrc( $args=array(), $querySep='&' ) { - $streamSrc = ZM_BASE_PROTOCOL.'://'; + $streamSrc = ''; + $Server = null; if ( $this->Storage()->ServerId() ) { + # The Event may have been moved to Storage on another server, + # So prefer viewing the Event from the Server that is actually + # storing the video $Server = $this->Storage()->Server(); - $streamSrc .= $Server->Hostname(); - if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); - } } else if ( $this->Monitor()->ServerId() ) { # Assume that the server that recorded it has it $Server = $this->Monitor()->Server(); - $streamSrc .= $Server->Hostname(); - if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); - } - } else if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); } else { - $streamSrc .= $_SERVER['HTTP_HOST']; + # A default Server will result in the use of ZM_DIR_EVENTS + $Server = new Server(); } + # If we are in a multi-port setup, then use the multiport, else by + # passing null Server->Url will use the Port set in the Server setting + $streamSrc .= $Server->Url( + ZM_MIN_STREAMING_PORT ? + ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} : + null); + if ( $this->{'DefaultVideo'} and $args['mode'] != 'jpeg' ) { - $streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php'; + $streamSrc .= $Server->PathToIndex(); $args['eid'] = $this->{'Id'}; $args['view'] = 'view_video'; } else { - $streamSrc .= ZM_PATH_ZMS; + $streamSrc .= $Server->PathToZMS(); $args['source'] = 'event'; $args['event'] = $this->{'Id'}; @@ -238,10 +240,10 @@ class Event { if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS); - } elseif ( ZM_AUTH_RELAY == 'plain' ) { + } else if ( ZM_AUTH_RELAY == 'plain' ) { $args['user'] = $_SESSION['username']; $args['pass'] = $_SESSION['password']; - } elseif ( ZM_AUTH_RELAY == 'none' ) { + } else if ( ZM_AUTH_RELAY == 'none' ) { $args['user'] = $_SESSION['username']; } } @@ -328,27 +330,21 @@ class Event { # The thumbnail is theoretically the image with the most motion. # We always store at least 1 image when capturing - $streamSrc = ZM_BASE_PROTOCOL.'://'; + $streamSrc = ''; + $Server = null; if ( $this->Storage()->ServerId() ) { $Server = $this->Storage()->Server(); - $streamSrc .= $Server->Hostname(); - if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); - } } else if ( $this->Monitor()->ServerId() ) { + # Assume that the server that recorded it has it $Server = $this->Monitor()->Server(); - $streamSrc .= $Server->Hostname(); - if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); - } - - } else if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'MonitorId'}); } else { - $streamSrc .= $_SERVER['HTTP_HOST']; - } + $Server = new Server(); + } + $streamSrc .= $Server->UrlToIndex( + ZM_MIN_STREAMING_PORT ? + ZM_MIN_STREAMING_PORT+$this->{'MonitorId'} : + null); - $streamSrc .= ( ZM_BASE_PATH != '/' ? ZM_BASE_PATH : '' ).'/index.php'; $args['eid'] = $this->{'Id'}; $args['fid'] = 'snapshot'; $args['view'] = 'image'; @@ -358,10 +354,10 @@ class Event { if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $args['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS); - } elseif ( ZM_AUTH_RELAY == 'plain' ) { + } else if ( ZM_AUTH_RELAY == 'plain' ) { $args['user'] = $_SESSION['username']; $args['pass'] = $_SESSION['password']; - } elseif ( ZM_AUTH_RELAY == 'none' ) { + } else if ( ZM_AUTH_RELAY == 'none' ) { $args['user'] = $_SESSION['username']; } } @@ -418,15 +414,13 @@ class Event { if ( ! file_exists($captPath) ) { Error( "Capture file does not exist at $captPath" ); } - $thumbCaptPath = ZM_DIR_IMAGES.'/'.$this->{'Id'}.'-'.$captImage; - //echo "CI:$captImage, CP:$captPath, TCP:$thumbCaptPath
"; + //echo "CI:$captImage, CP:$captPath, TCP:$captPath
"; $analImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyse.jpg', $frame['FrameId'] ); $analPath = $eventPath.'/'.$analImage; - $thumbAnalPath = ZM_DIR_IMAGES.'/'.$this->{'Id'}.'-'.$analImage; - //echo "AI:$analImage, AP:$analPath, TAP:$thumbAnalPath
"; + //echo "AI:$analImage, AP:$analPath, TAP:$analPath
"; $alarmFrame = $frame['Type']=='Alarm'; @@ -444,8 +438,8 @@ class Event { $fraction = sprintf( '%.3f', $scale/SCALE_BASE ); $scale = (int)round( $scale ); - $thumbCaptPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $thumbCaptPath ); - $thumbAnalPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $thumbAnalPath ); + $thumbCaptPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $captPath ); + $thumbAnalPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $analPath ); if ( $isAnalImage ) { $imagePath = $analPath; @@ -546,9 +540,11 @@ class Event { } $filters = array(); $result = dbQuery($sql, $values); - $results = $result->fetchALL(); - foreach ( $results as $row ) { - $filters[] = new Event($row); + if ( $result ) { + $results = $result->fetchALL(); + foreach ( $results as $row ) { + $filters[] = new Event($row); + } } return $filters; } @@ -574,7 +570,7 @@ class Event { $Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server(); if ( $Server->Id() != ZM_SERVER_ID ) { - $url = $Server->Url() . '/zm/api/events/'.$this->{'Id'}.'.json'; + $url = $Server->UrlToApi() . '/events/'.$this->{'Id'}.'.json'; if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); @@ -618,7 +614,7 @@ class Event { $Server = $Storage->ServerId() ? $Storage->Server() : $this->Monitor()->Server(); if ( $Server->Id() != ZM_SERVER_ID ) { - $url = $Server->Url() . '/zm/api/events/'.$this->{'Id'}.'.json'; + $url = $Server->UrlToApi() . '/events/'.$this->{'Id'}.'.json'; if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); diff --git a/web/includes/Group.php b/web/includes/Group.php index df9fd611e..82c1daba9 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -95,13 +95,12 @@ class Group { } } } # end if options - $groups = array(); - $result = dbQuery($sql, $values); - $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Group'); - foreach ( $results as $row => $obj ) { - $groups[] = $obj; + + $results = dbFetchAll($sql, NULL, $values); + if ( $results ) { + return array_map( function($row){ return new Group($row); }, $results ); } - return $groups; + return array(); } # end find() public static function find_one($parameters = null, $options = null) { @@ -121,12 +120,13 @@ class Group { } else { return null; } - } + } # end function find_one public function delete() { if ( array_key_exists('Id', $this) ) { - dbQuery( 'DELETE FROM Groups_Monitors WHERE GroupId=?', array($this->{'Id'}) ); - dbQuery( 'DELETE FROM Groups WHERE Id=?', array($this->{'Id'}) ); + dbQuery('DELETE FROM Groups_Monitors WHERE GroupId=?', array($this->{'Id'})); + dbQuery('UPDATE Groups SET ParentId=NULL WHERE ParentId=?', array($this->{'Id'})); + dbQuery('DELETE FROM Groups WHERE Id=?', array($this->{'Id'})); if ( isset($_COOKIE['zmGroup']) ) { if ( $this->{'Id'} == $_COOKIE['zmGroup'] ) { unset($_COOKIE['zmGroup']); @@ -151,16 +151,17 @@ class Group { $this->{$k} = $v; } } - } + } # end function set + public function depth( $new = null ) { if ( isset($new) ) { $this->{'depth'} = $new; } - if ( ! array_key_exists('depth', $this) or ($this->{'depth'} == null) ) { - $this->{'depth'} = 1; + if ( !array_key_exists('depth', $this) or ($this->{'depth'} === null) ) { + $this->{'depth'} = 0; if ( $this->{'ParentId'} != null ) { $Parent = Group::find_one(array('Id'=>$this->{'ParentId'})); - $this->{'depth'} += $Parent->depth(); + $this->{'depth'} += $Parent->depth()+1; } } return $this->{'depth'}; @@ -211,7 +212,7 @@ class Group { $children[$Group->ParentId()] = array(); $children[$Group->ParentId()][] = $Group; } - } + } # end foreach function get_options($Group) { global $children; @@ -222,7 +223,8 @@ class Group { } } return $options; - } + } # end function get_options + $group_options = array(); foreach ( $Groups as $id=>$Group ) { if ( ! $Group->ParentId() ) { @@ -230,7 +232,7 @@ class Group { } } return $group_options; - } + } # end function get_dropdown_options public static function get_group_sql($group_id) { $groupSql = ''; diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 2d84f5dae..cc1d8eed7 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -9,20 +9,95 @@ class Monitor { private $defaults = array( 'Id' => null, 'Name' => '', - 'StorageId' => 0, 'ServerId' => 0, + 'StorageId' => 0, 'Type' => 'Ffmpeg', 'Function' => 'None', 'Enabled' => 1, 'LinkedMonitors' => null, + 'Triggers' => null, + 'Device' => '', + 'Channel' => 0, + 'Format' => '0', + 'V4LMultiBuffer' => null, + 'V4LCapturesPerFrame' => null, + 'Protocol' => null, + 'Method' => '', + 'Host' => null, + 'Port' => '', + 'SubPath' => '', + 'Path' => null, + 'Options' => null, + 'User' => null, + 'Pass' => null, + // These are NOT NULL default 0 in the db, but 0 is not a valid value. FIXME 'Width' => null, 'Height' => null, + 'Colours' => 1, + 'Palette' => '0', 'Orientation' => null, + 'Deinterlacing' => 0, + 'SaveJPEGs' => 3, + 'VideoWriter' => '0', + 'OutputCodec' => null, + 'OutputContainer' => null, + 'EncoderParameters' => null, + 'RecordAudio' => 0, + 'RTSPDescribe' => null, + 'Brightness' => -1, + 'Contrast' => -1, + 'Hue' => -1, + 'Colour' => -1, + 'EventPrefix' => 'Event-', + 'LabelFormat' => null, + 'LabelX' => 0, + 'LabelY' => 0, + 'LabelSize' => 1, + 'ImageBufferCount' => 100, + 'WarmupCount' => 0, + 'PreEventCount' => 0, + 'PostEventCount' => 0, + 'StreamReplayBuffer' => 0, + 'AlarmFrameCount' => 1, + 'SectionLength' => 600, + 'FrameSkip' => 0, 'AnalysisFPSLimit' => null, - 'ZoneCount' => 0, - 'Triggers' => null, + 'AnalysisUpdateDelete' => 0, 'MaxFPS' => null, 'AlarmMaxFPS' => null, + 'FPSReportIneterval' => 100, + 'RefBlencPerc' => 6, + 'AlarmRefBlendPerc' => 6, + 'Controllable' => 0, + 'ControlId' => null, + 'ControlDevice' => null, + 'ControlAddress' => null, + 'AutoStopTimeout' => null, + 'TrackMotion' => 0, + 'TrackDelay' => null, + 'ReturnLocation' => -1, + 'ReturnDelay' => null, + 'DefaultView' => 'Events', + 'DefaultRate' => 100, + 'DefaultScale' => 100, + 'SignalCheckPoints' => 0, + 'SignalCheckColour' => '#0000BE', + 'WebColour' => 'red', + 'Exif' => 0, + 'Sequence' => null, + 'TotalEvents' => null, + 'TotalEventDiskSpace' => null, + 'HourEvents' => null, + 'HourEventDiskSpace' => null, + 'DayEvents' => null, + 'DayEventDiskSpace' => null, + 'WeekEvents' => null, + 'WeekEventDiskSpace' => null, + 'MonthEvents' => null, + 'MonthEventDiskSpace' => null, + 'ArchivedEvents' => null, + 'ArchivedEventDiskSpace' => null, + 'ZoneCount' => 0, 'Refresh' => null, ); private $status_fields = array( @@ -205,21 +280,12 @@ private $control_fields = array( } } - public function getStreamSrc( $args, $querySep='&' ) { + public function getStreamSrc($args, $querySep='&') { - $streamSrc = ZM_BASE_PROTOCOL.'://'; - if ( isset($this->{'ServerId'}) and $this->{'ServerId'} ) { - $Server = new Server( $this->{'ServerId'} ); - $streamSrc .= $Server->Hostname(); - if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= ':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'}); - } - } else if ( ZM_MIN_STREAMING_PORT ) { - $streamSrc .= $_SERVER['SERVER_NAME'].':'.(ZM_MIN_STREAMING_PORT+$this->{'Id'}); - } else { - $streamSrc .= $_SERVER['HTTP_HOST']; - } - $streamSrc .= ZM_PATH_ZMS; + $streamSrc = $this->Server()->UrlToZMS( + ZM_MIN_STREAMING_PORT ? + ZM_MIN_STREAMING_PORT+$this->{'Id'} : + null); $args['monitor'] = $this->{'Id'}; @@ -240,9 +306,9 @@ private $control_fields = array( $args['rand'] = time(); } - $streamSrc .= '?'.http_build_query( $args,'', $querySep ); + $streamSrc .= '?'.http_build_query($args,'', $querySep); - return( $streamSrc ); + return $streamSrc; } // end function getStreamSrc public function Width($new = null) { @@ -385,7 +451,7 @@ private $control_fields = array( } else if ( $this->ServerId() ) { $Server = $this->Server(); - $url = ZM_BASE_PROTOCOL . '://'.$Server->Hostname().'/zm/api/monitors/'.$this->{'Id'}.'.json'; + $url = $Server->UrlToApi().'/monitors/'.$this->{'Id'}.'.json'; if ( ZM_OPT_USE_AUTH ) { if ( ZM_AUTH_RELAY == 'hashed' ) { $url .= '?auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); @@ -525,13 +591,15 @@ private $control_fields = array( $source = preg_replace( '/^.*\//', '', $this->{'Path'} ); } elseif ( $this->{'Type'} == 'Ffmpeg' || $this->{'Type'} == 'Libvlc' || $this->{'Type'} == 'WebSite' ) { $url_parts = parse_url( $this->{'Path'} ); - if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) { # Filter out everything but the hostname + if ( ZM_WEB_FILTER_SOURCE == 'Hostname' ) { + # Filter out everything but the hostname if ( isset($url_parts['host']) ) { $source = $url_parts['host']; } else { $source = $this->{'Path'}; } - } elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) { # Filter out sensitive and common items + } elseif ( ZM_WEB_FILTER_SOURCE == "NoCredentials" ) { + # Filter out sensitive and common items unset($url_parts['user']); unset($url_parts['pass']); #unset($url_parts['scheme']); @@ -550,8 +618,8 @@ private $control_fields = array( return $source; } // end function Source - public function Url() { - return $this->Server()->Url( ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : null ); + public function UrlToIndex() { + return $this->Server()->UrlToIndex(ZM_MIN_STREAMING_PORT ? (ZM_MIN_STREAMING_PORT+$this->Id()) : null); } } // end class Monitor diff --git a/web/includes/Server.php b/web/includes/Server.php index 09d415e63..7424aafdf 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -5,23 +5,27 @@ $server_cache = array(); class Server { private $defaults = array( - 'Id' => null, - 'Name' => '', - 'Hostname' => '', - 'zmaudit' => 1, - 'zmstats' => 1, - 'zmtrigger' => 0, + 'Id' => null, + 'Name' => '', + 'Protocol' => '', + 'Hostname' => '', + 'Port' => null, + 'PathToIndex' => '/zm/index.php', + 'PathToZMS' => ZM_PATH_ZMS, + 'PathToApi' => '/zm/api', + 'zmaudit' => 1, + 'zmstats' => 1, + 'zmtrigger' => 0, ); - - public function __construct( $IdOrRow = NULL ) { - global $server_cache; + public function __construct($IdOrRow = NULL) { + global $server_cache; $row = NULL; if ( $IdOrRow ) { if ( is_integer($IdOrRow) or ctype_digit($IdOrRow) ) { $row = dbFetchOne('SELECT * FROM Servers WHERE Id=?', NULL, array($IdOrRow)); if ( !$row ) { - Error("Unable to load Server record for Id=" . $IdOrRow); + Error('Unable to load Server record for Id='.$IdOrRow); } } elseif ( is_array($IdOrRow) ) { $row = $IdOrRow; @@ -33,32 +37,105 @@ class Server { } $server_cache[$row['Id']] = $this; } else { - $this->{'Name'} = ''; - $this->{'Hostname'} = ''; + # Set defaults + foreach ( $this->defaults as $k => $v ) $this->{$k} = $v; } } + public function Hostname( $new = null ) { + if ( $new != null ) + $this->{'Hostname'} = $new; + + if ( isset( $this->{'Hostname'}) and ( $this->{'Hostname'} != '' ) ) { + return $this->{'Hostname'}; + } else if ( $this->Id() ) { + return $this->{'Name'}; + } + $result = explode(':',$_SERVER['HTTP_HOST']); + return $result[0]; + } + + public function Protocol( $new = null ) { + if ( $new != null ) + $this->{'Protocol'} = $new; + + if ( isset($this->{'Protocol'}) and ( $this->{'Protocol'} != '' ) ) { + return $this->{'Protocol'}; + } + + return ( + ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) + or + ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) + ) ? 'https' : 'http'; + } + + public function Port( $new = '' ) { + if ( $new != '' ) + $this->{'Port'} = $new; + + if ( isset($this->{'Port'}) and $this->{'Port'} ) { + return $this->{'Port'}; + } + + if ( isset($_SERVER['HTTP_X_FORWARDED_PORT']) ) { + return $_SERVER['HTTP_X_FORWARDED_PORT']; + } + + return $_SERVER['SERVER_PORT']; + } + + public function PathToZMS( $new = null ) { + if ( $new != null ) + $this{'PathToZMS'} = $new; + if ( $this->Id() and $this->{'PathToZMS'} ) { + return $this->{'PathToZMS'}; + } else { + return ZM_PATH_ZMS; + } + } + + public function UrlToZMS( $port = null ) { + return $this->Url($port).$this->PathToZMS(); + } + public function Url( $port = null ) { - $url = ZM_BASE_PROTOCOL . '://'; - if ( $this->Id() ) { - $url .= $this->Hostname(); - } else { - $url .= $_SERVER['SERVER_NAME']; - } + $url = $this->Protocol().'://'; + $url .= $this->Hostname(); if ( $port ) { $url .= ':'.$port; } else { - $url .= ':'.$_SERVER['SERVER_PORT']; + $url .= ':'.$this->Port(); } - $url .= $_SERVER['PHP_SELF']; return $url; } - public function Hostname() { - if ( isset( $this->{'Hostname'} ) and ( $this->{'Hostname'} != '' ) ) { - return $this->{'Hostname'}; - } - return $this->{'Name'}; - } + + public function PathToIndex( $new = null ) { + if ( $new != null ) + $this->{'PathToIndex'} = $new; + + if ( isset($this->{'PathToIndex'}) and $this->{'PathToIndex'} ) { + return $this->{'PathToIndex'}; + } + return $_SERVER['PHP_SELF']; + } + + public function UrlToIndex( $port=null ) { + return $this->Url($port).$this->PathToIndex(); + } + public function UrlToApi( $port=null ) { + return $this->Url($port).$this->PathToApi(); + } + public function PathToApi( $new = null ) { + if ( $new != null ) + $this->{'PathToApi'} = $new; + + if ( isset($this->{'PathToApi'}) and $this->{'PathToApi'} ) { + return $this->{'PathToApi'}; + } + return '/zm/api'; + } + public function __call($fn, array $args){ if ( count($args) ) { $this->{$fn} = $args[0]; @@ -66,13 +143,13 @@ class Server { if ( array_key_exists($fn, $this) ) { return $this->{$fn}; } else { - if ( array_key_exists( $fn, $this->defaults ) ) { + if ( array_key_exists($fn, $this->defaults) ) { return $this->defaults{$fn}; } else { $backTrace = debug_backtrace(); $file = $backTrace[1]['file']; $line = $backTrace[1]['line']; - Warning( "Unknown function call Server->$fn from $file:$line" ); + Warning("Unknown function call Server->$fn from $file:$line"); } } } @@ -117,7 +194,7 @@ class Server { } $results = dbFetchAll( $sql, NULL, $values ); if ( $results ) { - return array_map( function($id){ return new Server($id); }, $results ); + return array_map(function($id){ return new Server($id); }, $results); } return array(); } @@ -137,5 +214,5 @@ class Server { return $results[0]; } -} +} # end class Server ?> diff --git a/web/includes/Storage.php b/web/includes/Storage.php index 0744889f9..95f1dab84 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -189,7 +189,7 @@ class Storage { # This isn't a function like this in php, so we have to add up the space used in each event. if ( ( !array_key_exists('disk_used_space', $this)) or !$this->{'disk_used_space'} ) { if ( $this->{'Type'} == 's3fs' ) { - $this->{'disk_used_space'} = $this->disk_event_space(); + $this->{'disk_used_space'} = $this->event_disk_space(); } else { $path = $this->Path(); if ( file_exists($path) ) { diff --git a/web/includes/actions.php b/web/includes/actions.php index de0861fe0..746454bec 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -18,51 +18,6 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -// PP - POST request handler for PHP which does not need extensions -// credit: http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/ - - -function do_request($method, $url, $data=array(), $optional_headers = null) { - global $php_errormsg; - - $params = array('http' => array( - 'method' => $method, - 'content' => $data - )); - if ( $optional_headers !== null ) { - $params['http']['header'] = $optional_headers; - } - $ctx = stream_context_create($params); - $fp = @fopen($url, 'rb', false, $ctx); - if ( !$fp ) { - throw new Exception("Problem with $url, $php_errormsg"); - } - $response = @stream_get_contents($fp); - if ( $response === false ) { - throw new Exception("Problem reading data from $url, $php_errormsg"); - } - return $response; -} - -function do_post_request($url, $data, $optional_headers = null) { - $params = array('http' => array( - 'method' => 'POST', - 'content' => $data - )); - if ( $optional_headers !== null ) { - $params['http']['header'] = $optional_headers; - } - $ctx = stream_context_create($params); - $fp = @fopen($url, 'rb', false, $ctx); - if ( !$fp ) { - throw new Exception("Problem with $url, $php_errormsg"); - } - $response = @stream_get_contents($fp); - if ( $response === false ) { - throw new Exception("Problem reading data from $url, $php_errormsg"); - } - return $response; -} function getAffectedIds( $name ) { $names = $name.'s'; @@ -88,52 +43,17 @@ if ( empty($action) ) { return; } if ( $action == 'login' && isset($_REQUEST['username']) && ( ZM_AUTH_TYPE == 'remote' || isset($_REQUEST['password']) ) ) { - // if true, a popup will display after login - // PP - lets validate reCaptcha if it exists - if ( defined('ZM_OPT_USE_GOOG_RECAPTCHA') - && defined('ZM_OPT_GOOG_RECAPTCHA_SECRETKEY') - && defined('ZM_OPT_GOOG_RECAPTCHA_SITEKEY') - && ZM_OPT_USE_GOOG_RECAPTCHA && ZM_OPT_GOOG_RECAPTCHA_SECRETKEY - && ZM_OPT_GOOG_RECAPTCHA_SITEKEY ) - { - $url = 'https://www.google.com/recaptcha/api/siteverify'; - $fields = array ( - 'secret' => ZM_OPT_GOOG_RECAPTCHA_SECRETKEY, - 'response' => $_REQUEST['g-recaptcha-response'], - 'remoteip' => $_SERVER['REMOTE_ADDR'] - ); - $res = do_post_request($url, http_build_query($fields)); - $responseData = json_decode($res,true); - // PP - credit: https://github.com/google/recaptcha/blob/master/src/ReCaptcha/Response.php - // if recaptcha resulted in error, we might have to deny login - if ( isset($responseData['success']) && $responseData['success'] == false ) { - // PP - before we deny auth, let's make sure the error was not 'invalid secret' - // because that means the user did not configure the secret key correctly - // in this case, we prefer to let him login in and display a message to correct - // the key. Unfortunately, there is no way to check for invalid site key in code - // as it produces the same error as when you don't answer a recaptcha - if ( isset($responseData['error-codes']) && is_array($responseData['error-codes']) ) { - if ( !in_array('invalid-input-secret',$responseData['error-codes']) ) { - Error('reCaptcha authentication failed'); - userLogout(); - $view = 'login'; - $refreshParent = true; - return; - } else { - //Let them login but show an error - echo ''; - Error('Invalid recaptcha secret detected'); - } - } - } // end if success==false - } // end if using reCaptcha - $username = validStr($_REQUEST['username']); - $password = isset($_REQUEST['password'])?validStr($_REQUEST['password']):''; - userLogin($username, $password); $refreshParent = true; - $view = 'console'; - $redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console'; + // User login is automatically performed in includes/auth.php So we don't need to perform a login here, + // just handle redirects. This is the action that comes from the login view, so the logical thing to + // do on successful auth is redirect to console, otherwise loop back to login. + if ( !$user ) { + $view = 'login'; + } else { + $view = 'console'; + $redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=console'; + } } else if ( $action == 'logout' ) { userLogout(); $refreshParent = true; @@ -368,7 +288,13 @@ if ( !empty($_REQUEST['mid']) && canEdit('Monitors', $_REQUEST['mid']) ) { } unset( $_REQUEST['newZone']['Points'] ); - $types = array(); + + # convert these fields to integer e.g. NULL -> 0 + $types = array( + 'OverloadFrames' => 'integer', + 'ExtendAlarmFrames' => 'integer', + ); + $changes = getFormChanges($zone, $_REQUEST['newZone'], $types); if ( count($changes) ) { @@ -554,7 +480,8 @@ if ( canEdit('Monitors') ) { $maxSeq = dbFetchOne('SELECT MAX(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence'); $changes[] = 'Sequence = '.($maxSeq+1); - if ( dbQuery('INSERT INTO Monitors SET '.implode(', ', $changes)) ) { + $sql = 'INSERT INTO Monitors SET '.implode(', ', $changes); + if ( dbQuery($sql) ) { $mid = dbInsertId(); $zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height']; dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) ); @@ -566,6 +493,7 @@ if ( canEdit('Monitors') ) { } else { Error('Error saving new Monitor.'); + $error_message = dbError($sql); return; } } else { @@ -617,7 +545,7 @@ if ( canEdit('Monitors') ) { $new_monitor = new Monitor($mid); //fixDevices(); - if ( $monitor['Type'] != 'WebSite' ) { + if ( $new_monitor->Type() != 'WebSite' ) { $new_monitor->zmcControl('start'); $new_monitor->zmaControl('start'); } @@ -720,16 +648,11 @@ if ( canEdit('Groups') ) { $refreshParent = true; } else if ( $action == 'delete' ) { if ( !empty($_REQUEST['gid']) ) { - if ( is_array($_REQUEST['gid']) ) { - foreach ( $_REQUEST['gid'] as $gid ) { - $Group = new Group($gid); - $Group->delete(); - } - } else { - $Group = new Group($_REQUEST['gid'] ); + foreach ( Group::find(array('Id'=>$_REQUEST['gid'])) as $Group ) { $Group->delete(); } } + $redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=groups'; $refreshParent = true; } # end if action } // end if can edit groups @@ -753,7 +676,7 @@ if ( canEdit('System') ) { $_SESSION['zmMontageLayout'] = $Layout->Id(); setcookie('zmMontageLayout', $Layout->Id(), 1); session_write_close(); - $redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=montagereview'; + $redirect = ZM_BASE_URL.$_SERVER['PHP_SELF'].'?view=montage'; } // end if save } else if ( $_REQUEST['object'] == 'server' ) { diff --git a/web/includes/auth.php b/web/includes/auth.php index 9cf8d37c1..c74c13b80 100644 --- a/web/includes/auth.php +++ b/web/includes/auth.php @@ -2,25 +2,66 @@ // // ZoneMinder auth library, $Date$, $Revision$ // Copyright (C) 2001-2008 Philip Coombes -// +// // 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. -// +// -function userLogin($username, $password='', $passwordHashed=false) { +function userLogin($username='', $password='', $passwordHashed=false) { global $user; + if ( !$username and isset($_REQUEST['username']) ) + $username = $_REQUEST['username']; + if ( !$password and isset($_REQUEST['password']) ) + $password = $_REQUEST['password']; + + // if true, a popup will display after login + // PP - lets validate reCaptcha if it exists + if ( defined('ZM_OPT_USE_GOOG_RECAPTCHA') + && defined('ZM_OPT_GOOG_RECAPTCHA_SECRETKEY') + && defined('ZM_OPT_GOOG_RECAPTCHA_SITEKEY') + && ZM_OPT_USE_GOOG_RECAPTCHA + && ZM_OPT_GOOG_RECAPTCHA_SECRETKEY + && ZM_OPT_GOOG_RECAPTCHA_SITEKEY ) + { + $url = 'https://www.google.com/recaptcha/api/siteverify'; + $fields = array ( + 'secret' => ZM_OPT_GOOG_RECAPTCHA_SECRETKEY, + 'response' => $_REQUEST['g-recaptcha-response'], + 'remoteip' => $_SERVER['REMOTE_ADDR'] + ); + $res = do_post_request($url, http_build_query($fields)); + $responseData = json_decode($res,true); + // PP - credit: https://github.com/google/recaptcha/blob/master/src/ReCaptcha/Response.php + // if recaptcha resulted in error, we might have to deny login + if ( isset($responseData['success']) && $responseData['success'] == false ) { + // PP - before we deny auth, let's make sure the error was not 'invalid secret' + // because that means the user did not configure the secret key correctly + // in this case, we prefer to let him login in and display a message to correct + // the key. Unfortunately, there is no way to check for invalid site key in code + // as it produces the same error as when you don't answer a recaptcha + if ( isset($responseData['error-codes']) && is_array($responseData['error-codes']) ) { + if ( !in_array('invalid-input-secret',$responseData['error-codes']) ) { + Error('reCaptcha authentication failed'); + return null; + } else { + Error('Invalid recaptcha secret detected'); + } + } + } // end if success==false + } // end if using reCaptcha + $sql = 'SELECT * FROM Users WHERE Enabled=1'; $sql_values = NULL; if ( ZM_AUTH_TYPE == 'builtin' ) { @@ -36,7 +77,6 @@ function userLogin($username, $password='', $passwordHashed=false) { } $close_session = 0; if ( !is_session_started() ) { - Logger::Debug("Starting session in userLogin"); session_start(); $close_session = 1; } @@ -70,7 +110,6 @@ function userLogout() { session_start(); unset($_SESSION['user']); unset($user); - session_destroy(); } @@ -116,7 +155,7 @@ function generateAuthHash($useRemoteAddr, $force=false) { $time = time(); $mintime = $time - ( ZM_AUTH_HASH_TTL * 1800 ); - if ( $force or ( !isset($_SESSION['AuthHash']) ) or ( $_SESSION['AuthHashGeneratedAt'] < $mintime ) ) { + if ( $force or ( !isset($_SESSION['AuthHash'.$_SESSION['remoteAddr']]) ) or ( $_SESSION['AuthHashGeneratedAt'] < $mintime ) ) { # Don't both regenerating Auth Hash if an hour hasn't gone by yet $local_time = localtime(); $authKey = ''; @@ -133,7 +172,7 @@ function generateAuthHash($useRemoteAddr, $force=false) { session_start(); $close_session = 1; } - $_SESSION['AuthHash'] = $auth; + $_SESSION['AuthHash'.$_SESSION['remoteAddr']] = $auth; $_SESSION['AuthHashGeneratedAt'] = $time; session_write_close(); } else { @@ -143,7 +182,7 @@ function generateAuthHash($useRemoteAddr, $force=false) { #} else { #Logger::Debug("Using cached auth " . $_SESSION['AuthHash'] ." beacuse generatedat:" . $_SESSION['AuthHashGeneratedAt'] . ' < now:'. $time . ' - ' . ZM_AUTH_HASH_TTL . ' * 1800 = '. $mintime); } # end if AuthHash is not cached - return $_SESSION['AuthHash']; + return $_SESSION['AuthHash'.$_SESSION['remoteAddr']]; } # end if using AUTH and AUTH_RELAY return ''; } @@ -179,4 +218,18 @@ function is_session_started() { return FALSE; } +if ( ZM_OPT_USE_AUTH ) { + if ( ZM_AUTH_HASH_LOGINS && empty($user) && ! empty($_REQUEST['auth']) ) { + if ( $authUser = getAuthUser($_REQUEST['auth']) ) { + userLogin($authUser['Username'], $authUser['Password'], true); + } + } + else if ( isset($_REQUEST['username']) and isset($_REQUEST['password']) ) { + userLogin($_REQUEST['username'], $_REQUEST['password'], false); + } + if ( !empty($user) ) { + // generate it once here, while session is open. Value will be cached in session and return when called later on + generateAuthHash(ZM_AUTH_HASH_IPS); + } +} ?> diff --git a/web/includes/database.php b/web/includes/database.php index 55535659f..95fabee11 100644 --- a/web/includes/database.php +++ b/web/includes/database.php @@ -98,7 +98,14 @@ function dbLog( $sql, $update=false ) { } function dbError( $sql ) { - Error( "SQL-ERR '".$dbConn->errorInfo()."', statement was '".$sql."'" ); + global $dbConn; + $error = $dbConn->errorInfo(); + if ( ! $error[0] ) + return ''; + + $message = "SQL-ERR '".implode("\n",$dbConn->errorInfo())."', statement was '".$sql."'"; + Error($message); + return $message; } function dbEscape( $string ) { @@ -136,6 +143,10 @@ function dbQuery( $sql, $params=NULL ) { Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') ); } $result = $dbConn->query($sql); + if ( ! $result ) { + Error("SQL: Error preparing $sql: " . $pdo->errorInfo); + return NULL; + } } if ( defined('ZM_DB_DEBUG') ) { if ( $params ) diff --git a/web/includes/functions.php b/web/includes/functions.php index 0f49f611c..6f2877530 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -41,15 +41,19 @@ function CORSHeaders() { # The following is left for future reference/use. $valid = false; $Servers = Server::find(); - if ( sizeof($Servers) <= 1 ) { + if ( sizeof($Servers) < 1 ) { # Only need CORSHeaders in the event that there are multiple servers in use. # ICON: Might not be true. multi-port? return; } foreach( $Servers as $Server ) { - if ( preg_match('/^(https?:\/\/)?'.preg_quote($Server->Hostname(),'/').'/', $_SERVER['HTTP_ORIGIN']) ) { + if ( + preg_match('/^(https?:\/\/)?'.preg_quote($Server->Hostname(),'/').'/i', $_SERVER['HTTP_ORIGIN']) + or + preg_match('/^(https?:\/\/)?'.preg_quote($Server->Name(),'/').'/i', $_SERVER['HTTP_ORIGIN']) + ) { $valid = true; - Logger::Debug("Setting Access-Controll-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']); + Logger::Debug("Setting Access-Control-Allow-Origin from " . $_SERVER['HTTP_ORIGIN']); header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); header('Access-Control-Allow-Headers: x-requested-with,x-request'); break; @@ -604,6 +608,11 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { } } break; + case 'integer' : + if ( (!isset($values[$key])) or $values[$key] != $value ) { + $changes[$key] = $key . ' = '.intval($value); + } + break; default : { if ( !isset($values[$key]) || ($values[$key] != $value) ) { @@ -841,13 +850,7 @@ function getImageSrc( $event, $frame, $scale=SCALE_BASE, $captureOnly=false, $ov } function viewImagePath( $path, $querySep='&' ) { - if ( strncmp( $path, ZM_DIR_IMAGES, strlen(ZM_DIR_IMAGES) ) == 0 ) { - // Thumbnails - return( $path ); - } elseif ( strpos( ZM_DIR_EVENTS, '/' ) === 0 ) { - return( '?view=image'.$querySep.'path='.$path ); - } - return( ZM_DIR_EVENTS.'/'.$path ); + return( '?view=image'.$querySep.'path='.$path ); } function createListThumbnail( $event, $overwrite=false ) { @@ -1909,23 +1912,24 @@ function logState() { # This is an expensive request, as it has to hit every row of the Logs Table $sql = 'SELECT Level, COUNT(Level) AS LevelCount FROM Logs WHERE Level < '.Logger::INFO.' AND TimeKey > unix_timestamp(now() - interval '.ZM_LOG_CHECK_PERIOD.' second) GROUP BY Level ORDER BY Level ASC'; - $counts = dbFetchAll( $sql ); - - foreach ( $counts as $count ) { - if ( $count['Level'] <= Logger::PANIC ) - $count['Level'] = Logger::FATAL; - if ( !($levelCount = $levelCounts[$count['Level']]) ) { - Error( "Unexpected Log level ".$count['Level'] ); - next; - } - if ( $levelCount[1] && $count['LevelCount'] >= $levelCount[1] ) { - $state = 'alarm'; - break; - } elseif ( $levelCount[0] && $count['LevelCount'] >= $levelCount[0] ) { - $state = 'alert'; + $counts = dbFetchAll($sql); + if ( $counts ) { + foreach ( $counts as $count ) { + if ( $count['Level'] <= Logger::PANIC ) + $count['Level'] = Logger::FATAL; + if ( !($levelCount = $levelCounts[$count['Level']]) ) { + Error('Unexpected Log level '.$count['Level']); + next; + } + if ( $levelCount[1] && $count['LevelCount'] >= $levelCount[1] ) { + $state = 'alarm'; + break; + } elseif ( $levelCount[0] && $count['LevelCount'] >= $levelCount[0] ) { + $state = 'alert'; + } } } - return( $state ); + return $state; } function isVector ( &$array ) { @@ -2273,4 +2277,76 @@ function unparse_url($parsed_url, $substitutions = array() ) { $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; return "$scheme$user$pass$host$port$path$query$fragment"; } + +// PP - POST request handler for PHP which does not need extensions +// credit: http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/ + + +function do_request($method, $url, $data=array(), $optional_headers = null) { + global $php_errormsg; + + $params = array('http' => array( + 'method' => $method, + 'content' => $data + )); + if ( $optional_headers !== null ) { + $params['http']['header'] = $optional_headers; + } + $ctx = stream_context_create($params); + $fp = @fopen($url, 'rb', false, $ctx); + if ( !$fp ) { + throw new Exception("Problem with $url, $php_errormsg"); + } + $response = @stream_get_contents($fp); + if ( $response === false ) { + throw new Exception("Problem reading data from $url, $php_errormsg"); + } + return $response; +} + +function do_post_request($url, $data, $optional_headers = null) { + $params = array('http' => array( + 'method' => 'POST', + 'content' => $data + )); + if ( $optional_headers !== null ) { + $params['http']['header'] = $optional_headers; + } + $ctx = stream_context_create($params); + $fp = @fopen($url, 'rb', false, $ctx); + if ( !$fp ) { + throw new Exception("Problem with $url, $php_errormsg"); + } + $response = @stream_get_contents($fp); + if ( $response === false ) { + throw new Exception("Problem reading data from $url, $php_errormsg"); + } + return $response; +} + +// The following works around php not being built with semaphore functions. +if (!function_exists('sem_get')) { + function sem_get($key) { + return fopen(__FILE__ . '.sem.' . $key, 'w+'); + } + function sem_acquire($sem_id) { + return flock($sem_id, LOCK_EX); + } + function sem_release($sem_id) { + return flock($sem_id, LOCK_UN); + } +} + +if( !function_exists('ftok') ) { + function ftok($filename = "", $proj = "") { + if ( empty($filename) || !file_exists($filename) ) { + return -1; + } else { + $filename = $filename . (string) $proj; + for($key = array(); sizeof($key) < strlen($filename); $key[] = ord(substr($filename, sizeof($key), 1))); + return dechex(array_sum($key)); + } + } +} + ?> diff --git a/web/includes/lang.php b/web/includes/lang.php index 0c40e7f60..38f1179d8 100644 --- a/web/includes/lang.php +++ b/web/includes/lang.php @@ -1,6 +1,6 @@ $value) { - if ( ! array_key_exists( $key, $SLANG ) ) - $SLANG[$key] = $DLANG[$key]; - } + require_once($langFile); + require_once('lang/default.php'); + foreach ($DLANG as $key => $value) { + if ( ! array_key_exists($key, $SLANG) ) + $SLANG[$key] = $DLANG[$key]; + } } - // // Date and time formats fallback, if not set up by the language file already // -defined("DATE_FMT_CONSOLE_LONG") or define("DATE_FMT_CONSOLE_LONG", "D jS M, g:ia"); // This is the main console date/time, date() or strftime() format -defined("DATE_FMT_CONSOLE_SHORT") or define( "DATE_FMT_CONSOLE_SHORT", "%H:%M" ); // This is the xHTML console date/time, date() or strftime() format +defined('DATE_FMT_CONSOLE_LONG') or define('DATE_FMT_CONSOLE_LONG', 'D jS M, g:ia'); // This is the main console date/time, date() or strftime() format +defined('DATE_FMT_CONSOLE_SHORT') or define('DATE_FMT_CONSOLE_SHORT', '%H:%M'); // This is the xHTML console date/time, date() or strftime() format -defined("STRF_FMT_DATETIME") or define( "STRF_FMT_DATETIME", "%c" ); // Strftime locale aware format for dates with times -defined("STRF_FMT_DATE") or define( "STRF_FMT_DATE", "%x" ); // Strftime locale aware format for dates without times -defined("STRF_FMT_TIME") or define( "STRF_FMT_TIME", "%X" ); // Strftime locale aware format for times without dates +defined('STRF_FMT_DATETIME') or define('STRF_FMT_DATETIME', '%c'); // Strftime locale aware format for dates with times +defined('STRF_FMT_DATE') or define('STRF_FMT_DATE', '%x'); // Strftime locale aware format for dates without times +defined('STRF_FMT_TIME') or define('STRF_FMT_TIME', '%X'); // Strftime locale aware format for times without dates -defined("STRF_FMT_DATETIME_SHORT") or define( "STRF_FMT_DATETIME_SHORT", "%y/%m/%d %H:%M:%S" ); // Strftime shorter format for dates with time, not locale aware -defined("STRF_FMT_DATETIME_SHORTER") or define( "STRF_FMT_DATETIME_SHORTER", "%m/%d %H:%M:%S" );// Strftime shorter format for dates with time, not locale aware, used where space is tight +defined('STRF_FMT_DATETIME_SHORT') or define('STRF_FMT_DATETIME_SHORT', '%y/%m/%d %H:%M:%S'); // Strftime shorter format for dates with time, not locale aware +defined('STRF_FMT_DATETIME_SHORTER') or define('STRF_FMT_DATETIME_SHORTER','%m/%d %H:%M:%S');// Strftime shorter format for dates with time, not locale aware, used where space is tight ?> diff --git a/web/index.php b/web/index.php index addddce06..2331809bc 100644 --- a/web/index.php +++ b/web/index.php @@ -156,7 +156,6 @@ session_write_close(); require_once('includes/lang.php'); require_once('includes/functions.php'); -require_once('includes/auth.php'); # Running is global but only do the daemonCheck if it is actually needed $running = null; @@ -165,11 +164,12 @@ $running = null; CORSHeaders(); // Check for valid content dirs -if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) ) { - Warning("Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."'). Check that these exist and are owned by the web account user"); +if ( !is_writable(ZM_DIR_EVENTS) ) { + Warning("Cannot write to event folder ".ZM_DIR_EVENTS.". Check that it exists and is owned by the web account user."); } # Globals +$error_message = null; $redirect = null; $view = null; if ( isset($_REQUEST['view']) ) @@ -182,20 +182,8 @@ if ( isset($_REQUEST['request']) ) foreach ( getSkinIncludes('skin.php') as $includeFile ) require_once $includeFile; -if ( ZM_OPT_USE_AUTH ) { - if ( ZM_AUTH_HASH_LOGINS && empty($user) && ! empty($_REQUEST['auth']) ) { - if ( $authUser = getAuthUser($_REQUEST['auth']) ) { - userLogin($authUser['Username'], $authUser['Password'], true); - } - } - else if ( isset($_REQUEST['username']) and isset($_REQUEST['password']) ) { - userLogin($_REQUEST['username'], $_REQUEST['password'], false); - } - if ( !empty($user) ) { - // generate it once here, while session is open. Value will be cached in session and return when called later on - generateAuthHash(ZM_AUTH_HASH_IPS); - } -} +# User Login will be performed in auth.php +require_once('includes/auth.php'); if ( isset($_REQUEST['action']) ) { $action = detaintPath($_REQUEST['action']); @@ -229,7 +217,7 @@ if ( ZM_OPT_USE_AUTH and !isset($user) ) { Logger::Debug('Redirecting to login'); $view = 'login'; $request = null; -} else if ( ZM_SHOW_PRIVACY && ($action != 'privacy') && ($view !='options') && (!$request) && canEdit('System') ) { +} else if ( ZM_SHOW_PRIVACY && ($action != 'privacy') && ($view != 'options') && (!$request) && canEdit('System') ) { Logger::Debug('Redirecting to privacy'); $view = 'privacy'; $request = null; diff --git a/web/js/Server.js b/web/js/Server.js new file mode 100644 index 000000000..61d1ff713 --- /dev/null +++ b/web/js/Server.js @@ -0,0 +1,28 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Server = function () { + function Server(json) { + _classCallCheck(this, Server); + + for (var k in json) { + this[k] = json[k]; + } + } + + _createClass(Server, [{ + key: 'url', + value: function url() { + var port = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; + + return location.protocol + '//' + this.Hostname + (port ? ':' + port : '') + (this.PathPrefix && this.PathPrefix != 'null' ? this.PathPrefix : ''); + } + }]); + + return Server; +}(); + +; diff --git a/web/lang/ba_ba.php b/web/lang/ba_ba.php new file mode 100644 index 000000000..e60e69066 --- /dev/null +++ b/web/lang/ba_ba.php @@ -0,0 +1,995 @@ + 'Dnevnik', + 'DateTime' => 'Datum/Vrijeme', + 'Component' => 'Komponenta', + 'Pid' => 'PID', + 'Level' => 'Nivo', + 'Message' => 'Poruka', + 'Line' => 'Linija', + 'More' => 'Više', + 'Clear' => 'Očisti', + '24BitColour' => '24 bitne boje', + '32BitColour' => '32 bitne boje', + '8BitGrey' => '8 bit siva nijansa', + 'Action' => 'Action', + 'Actual' => 'Stvarno', + 'AddNewControl' => 'Dodaj kontrolu', + 'AddNewMonitor' => 'Dodaj monitor', + 'AddNewServer' => 'Dodaj novi server', + 'AddNewStorage' => 'Dodaj novi disk', + 'AddNewUser' => 'Dodaj novog korisnika', + 'AddNewZone' => 'Dodaj novu zonu', + 'Alarm' => 'Alarm', + 'AlarmBrFrames' => 'Alarm
Sličice', + 'AlarmFrame' => 'Alarm sličica', + 'AlarmFrameCount' => 'Brzina snimanja alarma (u frejmovima)', + 'AlarmLimits' => 'Alarm limiti', + 'AlarmMaximumFPS' => 'Alarm Max SPS', + 'AlarmPx' => 'Alarm Px', + 'AlarmRefImageBlendPct' => 'Alarm Reference Image Blend %ge', + 'AlarmRGBUnset' => 'Morate postaviti RGB boju za alarm', + 'Alert' => 'Uzbuna', + 'All' => 'Sve', + 'AnalysisFPS' => 'Analiza frejmova', + 'AnalysisUpdateDelay' => 'Analysis Update Delay', + 'Apply' => 'Primjeni', + 'ApplyingStateChange' => 'Primjenjujem promjenu stanja', + 'ArchArchived' => 'Samo arhivirano', + 'Archive' => 'Arhiva', + 'Archived' => 'Ahivirano', + 'ArchUnarchived' => 'Samo nearhivirano', + 'Area' => 'Oblast', + 'AreaUnits' => 'Oblast (px/%)', + 'AttrAlarmFrames' => 'Alarm frejmovi', + 'AttrArchiveStatus' => 'Status arhive', + 'AttrAvgScore' => 'Prosj. score', + 'AttrCause' => 'Uzrok', + 'AttrStartDate' => 'Pocetni datum', + 'AttrEndDate' => 'Krajnji datum', + 'AttrStartDateTime' => 'Pocetni Datum/Vrijeme', + 'AttrEndDateTime' => 'Krajnji Datum/Vrijeme', + 'AttrDiskSpace' => 'Disk prostor', + 'AttrDiskBlocks' => 'Disk blokovi', + 'AttrDiskPercent' => 'Disk procentualno', + 'AttrDuration' => 'Trajanje', + 'AttrFrames' => 'Frejmovi', + 'AttrId' => 'Id', + 'AttrMaxScore' => 'Max. Score', + 'AttrMonitorId' => 'ID Kamere', + 'AttrMonitorName' => 'Naziv Kamere', + 'AttrStorageArea' => 'Storage Area', + 'AttrFilterServer' => 'Server Filter je pokrenut na', + 'AttrMonitorServer' => 'Server Monitor je pokrenut na', + 'AttrStorageServer' => 'Server Hosting Storage', + 'AttrStateId' => 'Status', + 'AttrName' => 'Naziv', + 'AttrNotes' => 'Bilješke', + 'AttrSystemLoad' => 'Opterećenje sistema', + 'AttrStartTime' => 'Vrijeme početka', + 'AttrEndTime' => 'Vrijeme završetka', + 'AttrTotalScore' => 'Ukupan score', + 'AttrStartWeekday' => 'Početni dan', + 'AttrEndWeekday' => 'Krajnji dan', + 'Auto' => 'Automatski', + 'AutoStopTimeout' => 'Auto Stop Timeout', + 'Available' => 'Dostupno', + 'AvgBrScore' => 'Avg.
Score', + 'Available' => 'Dostupno', + 'Background' => 'Pozadina', + 'BackgroundFilter' => 'Pokreni filter u pozadini', + 'BadAlarmFrameCount' => 'Brojač alarm frejmova mora biti tipa integer počevši od jedan ili više', + 'BadAlarmMaxFPS' => 'Max FPS za alarm mora biti pozitivan cjeli broj ili broj sa pomičnim zarezom', + 'BadAnalysisFPS' => 'Broj frejmova za analitiku mora pozitivan cjeli broj ili broj sa pomičnim zarezom', + 'BadAnalysisUpdateDelay'=> 'Vrijeme zadrške analitike mora biti broj od nula ili više', + 'BadChannel' => 'Kanal mora biti postavljen na cjeli broj nula ili više', + 'BadDevice' => 'Uredaj mora biti postavljen na validnu vrijednost', + 'BadFormat' => 'Format mora biti postavljen na validnu vrijenost', + 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', + 'BadFrameSkip' => 'Frame skip count must be an integer of zero or more', + 'BadMotionFrameSkip' => 'Motion Frame skip count must be an integer of zero or more', + 'BadHeight' => 'Height must be set to a valid value', + 'BadHost' => 'Host must be set to a valid ip address or hostname, do not include http://', + 'BadImageBufferCount' => 'Image buffer size must be an integer of 10 or more', + 'BadLabelX' => 'Label X co-ordinate must be set to an integer of zero or more', + 'BadLabelY' => 'Label Y co-ordinate must be set to an integer of zero or more', + 'BadMaxFPS' => 'Maximum FPS must be a positive integer or floating point value', + 'BadNameChars' => 'Names may only contain alphanumeric characters plus spaces, hyphen and underscore', + 'BadPalette' => 'Palette must be set to a valid value', + 'BadColours' => 'Target colour must be set to a valid value', + 'BadPath' => 'Path must be set to a valid value', + 'BadPort' => 'Port must be set to a valid number', + 'BadPostEventCount' => 'Post event image count must be an integer of zero or more', + 'BadPreEventCount' => 'Pre event image count must be at least zero, and less than image buffer size', + 'BadRefBlendPerc' => 'Reference blend percentage must be a positive integer', + 'BadSectionLength' => 'Section length must be an integer of 30 or more', + 'BadSignalCheckColour' => 'Signal check colour must be a valid RGB colour string', + 'BadStreamReplayBuffer' => 'Stream replay buffer must be an integer of zero or more', + 'BadSourceType' => 'Source Type \"Web Site\" requires the Function to be set to \"Monitor\"', + 'BadWarmupCount' => 'Warmup frames must be an integer of zero or more', + 'BadWebColour' => 'Web colour must be a valid web colour string', + 'BadWebSitePath' => 'Please enter a complete website url, including the http:// or https:// prefix.', + 'BadWidth' => 'Width must be set to a valid value', + 'Bandwidth' => 'Propusnost', + 'BandwidthHead' => 'propusnost', // This is the end of the bandwidth status on the top of the console, different in many language due to phrasing + 'BlobPx' => 'Blob Px', + 'Blobs' => 'Blobs', + 'BlobSizes' => 'Blob velicine', + 'Brightness' => 'Svjetloća', + 'Buffer' => 'Bufer', + 'Buffers' => 'Buferi', + 'CanAutoFocus' => 'Podržava Auto fokusiranje', + 'CanAutoGain' => 'Podržava Auto pojačanje', + 'CanAutoIris' => 'Podržava Auto blenda', + 'CanAutoWhite' => 'Podržava Auto balans bijel.', + 'CanAutoZoom' => 'Podržava Auto zum', + 'Cancel' => 'otkaži', + 'CancelForcedAlarm' => 'Otkaži prisilni alarm', + 'CanFocusAbs' => 'Podržava Abs fokus', + 'CanFocus' => 'Podržava Fokus', + 'CanFocusCon' => 'Podržava Kontinuirani fokus', + 'CanFocusRel' => 'Podržava Relativni fokus', + 'CanGainAbs' => 'Podržava Aps. pojačanje', + 'CanGain' => 'Podržava Pojačanje ', + 'CanGainCon' => 'Podržava Kontinuirano pojačanje', + 'CanGainRel' => 'Podržava Relativno pojačanje', + 'CanIrisAbs' => 'Podržava Aps. blenda', + 'CanIris' => 'Podržava Blenda', + 'CanIrisCon' => 'Podržava kontinuirana blenda', + 'CanIrisRel' => 'Podržava Relativna blenda', + 'CanMoveAbs' => 'Podržava Aps. kretanje', + 'CanMove' => 'Podržava Kretanje', + 'CanMoveCon' => 'Podržava Kontinuirano kretanje', + 'CanMoveDiag' => 'Podržava Dijagonalno kretanje', + 'CanMoveMap' => 'Podržava Mapirano kretanje', + 'CanMoveRel' => 'Podržava Relativno kretanje', + 'CanPan' => 'Podržava Pomak' , + 'CanReset' => 'PodržavaReset', + 'CanSetPresets' => 'Podržava presetove', + 'CanSleep' => 'Podržava Sleep', + 'CanTilt' => 'Podržava nagib', + 'CanWake' => 'Podržava Wake', + 'CanWhiteAbs' => 'Podržava Aps. balans bijele boje', + 'CanWhiteBal' => 'Podržava balans bijel.', + 'CanWhite' => 'Podržava bijelu', + 'CanWhiteCon' => 'Podržava kont. balans bijele boje', + 'CanWhiteRel' => 'Podržava relativ. balans bijele boje', + 'CanZoomAbs' => 'Podržava Aps. zoom', + 'CanZoom' => 'Podržava Zoom', + 'CanZoomCon' => 'Podržava kontinuirani Zoom', + 'CanZoomRel' => 'Podržava Relativni zoom', + 'CaptureHeight' => 'Visina slike', + 'CaptureMethod' => 'Metoda snimanja', + 'CaptureResolution' => 'Snimi rezoluciju', + 'CapturePalette' => 'Paleta boja', + 'CaptureWidth' => 'Širina slike', + 'Cause' => 'Uzrok', + 'CheckMethod' => 'Metoda provjere alarma', + 'ChooseDetectedCamera' => 'Odaberi otkrivenu kameru', + 'ChooseFilter' => 'Odaberi filter', + 'ChooseLogFormat' => 'Odaberi dugi format', + 'ChooseLogSelection' => 'Odaberi dugu selekciju', + 'ChoosePreset' => 'Odaberi preset', + 'CloneMonitor' => 'Kloniraj', + 'Close' => 'Zatvori', + 'Colour' => 'Bojs', + 'Command' => 'Komanda', + 'ConcurrentFilter' => 'Istovremeno pokreni filter', + 'Config' => 'Postavke', + 'ConfiguredFor' => 'Podešeno za', + 'ConfirmDeleteEvents' => 'Sigurni ste da želite izbrisati odabrane događaje?', + 'ConfirmPassword' => 'Potvrdi lozinku', + 'ConjAnd' => 'i', + 'ConjOr' => 'ili', + 'Console' => 'Konzola', + 'ContactAdmin' => 'Molimo konkatirajte svog administratora za detalje.', + 'Continue' => 'Nastavi', + 'Contrast' => 'Kontrast', + 'ControlAddress' => 'Kontrolna adresa', + 'ControlCap' => 'Control Capability', + 'ControlCaps' => 'Control Capabilities', + 'Control' => 'PTZ kontole', + 'ControlDevice' => 'Kontroliši uređaj', + 'Controllable' => 'Moguće kontrolisati', + 'ControlType' => 'Tipa kontrole', + 'Current' => 'Tekuće', + 'Cycle' => 'Kruži', + 'CycleWatch' => 'Kružni prikaz', + 'Day' => 'Dan', + 'Debug' => 'Debug', + 'DefaultRate' => 'Podrazumjevana stopa', + 'DefaultScale' => 'Podrazumjevani razmjer', + 'DefaultView' => 'Podrazumjevani prikaz', + 'Deinterlacing' => 'Deinterlacing', + 'RTSPDescribe' => 'Use RTSP Response Media URL', + 'Delay' => 'Zadrška', + 'DeleteAndNext' => 'Izbriši & Sljedeće', + 'DeleteAndPrev' => 'Izbriši & Preth', + 'Delete' => 'Izbriši', + 'DeleteSavedFilter' => 'Izbriši spremljeni filter', + 'Description' => 'Opis', + 'DetectedCameras' => 'Detektovane kamere:', + 'DetectedProfiles' => 'Otkriveni profili', + 'DeviceChannel' => 'Kanal', + 'DeviceFormat' => 'Sistem boja', + 'DeviceNumber' => 'Broj uređaja', + 'DevicePath' => 'Putanja uređaja', + 'Device' => 'Uređaj', + 'Devices' => 'Uređaji', + 'Dimensions' => 'Dimenzije', + 'DisableAlarms' => 'Onemogući alarme', + 'Disk' => 'Disk', + 'Display' => 'Prikaz', + 'Displaying' => 'Prikazujem', + 'DonateAlready' => 'Ne, već sam napravio donaciju.', + 'DonateEnticement' => 'You\'ve been running ZoneMinder for a while now and hopefully are finding it a useful addition to your home or workplace security. Although ZoneMinder is, and will remain, free and open source, it costs money to develop and support. If you would like to help support future development and new features then please consider donating. Donating is, of course, optional but very much appreciated and you can donate as much or as little as you like.

If you would like to donate please select the option below or go to http://www.zoneminder.com/donate.html in your browser.

Thank you for using ZoneMinder and don\'t forget to visit the forums on ZoneMinder.com for support or suggestions about how to make your ZoneMinder experience even better.', + 'Donate' => 'Molimo donirajte', + 'DonateRemindDay' => 'Ne još, podsjetime za 1 dan', + 'DonateRemindHour' => 'Ne još, podsjetime za 1 sat', + 'DonateRemindMonth' => 'Ne još, podsjeti me za jedan mjesec', + 'DonateRemindNever' => 'Ne, ne želim donirati, nemoj me više podsjećati.', + 'DonateRemindWeek' => 'Ne još, podsjeti me za sedam dana.', + 'DonateYes' => 'Da, želim da doniram sada.', + 'DoNativeMotionDetection'=> 'Nativna detekcija pokreta', + 'Download' => 'Preuzmi', + 'DuplicateMonitorName' => 'Dupliciraj ime monitora', + 'Duration' => 'Trajanje', + 'Edit' => 'Uredi', + 'EditLayout' => 'Uredi raspored', + 'Email' => 'Email', + 'EnableAlarms' => 'Omogući alarme', + 'Enabled' => 'Omogućeno', + 'EnterNewFilterName' => 'Unesi novo ime za filter', + 'ErrorBrackets' => 'Greška, provjerite da li imate jednak broj otvorenih i zatvorenih zagrada.', + 'Error' => 'Greška', + 'ErrorValidValue' => 'Greška, osigurajte se da svi pojmovi imaju valide vrijednosti', + 'Etc' => 'itd', + 'Event' => 'Događaj', + 'EventFilter' => 'Filter događaja', + 'EventId' => 'ID događaja', + 'EventName' => 'Naziv događaja', + 'EventPrefix' => 'Prefiks događaja', + 'Events' => 'Događaji', + 'Exclude' => 'Isključi', + 'Execute' => 'Izvrši', + 'ExportDetails' => 'Izvezi detalje o događaju', + 'Exif' => 'Umetni EXIF podatke u sliku', + 'Export' => 'Izvezi', + 'DownloadVideo' => 'Preuzmi video', + 'GenerateDownload' => 'Generiši preuzimanje', + 'ExportFailed' => 'Izvoz nije uspio', + 'ExportFormat' => 'Format za izvoz', + 'ExportFormatTar' => 'Tar', + 'ExportFormatZip' => 'Zip', + 'ExportFrames' => 'Izvezi detalje frejma', + 'ExportImageFiles' => 'Izvezi slike', + 'ExportLog' => 'Izvezi zapisnik', + 'Exporting' => 'Izvozim', + 'ExportMiscFiles' => 'Izvezi druge fajlove (ukoliko postoje)', + 'ExportOptions' => 'Opcije izvoženja', + 'ExportSucceeded' => 'Izvoz uspio', + 'ExportVideoFiles' => 'Izvezi video fileove (ukoliko postoje)', + 'Far' => 'Far', + 'FastForward' => 'Naprijed', + 'Feed' => 'Feed', + 'Ffmpeg' => 'Ffmpeg', + 'File' => 'File', + 'FilterArchiveEvents' => 'Arhiviraj pronađeno', + 'FilterUpdateDiskSpace' => 'Ažuriraj korišteni prostor na disku', + 'FilterDeleteEvents' => 'Izbriši sve pronađeno', + 'FilterMoveEvents' => 'Premjesti pronađeno', + 'FilterEmailEvents' => 'Pošalji detalje mailom', + 'FilterExecuteEvents' => 'Izvrši sljededeću komandu', + 'FilterLog' => 'Filtriraj zapis', + 'FilterMessageEvents' => 'Message details of all matches', + 'FilterPx' => 'Filter Px', + 'Filter' => 'Filter', + 'Filters' => 'Filteri', + 'FilterUnset' => 'Morate navesti širinu i visinu filtera', + 'FilterUploadEvents' => 'Učitaj sve događaje', + 'FilterVideoEvents' => 'Napravi video', + 'First' => 'Prvi', + 'FlippedHori' => 'Zaokrenuto horizontalno', + 'FlippedVert' => 'Zaokrenuto vertikalno', + 'FnNone' => 'nijedan', // Added 2013.08.16. + 'FnMonitor' => 'Monitor', // Added 2013.08.16. + 'FnModect' => 'Modect', // Added 2013.08.16. + 'FnRecord' => 'Record', // Added 2013.08.16. + 'FnMocord' => 'Mocord', // Added 2013.08.16. + 'FnNodect' => 'Nodect', // Added 2013.08.16. + 'Focus' => 'Fokus', + 'ForceAlarm' => 'Prisilni alarm', + 'Format' => 'Format', + 'FPS' => 'fps', + 'FPSReportInterval' => 'FPS Report Interval', + 'Frame' => 'Frame', + 'FrameId' => 'Frame Id', + 'FrameRate' => 'Frame Rate', + 'Frames' => 'Frejmovi', + 'FrameSkip' => 'Preskoči frejm', + 'MotionFrameSkip' => 'Motion Frame Skip', + 'FTP' => 'FTP', + 'Func' => 'Func', + 'Function' => 'Funkcija', + 'Gain' => 'Pojačanje', + 'General' => 'Opšte', + 'GenerateVideo' => 'Generiši video', + 'GeneratingVideo' => 'Generiši video', + 'GoToZoneMinder' => 'Idi na ZoneMinder.com', + 'Grey' => 'Siva', + 'Group' => 'Grupa', + 'Groups' => 'Grupe', + 'HasFocusSpeed' => 'Posjeduje brzo fokusiranja', + 'HasGainSpeed' => 'Posjeduje brzo pojačanja', + 'HasHomePreset' => 'Has Home Preset', + 'HasIrisSpeed' => 'Posjeduje brzu blendu', + 'HasPanSpeed' => 'Posjeduje brzi pomak', + 'HasPresets' => 'Posjeduje pre-setove', + 'HasTiltSpeed' => 'Posjeduje brzi nagiba', + 'HasTurboPan' => 'Posjeduje turbo pomak', + 'HasTurboTilt' => 'Posjeduje turbo nagib', + 'HasWhiteSpeed' => 'Posjeduje brzo podeš.bijele', + 'HasZoomSpeed' => 'Posjeduje brzi zoom', + 'HighBW' => 'High B/W', + 'High' => 'veliku', + 'Home' => 'Početna', + 'Hostname' => 'Hostname', + 'Hour' => 'Sat', + 'Hue' => 'Nijansa', + 'Id' => 'Id', + 'Idle' => 'Na čekanju', + 'Ignore' => 'Zanemari', + 'ImageBufferSize' => 'Veličina slikovnog bufera (u frejmovima)', + 'Image' => 'Slika', + 'Images' => 'Slike', + 'Include' => 'Uključi', + 'In' => 'U', + 'Inverted' => 'Invertirano', + 'Iris' => 'Blenda', + 'KeyString' => 'Key String', + 'Label' => 'Oznaka', + 'Language' => 'Jezik', + 'Last' => 'Zadnje', + 'Layout' => 'Raspored', + 'Libvlc' => 'Libvlc', + 'LimitResultsPost' => 'results only', // This is used at the end of the phrase 'Limit to first N results only' + 'LimitResultsPre' => 'Limit to first', // This is used at the beginning of the phrase 'Limit to first N results only' + 'LinkedMonitors' => 'Povezani monitori', + 'List' => 'Popis', + 'ListMatches' => 'Prikaži pronađeno', + 'Load' => 'Opterećenje', + 'Local' => 'Lokalno', + 'Log' => 'Zapis', + 'Logs' => 'Zapisi', + 'Logging' => 'Dnevnik događaja', + 'LoggedInAs' => 'Prijavljen kao', + 'LoggingIn' => 'Prijavljujem', + 'Login' => 'prijava', + 'Logout' => 'odjava', + 'LowBW' => 'Low B/W', + 'Low' => 'nisku', + 'Main' => 'Glavno', + 'Man' => 'Man', + 'Manual' => 'Ručno', + 'Mark' => 'Označi', + 'MaxBandwidth' => 'Max propusnost', + 'MaxBrScore' => 'Max.
Score', + 'MaxFocusRange' => 'Max raspon fokusa', + 'MaxFocusSpeed' => 'Max brzina fokusa', + 'MaxFocusStep' => 'Max korak fokusa', + 'MaxGainRange' => 'Max raspon pojačanja', + 'MaxGainSpeed' => 'Max brzina pojačanja', + 'MaxGainStep' => 'Max korak pojačanja', + 'MaximumFPS' => 'Maximum FPS', + 'MaxIrisRange' => 'Max raspon blende', + 'MaxIrisSpeed' => 'Max brzina blende', + 'MaxIrisStep' => 'Max korak blende', + 'Max' => 'Max', + 'MaxPanRange' => 'Max raspon pomaka', + 'MaxPanSpeed' => 'Max brzina pomaka', + 'MaxPanStep' => 'Max korak pomaka', + 'MaxTiltRange' => 'Max raspon nagiba', + 'MaxTiltSpeed' => 'Max brzina nagiba', + 'MaxTiltStep' => 'Max korak nagiba', + 'MaxWhiteRange' => 'Max raspon bijele', + 'MaxWhiteSpeed' => 'Max brzina bijele', + 'MaxWhiteStep' => 'Max korak bijele', + 'MaxZoomRange' => 'Max raspon zumiranja', + 'MaxZoomSpeed' => 'Max brzina zumiranja', + 'MaxZoomStep' => 'Max korak zumiranja', + 'MediumBW' => 'Medium B/W', + 'Medium' => 'srednju', + 'MinAlarmAreaLtMax' => 'Min područje alarma mora biti manje od maksimalnog', + 'MinAlarmAreaUnset' => 'Morate zadati minimalni broj alarm piksela', + 'MinBlobAreaLtMax' => 'Min blob područje mora biti manje od maksimalnog', + 'MinBlobAreaUnset' => 'Morate zadati minimalni broj blob piksela', + 'MinBlobLtMinFilter' => 'Min blob oblast mora biti manja ili jednaka minimalnoj oblasti filtera', + 'MinBlobsLtMax' => 'Min blob mora biti manji od maksimalne', + 'MinBlobsUnset' => 'morate zadati minimalni broj blob-ova', + 'MinFilterAreaLtMax' => 'Minimalna oblast filtera mora biti manja od maksimalne', + 'MinFilterAreaUnset' => 'Morate zadati minimalni broj filter piksela', + 'MinFilterLtMinAlarm' => 'Min oblast filtera mora biti manja ili jednaka minimalnoj oblasti alarmne oblasti', + 'MinFocusRange' => 'Min raspon fokusiranja', + 'MinFocusSpeed' => 'Min brzina fokusiranja', + 'MinFocusStep' => 'Min korak fokusiranja', + 'MinGainRange' => 'Min raspon pojačanja', + 'MinGainSpeed' => 'Min brzina pojačanja', + 'MinGainStep' => 'Min korak pojačanja', + 'MinIrisRange' => 'Min raspon blende', + 'MinIrisSpeed' => 'Min brzina blende', + 'MinIrisStep' => 'Min korak blende', + 'MinPanRange' => 'Min raspon pomaka', + 'MinPanSpeed' => 'Min brzina pomaka', + 'MinPanStep' => 'Min korak pomaka', + 'MinPixelThresLtMax' => 'Min prag piksela mora biti manji od maksimalnog', + 'MinPixelThresUnset' => 'Morate zadati minimalni prag piksela', + 'MinTiltRange' => 'Min Tilt Range', + 'MinTiltSpeed' => 'Min Tilt Speed', + 'MinTiltStep' => 'Min Tilt Step', + 'MinWhiteRange' => 'Min raspon bijelog balansa', + 'MinWhiteSpeed' => 'Min brzina bijelog balansa', + 'MinWhiteStep' => 'Min White Bal. Step', + 'MinZoomRange' => 'Min raspon zumiranja', + 'MinZoomSpeed' => 'Min brzina zumiranja', + 'MinZoomStep' => 'Min korak zumiranja', + 'Misc' => 'Razno', + 'Mode' => 'Modus', + 'MonitorIds' => 'Monitor Ids', + 'Monitor' => 'Monitor', + 'MonitorPresetIntro' => 'Odaberite odgovarajuće pre-setove sa popisa.

Imajte u vidu da ovo može prepisati bilo koju vrijednost koja postoji za odabrane monitore.

', + 'MonitorPreset' => 'Monitor Preset', + 'MonitorProbeIntro' => 'Donji popis prikazuje otkrivene analogne i mrežne kamere, te da li se iste već koriste i da li su dostupne.

Odaberite željenu kameru sa donjeg popisa.

Imajte u vidu da ovo može prepisati bilo koju vrijednost koja postoji za odabrane monitore.

', + 'MonitorProbe' => 'Detektuj kameru', + 'Monitors' => 'Monitori', + 'Montage' => 'Montage', + 'MontageReview' => 'Montage pregled', + 'Month' => 'Mjesec', + 'Move' => 'Pomjeri', + 'MtgDefault' => 'Podrazumjevano', // Added 2013.08.15. + 'Mtg2widgrd' => '2-struka rešetka', // Added 2013.08.15. + 'Mtg3widgrd' => '3-struka rešetka', // Added 2013.08.15. + 'Mtg4widgrd' => '4-struka rešetka', // Added 2013.08.15. + 'Mtg3widgrx' => '3-wide grid, scaled, enlarge on alarm', // Added 2013.08.15. + 'MustBeGe' => 'mora biti veće ili jednako', + 'MustBeLe' => 'mora biti manje ili jednako', + 'MustConfirmPassword' => 'Morate potvrditi lozinku', + 'MustSupplyPassword' => 'Morate unjeti lozinku', + 'MustSupplyUsername' => 'Morate unjeti korisničko ime', + 'Name' => 'Ime', + 'Near' => 'Blizu', + 'Network' => 'Mreža', + 'NewGroup' => 'Nova grupa', + 'NewLabel' => 'Nova oznaka', + 'New' => 'Novo', + 'NewPassword' => 'Nova lozinka', + 'NewState' => 'Novi radni modus', + 'NewUser' => 'Novi korisnik', + 'Next' => 'Sljedeće', + 'NoDetectedCameras' => 'Nema otkrivenih kamera', + 'NoDetectedProfiles' => 'Nema otkrivenih profila', + 'NoFramesRecorded' => 'Nije ništa snimljeno za ovaj događaj', + 'NoGroup' => 'Nema grupe', + 'NoneAvailable' => 'Nijedno dostupno', + 'None' => 'Nijedno', + 'No' => 'Ne', + 'Normal' => 'Normalno', + 'NoSavedFilters' => 'NemaSnimljenihFiltera', + 'NoStatisticsRecorded' => 'Nema snimljenih statistika za ovaj događaj', + 'Notes' => 'Bilješke', + 'NumPresets' => 'Num Presets', + 'Off' => 'Isključeno', + 'On' => 'Uključeno', + 'OnvifProbe' => 'ONVIF detekcija', + 'OnvifProbeIntro' => 'The list below shows detected ONVIF cameras and whether they are already being used or available for selection.

Select the desired entry from the list below.

Please note that not all cameras may be detected and that choosing a camera here may overwrite any values you already have configured for the current monitor.

', + 'OnvifCredentialsIntro' => 'Please supply user name and password for the selected camera.
If no user has been created for the camera then the user given here will be created with the given password.

', + 'Open' => 'Otvori', + 'OpEq' => 'jednako', + 'OpGtEq' => 'veće ili jednako od', + 'OpGt' => 'veće ', + 'OpIn' => 'in set', + 'OpLtEq' => 'manje ili jednako od', + 'OpLt' => 'manje od', + 'OpMatches' => 'matches', + 'OpNe' => 'nije jednako', + 'OpNotIn' => 'nije u ', + 'OpNotMatches' => 'ne poklapa se', + 'OpIs' => 'je', + 'OpIsNot' => 'nije', + 'OptionalEncoderParam' => 'Opcionalni parametri enkodera', + 'OptionHelp' => 'Option Help', + 'OptionRestartWarning' => 'These changes may not come into effect fully\nwhile the system is running. When you have\nfinished making your changes please ensure that\nyou restart ZoneMinder.', + 'Options' => 'Opcije', + 'Order' => 'Redosljed', + 'OrEnterNewName' => 'ili unesi novo ime', + 'Orientation' => 'Orijentacija', + 'Out' => 'Izlaz', + 'OverwriteExisting' => 'Prepiši preko postojećeg', + 'Paged' => 'stranično', + 'PanLeft' => 'Pomak lijevo', + 'Pan' => 'Pomak', + 'PanRight' => 'Pomak desno', + 'PanTilt' => 'Pomak/Nagib', + 'Parameter' => 'Parametar', + 'Password' => 'Lozinka', + 'PasswordsDifferent' => 'Nova i potvrđena lozinka se razlikuju', + 'Paths' => 'Putanje', + 'Pause' => 'Pauza', + 'PhoneBW' => 'Telefon B/W', + 'Phone' => 'Telefon', + 'PixelDiff' => 'Piksel razli.', + 'Pixels' => 'pikseli', + 'PlayAll' => 'play all', + 'Play' => 'Play', + 'Plugins' => 'Plugini', + 'PleaseWait' => 'Molim čekati', + 'Point' => 'Point', + 'PostEventImageBuffer' => 'Br. frejmova poslije događaja', + 'PreEventImageBuffer' => 'Br. frejmova prije događaja', + 'PreserveAspect' => 'Zadrži omjer', + 'Preset' => 'Preset', + 'Presets' => 'Presets', + 'Prev' => 'Preth', + 'Privacy' => 'Privatnost', + 'PrivacyAbout' => 'O', + 'PrivacyAboutText' => 'Since 2002, ZoneMinder has been the premier free and open-source Video Management System (VMS) solution for Linux platforms. ZoneMinder is supported by the community and is managed by those who choose to volunteer their spare time to the project. The best way to improve ZoneMinder is to get involved.', + 'PrivacyContact' => 'Konakt', + 'PrivacyContactText' => 'Please contact us here for any questions regarding our privacy policy or to have your information removed.

For support, there are three primary ways to engage with the community:

Our Github forum is only for bug reporting. Please use our user forum or slack channel for all other questions or comments.

', + 'PrivacyCookies' => 'Kolačići', + 'PrivacyCookiesText' => 'Whether you use a web browser or a mobile app to communicate with the ZoneMinder server, a ZMSESSID cookie is created on the client to uniquely identify a session with the ZoneMinder server. ZmCSS and zmSkin cookies are created to remember your style and skin choices.', + 'PrivacyTelemetry' => 'Telemetry', + 'PrivacyTelemetryText' => 'Because ZoneMinder is open-source, anyone can install it without registering. This makes it difficult to answer questions such as: how many systems are out there, what is the largest system out there, what kind of systems are out there, or where are these systems located? Knowing the answers to these questions, helps users who ask us these questions, and it helps us set priorities based on the majority user base.', + 'PrivacyTelemetryList' => 'The ZoneMinder Telemetry daemon collects the following data about your system:
  • A unique identifier (UUID)
  • City based location is gathered by querying ipinfo.io. City, region, country, latitude, and longitude parameters are saved. The latitude and longitude coordinates are accurate down to the city or town level only!
  • Current time
  • Total number of monitors
  • Total number of events
  • System architecture
  • Operating system kernel, distro, and distro version
  • Version of ZoneMinder
  • Total amount of memory
  • Number of cpu cores
', + 'PrivacyMonitorList' => 'The following configuration parameters from each monitor are collected:
  • Id
  • Name
  • Type
  • Function
  • Width
  • Height
  • Colours
  • MaxFPS
  • AlarmMaxFPS
', + 'PrivacyConclusionText' => 'We are NOT collecting any image specific data from your cameras. We don�t know what your cameras are watching. This data will not be sold or used for any purpose not stated herein. By clicking accept, you agree to send us this data to help make ZoneMinder a better product. By clicking decline, you can still freely use ZoneMinder and all its features.', + 'Probe' => 'Detektuj kameru', + 'ProfileProbe' => 'Stream proba', + 'ProfileProbeIntro' => 'The list below shows the existing stream profiles of the selected camera .

Select the desired entry from the list below.

Please note that ZoneMinder cannot configure additional profiles and that choosing a camera here may overwrite any values you already have configured for the current monitor.

', + 'Progress' => 'Napredak', + 'Protocol' => 'Protkol', + 'Rate' => 'Stopa', + 'RecaptchaWarning' => 'Your reCaptcha secret key is invalid. Please correct it, or reCaptcha will not work', // added Sep 24 2015 - PP + 'RecordAudio' => 'Whether to store the audio stream when saving an event.', + 'Real' => 'Stvarno', + 'Record' => 'Snimaj', + 'RefImageBlendPct' => 'Reference Image Blend %ge', + 'Refresh' => 'Osvježi', + 'RemoteHostName' => 'Naziv uređaja', + 'RemoteHostPath' => 'Putanja', + 'RemoteHostSubPath' => 'Pod-putanja', + 'RemoteHostPort' => 'Port', + 'RemoteImageColours' => 'Boje slike', + 'RemoteMethod' => 'Metoda', + 'RemoteProtocol' => 'Protokol', + 'Remote' => 'Udaljeno', + 'Rename' => 'Preimenuj', + 'ReplayAll' => 'Svi događaji', + 'ReplayGapless' => 'Gapless Events', + 'Replay' => 'Ponovo odigraj', + 'ReplaySingle' => 'Jedan događaj', + 'ReportEventAudit' => 'Audit Events Report', + 'ResetEventCounts' => 'Resetiraj događaje', + 'Reset' => 'Reset', + 'Restarting' => 'Restartiram', + 'Restart' => 'Restaruj', + 'RestrictedCameraIds' => 'Restricted Camera Ids', + 'RestrictedMonitors' => 'Ograničeni monitori', + 'ReturnDelay' => 'Vrati kašnjenje', + 'ReturnLocation' => 'Vrati lokaciju', + 'Rewind' => 'Premotaj', + 'RotateLeft' => 'Rotoraj ulijevo', + 'RotateRight' => 'Rotiraj udesno', + 'RTSPTransport' => 'RTSP Transport Protocol', + 'RunAudit' => 'Run Audit Process', + 'RunLocalUpdate' => 'Pokrenite zmupdate.pl za ažuriranje', + 'RunMode' => 'Modus rada', + 'Running' => 'Pokrenuto', + 'RunState' => 'Radni modus', + 'RunStats' => 'Pokreni stats proces', + 'RunTrigger' => 'Pokreni triger proces', + 'SaveAs' => 'Spremi kao', + 'SaveFilter' => 'Spremi Filter', + 'SaveJPEGs' => 'Spremi JPEGs', + 'Save' => 'Spremi', + 'Scale' => 'Razmjer', + 'Score' => 'Zbir', + 'Secs' => 'Secs', + 'Sectionlength' => 'Odaberi dužinu', + 'SelectMonitors' => 'SOdaberi monitore', + 'Select' => 'Odaberi', + 'SelectFormat' => 'Odaberi format', + 'SelectLog' => 'Odaberi zapis', + 'SelfIntersecting' => 'Polygon edges must not intersect', + 'SetNewBandwidth' => 'Postavi propusnost na', + 'SetPreset' => 'Postavi pozicije', + 'Set' => 'Postavi', + 'Settings' => 'Postavke', + 'ShowFilterWindow' => 'Prikaži prozor za filter', + 'ShowTimeline' => 'Prikaži vremensku liniju', + 'SignalCheckColour' => 'Signal Check Colour', + 'SignalCheckPoints' => 'Signal Check Points', + 'Size' => 'Veličina', + 'SkinDescription' => 'Izmjeni izgled za ovu sesiju', + 'CSSDescription' => 'Izmjeni css za ovu sesiju', + 'Sleep' => 'Sleep', + 'SortAsc' => 'Rastuće', + 'SortBy' => 'Sortiraj po', + 'SortDesc' => 'Padajuće', + 'Source' => 'Izvor', + 'SourceColours' => 'Source Colours', + 'SourcePath' => 'Putanja izvora ', + 'SourceType' => 'Izvor videa', + 'SpeedHigh' => 'Velika brzina', + 'SpeedLow' => 'Niska brzina', + 'SpeedMedium' => 'Srednja brzina', + 'Speed' => 'brzina', + 'SpeedTurbo' => 'Turbo brzina', + 'Start' => 'Start', + 'State' => 'Stanje', + 'Stats' => 'Statistka', + 'Status' => 'Status', + 'StatusUnknown' => 'Nepoznato', + 'StatusConnected' => 'Snimam', + 'StatusNotRunning' => 'Nije pokrenuto', + 'StatusRunning' => 'Ne snima', + 'StepBack' => 'Korak nazad', + 'StepForward' => 'Korak naprijed', + 'StepLarge' => 'Veliki korak', + 'StepMedium' => 'Srednji korak', + 'StepNone' => 'Bez koraka', + 'StepSmall' => 'Mali korak', + 'Step' => 'Korak', + 'Stills' => 'Stills', + 'Stopped' => 'Zaustavljeno', + 'Stop' => 'Zaustavi', + 'StorageArea' => 'Storage Area', + 'StorageDoDelete' => 'Brisanja', + 'StorageScheme' => 'Šema', + 'StreamReplayBuffer' => 'Stream Replay Image Buffer', + 'Stream' => 'Stream', + 'Submit' => 'Pošalji', + 'System' => 'Sistem', + 'TargetColorspace' => 'Rezolucija boja', + 'Tele' => 'Udaljeno', + 'Thumbnail' => 'Sličica', + 'Tilt' => 'Tilt', + 'TimeDelta' => 'Vremenska razlika', + 'Timeline' => 'Vremenska linija', + 'TimelineTip1' => 'Pass your mouse over the graph to view a snapshot image and event details.', // Added 2013.08.15. + 'TimelineTip2' => 'Click on the coloured sections of the graph, or the image, to view the event.', // Added 2013.08.15. + 'TimelineTip3' => 'Click on the background to zoom in to a smaller time period based around your click.', // Added 2013.08.15. + 'TimelineTip4' => 'Use the controls below to zoom out or navigate back and forward through the time range.', // Added 2013.08.15. + 'TimestampLabelFormat' => 'Timestamp format oznake', + 'TimestampLabelX' => 'Timestamp oznaka X', + 'TimestampLabelY' => 'Timestamp oznaka Y', + 'TimestampLabelSize' => 'Veličina fonta', + 'Timestamp' => 'Timestamp', + 'TimeStamp' => 'Vremenski pečat', + 'Time' => 'Vrijeme', + 'Today' => 'Danas', + 'Tools' => 'Alati', + 'Total' => 'Ukupno', + 'TotalBrScore' => 'Total
Score', + 'TrackDelay' => 'Kašnjenje', + 'TrackMotion' => 'Prati pokret', + 'Triggers' => 'Okidači', + 'TurboPanSpeed' => 'Turbo Pan brzina', + 'TurboTiltSpeed' => 'Turbo Tilt brzina', + 'Type' => 'Tip', + 'Unarchive' => 'Dearhiviraj', + 'Undefined' => 'Nedefinisano', + 'Units' => 'Mjere', + 'Unknown' => 'Nepoznato', + 'UpdateAvailable' => 'Dostupno je novo ažurranje za Zoneminder .', + 'UpdateNotNecessary' => 'Ažuriranje nije potrebno.', + 'Update' => 'Ažuiriaj', + 'Upload' => 'Upload', + 'Updated' => 'Ažurirano', + 'UsedPlugins' => 'Korišteni plugini ', + 'UseFilterExprsPost' => ' filter expressions', // This is used at the end of the phrase 'use N filter expressions' + 'UseFilterExprsPre' => 'Use ', // This is used at the beginning of the phrase 'use N filter expressions' + 'UseFilter' => 'Koristi filter', + 'Username' => 'Korisničko ime', + 'Users' => 'Korisnici', + 'User' => 'Korisnik', + 'Value' => 'Vrijednost', + 'VersionIgnore' => 'Ignoriši ovu verziju', + 'VersionRemindDay' => 'Podsjeti me za jedan dan', + 'VersionRemindHour' => 'Podsjeti me za jedan sat', + 'VersionRemindNever' => 'Ne podsjecaj me na nove verzije', + 'VersionRemindWeek' => 'Podsjeti me za sedam dana', + 'Version' => 'Verzija', + 'VideoFormat' => 'Video Format', + 'VideoGenFailed' => 'Generisanje videa nije uspjelo!', + 'VideoGenFiles' => 'Postojece video datoteke', + 'VideoGenNoFiles' => 'Video datoteke nisu pronadjene', + 'VideoGenParms' => 'Parametri za generisanje videa', + 'VideoGenSucceeded' => 'Generisanje videa uspjelo!', + 'VideoSize' => 'Velicina videa', + 'VideoWriter' => 'Video pisac', + 'Video' => 'Video', + 'ViewAll' => 'Pregledaj sve', + 'ViewEvent' => 'Pregled događaja', + 'ViewPaged' => 'Stanični pregled', + 'View' => 'Pregled', + 'V4L' => 'V4L', + 'V4LCapturesPerFrame' => 'Snimci po frejmu', + 'V4LMultiBuffer' => 'Višestr. bafer', + 'Wake' => 'Budi', + 'WarmupFrames' => 'Warmup frejmovi', + 'Watch' => 'Gledaj', + 'WebColour' => 'Web boja', + 'Web' => 'Web', + 'WebSiteUrl' => 'URL web stranice', + 'Week' => 'Sedmica', + 'WhiteBalance' => 'Balans bijele', + 'White' => 'Bijelo', + 'Wide' => 'Široko', + 'X10ActivationString' => 'X10 znakovni niz za aktiviranje', + 'X10InputAlarmString' => 'X10 ulazni znakovni niz za alarm', + 'X10OutputAlarmString' => 'X10 izlazni znakovni niz za alarm', + 'X10' => 'X10', + 'X' => 'X', + 'Yes' => 'Da', + 'YouNoPerms' => 'Nemate potrebne dozvole za pristup ovom resursu.', + 'Y' => 'Y', + 'ZoneAlarmColour' => 'Boja alarma (Red/Green/Blue)', + 'ZoneArea' => 'Oblast zone', + 'ZoneFilterSize' => 'Filter Width/Height (pixels)', + 'ZoneMinderLog' => 'ZoneMinder zapisnik', + 'ZoneMinMaxAlarmArea' => 'Min/Max alarmirana oblast', + 'ZoneMinMaxBlobArea' => 'Min/Max blob oblast', + 'ZoneMinMaxBlobs' => 'Min/Max Blobovi', + 'ZoneMinMaxFiltArea' => 'Min/Max filtrirane oblasti', + 'ZoneMinMaxPixelThres' => 'Min/Max Pixel Threshold (0-255)', + 'ZoneOverloadFrames' => 'Overload Frame Ignore Count', + 'ZoneExtendAlarmFrames' => 'Extend Alarm Frame Count', + 'Zones' => 'Zone', + 'Zone' => 'Zona', + 'ZoomIn' => 'Zoom In', + 'ZoomOut' => 'Zoom Out', + 'Zoom' => 'Zumiranje', +); + +// Complex replacements with formatting and/or placements, must be passed through sprintf +$CLANG = array( + 'CurrentLogin' => 'Prijavljeni ste kao \'%1$s\'', + 'EventCount' => '%1$s %2$s', // For example '37 Events' (from Vlang below) + 'LastEvents' => 'Last %1$s %2$s', // For example 'Last 37 Events' (from Vlang below) + 'LatestRelease' => 'Zadnja verzija servera je v%1$s, vi imate v%2$s.', + 'MonitorCount' => '%1$s %2$s', // For example '4 Monitors' (from Vlang below) + 'MonitorFunction' => 'Monitor %1$s Function', + 'RunningRecentVer' => 'Koristite najnoviju verziju Zoneminder servera, v%s.', + 'VersionMismatch' => 'Version mismatch, system is version %1$s, database is %2$s.', +); + +// The next section allows you to describe a series of word ending and counts used to +// generate the correctly conjugated forms of words depending on a count that is associated +// with that word. +// This intended to allow phrases such a '0 potatoes', '1 potato', '2 potatoes' etc to +// conjugate correctly with the associated count. +// In some languages such as English this is fairly simple and can be expressed by assigning +// a count with a singular or plural form of a word and then finding the nearest (lower) value. +// So '0' of something generally ends in 's', 1 of something is singular and has no extra +// ending and 2 or more is a plural and ends in 's' also. So to find the ending for '187' of +// something you would find the nearest lower count (2) and use that ending. +// +// So examples of this would be +// $zmVlangPotato = array( 0=>'Potatoes', 1=>'Potato', 2=>'Potatoes' ); +// $zmVlangSheep = array( 0=>'Sheep' ); +// +// where you can have as few or as many entries in the array as necessary +// If your language is similar in form to this then use the same format and choose the +// appropriate zmVlang function below. +// If however you have a language with a different format of plural endings then another +// approach is required . For instance in Russian the word endings change continuously +// depending on the last digit (or digits) of the numerator. In this case then zmVlang +// arrays could be written so that the array index just represents an arbitrary 'type' +// and the zmVlang function does the calculation about which version is appropriate. +// +// So an example in Russian might be (using English words, and made up endings as I +// don't know any Russian!!) +// 'Potato' => array( 1=>'Potati', 2=>'Potaton', 3=>'Potaten' ), +// +// and the zmVlang function decides that the first form is used for counts ending in +// 0, 5-9 or 11-19 and the second form when ending in 1 etc. +// + +// Variable arrays expressing plurality, see the zmVlang description above +$VLANG = array( + 'Event' => array( 0=>'Events', 1=>'Event', 2=>'Events' ), + 'Monitor' => array( 0=>'Monitors', 1=>'Monitor', 2=>'Monitors' ), +); +// You will need to choose or write a function that can correlate the plurality string arrays +// with variable counts. This is used to conjugate the Vlang arrays above with a number passed +// in to generate the correct noun form. +// +// In languages such as English this is fairly simple +// Note this still has to be used with printf etc to get the right formatting +function zmVlang( $langVarArray, $count ) +{ + krsort( $langVarArray ); + foreach ( $langVarArray as $key=>$value ) + { + if ( abs($count) >= $key ) + { + return( $value ); + } + } + die( 'Error, unable to correlate variable language string' ); +} + +// This is an version that could be used in the Russian example above +// The rules are that the first word form is used if the count ends in +// 0, 5-9 or 11-19. The second form is used then the count ends in 1 +// (not including 11 as above) and the third form is used when the +// count ends in 2-4, again excluding any values ending in 12-14. +// +// function zmVlang( $langVarArray, $count ) +// { +// $secondlastdigit = substr( $count, -2, 1 ); +// $lastdigit = substr( $count, -1, 1 ); +// // or +// // $secondlastdigit = ($count/10)%10; +// // $lastdigit = $count%10; +// +// // Get rid of the special cases first, the teens +// if ( $secondlastdigit == 1 && $lastdigit != 0 ) +// { +// return( $langVarArray[1] ); +// } +// switch ( $lastdigit ) +// { +// case 0 : +// case 5 : +// case 6 : +// case 7 : +// case 8 : +// case 9 : +// { +// return( $langVarArray[1] ); +// break; +// } +// case 1 : +// { +// return( $langVarArray[2] ); +// break; +// } +// case 2 : +// case 3 : +// case 4 : +// { +// return( $langVarArray[3] ); +// break; +// } +// } +// die( 'Error, unable to correlate variable language string' ); +// } + +// This is an example of how the function is used in the code which you can uncomment and +// use to test your custom function. +//$monitors = array(); +//$monitors[] = 1; // Choose any number +//echo sprintf( $CLANG['MonitorCount'], count($monitors), zmVlang( $VLANG['VlangMonitor'], count($monitors) ) ); + +// In this section you can override the default prompt and help texts for the options area +// These overrides are in the form show below where the array key represents the option name minus the initial ZM_ +// So for example, to override the help text for ZM_LANG_DEFAULT do +$OLANG = array( + 'OPTIONS_FFMPEG' => array( + 'Help' => "Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,~~ ". + "Examples (do not enter quotes)~~~~". + "\"allowed_media_types=video\" Set datatype to request fromcam (audio, video, data)~~~~". + "\"reorder_queue_size=nnn\" Set number of packets to buffer for handling of reordered packets~~~~". + "\"loglevel=debug\" Set verbosity of FFmpeg (quiet, panic, fatal, error, warning, info, verbose, debug)" + ), + 'OPTIONS_RTSPTrans' => array( + 'Help' => "This sets the RTSP Transport Protocol for FFmpeg.~~ ". + "TCP - Use TCP (interleaving within the RTSP control channel) as transport protocol.~~". + "UDP - Use UDP as transport protocol. Higher resolution cameras have experienced some 'smearing' while using UDP, if so try TCP~~". + "UDP Multicast - Use UDP Multicast as transport protocol~~". + "HTTP - Use HTTP tunneling as transport protocol, which is useful for passing proxies.~~" + ), + 'OPTIONS_LIBVLC' => array( + 'Help' => "Parameters in this field are passed on to libVLC. Multiple parameters can be separated by ,~~ ". + "Examples (do not enter quotes)~~~~". + "\"--rtp-client-port=nnn\" Set local port to use for rtp data~~~~". + "\"--verbose=2\" Set verbosity of libVLC" + ), + 'OPTIONS_EXIF' => array( + 'Help' => "Enable this option to embed EXIF data into each jpeg frame." + ), + 'OPTIONS_RTSPDESCRIBE' => array( + 'Help' => "Sometimes, during the initial RTSP handshake, the camera will send an updated media URL. ". + "Enable this option to tell ZoneMinder to use this URL. Disable this option to ignore the ". + "value from the camera and use the value as entered in the monitor configuration~~~~". + "Generally this should be enabled. However, there are cases where the camera can get its". + "own URL incorrect, such as when the camera is streaming through a firewall"), + 'OPTIONS_MAXFPS' => array( + 'Help' => "This field has certain limitations when used for non-local devices.~~ ". + "Failure to adhere to these limitations will cause a delay in live video, irregular frame skipping, ". + "and missed events~~". + "For streaming IP cameras, do not use this field to reduce the frame rate. Set the frame rate in the". + " camera, instead. You can, however, use a value that is slightly higher than the frame rate in the camera. ". + "In this case, this helps keep the cpu from being overtaxed in the event of a network problem.~~". + "Some, mostly older, IP cameras support snapshot mode. In this case ZoneMinder is actively polling the camera ". + "for new images. In this case, it is safe to use the field." + ), + +// 'LANG_DEFAULT' => array( +// 'Prompt' => "This is a new prompt for this option", +// 'Help' => "This is some new help for this option which will be displayed in the popup window when the ? is clicked" +// ), +); + +?> diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 0fca2f81d..721a86253 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -237,6 +237,7 @@ $SLANG = array( 'Cause' => 'Cause', 'CheckMethod' => 'Alarm Check Method', 'ChooseDetectedCamera' => 'Choose Detected Camera', + 'ChooseDetectedProfile' => 'Choose Detected Profile', 'ChooseFilter' => 'Choose Filter', 'ChooseLogFormat' => 'Choose a log format', 'ChooseLogSelection' => 'Choose a log selection', @@ -583,6 +584,9 @@ $SLANG = array( 'Parameter' => 'Parameter', 'Password' => 'Password', 'PasswordsDifferent' => 'The new and confirm passwords are different', + 'PathToIndex' => 'Path To Index', + 'PathToZMS' => 'Path To ZMS', + 'PathToApi' => 'Path To Api', 'Paths' => 'Paths', 'Pause' => 'Pause', 'PhoneBW' => 'Phone B/W', diff --git a/web/lang/ro_ro.php b/web/lang/ro_ro.php index 1f2d17e2e..5526be753 100644 --- a/web/lang/ro_ro.php +++ b/web/lang/ro_ro.php @@ -882,10 +882,6 @@ $OLANG = array( 'Prompt' => "Directorul în care sunt stocate evenimentele", 'Help' => "Acesta este subdirectorul în care sunt salvate imaginile generate de evenimente şi alte fişiere. Implicit este un subdirector al directorului rădăcina zoneminder; dacă spaţiul nu vă permite puteţi să stocaţi imaginile pe altă partiţie, caz în care ar trebui să faceţi un link la subdirectorul implicit." ), - 'DIR_IMAGES' => array( - 'Prompt' => "Directorul în care sunt stocate imaginile", - 'Help' => "ZoneMinder generează multe imagini, majoritate asociate cu evenimente. În acest director vor fi stocate imaginile neasociate evenimentelor." - ), 'DIR_SOUNDS' => array( 'Prompt' => "Directorul cu sunetele care pot fi folosite de ZoneMinder", 'Help' => "ZoneMinder poate rula un sunet atunci când este detectată o alarmă. Acesta este directorul în care este stocat sunetul care va fi rulat." diff --git a/web/skins/classic/css/base/jquery-ui-theme.css b/web/skins/classic/css/base/jquery-ui-theme.css deleted file mode 100644 index c50986c55..000000000 --- a/web/skins/classic/css/base/jquery-ui-theme.css +++ /dev/null @@ -1,410 +0,0 @@ -/*! - * jQuery UI CSS Framework 1.11.3 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/theming/ - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&fwDefault=normal&cornerRadius=3px&bgColorHeader=e9e9e9&bgTextureHeader=flat&borderColorHeader=dddddd&fcHeader=333333&iconColorHeader=444444&bgColorContent=ffffff&bgTextureContent=flat&borderColorContent=dddddd&fcContent=333333&iconColorContent=444444&bgColorDefault=f6f6f6&bgTextureDefault=flat&borderColorDefault=c5c5c5&fcDefault=454545&iconColorDefault=777777&bgColorHover=ededed&bgTextureHover=flat&borderColorHover=cccccc&fcHover=2b2b2b&iconColorHover=555555&bgColorActive=007fff&bgTextureActive=flat&borderColorActive=003eff&fcActive=ffffff&iconColorActive=ffffff&bgColorHighlight=fffa90&bgTextureHighlight=flat&borderColorHighlight=dad55e&fcHighlight=777620&iconColorHighlight=777620&bgColorError=fddfdf&bgTextureError=flat&borderColorError=f1a899&fcError=5f3f3f&iconColorError=cc0000&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=666666&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=5px&offsetTopShadow=0px&offsetLeftShadow=0px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget-content { - border: 1px solid #dddddd; - background: #ffffff; - color: #333333; -} -.ui-widget-content a { - color: #333333; -} -.ui-widget-header { - border: 1px solid #dddddd; - background: #e9e9e9; - color: #333333; - font-weight: bold; -} -.ui-widget-header a { - color: #333333; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - border: 1px solid #c5c5c5; - background: #f6f6f6; - font-weight: normal; - color: #454545; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited { - color: #454545; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus { - border: 1px solid #cccccc; - background: #ededed; - font-weight: normal; - color: #2b2b2b; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited { - color: #2b2b2b; - text-decoration: none; -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #003eff; - background: #007fff; - font-weight: normal; - color: #ffffff; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #ffffff; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #dad55e; - background: #fffa90; - color: #777620; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #777620; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #f1a899; - background: #fddfdf; - color: #5f3f3f; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #5f3f3f; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #5f3f3f; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); /* support: IE8 */ - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); /* support: IE8 */ - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_444444_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_444444_256x240.png"); -} -.ui-state-default .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_555555_256x240.png"); -} -.ui-state-active .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_ffffff_256x240.png"); -} -.ui-state-highlight .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777620_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_cc0000_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 3px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #aaaaaa; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ -} -.ui-widget-shadow { - margin: 0px 0 0 0px; - padding: 5px; - background: #666666; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ - border-radius: 8px; -} diff --git a/web/skins/classic/css/base/skin.css b/web/skins/classic/css/base/skin.css index 3fdd5a12f..069952d40 100644 --- a/web/skins/classic/css/base/skin.css +++ b/web/skins/classic/css/base/skin.css @@ -150,6 +150,7 @@ input,textarea,select,button,.btn-primary { font-weight: 400; font-size: 100%; color: #333333; + background-color: #f8f8f8; text-align: left; border-radius:4px; } @@ -341,17 +342,17 @@ fieldset > legend { /* * Behavior classes */ -.alarm, .errorText, .error { - color: #ff3f34; -} -.alert, .warnText, .warning { - color: #ffa801; -} .ok, .infoText { color: #0fb9b1; } +.alert, .warnText, .warning, .disabledText { + color: #ffa801; +} +.alarm, .errorText, .error { + color: #ff3f34; +} .fakelink { color: #7f7fb2; diff --git a/web/skins/classic/css/classic/jquery-ui-theme.css b/web/skins/classic/css/classic/jquery-ui-theme.css deleted file mode 100644 index c50986c55..000000000 --- a/web/skins/classic/css/classic/jquery-ui-theme.css +++ /dev/null @@ -1,410 +0,0 @@ -/*! - * jQuery UI CSS Framework 1.11.3 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/theming/ - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&fwDefault=normal&cornerRadius=3px&bgColorHeader=e9e9e9&bgTextureHeader=flat&borderColorHeader=dddddd&fcHeader=333333&iconColorHeader=444444&bgColorContent=ffffff&bgTextureContent=flat&borderColorContent=dddddd&fcContent=333333&iconColorContent=444444&bgColorDefault=f6f6f6&bgTextureDefault=flat&borderColorDefault=c5c5c5&fcDefault=454545&iconColorDefault=777777&bgColorHover=ededed&bgTextureHover=flat&borderColorHover=cccccc&fcHover=2b2b2b&iconColorHover=555555&bgColorActive=007fff&bgTextureActive=flat&borderColorActive=003eff&fcActive=ffffff&iconColorActive=ffffff&bgColorHighlight=fffa90&bgTextureHighlight=flat&borderColorHighlight=dad55e&fcHighlight=777620&iconColorHighlight=777620&bgColorError=fddfdf&bgTextureError=flat&borderColorError=f1a899&fcError=5f3f3f&iconColorError=cc0000&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=666666&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=5px&offsetTopShadow=0px&offsetLeftShadow=0px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget-content { - border: 1px solid #dddddd; - background: #ffffff; - color: #333333; -} -.ui-widget-content a { - color: #333333; -} -.ui-widget-header { - border: 1px solid #dddddd; - background: #e9e9e9; - color: #333333; - font-weight: bold; -} -.ui-widget-header a { - color: #333333; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - border: 1px solid #c5c5c5; - background: #f6f6f6; - font-weight: normal; - color: #454545; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited { - color: #454545; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus { - border: 1px solid #cccccc; - background: #ededed; - font-weight: normal; - color: #2b2b2b; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited { - color: #2b2b2b; - text-decoration: none; -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #003eff; - background: #007fff; - font-weight: normal; - color: #ffffff; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #ffffff; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #dad55e; - background: #fffa90; - color: #777620; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #777620; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #f1a899; - background: #fddfdf; - color: #5f3f3f; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #5f3f3f; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #5f3f3f; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); /* support: IE8 */ - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); /* support: IE8 */ - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_444444_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_444444_256x240.png"); -} -.ui-state-default .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_555555_256x240.png"); -} -.ui-state-active .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_ffffff_256x240.png"); -} -.ui-state-highlight .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777620_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_cc0000_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 3px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 3px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #aaaaaa; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ -} -.ui-widget-shadow { - margin: 0px 0 0 0px; - padding: 5px; - background: #666666; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ - border-radius: 8px; -} diff --git a/web/skins/classic/css/classic/skin.css b/web/skins/classic/css/classic/skin.css index ecd9f3949..b90412093 100644 --- a/web/skins/classic/css/classic/skin.css +++ b/web/skins/classic/css/classic/skin.css @@ -85,7 +85,8 @@ input,textarea,select,button { border: 1px #7f7fb2 solid; font-family: inherit; font-size: 100%; - color: #333333; + color: #333333; + background-color: #eeeeee; } input[type=text], input[type=password], textarea { diff --git a/web/skins/classic/css/dark/jquery-ui-theme.css b/web/skins/classic/css/dark/jquery-ui-theme.css deleted file mode 100644 index 6288b262e..000000000 --- a/web/skins/classic/css/dark/jquery-ui-theme.css +++ /dev/null @@ -1,410 +0,0 @@ -/*! - * jQuery UI CSS Framework 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/theming/ - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Arial%2CHelvetica%2Csans-serif&fsDefault=1em&fwDefault=normal&cornerRadius=2px&bgColorHeader=%23222222&bgTextureHeader=flat&borderColorHeader=%23222222&fcHeader=%23eeeeee&iconColorHeader=%23777777&bgColorContent=%23222222&bgTextureContent=flat&borderColorContent=%23dddddd&fcContent=%23dddddd&iconColorContent=%23444444&bgColorDefault=%23444444&bgTextureDefault=flat&borderColorDefault=%23444444&fcDefault=%23eeeeee&iconColorDefault=%23777777&bgColorHover=%23555555&bgTextureHover=flat&borderColorHover=%23444444&fcHover=%23eeeeee&iconColorHover=%23777777&bgColorActive=%23666666&bgTextureActive=flat&borderColorActive=%23666666&fcActive=%23eeeeee&iconColorActive=%23777777&bgColorHighlight=%23222222&bgTextureHighlight=flat&borderColorHighlight=%23777777&fcHighlight=%23eeeeee&iconColorHighlight=%23777777&bgColorError=%23fddfdf&bgTextureError=flat&borderColorError=%23f1a899&fcError=%235f3f3f&iconColorError=%23cc0000&bgColorOverlay=%23aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=%23666666&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=5px&offsetTopShadow=0px&offsetLeftShadow=0px&cornerRadiusShadow=8px&bgImgOpacityHeader=&bgImgOpacityContent=&bgImgOpacityDefault=&bgImgOpacityHover=&bgImgOpacityActive=&bgImgOpacityHighlight=&bgImgOpacityError= - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget .ui-widget { - font-size: 1em; -} -.ui-widget input, -.ui-widget select, -.ui-widget textarea, -.ui-widget button { - font-family: Arial,Helvetica,sans-serif; - font-size: 1em; -} -.ui-widget-content { - border: 1px solid #dddddd; - background: #222222; - color: #dddddd; -} -.ui-widget-content a { - color: #dddddd; -} -.ui-widget-header { - border: 1px solid #222222; - background: #222222; - color: #eeeeee; - font-weight: bold; -} -.ui-widget-header a { - color: #eeeeee; -} - -/* Interaction states -----------------------------------*/ -.ui-state-default, -.ui-widget-content .ui-state-default, -.ui-widget-header .ui-state-default { - border: 1px solid #444444; - background: #444444; - font-weight: normal; - color: #eeeeee; -} -.ui-state-default a, -.ui-state-default a:link, -.ui-state-default a:visited { - color: #eeeeee; - text-decoration: none; -} -.ui-state-hover, -.ui-widget-content .ui-state-hover, -.ui-widget-header .ui-state-hover, -.ui-state-focus, -.ui-widget-content .ui-state-focus, -.ui-widget-header .ui-state-focus { - border: 1px solid #444444; - background: #555555; - font-weight: normal; - color: #eeeeee; -} -.ui-state-hover a, -.ui-state-hover a:hover, -.ui-state-hover a:link, -.ui-state-hover a:visited, -.ui-state-focus a, -.ui-state-focus a:hover, -.ui-state-focus a:link, -.ui-state-focus a:visited { - color: #eeeeee; - text-decoration: none; -} -.ui-state-active, -.ui-widget-content .ui-state-active, -.ui-widget-header .ui-state-active { - border: 1px solid #666666; - background: #666666; - font-weight: normal; - color: #eeeeee; -} -.ui-state-active a, -.ui-state-active a:link, -.ui-state-active a:visited { - color: #eeeeee; - text-decoration: none; -} - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, -.ui-widget-content .ui-state-highlight, -.ui-widget-header .ui-state-highlight { - border: 1px solid #777777; - background: #222222; - color: #eeeeee; -} -.ui-state-highlight a, -.ui-widget-content .ui-state-highlight a, -.ui-widget-header .ui-state-highlight a { - color: #eeeeee; -} -.ui-state-error, -.ui-widget-content .ui-state-error, -.ui-widget-header .ui-state-error { - border: 1px solid #f1a899; - background: #fddfdf; - color: #5f3f3f; -} -.ui-state-error a, -.ui-widget-content .ui-state-error a, -.ui-widget-header .ui-state-error a { - color: #5f3f3f; -} -.ui-state-error-text, -.ui-widget-content .ui-state-error-text, -.ui-widget-header .ui-state-error-text { - color: #5f3f3f; -} -.ui-priority-primary, -.ui-widget-content .ui-priority-primary, -.ui-widget-header .ui-priority-primary { - font-weight: bold; -} -.ui-priority-secondary, -.ui-widget-content .ui-priority-secondary, -.ui-widget-header .ui-priority-secondary { - opacity: .7; - filter:Alpha(Opacity=70); /* support: IE8 */ - font-weight: normal; -} -.ui-state-disabled, -.ui-widget-content .ui-state-disabled, -.ui-widget-header .ui-state-disabled { - opacity: .35; - filter:Alpha(Opacity=35); /* support: IE8 */ - background-image: none; -} -.ui-state-disabled .ui-icon { - filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ -} - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { - width: 16px; - height: 16px; -} -.ui-icon, -.ui-widget-content .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_444444_256x240.png"); -} -.ui-widget-header .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-default .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-hover .ui-icon, -.ui-state-focus .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-active .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-highlight .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_777777_256x240.png"); -} -.ui-state-error .ui-icon, -.ui-state-error-text .ui-icon { - background-image: url("../skins/classic/graphics/ui-icons_cc0000_256x240.png"); -} - -/* positioning */ -.ui-icon-blank { background-position: 16px 16px; } -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-on { background-position: -96px -144px; } -.ui-icon-radio-off { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, -.ui-corner-top, -.ui-corner-left, -.ui-corner-tl { - border-top-left-radius: 2px; -} -.ui-corner-all, -.ui-corner-top, -.ui-corner-right, -.ui-corner-tr { - border-top-right-radius: 2px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-left, -.ui-corner-bl { - border-bottom-left-radius: 2px; -} -.ui-corner-all, -.ui-corner-bottom, -.ui-corner-right, -.ui-corner-br { - border-bottom-right-radius: 2px; -} - -/* Overlays */ -.ui-widget-overlay { - background: #aaaaaa; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ -} -.ui-widget-shadow { - margin: 0px 0 0 0px; - padding: 5px; - background: #666666; - opacity: .3; - filter: Alpha(Opacity=30); /* support: IE8 */ - border-radius: 8px; -} diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index ceb12d621..196c9fe89 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -81,10 +81,10 @@ echo output_link_if_exists( array( 'css/'.$css.'/skin.css', 'css/base/views/'.$basename.'.css', 'css/'.$css.'/views/'.$basename.'.css', - '/js/dateTimePicker/jquery-ui-timepicker-addon.css', - '/js/jquery-ui-1.12.1/jquery-ui.structure.min.css', - '/css/jquery-ui-1.12.1/jquery-ui.theme.min.css', - '/css/'.$css.'/jquery-ui-theme.css', + 'js/dateTimePicker/jquery-ui-timepicker-addon.css', + 'js/jquery-ui-1.12.1/jquery-ui.structure.min.css', + 'js/jquery-ui-1.12.1/jquery-ui.theme.min.css', + 'css/'.$css.'/jquery-ui-theme.css', ) ); ?> @@ -119,6 +119,7 @@ echo output_link_if_exists( array( + - - "> @@ -208,6 +201,23 @@ echo output_link_if_exists( array( + +'; + global $error_message; + if ( $error_message ) { + echo '
'.$error_message.'
'; + } +} // end function getBodyTopHTML + function getNavBarHTML($reload = null) { # Provide a facility to turn off the headers if you put headers=0 into the url if ( isset($_REQUEST['navbar']) and $_REQUEST['navbar']=='0' ) @@ -235,11 +245,6 @@ function getNavBarHTML($reload = null) { $running = daemonCheck(); $status = $running?translate('Running'):translate('Stopped'); ?> -