diff --git a/.travis.yml b/.travis.yml index cd9a44b9a..3afa0f02a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: cpp sudo: required dist: trusty +git: + depth: 9999999 notifications: irc: chat.freenode.net#zoneminder-dev branches: @@ -20,6 +22,7 @@ addons: - git - curl - sshfs + - sed env: matrix: - OS=el DIST=6 diff --git a/distros/ubuntu1204/NEWS b/distros/ubuntu1204/NEWS index 6200726cf..e69de29bb 100644 --- a/distros/ubuntu1204/NEWS +++ b/distros/ubuntu1204/NEWS @@ -1,10 +0,0 @@ -zoneminder (1.28.1-1) unstable; urgency=low - - This version is no longer automatically initialize or upgrade database. - See README.Debian for details. - - Changed installation paths (please correct your web server configuration): - /usr/share/zoneminder --> /usr/share/zoneminder/www - /usr/lib/cgi-bin --> /usr/lib/zoneminder/cgi-bin - - -- Dmitry Smirnov Tue, 31 Mar 2015 15:12:17 +1100 diff --git a/distros/ubuntu1204/changelog b/distros/ubuntu1204/changelog new file mode 100644 index 000000000..e69de29bb diff --git a/distros/ubuntu1204/patches/default_cgi-path.patch b/distros/ubuntu1204/patches/default_cgi-path.patch deleted file mode 100644 index 8bfc2ba06..000000000 --- a/distros/ubuntu1204/patches/default_cgi-path.patch +++ /dev/null @@ -1,16 +0,0 @@ -Last-Update: 2015-08-16 -Forwarded: no -Author: Dmitry Smirnov -Description: correct path to CGI app according to default web server configuration. - ---- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in -+++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in -@@ -428,7 +428,7 @@ our @options = - }, - { - name => "ZM_PATH_ZMS", -- default => "/cgi-bin/nph-zms", -+ default => "/zm/cgi-bin/nph-zms", - description => "Web path to zms streaming server", - help => qqq(" - The ZoneMinder streaming server is required to send streamed diff --git a/distros/ubuntu1204/patches/series b/distros/ubuntu1204/patches/series index fc70f4006..e69de29bb 100644 --- a/distros/ubuntu1204/patches/series +++ b/distros/ubuntu1204/patches/series @@ -1,2 +0,0 @@ -default_cgi-path.patch -use_libjs-mootools.patch diff --git a/distros/ubuntu1204/patches/use_libjs-mootools.patch b/distros/ubuntu1204/patches/use_libjs-mootools.patch deleted file mode 100644 index b3925f6d0..000000000 --- a/distros/ubuntu1204/patches/use_libjs-mootools.patch +++ /dev/null @@ -1,18 +0,0 @@ -Last-Update: 2015-03-29 -Forwarded: no -Bug-Debian: http://bugs.debian.org/585590 -Reviewed-By: Dmitry Smirnov -Description: use mootools shipped by debian, rather than the zoneminder included mootools. - ---- a/web/skins/classic/includes/functions.php -+++ b/web/skins/classic/includes/functions.php -@@ -63,9 +63,8 @@ - } - ?> - - -- - - - Uploaders: Vagrant Cascadian Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree ,cmake + ,libx264-dev, libmp4v2-dev ,libboost-dev ,libavdevice-dev (>= 6:10~) ,libavcodec-dev (>= 6:10~) @@ -15,7 +16,7 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa ,libgcrypt-dev ,libcurl4-gnutls-dev ,libgnutls-openssl-dev - ,libjpeg-dev + ,libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev ,libmysqlclient-dev ,libpcre3-dev ,libpolkit-gobject-1-dev @@ -27,12 +28,10 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa ,libsys-mmap-perl [!hurd-any] ,libwww-perl ,libdata-uuid-perl - ,libx264-dev - ,libmp4v2-dev # Unbundled (dh_linktree): ,libjs-jquery ,libjs-mootools -Standards-Version: 3.9.6 +Standards-Version: 3.9.8 Homepage: http://www.zoneminder.com/ Vcs-Browser: http://anonscm.debian.org/cgit/collab-maint/zoneminder.git Vcs-Git: git://anonscm.debian.org/collab-maint/zoneminder.git @@ -41,11 +40,10 @@ Package: zoneminder Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,javascript-common + ,libmp4v2-2, libx264-142|libx264-148, libswscale-ffmpeg3|libswscale4|libswscale3 ,ffmpeg | libav-tools - ,libdate-manip-perl + ,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl ,libdbd-mysql-perl - ,libmime-lite-perl - ,libmime-tools-perl ,libphp-serialization-perl ,libmodule-load-conditional-perl ,libnet-sftp-foreign-perl @@ -66,10 +64,11 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,libdata-uuid-perl ,mysql-client | virtual-mysql-client ,perl-modules - ,php5-mysql | php-mysql, php5-gd | php-gd, php-apcu, php-apcu-bc | php-gd + ,php5-mysql | php-mysql, php5-gd | php-gd , php5-apcu | php-apcu , php-apc | php-apcu-bc ,policykit-1 ,rsyslog | system-log-daemon ,zip + ,libpcre3 Recommends: ${misc:Recommends} ,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm ,mysql-server | virtual-mysql-server diff --git a/distros/ubuntu1604/patches/series b/distros/ubuntu1604/patches/series index fc70f4006..e69de29bb 100644 --- a/distros/ubuntu1604/patches/series +++ b/distros/ubuntu1604/patches/series @@ -1,2 +0,0 @@ -default_cgi-path.patch -use_libjs-mootools.patch diff --git a/distros/ubuntu1604/rules b/distros/ubuntu1604/rules index c7fb00198..e3b235be8 100755 --- a/distros/ubuntu1604/rules +++ b/distros/ubuntu1604/rules @@ -28,7 +28,7 @@ override_dh_auto_configure: override_dh_clean: dh_clean $(MANPAGES1) - $(RM) -r docs/_build docs/installationguide + $(RM) -r docs/_build build-indep: #$(MAKE) -C docs text diff --git a/distros/ubuntu1604/source/format b/distros/ubuntu1604/source/format index 89ae9db8f..163aaf8d8 100644 --- a/distros/ubuntu1604/source/format +++ b/distros/ubuntu1604/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt) diff --git a/distros/ubuntu1604/zoneminder.install b/distros/ubuntu1604/zoneminder.install index 8a26777c0..b0b1ad5b6 100644 --- a/distros/ubuntu1604/zoneminder.install +++ b/distros/ubuntu1604/zoneminder.install @@ -3,6 +3,7 @@ usr/bin usr/lib/zoneminder usr/share/polkit-1 usr/share/zoneminder/db +usr/share/zoneminder/icons usr/share/zoneminder/www # libzoneminder-perl files: diff --git a/distros/ubuntu1604/zoneminder.logrotate b/distros/ubuntu1604/zoneminder.logrotate index 18fc6b0a0..59238b7fe 100644 --- a/distros/ubuntu1604/zoneminder.logrotate +++ b/distros/ubuntu1604/zoneminder.logrotate @@ -2,6 +2,8 @@ missingok notifempty sharedscripts + delaycompress + compress postrotate /usr/bin/zmpkg.pl logrot >>/dev/null 2>&1 || : endscript diff --git a/distros/ubuntu1604/zoneminder.menu b/distros/ubuntu1604/zoneminder.menu new file mode 100644 index 000000000..fa3f3ff36 --- /dev/null +++ b/distros/ubuntu1604/zoneminder.menu @@ -0,0 +1,2 @@ +?package(zoneminder):needs="x11" section="Applications/Video" title="ZoneMinder" command="/usr/bin/x-www-browser http://localhost/zm" icon="/usr/share/zoneminder/icons/16x16/icon.xpm" + diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index 05f0c0448..a8f93c4d0 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -12,6 +12,10 @@ if [ "$1" = "configure" ]; then if [ -z "$2" ]; then chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* fi + if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ]; then + echo "The cgi module is not enabled in apache2. I am enabling it using a2enmod cgi." + a2enmod cgi + fi # Do this every time the package is installed or upgraded diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 0082707c6..29efe85ca 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -49,7 +49,7 @@ our %EXPORT_TAGS = ( ); push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'data'} } ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{data} } ); our @EXPORT = qw(); @@ -72,152 +72,146 @@ sub INIT { # Types our %types = ( string => { - db_type => "string", - hint => "string", - pattern => qr|^(.+)$|, - format => q( $1 ) - }, - alphanum => { - db_type => "string", - hint => "alphanumeric", - pattern => qr|^([a-zA-Z0-9-_]+)$|, - format => q( $1 ) - }, - text => { - db_type => "text", - hint => "free text", - pattern => qr|^(.+)$|, - format => q( $1 ) - }, - boolean => { - db_type => "boolean", - hint => "yes|no", - pattern => qr|^([yn])|i, - check => q( $1 ), - format => q( ($1 =~ /^y/) ? "yes" : "no" ) - }, - integer => { - db_type => "integer", - hint => "integer", - pattern => qr|^(\d+)$|, - format => q( $1 ) - }, - decimal => { - db_type => "decimal", - hint => "decimal", - pattern => qr|^(\d+(?:\.\d+)?)$|, - format => q( $1 ) - }, - hexadecimal => { - db_type => "hexadecimal", - hint => "hexadecimal", - pattern => qr|^(?:0x)?([0-9a-f]{1,8})$|, - format => q( "0x".$1 ) - }, - tristate => { - db_type => "string", - hint => "auto|yes|no", - pattern => qr|^([ayn])|i, check=>q( $1 ), - format => q( ($1 =~ /^y/) ? "yes" : ($1 =~ /^n/ ? "no" : "auto" ) ) - }, - abs_path => { - db_type => "string", - hint => "/absolute/path/to/somewhere", - pattern => qr|^((?:/[^/]*)+?)/?$|, - format => q( $1 ) - }, - rel_path => { - db_type => "string", - hint => "relative/path/to/somewhere", - pattern => qr|^((?:[^/].*)?)/?$|, - format => q( $1 ) - }, - directory => { - db_type => "string", - hint => "directory", - pattern => qr|^([a-zA-Z0-9-_.]+)$|, - format => q( $1 ) - }, - file => { - db_type => "string", - hint => "filename", - pattern => qr|^([a-zA-Z0-9-_.]+)$|, - format => q( $1 ) - }, - hostname => { - db_type => "string", - hint => "host.your.domain", - pattern => qr|^([a-zA-Z0-9_.-]+)$|, - format => q( $1 ) - }, - url => { - db_type => "string", - hint => "http://host.your.domain/", - pattern => qr|^(?:http://)?(.+)$|, - format => q( "http://".$1 ) - }, - email => { - db_type => "string", - hint => "your.name\@your.domain", - pattern => qr|^([a-zA-Z0-9_.-]+)\@([a-zA-Z0-9_.-]+)$|, - format => q( $1\@$2 ) - }, - ); - -sub qqq { ## Un-pad paragraph of text. - local $_ = shift; - s{\n?^\s*}{ }mg; - return $_; -} + db_type => 'string', + hint => 'string', + pattern => qr|^(.+)$|, + format => q( $1 ) + }, + alphanum => { + db_type => 'string', + hint => 'alphanumeric', + pattern => qr|^([a-zA-Z0-9-_]+)$|, + format => q( $1 ) + }, + text => { + db_type => 'text', + hint => 'free text', + pattern => qr|^(.+)$|, + format => q( $1 ) + }, + boolean => { + db_type => 'boolean', + hint => 'yes|no', + pattern => qr|^([yn])|i, + check => q( $1 ), + format => q( ($1 =~ /^y/) ? 'yes' : 'no' ) + }, + integer => { + db_type => 'integer', + hint => 'integer', + pattern => qr|^(\d+)$|, + format => q( $1 ) + }, + decimal => { + db_type => 'decimal', + hint => 'decimal', + pattern => qr|^(\d+(?:\.\d+)?)$|, + format => q( $1 ) + }, + hexadecimal => { + db_type => 'hexadecimal', + hint => 'hexadecimal', + pattern => qr|^(?:0x)?([0-9a-f]{1,8})$|, + format => q( '0x'.$1 ) + }, + tristate => { + db_type => 'string', + hint => 'auto|yes|no', + pattern => qr|^([ayn])|i, check=>q( $1 ), + format => q( ($1 =~ /^y/) ? 'yes' : ($1 =~ /^n/ ? 'no' : 'auto' ) ) + }, + abs_path => { + db_type => 'string', + hint => '/absolute/path/to/somewhere', + pattern => qr|^((?:/[^/]*)+?)/?$|, + format => q( $1 ) + }, + rel_path => { + db_type => 'string', + hint => 'relative/path/to/somewhere', + pattern => qr|^((?:[^/].*)?)/?$|, + format => q( $1 ) + }, + directory => { + db_type => 'string', + hint => 'directory', + pattern => qr|^([a-zA-Z0-9-_.]+)$|, + format => q( $1 ) + }, + file => { + db_type => 'string', + hint => 'filename', + pattern => qr|^([a-zA-Z0-9-_.]+)$|, + format => q( $1 ) + }, + hostname => { + db_type => 'string', + hint => 'host.your.domain', + pattern => qr|^([a-zA-Z0-9_.-]+)$|, + format => q( $1 ) + }, + url => { + db_type => 'string', + hint => 'http://host.your.domain/', + pattern => qr|^(?:http://)?(.+)$|, + format => q( 'http://'.$1 ) + }, + email => { + db_type => 'string', + hint => 'your.name@your.domain', + pattern => qr|^([a-zA-Z0-9_.-]+)\@([a-zA-Z0-9_.-]+)$|, + format => q( $1\@$2 ) + }, +); our @options = ( { - name => "ZM_SKIN_DEFAULT", - default => "classic", - description => "Default skin used by web interface", + name => 'ZM_SKIN_DEFAULT', + default => 'classic', + description => 'Default skin used by web interface', - help => qqq(" + help => q` ZoneMinder allows the use of many different web interfaces. This option allows you to set the default skin used by the website. Users can change their skin later, this merely sets the default. - "), + `, type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_CSS_DEFAULT", - default => "classic", - description => "Default set of css files used by web interface", - help => qqq(" + name => 'ZM_CSS_DEFAULT', + default => 'classic', + description => 'Default set of css files used by web interface', + help => q` ZoneMinder allows the use of many different web interfaces, and some skins allow the use of different set of CSS files to control the appearance. This option allows you to set the default set of css files used by the website. Users can change their css later, this merely sets the default. - "), + `, type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_LANG_DEFAULT", - default => "en_gb", - description => "Default language used by web interface", - help => qqq(" + name => 'ZM_LANG_DEFAULT', + default => 'en_gb', + description => 'Default language used by web interface', + help => q` ZoneMinder allows the web interface to use languages other than English if the appropriate language file has been created and is present. This option allows you to change the default language that is used from the shipped language, British English, to another language - "), + `, type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_OPT_USE_AUTH", - default => "no", - description => "Authenticate user logins to ZoneMinder", - help => qqq(" + name => 'ZM_OPT_USE_AUTH', + default => 'no', + description => 'Authenticate user logins to ZoneMinder', + help => q` ZoneMinder can run in two modes. The simplest is an entirely unauthenticated mode where anyone can access ZoneMinder and perform all tasks. This is most suitable for installations @@ -225,15 +219,15 @@ our @options = ( mode enables user accounts with varying sets of permissions. Users must login or authenticate to access ZoneMinder and are limited by their defined permissions. - "), + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_AUTH_TYPE", - default => "builtin", - description => "What is used to authenticate ZoneMinder users", - help => qqq(" + name => 'ZM_AUTH_TYPE', + default => 'builtin', + description => 'What is used to authenticate ZoneMinder users', + help => q` ZoneMinder can use two methods to authenticate users when running in authenticated mode. The first is a builtin method where ZoneMinder provides facilities for users to log in and @@ -243,21 +237,21 @@ our @options = ( 'remote' user via http. In this case ZoneMinder would use the supplied user without additional authentication provided such a user is configured ion ZoneMinder. - "), - requires => [ { name=>"ZM_OPT_USE_AUTH", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_USE_AUTH', value=>'yes' } ], type => { - db_type => "string", - hint => "builtin|remote", + db_type => 'string', + hint => 'builtin|remote', pattern => qr|^([br])|i, - format => q( $1 =~ /^b/ ? "builtin" : "remote" ) + format => q( $1 =~ /^b/ ? 'builtin' : 'remote' ) }, - category => "system", + category => 'system', }, { - name => "ZM_AUTH_RELAY", - default => "hashed", - description => "Method used to relay authentication information", - help => qqq(" + name => 'ZM_AUTH_RELAY', + default => 'hashed', + description => 'Method used to relay authentication information', + help => q` When ZoneMinder is running in authenticated mode it can pass user details between the web pages and the back end processes. There are two methods for doing this. This first is to use a @@ -268,39 +262,39 @@ our @options = ( your system or you have a completely isolated system with no external access. You can also switch off authentication relaying if your system is isolated in other ways. - "), - requires => [ { name=>"ZM_OPT_USE_AUTH", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_USE_AUTH', value=>'yes' } ], type => { - db_type => "string", - hint => "hashed|plain|none", + db_type => 'string', + hint => 'hashed|plain|none', pattern => qr|^([hpn])|i, - format => q( ($1 =~ /^h/) ? "hashed" : ($1 =~ /^p/ ? "plain" : "none" ) ) + format => q( ($1 =~ /^h/) ? 'hashed' : ($1 =~ /^p/ ? 'plain' : 'none' ) ) }, - category => "system", + category => 'system', }, { - name => "ZM_AUTH_HASH_SECRET", - default => "...Change me to something unique...", - description => "Secret for encoding hashed authentication information", - help => qqq(" + name => 'ZM_AUTH_HASH_SECRET', + default => '...Change me to something unique...', + description => 'Secret for encoding hashed authentication information', + help => q` When ZoneMinder is running in hashed authenticated mode it is necessary to generate hashed strings containing encrypted sensitive information such as usernames and password. Although these string are reasonably secure the addition of a random secret increases security substantially. - "), + `, requires => [ - { name=>"ZM_OPT_USE_AUTH", value=>"yes" }, - { name=>"ZM_AUTH_RELAY", value=>"hashed" } + { name=>'ZM_OPT_USE_AUTH', value=>'yes' }, + { name=>'ZM_AUTH_RELAY', value=>'hashed' } ], type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_AUTH_HASH_IPS", - default => "yes", - description => "Include IP addresses in the authentication hash", - help => qqq(" + name => 'ZM_AUTH_HASH_IPS', + default => 'yes', + description => 'Include IP addresses in the authentication hash', + help => q` When ZoneMinder is running in hashed authenticated mode it can optionally include the requesting IP address in the resultant hash. This adds an extra level of security as only requests @@ -311,19 +305,19 @@ our @options = ( whether IP addresses are included in the authentication hash on your system. If you experience intermitent problems with authentication, switching this option off may help. - "), + `, requires => [ - { name=>"ZM_OPT_USE_AUTH", value=>"yes" }, - { name=>"ZM_AUTH_RELAY", value=>"hashed" } + { name=>'ZM_OPT_USE_AUTH', value=>'yes' }, + { name=>'ZM_AUTH_RELAY', value=>'hashed' } ], type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_AUTH_HASH_LOGINS", - default => "no", - description => "Allow login by authentication hash", - help => qqq(" + name => 'ZM_AUTH_HASH_LOGINS', + default => 'no', + description => 'Allow login by authentication hash', + help => q` The normal process for logging into ZoneMinder is via the login screen with username and password. In some circumstances it may be desirable to allow access directly to one or more pages, for @@ -337,19 +331,19 @@ our @options = ( authentication hash itself and ensure it is valid. If you use this option you should ensure that you have modified the ZM_AUTH_HASH_SECRET to something unique to your system. - "), + `, requires => [ - { name=>"ZM_OPT_USE_AUTH", value=>"yes" }, - { name=>"ZM_AUTH_RELAY", value=>"hashed" } + { name=>'ZM_OPT_USE_AUTH', value=>'yes' }, + { name=>'ZM_AUTH_RELAY', value=>'hashed' } ], type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_ENABLE_CSRF_MAGIC", - default => "no", - description => "Enable csrf-magic library", - help => qqq(" + name => 'ZM_ENABLE_CSRF_MAGIC', + default => 'no', + description => 'Enable csrf-magic library', + help => q` CSRF stands for Cross-Site Request Forgery which, under specific circumstances, can allow an attacker to perform any task your ZoneMinder user account has permission to perform. To accomplish @@ -361,86 +355,83 @@ our @options = ( If you find a false positive and can document how to reproduce it, then please report it. This feature defaults to OFF currently due to its experimental nature. - "), + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_OPT_USE_API", - default => "yes", - description => "Enable ZoneMinder APIs", - help => qqq(" + name => 'ZM_OPT_USE_API', + default => 'yes', + description => 'Enable ZoneMinder APIs', + help => q` ZoneMinder now features a new API using which 3rd party - applications can interact with ZoneMinder data. It is + applications can interact with ZoneMinder data. It is STRONGLY recommended that you enable authentication along with APIs. Note that the APIs return sensitive data like Monitor access details which are configured as JSON objects. Which is why we recommend you enabling authentication, especially if you are exposing your ZM instance on the Internet. - "), + `, type => $types{boolean}, - category => "system", + category => 'system', }, # PP - Google reCaptcha settings { - name => "ZM_OPT_USE_GOOG_RECAPTCHA", - default => "no", - description => "Add Google reCaptcha to login page", - help => qqq(" - This option allows you to include a google + name => 'ZM_OPT_USE_GOOG_RECAPTCHA', + default => 'no', + description => 'Add Google reCaptcha to login page', + help => q` + This option allows you to include a google reCaptcha validation at login. This means in addition to providing - a valid usernane and password, you will also have to + a valid usernane and password, you will also have to pass the reCaptcha test. Please note that enabling this option results in the zoneminder login page reach out to google servers for captcha validation. Also please note that enabling this option will break 3rd party clients like zmNinja and zmView as they also need to login to ZoneMinder and they will fail the reCaptcha test. - "), + `, requires => [ - {name=>"ZM_OPT_USE_AUTH", value=>"yes"} + {name=>'ZM_OPT_USE_AUTH', value=>'yes'} ], type => $types{boolean}, - category => "system", + category => 'system', }, - { - name => "ZM_OPT_GOOG_RECAPTCHA_SITEKEY", - default => "...Insert your recaptcha site-key here...", - description => "Your recaptcha site-key", - help => qqq("You need to generate your keys from - the Google reCaptcha website. - Please refer to https://www.google.com/recaptcha/ + name => 'ZM_OPT_GOOG_RECAPTCHA_SITEKEY', + default => '...Insert your recaptcha site-key here...', + description => 'Your recaptcha site-key', + help => q`You need to generate your keys from + the Google reCaptcha website. + Please refer to https://www.google.com/recaptcha/ for more details. - "), + `, requires => [ - {name=>"ZM_OPT_USE_GOOG_RECAPTCHA", value=>"yes"} + {name=>'ZM_OPT_USE_GOOG_RECAPTCHA', value=>'yes'} ], type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_OPT_GOOG_RECAPTCHA_SECRETKEY", - default => "...Insert your recaptcha secret-key here...", - description => "Your recaptcha secret-key", - help => qqq("You need to generate your keys from - the Google reCaptcha website. - Please refer to https://www.google.com/recaptcha/ + name => 'ZM_OPT_GOOG_RECAPTCHA_SECRETKEY', + default => '...Insert your recaptcha secret-key here...', + description => 'Your recaptcha secret-key', + help => q`You need to generate your keys from + the Google reCaptcha website. + Please refer to https://www.google.com/recaptcha/ for more details. - "), + `, requires => [ - {name=>"ZM_OPT_USE_GOOG_RECAPTCHA", value=>"yes"} + {name=>'ZM_OPT_USE_GOOG_RECAPTCHA', value=>'yes'} ], type => $types{string}, - category => "system", + category => 'system', }, - - { - name => "ZM_DIR_EVENTS", - default => "events", - description => "Directory where events are stored", - help => qqq(" + name => 'ZM_DIR_EVENTS', + default => 'events', + description => 'Directory where events are stored', + help => q` This is the path to the events directory where all the event images and other miscellaneous files are stored. CAUTION: The directory you specify here cannot be outside the web root. This @@ -449,15 +440,15 @@ our @options = ( share, then you should mount the drive or share directly to the ZoneMinder events folder or follow the instructions in the ZoneMinder Wiki titled Using a dedicated Hard Drive. - "), + `, type => $types{directory}, - category => "paths", + category => 'paths', }, { - name => "ZM_USE_DEEP_STORAGE", - default => "yes", - description => "Use a deep filesystem hierarchy for events", - help => qqq(" + name => 'ZM_USE_DEEP_STORAGE', + default => 'yes', + description => 'Use a deep filesystem hierarchy for events', + help => q` This option is now the default for new ZoneMinder systems and should not be changed. Previous versions of ZoneMinder stored all events for a monitor under one folder. Enabling @@ -467,18 +458,18 @@ our @options = ( than 32k files in a single folder inherent in some filesystems. It is important to note that you cannot simply change this option. You must stop zoneminder, enable USE_DEEP_STORAGE, and - then run \"sudo zmupdate.pl --migrate-events\". FAILURE TO DO + then run "sudo zmupdate.pl --migrate-events". FAILURE TO DO SO WILL RESULT IN LOSS OF YOUR DATA! Consult the ZoneMinder WiKi for further details. - "), + `, type => $types{boolean}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_DIR_IMAGES", - default => "images", - description => "Directory where the images that the ZoneMinder client generates are stored", - help => qqq(" + name => 'ZM_DIR_IMAGES', + default => 'images', + description => 'Directory where the images that the ZoneMinder client generates are stored', + help => q` 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 @@ -488,42 +479,42 @@ our @options = ( or share directly to the ZoneMinder images folder or follow the instructions in the ZoneMinder Wiki titled Using a dedicated Hard Drive. - "), + `, type => $types{directory}, - category => "paths", + category => 'paths', }, { - name => "ZM_DIR_SOUNDS", - default => "sounds", - description => "Directory to the sounds that the ZoneMinder client can use", - help => qqq(" + name => 'ZM_DIR_SOUNDS', + default => 'sounds', + description => 'Directory to the sounds that the ZoneMinder client can use', + help => q` 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. - "), + `, type => $types{directory}, - category => "paths", + category => 'paths', }, { - name => "ZM_DIR_EXPORTS", - default => "@ZM_TMPDIR@", - description => "Directory where exported archives are stored", - help => qqq(" + name => 'ZM_DIR_EXPORTS', + default => '@ZM_TMPDIR@', + description => 'Directory where exported archives are stored', + help => q` This is the path to the exports directory where exported tar.gz and zip archives are stored. By default this points to ZoneMinder's temp folder, which often sits in ram. Since exported archives can potentially become large, it is a good idea to move this folder to some other location on machines with low memory. - "), + `, type => $types{directory}, - category => "paths", + category => 'paths', }, { - name => "ZM_PATH_ZMS", - default => "/cgi-bin/nph-zms", - description => "Web path to zms streaming server", - help => qqq(" + name => 'ZM_PATH_ZMS', + default => '/cgi-bin/nph-zms', + description => 'Web path to zms streaming server', + help => q` 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 @@ -532,15 +523,15 @@ our @options = ( 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'. - "), + `, type => $types{rel_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_COLOUR_JPEG_FILES", - default => "no", - description => "Colourise greyscale JPEG files", - help => qqq(" + name => 'ZM_COLOUR_JPEG_FILES', + default => 'no', + description => 'Colourise greyscale JPEG files', + help => q` Cameras that capture in greyscale can write their captured images to jpeg files with a corresponding greyscale colour space. This saves a small amount of disk space over colour @@ -548,15 +539,15 @@ our @options = ( with this colour space or have to convert it beforehand. Setting this option to yes uses up a little more space but makes creation of MPEG files much faster. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_ADD_JPEG_COMMENTS", - default => "no", - description => "Add jpeg timestamp annotations as file header comments", - help => qqq(" + name => 'ZM_ADD_JPEG_COMMENTS', + default => 'no', + description => 'Add jpeg timestamp annotations as file header comments', + help => q` JPEG files may have a number of extra fields added to the file header. The comment field may have any kind of text added. This options allows you to have the same text that is used to @@ -564,15 +555,15 @@ our @options = ( comment. If you archive event images to other locations this may help you locate images for particular events or times if you use software that can read comment headers. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_JPEG_FILE_QUALITY", - default => "70", - description => "Set the JPEG quality setting for the saved event files (1-100)", - help => qqq(" + name => 'ZM_JPEG_FILE_QUALITY', + default => '70', + description => 'Set the JPEG quality setting for the saved event files (1-100)', + help => q` When ZoneMinder detects an event it will save the images associated with that event to files. These files are in the JPEG format and can be viewed or streamed later. This option @@ -585,15 +576,15 @@ our @options = ( except if the capture image has caused an alarm and the alarm file quality option is set at a higher value when that is used instead. - "), + `, type => $types{integer}, - category => "images", + category => 'images', }, { - name => "ZM_JPEG_ALARM_FILE_QUALITY", - default => "0", - description => "Set the JPEG quality setting for the saved event files during an alarm (1-100)", - help => qqq(" + name => 'ZM_JPEG_ALARM_FILE_QUALITY', + default => '0', + description => 'Set the JPEG quality setting for the saved event files during an alarm (1-100)', + help => q` This value is equivalent to the regular jpeg file quality setting above except that it only applies to images saved while in an alarm state and then only if this value is set to a @@ -602,16 +593,16 @@ our @options = ( default of 0 effectively means to use the regular file quality setting for all saved images. This is to prevent acccidentally saving important images at a worse quality setting. - "), + `, type => $types{integer}, - category => "images", + category => 'images', }, # Deprecated, now stream quality { - name => "ZM_JPEG_IMAGE_QUALITY", - default => "70", - description => "Set the JPEG quality setting for the streamed 'live' images (1-100)", - help => qqq(" + name => 'ZM_JPEG_IMAGE_QUALITY', + default => '70', + description => q`Set the JPEG quality setting for the streamed 'live' images (1-100)`, + help => q` When viewing a 'live' stream for a monitor ZoneMinder will grab an image from the buffer and encode it into JPEG format before sending it. This option specifies what image quality should be @@ -622,15 +613,15 @@ our @options = ( does not apply when viewing events or still images as these are usually just read from disk and so will be encoded at the quality specified by the previous options. - "), + `, type => $types{integer}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_JPEG_STREAM_QUALITY", - default => "70", - description => "Set the JPEG quality setting for the streamed 'live' images (1-100)", - help => qqq(" + name => 'ZM_JPEG_STREAM_QUALITY', + default => '70', + description => q`Set the JPEG quality setting for the streamed 'live' images (1-100)`, + help => q` When viewing a 'live' stream for a monitor ZoneMinder will grab an image from the buffer and encode it into JPEG format before sending it. This option specifies what image quality should be @@ -641,15 +632,15 @@ our @options = ( does not apply when viewing events or still images as these are usually just read from disk and so will be encoded at the quality specified by the previous options. - "), + `, type => $types{integer}, - category => "images", + category => 'images', }, { - name => "ZM_MPEG_TIMED_FRAMES", - default => "yes", - description => "Tag video frames with a timestamp for more realistic streaming", - help => qqq(" + name => 'ZM_MPEG_TIMED_FRAMES', + default => 'yes', + description => 'Tag video frames with a timestamp for more realistic streaming', + help => q` When using streamed MPEG based video, either for live monitor streams or events, ZoneMinder can send the streams in two ways. If this option is selected then the timestamp for each frame, @@ -660,15 +651,15 @@ our @options = ( calculated and that is used to schedule frames instead. This option should be selected unless you encounter problems with your preferred streaming method. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_MPEG_LIVE_FORMAT", - default => "swf", - description => "What format 'live' video streams are played in", - help => qqq(" + name => 'ZM_MPEG_LIVE_FORMAT', + default => 'swf', + description => q`What format 'live' video streams are played in`, + help => q` When using MPEG mode ZoneMinder can output live video. However what formats are handled by the browser varies greatly between machines. This option allows you to specify a video format @@ -679,15 +670,15 @@ our @options = ( what, if anything, works on a Linux platform. If you find out please let me know! If this option is left blank then live streams will revert to being in motion jpeg format - "), + `, type => $types{string}, - category => "images", + category => 'images', }, { - name => "ZM_MPEG_REPLAY_FORMAT", - default => "swf", - description => "What format 'replay' video streams are played in", - help => qqq(" + name => 'ZM_MPEG_REPLAY_FORMAT', + default => 'swf', + description => q`What format 'replay' video streams are played in`, + help => q` 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 @@ -698,27 +689,27 @@ our @options = ( 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 - "), + `, type => $types{string}, - category => "images", + category => 'images', }, { - name => "ZM_RAND_STREAM", - default => "yes", - description => "Add a random string to prevent caching of streams", - help => qqq(" + name => 'ZM_RAND_STREAM', + default => 'yes', + 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 to the url to make each invocation of the stream appear unique. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_OPT_CAMBOZOLA", - default => "no", - description => "Is the (optional) cambozola java streaming client installed", - help => qqq(" + name => 'ZM_OPT_CAMBOZOLA', + default => 'no', + description => 'Is the (optional) cambozola java streaming client installed', + help => q` 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 @@ -726,15 +717,15 @@ our @options = ( from http://www.charliemouse.com/code/cambozola/ however if it is not installed still images at a lower refresh rate can still be viewed. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_PATH_CAMBOZOLA", - default => "cambozola.jar", - description => "Web path to (optional) cambozola java streaming client", - help => qqq(" + name => 'ZM_PATH_CAMBOZOLA', + default => 'cambozola.jar', + description => 'Web path to (optional) cambozola java streaming client', + help => q` 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 @@ -744,30 +735,30 @@ our @options = ( be viewed. Leave this as 'cambozola.jar' if cambozola is installed in the same directory as the ZoneMinder web client files. - "), - requires => [ { name=>"ZM_OPT_CAMBOZOLA", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_CAMBOZOLA', value=>'yes' } ], type => $types{rel_path}, - category => "images", + category => 'images', }, { - name => "ZM_RELOAD_CAMBOZOLA", - default => "0", - description => "After how many seconds should Cambozola be reloaded in live view", - help => qqq(" + name => 'ZM_RELOAD_CAMBOZOLA', + default => '0', + description => 'After how many seconds should Cambozola be reloaded in live view', + help => q` Cambozola allows for the viewing of streaming MJPEG however it caches the entire stream into cache space on the computer, setting this to a number > 0 will cause it to automatically reload after that many seconds to avoid filling up a hard drive. - "), + `, type => $types{integer}, - category => "images", + category => 'images', }, { - name => "ZM_TIMESTAMP_ON_CAPTURE", - default => "yes", - description => "Timestamp images as soon as they are captured", - help => qqq(" + name => 'ZM_TIMESTAMP_ON_CAPTURE', + default => 'yes', + description => 'Timestamp images as soon as they are captured', + help => q` ZoneMinder can add a timestamp to images in two ways. The default method, when this option is set, is that each image is timestamped immediately when captured and so the image held in @@ -784,30 +775,30 @@ our @options = ( desirable side effect that the timestamp is always applied at the same resolution so an image that has scaling applied will still have a legible and correctly scaled timestamp. - "), + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_CPU_EXTENSIONS", - default => "yes", - description => "Use advanced CPU extensions to increase performance", - help => qqq(" + name => 'ZM_CPU_EXTENSIONS', + default => 'yes', + description => 'Use advanced CPU extensions to increase performance', + help => q` When advanced processor extensions such as SSE2 or SSSE3 are available, ZoneMinder can use them, which should increase performance and reduce system load. Enabling this option on processors that do not support the advanced processors extensions used by ZoneMinder is harmless and will have no effect. - "), + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_FAST_IMAGE_BLENDS", - default => "yes", - description => "Use a fast algorithm to blend the reference image", - help => qqq(" + name => 'ZM_FAST_IMAGE_BLENDS', + default => 'yes', + description => 'Use a fast algorithm to blend the reference image', + help => q` To detect alarms ZoneMinder needs to blend the captured image with the stored reference image to update it for comparison with the next image. The reference blend percentage specified @@ -820,15 +811,15 @@ our @options = ( Any other blend percentage will be rounded to the nearest possible one. The alternative is to switch this option off and use standard blending instead, which is slower. - "), + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_OPT_ADAPTIVE_SKIP", - default => "yes", - description => "Should frame analysis try and be efficient in skipping frames", - help => qqq(" + name => 'ZM_OPT_ADAPTIVE_SKIP', + default => 'yes', + description => 'Should frame analysis try and be efficient in skipping frames', + help => q` In previous versions of ZoneMinder the analysis daemon would attempt to keep up with the capture daemon by processing the last captured frame on each pass. This would sometimes have the @@ -851,15 +842,15 @@ our @options = ( adaptive algorithm to be overwhelmed and not have time to react to a rapid build up of pending frames and thus for a buffer overrun condition to occur. - "), + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_MAX_SUSPEND_TIME", - default => "30", - description => "Maximum time that a monitor may have motion detection suspended", - help => qqq(" + name => 'ZM_MAX_SUSPEND_TIME', + default => '30', + description => 'Maximum time that a monitor may have motion detection suspended', + help => q` ZoneMinder allows monitors to have motion detection to be suspended, for instance while panning a camera. Ordinarily this relies on the operator resuming motion detection afterwards as @@ -869,29 +860,29 @@ our @options = ( motion detection. This time can be extended by subsequent suspend indications after the first so continuous camera movement will also occur while the monitor is suspended. - "), + `, type => $types{integer}, - category => "config", + category => 'config', }, # Deprecated, really no longer necessary { - name => "ZM_OPT_REMOTE_CAMERAS", - default => "no", - description => "Are you going to use remote/networked cameras", - help => qqq(" + name => 'ZM_OPT_REMOTE_CAMERAS', + default => 'no', + description => 'Are you going to use remote/networked cameras', + help => q` ZoneMinder can work with both local cameras, ie. those attached physically to your computer and remote or network cameras. If you will be using networked cameras select this option. - "), + `, type => $types{boolean}, - category => "hidden", + category => 'hidden', }, # Deprecated, now set on a per monitor basis using the Method field { - name => "ZM_NETCAM_REGEXPS", - default => "yes", - description => "Use regular expression matching with network cameras", - help => qqq(" + name => 'ZM_NETCAM_REGEXPS', + default => 'yes', + description => 'Use regular expression matching with network cameras', + help => q` Traditionally ZoneMinder has used complex regular regular expressions to handle the multitude of formats that network cameras produce. In versions from 1.21.1 the default is to use @@ -900,64 +891,64 @@ our @options = ( problems you can try the older, but more flexible, regular expression based method by selecting this option. Note, to use this method you must have libpcre installed on your system. - "), - requires => [ { name => "ZM_OPT_REMOTE_CAMERAS", value => "yes" } ], + `, + requires => [ { name => 'ZM_OPT_REMOTE_CAMERAS', value => 'yes' } ], type => $types{boolean}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_HTTP_VERSION", - default => "1.0", - description => "The version of HTTP that ZoneMinder will use to connect", - help => qqq(" + name => 'ZM_HTTP_VERSION', + default => '1.0', + description => 'The version of HTTP that ZoneMinder will use to connect', + help => q` ZoneMinder can communicate with network cameras using either of the HTTP/1.1 or HTTP/1.0 standard. A server will normally fall back to the version it supports with no problem so this should usually by left at the default. However it can be changed to HTTP/1.0 if necessary to resolve particular issues. - "), + `, type => { - db_type => "string", - hint => "1.1|1.0", + db_type => 'string', + hint => '1.1|1.0', pattern => qr|^(1\.[01])$|, - format => q( $1?$1:"" ) + format => q( $1?$1:'' ) }, - category => "network", + category => 'network', }, { - name => "ZM_HTTP_UA", - default => "ZoneMinder", - description => "The user agent that ZoneMinder uses to identify itself", - help => qqq(" + name => 'ZM_HTTP_UA', + default => 'ZoneMinder', + description => 'The user agent that ZoneMinder uses to identify itself', + help => q` When ZoneMinder communicates with remote cameras it will identify itself using this string and it's version number. This is normally sufficient, however if a particular cameras expects only to communicate with certain browsers then this can be changed to a different string identifying ZoneMinder as Internet Explorer or Netscape etc. - "), + `, type => $types{string}, - category => "network", + category => 'network', }, { - name => "ZM_HTTP_TIMEOUT", - default => "2500", - description => "How long ZoneMinder waits before giving up on images (milliseconds)", - help => qqq(" + name => 'ZM_HTTP_TIMEOUT', + default => '2500', + description => 'How long ZoneMinder waits before giving up on images (milliseconds)', + help => q` When retrieving remote images ZoneMinder will wait for this length of time before deciding that an image is not going to arrive and taking steps to retry. This timeout is in milliseconds (1000 per second) and will apply to each part of an image if it is not sent in one whole chunk. - "), + `, type => $types{integer}, - category => "network", + category => 'network', }, { - name => "ZM_MIN_RTP_PORT", - default => "40200", - description => "Minimum port that ZoneMinder will listen for RTP traffic on", - help => qqq(" + name => 'ZM_MIN_RTP_PORT', + default => '40200', + description => 'Minimum port that ZoneMinder will listen for RTP traffic on', + help => q` When ZoneMinder communicates with MPEG4 capable cameras using RTP with the unicast method it must open ports for the camera to connect back to for control and streaming purposes. This @@ -967,15 +958,15 @@ our @options = ( should be set to an even number, you may also need to open up a hole in your firewall to allow cameras to connect back if you wish to use unicasting. - "), + `, type => $types{integer}, - category => "network", + category => 'network', }, { - name => "ZM_MAX_RTP_PORT", - default => "40499", - description => "Maximum port that ZoneMinder will listen for RTP traffic on", - help => qqq(" + name => 'ZM_MAX_RTP_PORT', + default => '40499', + description => 'Maximum port that ZoneMinder will listen for RTP traffic on', + help => q` When ZoneMinder communicates with MPEG4 capable cameras using RTP with the unicast method it must open ports for the camera to connect back to for control and streaming purposes. This @@ -987,54 +978,54 @@ our @options = ( wish to use unicasting. You should also ensure that you have opened up at least two ports for each monitor that will be connecting to unicasting network cameras. - "), + `, type => $types{integer}, - category => "network", + category => 'network', }, { - name => "ZM_OPT_FFMPEG", - default => "@OPT_FFMPEG@", - description => "Is the ffmpeg video encoder/decoder installed", - help => qqq(" + name => 'ZM_OPT_FFMPEG', + default => '@OPT_FFMPEG@', + description => 'Is the ffmpeg video encoder/decoder installed', + help => q` ZoneMinder can optionally encode a series of video images into an MPEG encoded movie file for viewing, downloading or storage. This option allows you to specify whether you have the ffmpeg tools installed. Note that creating MPEG files can be fairly CPU and disk intensive and is not a required option as events can still be reviewed as video streams without it. - "), + `, type => $types{boolean}, - category => "images", + category => 'images', }, { - name => "ZM_PATH_FFMPEG", - default => "@PATH_FFMPEG@", - description => "Path to (optional) ffmpeg mpeg encoder", - help => "This path should point to where ffmpeg has been installed.", - requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + name => 'ZM_PATH_FFMPEG', + default => '@PATH_FFMPEG@', + description => 'Path to (optional) ffmpeg mpeg encoder', + help => 'This path should point to where ffmpeg has been installed.', + requires => [ { name=>'ZM_OPT_FFMPEG', value=>'yes' } ], type => $types{abs_path}, - category => "images", + category => 'images', }, { - name => "ZM_FFMPEG_INPUT_OPTIONS", - default => "", - description => "Additional input options to ffmpeg", - help => qqq(" + name => 'ZM_FFMPEG_INPUT_OPTIONS', + default => '', + description => 'Additional input options to ffmpeg', + help => q` Ffmpeg can take many options on the command line to control the quality of video produced. This option allows you to specify your own set that apply to the input to ffmpeg (options that are given before the -i option). Check the ffmpeg documentation for a full list of options which may be used here. - "), - requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_FFMPEG', value=>'yes' } ], type => $types{string}, - category => "images", + category => 'images', }, { - name => "ZM_FFMPEG_OUTPUT_OPTIONS", - default => "-r 25", - description => "Additional output options to ffmpeg", - help => qqq(" + name => 'ZM_FFMPEG_OUTPUT_OPTIONS', + default => '-r 25', + description => 'Additional output options to ffmpeg', + help => q` Ffmpeg can take many options on the command line to control the quality of video produced. This option allows you to specify your own set that apply to the output from ffmpeg (options that @@ -1042,16 +1033,16 @@ our @options = ( for a full list of options which may be used here. The most common one will often be to force an output frame rate supported by the video encoder. - "), - requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_FFMPEG', value=>'yes' } ], type => $types{string}, - category => "images", + category => 'images', }, { - name => "ZM_FFMPEG_FORMATS", - default => "mpg mpeg wmv asf avi* mov swf 3gp**", - description => "Formats to allow for ffmpeg video generation", - help => qqq(" + name => 'ZM_FFMPEG_FORMATS', + default => 'mpg mpeg wmv asf avi* mov swf 3gp**', + description => 'Formats to allow for ffmpeg video generation', + help => q` Ffmpeg can generate video in many different formats. This option allows you to list the ones you want to be able to select. As new formats are supported by ffmpeg you can add them @@ -1059,31 +1050,31 @@ our @options = ( format indicates that this will be the default format used for web video, adding '**' defines the default format for phone video. - "), - requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_FFMPEG', value=>'yes' } ], type => $types{string}, - category => "images", + category => 'images', }, { - name => "ZM_FFMPEG_OPEN_TIMEOUT", - default => "10", - description => "Timeout in seconds when opening a stream.", - help => qqq(" + name => 'ZM_FFMPEG_OPEN_TIMEOUT', + default => '10', + description => 'Timeout in seconds when opening a stream.', + help => q` When Ffmpeg is opening a stream, it can take a long time before failing; certain circumstances even seem to be able to lock indefinitely. This option allows you to set a maximum time in seconds to pass before closing the stream and trying to reopen it again. - "), - requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ], + `, + requires => [ { name=>'ZM_OPT_FFMPEG', value=>'yes' } ], type => $types{integer}, - category => "images", + category => 'images', }, { - name => "ZM_LOG_LEVEL_SYSLOG", - default => "0", - description => "Save logging output to the system log", - help => qqq(" + name => 'ZM_LOG_LEVEL_SYSLOG', + default => '0', + description => 'Save logging output to the system log', + help => q` ZoneMinder logging is now more more integrated between components and allows you to specify the destination for logging output and the individual levels for each. This option @@ -1097,20 +1088,20 @@ our @options = ( should use caution when setting this option to Debug as it can affect severely affect system performance. If you want debug you will also need to set a level and component below - "), + `, type => { - db_type => "integer", - hint => "None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1", + db_type => 'integer', + hint => 'None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1', pattern => qr|^(\d+)$|, format => q( $1 ) }, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_LEVEL_FILE", - default => "-5", - description => "Save logging output to component files", - help => qqq(" + name => 'ZM_LOG_LEVEL_FILE', + default => '-5', + description => 'Save logging output to component files', + help => q` ZoneMinder logging is now more more integrated between components and allows you to specify the destination for logging output and the individual levels for each. This option @@ -1127,20 +1118,20 @@ our @options = ( performance though file output has less impact than the other options. If you want debug you will also need to set a level and component below - "), + `, type => { - db_type => "integer", - hint => "None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1", + db_type => 'integer', + hint => 'None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1', pattern => qr|^(\d+)$|, format => q( $1 ) }, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_LEVEL_WEBLOG", - default => "-5", - description => "Save logging output to the weblog", - help => qqq(" + name => 'ZM_LOG_LEVEL_WEBLOG', + default => '-5', + description => 'Save logging output to the weblog', + help => q` ZoneMinder logging is now more more integrated between components and allows you to specify the destination for logging output and the individual levels for each. This option @@ -1154,20 +1145,20 @@ our @options = ( should use caution when setting this option to Debug as it can affect severely affect system performance. If you want debug you will also need to set a level and component below - "), + `, type => { - db_type => "integer", - hint => "None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1", + db_type => 'integer', + hint => 'None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1', pattern => qr|^(\d+)$|, format => q( $1 ) }, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_LEVEL_DATABASE", - default => "0", - description => "Save logging output to the database", - help => qqq(" + name => 'ZM_LOG_LEVEL_DATABASE', + default => '0', + description => 'Save logging output to the database', + help => q` ZoneMinder logging is now more more integrated between components and allows you to specify the destination for logging output and the individual levels for each. This option @@ -1185,20 +1176,20 @@ our @options = ( caution when setting this option to Debug as it can affect severely affect system performance. If you want debug you will also need to set a level and component below - "), + `, type => { - db_type => "integer", - hint => "None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1", + db_type => 'integer', + hint => 'None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1', pattern => qr|^(\d+)$|, format => q( $1 ) }, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_DATABASE_LIMIT", - default => "7 day", - description => "Maximum number of log entries to retain", - help => qqq(" + name => 'ZM_LOG_DATABASE_LIMIT', + default => '7 day', + description => 'Maximum number of log entries to retain', + help => q` If you are using database logging then it is possible to quickly build up a large number of entries in the Logs table. This option allows you to specify how many of these entries are @@ -1212,15 +1203,15 @@ our @options = ( end). The Logs table is pruned periodically so it is possible for more than the expected number of rows to be present briefly in the meantime. - "), + `, type => $types{string}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_DEBUG", - default => "no", - description => "Switch debugging on", - help => qqq(" + name => 'ZM_LOG_DEBUG', + default => 'no', + description => 'Switch debugging on', + help => q` ZoneMinder components usually support debug logging available to help with diagnosing problems. Binary components have several levels of debug whereas more other components have only @@ -1229,15 +1220,15 @@ our @options = ( you switch on other options that allow you to configure additional debug information to be output. Components will pick up this instruction when they are restarted. - "), + `, type => $types{boolean}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_DEBUG_TARGET", - default => "", - description => "What components should have extra debug enabled", - help => qqq(" + name => 'ZM_LOG_DEBUG_TARGET', + default => '', + description => 'What components should have extra debug enabled', + help => q` There are three scopes of debug available. Leaving this option blank means that all components will use extra debug (not recommended). Setting this option to '_', e.g. _zmc, @@ -1248,16 +1239,16 @@ our @options = ( their names without the .pl extension, e.g. '_zmvideo' and to debug issues with the web interface use '_web'. You can specify multiple targets by separating them with '|' characters. - "), - requires => [ { name => "ZM_LOG_DEBUG", value => "yes" } ], + `, + requires => [ { name => 'ZM_LOG_DEBUG', value => 'yes' } ], type => $types{string}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_DEBUG_LEVEL", + name => 'ZM_LOG_DEBUG_LEVEL', default => 1, - description => "What level of extra debug should be enabled", - help => qqq(" + description => 'What level of extra debug should be enabled', + help => q` There are 9 levels of debug available, with higher numbers being more debug and level 0 being no debug. However not all levels are used by all components. Also if there is debug at a @@ -1267,21 +1258,21 @@ our @options = ( of debug you wish to see is present. Scripts and the web interface only have one level so this is an on/off type option for them. - "), - requires => [ { name => "ZM_LOG_DEBUG", value => "yes" } ], + `, + requires => [ { name => 'ZM_LOG_DEBUG', value => 'yes' } ], type => { - db_type => "integer", - hint => "1|2|3|4|5|6|7|8|9", + db_type => 'integer', + hint => '1|2|3|4|5|6|7|8|9', pattern => qr|^(\d+)$|, format => q( $1 ) }, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_DEBUG_FILE", - default => "@ZM_LOGDIR@/zm_debug.log+", - description => "Where extra debug is output to", - help => qqq(" + name => 'ZM_LOG_DEBUG_FILE', + default => '@ZM_LOGDIR@/zm_debug.log+', + description => 'Where extra debug is output to', + help => q` This option allows you to specify a different target for debug output. All components have a default log file which will norally be in /tmp or /var/log and this is where debug will be @@ -1297,31 +1288,31 @@ our @options = ( overwriting the same log. You should ensure that permissions are set up to allow writing to the file and directory specified here. - "), - requires => [ { name => "ZM_LOG_DEBUG", value => "yes" } ], + `, + requires => [ { name => 'ZM_LOG_DEBUG', value => 'yes' } ], type => $types{string}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_CHECK_PERIOD", - default => "900", - description => "Time period used when calculating overall system health", - help => qqq(" + name => 'ZM_LOG_CHECK_PERIOD', + default => '900', + description => 'Time period used when calculating overall system health', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. This option allows you to indicate what period of historical events are used in this calculation. This value is expressed in seconds and is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALERT_WAR_COUNT", - default => "1", - description => "Number of warnings indicating system alert state", - help => qqq(" + name => 'ZM_LOG_ALERT_WAR_COUNT', + default => '1', + description => 'Number of warnings indicating system alert state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1330,15 +1321,15 @@ our @options = ( system alert state. A value of zero means warnings are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALERT_ERR_COUNT", - default => "1", - description => "Number of errors indicating system alert state", - help => qqq(" + name => 'ZM_LOG_ALERT_ERR_COUNT', + default => '1', + description => 'Number of errors indicating system alert state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1347,15 +1338,15 @@ our @options = ( system alert state. A value of zero means errors are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALERT_FAT_COUNT", - default => "0", - description => "Number of fatal error indicating system alert state", - help => qqq(" + name => 'ZM_LOG_ALERT_FAT_COUNT', + default => '0', + description => 'Number of fatal error indicating system alert state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1364,15 +1355,15 @@ our @options = ( period to generate an overall system alert state. A value of zero means fatal errors are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALARM_WAR_COUNT", - default => "100", - description => "Number of warnings indicating system alarm state", - help => qqq(" + name => 'ZM_LOG_ALARM_WAR_COUNT', + default => '100', + description => 'Number of warnings indicating system alarm state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1381,15 +1372,15 @@ our @options = ( system alarm state. A value of zero means warnings are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALARM_ERR_COUNT", - default => "10", - description => "Number of errors indicating system alarm state", - help => qqq(" + name => 'ZM_LOG_ALARM_ERR_COUNT', + default => '10', + description => 'Number of errors indicating system alarm state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1398,15 +1389,15 @@ our @options = ( system alarm state. A value of zero means errors are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_LOG_ALARM_FAT_COUNT", - default => "1", - description => "Number of fatal error indicating system alarm state", - help => qqq(" + name => 'ZM_LOG_ALARM_FAT_COUNT', + default => '1', + description => 'Number of fatal error indicating system alarm state', + help => q` When ZoneMinder is logging events to the database it can retrospectively examine the number of warnings and errors that have occurred to calculate an overall state of system health. @@ -1415,15 +1406,15 @@ our @options = ( period to generate an overall system alarm state. A value of zero means fatal errors are not considered. This value is ignored if LOG_LEVEL_DATABASE is set to None. - "), + `, type => $types{integer}, - category => "logging", + category => 'logging', }, { - name => "ZM_RECORD_EVENT_STATS", - default => "yes", - description => "Record event statistical information, switch off if too slow", - help => qqq(" + name => 'ZM_RECORD_EVENT_STATS', + default => 'yes', + description => 'Record event statistical information, switch off if too slow', + help => q` This version of ZoneMinder records detailed information about events in the Stats table. This can help in profiling what the optimum settings are for Zones though this is tricky at @@ -1433,15 +1424,15 @@ our @options = ( be collected now in readiness for this but if you are concerned about performance you can switch this off in which case no Stats information will be saved. - "), + `, type => $types{boolean}, - category => "logging", + category => 'logging', }, { - name => "ZM_RECORD_DIAG_IMAGES", - default => "no", - description => "Record intermediate alarm diagnostic images, can be very slow", - help => qqq(" + name => 'ZM_RECORD_DIAG_IMAGES', + default => 'no', + description => 'Record intermediate alarm diagnostic images, can be very slow', + help => q` In addition to recording event statistics you can also record the intermediate diagnostic images that display the results of the various checks and processing that occur when trying to @@ -1451,15 +1442,15 @@ our @options = ( performance. Only switch this setting on for debug or analysis purposes and remember to switch it off again once no longer required. - "), + `, type => $types{boolean}, - category => "logging", + category => 'logging', }, { - name => "ZM_DUMP_CORES", - default => "no", - description => "Create core files on unexpected process failure.", - help => qqq(" + name => 'ZM_DUMP_CORES', + default => 'no', + description => 'Create core files on unexpected process failure.', + help => q` When an unrecoverable error occurs in a ZoneMinder binary process is has traditionally been trapped and the details written to logs to aid in remote analysis. However in some @@ -1476,15 +1467,15 @@ our @options = ( on your system via the 'ulimit -c' command or other means otherwise no file will be created regardless of the value of this option. - "), + `, type => $types{boolean}, - category => "logging", + category => 'logging', }, { - name => "ZM_PATH_MAP", - default => "/dev/shm", - description => "Path to the mapped memory files that that ZoneMinder can use", - help => qqq(" + name => 'ZM_PATH_MAP', + default => '/dev/shm', + description => 'Path to the mapped memory files that that ZoneMinder can use', + help => q` ZoneMinder has historically used IPC shared memory for shared data between processes. This has it's advantages and limitations. This version of ZoneMinder can use an alternate @@ -1497,754 +1488,757 @@ our @options = ( files and for the best performance it should be a tmpfs file system or ramdisk otherwise disk access may render this method slower than the regular shared memory one. - "), + `, type => $types{abs_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_PATH_SOCKS", - default => "@ZM_SOCKDIR@", - description => "Path to the various Unix domain socket files that ZoneMinder uses", - help => qqq(" - ZoneMinder generally uses Unix domain sockets where possible. - This reduces the need for port assignments and prevents - external applications from possibly compromising the daemons. - However each Unix socket requires a .sock file to be created. - This option indicates where those socket files go. - "), + name => 'ZM_PATH_SOCKS', + default => '@ZM_SOCKDIR@', + description => 'Path to the various Unix domain socket files that ZoneMinder uses', + help => q` + ZoneMinder generally uses Unix domain sockets where possible. + This reduces the need for port assignments and prevents + external applications from possibly compromising the daemons. + However each Unix socket requires a .sock file to be created. + This option indicates where those socket files go. + `, type => $types{abs_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_PATH_LOGS", - default => "@ZM_LOGDIR@", - description => "Path to the various logs that the ZoneMinder daemons generate", - help => qqq(" - There are various daemons that are used by ZoneMinder to - perform various tasks. Most generate helpful log files and this - is where they go. They can be deleted if not required for - debugging. - "), + name => 'ZM_PATH_LOGS', + default => '@ZM_LOGDIR@', + description => 'Path to the various logs that the ZoneMinder daemons generate', + help => q` + There are various daemons that are used by ZoneMinder to + perform various tasks. Most generate helpful log files and this + is where they go. They can be deleted if not required for + debugging. + `, type => $types{abs_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_PATH_SWAP", - default => "@ZM_TMPDIR@", - description => "Path to location for temporary swap images used in streaming", - help => qqq(" - Buffered playback requires temporary swap images to be stored - for each instance of the streaming daemons. This option - determines where these images will be stored. The images will - actually be stored in sub directories beneath this location and - will be automatically cleaned up after a period of time. - "), + name => 'ZM_PATH_SWAP', + default => '@ZM_TMPDIR@', + description => 'Path to location for temporary swap images used in streaming', + help => q` + Buffered playback requires temporary swap images to be stored + for each instance of the streaming daemons. This option + determines where these images will be stored. The images will + actually be stored in sub directories beneath this location and + will be automatically cleaned up after a period of time. + `, type => $types{abs_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_PATH_ARP", - default => "", - description => "Path to a supported ARP tool", - help => qqq(" - The camera probe function uses Address Resolution Protocol in - order to find known devices on the network. Optionally supply - the full path to \"ip neigh\", \"arp -a\", or any other tool on - your system that returns ip/mac address pairs. If this field is - left empty, ZoneMinder will search for the command \"arp\" and - attempt to use that. - "), + name => 'ZM_PATH_ARP', + default => '', + description => 'Path to a supported ARP tool', + help => q` + The camera probe function uses Address Resolution Protocol in + order to find known devices on the network. Optionally supply + the full path to \"ip neigh\", \"arp -a\", or any other tool on + your system that returns ip/mac address pairs. If this field is + left empty, ZoneMinder will search for the command \"arp\" and + attempt to use that. + `, type => $types{abs_path}, - category => "paths", + category => 'paths', }, { - name => "ZM_WEB_TITLE_PREFIX", - default => "ZM", - description => "The title prefix displayed on each window", - help => qqq(" - If you have more than one installation of ZoneMinder it can be - helpful to display different titles for each one. Changing this - option allows you to customise the window titles to include - further information to aid identification. - "), + name => 'ZM_WEB_TITLE_PREFIX', + default => 'ZM', + description => 'The title prefix displayed on each window', + help => q` + If you have more than one installation of ZoneMinder it can be + helpful to display different titles for each one. Changing this + option allows you to customise the window titles to include + further information to aid identification. + `, type => $types{string}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_CONSOLE_BANNER", - default => "", - description => "Arbitrary text message near the top of the console", - help => qqq(" - Allows the administrator to place an arbitrary text message - near the top of the web console. This is useful for the developers - to display a message which indicates the running instance of - ZoneMinder is a development snapshot, but it can also be used for - any other purpose as well. - "), + name => 'ZM_WEB_CONSOLE_BANNER', + default => '', + description => 'Arbitrary text message near the top of the console', + help => q` + Allows the administrator to place an arbitrary text message + near the top of the web console. This is useful for the developers + to display a message which indicates the running instance of + ZoneMinder is a development snapshot, but it can also be used for + any other purpose as well. + `, type => $types{string}, - category => "web", + category => 'web', }, { name => 'ZM_WEB_EVENT_DISK_SPACE', - default => '', - description => "Whether to show disk space used by each event.", - help => qqq("Adds another column to the listing of events - showing the disk space used by the event. This will impart a small - overhead as it will call du on the event directory. In practice - this overhead is fairly small but may be noticeable on IO-constrained - systems. - "), - type => $types{string}, - category => "web", - }, - { - name => "ZM_WEB_RESIZE_CONSOLE", - default => "yes", - description => "Should the console window resize itself to fit", - help => qqq(" - Traditionally the main ZoneMinder web console window has - resized itself to shrink to a size small enough to list only - the monitors that are actually present. This is intended to - make the window more unobtrusize but may not be to everyones - tastes, especially if opened in a tab in browsers which support - this kind if layout. Switch this option off to have the console - window size left to the users preference - "), + default => 'no', + description => 'Whether to show disk space used by each event.', + help => q`Adds another column to the listing of events + showing the disk space used by the event. This will impart a small + overhead as it will call du on the event directory. In practice + this overhead is fairly small but may be noticeable on IO-constrained + systems. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_ID_ON_CONSOLE", - default => "no", - description => "Should the console list the monitor id", - help => qqq("Some find it useful to have the id always visible - on the console. This option will add a column listing it. - "), + name => 'ZM_WEB_RESIZE_CONSOLE', + default => 'yes', + description => 'Should the console window resize itself to fit', + help => q` + Traditionally the main ZoneMinder web console window has + resized itself to shrink to a size small enough to list only + the monitors that are actually present. This is intended to + make the window more unobtrusize but may not be to everyones + tastes, especially if opened in a tab in browsers which support + this kind if layout. Switch this option off to have the console + window size left to the users preference + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_POPUP_ON_ALARM", - default => "yes", - description => "Should the monitor window jump to the top if an alarm occurs", - help => qqq(" - When viewing a live monitor stream you can specify whether you - want the window to pop to the front if an alarm occurs when the - window is minimised or behind another window. This is most - useful if your monitors are over doors for example when they - can pop up if someone comes to the doorway. - "), + name => 'ZM_WEB_ID_ON_CONSOLE', + default => 'no', + description => 'Should the console list the monitor id', + help => q` + Some find it useful to have the id always visible + on the console. This option will add a column listing it. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_OPT_X10", - default => "no", - description => "Support interfacing with X10 devices", - help => qqq(" - If you have an X10 Home Automation setup in your home you can - use ZoneMinder to initiate or react to X10 signals if your - computer has the appropriate interface controller. This option - indicates whether X10 options will be available in the browser - client. - "), + name => 'ZM_WEB_POPUP_ON_ALARM', + default => 'yes', + description => 'Should the monitor window jump to the top if an alarm occurs', + help => q` + When viewing a live monitor stream you can specify whether you + want the window to pop to the front if an alarm occurs when the + window is minimised or behind another window. This is most + useful if your monitors are over doors for example when they + can pop up if someone comes to the doorway. + `, type => $types{boolean}, - category => "x10", + category => 'web', }, { - name => "ZM_X10_DEVICE", - default => "/dev/ttyS0", - description => "What device is your X10 controller connected on", - requires => [ { name => "ZM_OPT_X10", value => "yes" } ], - help => qqq(" - If you have an X10 controller device (e.g. XM10U) connected to - your computer this option details which port it is connected on, - the default of /dev/ttyS0 maps to serial or com port 1. - "), + name => 'ZM_OPT_X10', + default => 'no', + description => 'Support interfacing with X10 devices', + help => q` + If you have an X10 Home Automation setup in your home you can + use ZoneMinder to initiate or react to X10 signals if your + computer has the appropriate interface controller. This option + indicates whether X10 options will be available in the browser + client. + `, + type => $types{boolean}, + category => 'x10', + }, + { + name => 'ZM_X10_DEVICE', + default => '/dev/ttyS0', + description => 'What device is your X10 controller connected on', + requires => [ { name => 'ZM_OPT_X10', value => 'yes' } ], + help => q` + If you have an X10 controller device (e.g. XM10U) connected to + your computer this option details which port it is connected on, + the default of /dev/ttyS0 maps to serial or com port 1. + `, type => $types{abs_path}, - category => "x10", + category => 'x10', }, { - name => "ZM_X10_HOUSE_CODE", - default => "A", - description => "What X10 house code should be used", - requires => [ { name => "ZM_OPT_X10", value => "yes" } ], - help => qqq(" - X10 devices are grouped together by identifying them as all - belonging to one House Code. This option details what that is. - It should be a single letter between A and P. - "), - type => { db_type=>"string", hint=>"A-P", pattern=>qr|^([A-P])|i, format=>q( uc($1) ) }, - category => "x10", + name => 'ZM_X10_HOUSE_CODE', + default => 'A', + description => 'What X10 house code should be used', + requires => [ { name => 'ZM_OPT_X10', value => 'yes' } ], + help => q` + X10 devices are grouped together by identifying them as all + belonging to one House Code. This option details what that is. + It should be a single letter between A and P. + `, + type => { db_type=>'string', hint=>'A-P', pattern=>qr|^([A-P])|i, format=>q( uc($1) ) }, + category => 'x10', }, { - name => "ZM_X10_DB_RELOAD_INTERVAL", - default => "60", - description => "How often (in seconds) the X10 daemon reloads the monitors from the database", - requires => [ { name => "ZM_OPT_X10", value => "yes" } ], - help => qqq(" - The zmx10 daemon periodically checks the database to find out - what X10 events trigger, or result from, alarms. This option - determines how frequently this check occurs, unless you change - this area frequently this can be a fairly large value. - "), + name => 'ZM_X10_DB_RELOAD_INTERVAL', + default => '60', + description => 'How often (in seconds) the X10 daemon reloads the monitors from the database', + requires => [ { name => 'ZM_OPT_X10', value => 'yes' } ], + help => q` + The zmx10 daemon periodically checks the database to find out + what X10 events trigger, or result from, alarms. This option + determines how frequently this check occurs, unless you change + this area frequently this can be a fairly large value. + `, type => $types{integer}, - category => "x10", + category => 'x10', }, { - name => "ZM_WEB_SOUND_ON_ALARM", - default => "no", - description => "Should the monitor window play a sound if an alarm occurs", - help => qqq(" - When viewing a live monitor stream you can specify whether you - want the window to play a sound to alert you if an alarm - occurs. - "), + name => 'ZM_WEB_SOUND_ON_ALARM', + default => 'no', + description => 'Should the monitor window play a sound if an alarm occurs', + help => q` + When viewing a live monitor stream you can specify whether you + want the window to play a sound to alert you if an alarm + occurs. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_ALARM_SOUND", - default => "", - description => "The sound to play on alarm, put this in the sounds directory", - help => qqq(" - You can specify a sound file to play if an alarm occurs whilst - you are watching a live monitor stream. So long as your browser - understands the format it does not need to be any particular - type. This file should be placed in the sounds directory - defined earlier. - "), + name => 'ZM_WEB_ALARM_SOUND', + default => '', + description => 'The sound to play on alarm, put this in the sounds directory', + help => q` + You can specify a sound file to play if an alarm occurs whilst + you are watching a live monitor stream. So long as your browser + understands the format it does not need to be any particular + type. This file should be placed in the sounds directory + defined earlier. + `, type => $types{file}, - requires => [ { name => "ZM_WEB_SOUND_ON_ALARM", value => "yes" } ], - category => "web", + requires => [ { name => 'ZM_WEB_SOUND_ON_ALARM', value => 'yes' } ], + category => 'web', }, { - name => "ZM_WEB_COMPACT_MONTAGE", - default => "no", - description => "Compact the montage view by removing extra detail", - help => qqq(" - The montage view shows the output of all of your active - monitors in one window. This include a small menu and status - information for each one. This can increase the web traffic and - make the window larger than may be desired. Setting this option - on removes all this extraneous information and just displays - the images. - "), + name => 'ZM_WEB_COMPACT_MONTAGE', + default => 'no', + description => 'Compact the montage view by removing extra detail', + help => q` + The montage view shows the output of all of your active + monitors in one window. This include a small menu and status + information for each one. This can increase the web traffic and + make the window larger than may be desired. Setting this option + on removes all this extraneous information and just displays + the images. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_OPT_FAST_DELETE", - default => "no", - description => "Delete only event database records for speed", - help => qqq(" - Normally an event created as the result of an alarm consists of - entries in one or more database tables plus the various files - associated with it. When deleting events in the browser it can - take a long time to remove all of this if your are trying to do - a lot of events at once. It is recommended that you set this - option which means that the browser client only deletes the key - entries in the events table, which means the events will no - longer appear in the listing, and leaves the zmaudit daemon to - clear up the rest later. Note that this feature is less relevant - with modern hardware. Recommend this feature be left off. - "), + name => 'ZM_OPT_FAST_DELETE', + default => 'no', + description => 'Delete only event database records for speed', + help => q` + Normally an event created as the result of an alarm consists of + entries in one or more database tables plus the various files + associated with it. When deleting events in the browser it can + take a long time to remove all of this if your are trying to do + a lot of events at once. It is recommended that you set this + option which means that the browser client only deletes the key + entries in the events table, which means the events will no + longer appear in the listing, and leaves the zmaudit daemon to + clear up the rest later. Note that this feature is less relevant + with modern hardware. Recommend this feature be left off. + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_STRICT_VIDEO_CONFIG", - default => "yes", - description => "Allow errors in setting video config to be fatal", - help => qqq(" - With some video devices errors can be reported in setting the - various video attributes when in fact the operation was - successful. Switching this option off will still allow these - errors to be reported but will not cause them to kill the video - capture daemon. Note however that doing this will cause all - errors to be ignored including those which are genuine and - which may cause the video capture to not function correctly. - Use this option with caution. - "), + name => 'ZM_STRICT_VIDEO_CONFIG', + default => 'yes', + description => 'Allow errors in setting video config to be fatal', + help => q` + With some video devices errors can be reported in setting the + various video attributes when in fact the operation was + successful. Switching this option off will still allow these + errors to be reported but will not cause them to kill the video + capture daemon. Note however that doing this will cause all + errors to be ignored including those which are genuine and + which may cause the video capture to not function correctly. + Use this option with caution. + `, type => $types{boolean}, - category => "config", + category => 'config', }, { name => 'ZM_LD_PRELOAD', default => '', description => "Path to library to preload before launching daemons", - help => qqq("Some older cameras require the use of the v4l1 compat - library. This setting allows the setting of the path - to the library, so that it can be loaded by zmdc.pl - before launching zmc."), + help => q` + Some older cameras require the use of the v4l1 compat + library. This setting allows the setting of the path + to the library, so that it can be loaded by zmdc.pl + before launching zmc. + `, type => $types{abs_path}, category => 'config', }, { - name => "ZM_SIGNAL_CHECK_POINTS", - default => "10", - description => "How many points in a captured image to check for signal loss", - help => qqq(" - For locally attached video cameras ZoneMinder can check for - signal loss by looking at a number of random points on each - captured image. If all of these points are set to the same - fixed colour then the camera is assumed to have lost signal. - When this happens any open events are closed and a short one - frame signal loss event is generated, as is another when the - signal returns. This option defines how many points on each - image to check. Note that this is a maximum, any points found - to not have the check colour will abort any further checks so - in most cases on a couple of points will actually be checked. - Network and file based cameras are never checked. - "), + name => 'ZM_SIGNAL_CHECK_POINTS', + default => '10', + description => 'How many points in a captured image to check for signal loss', + help => q` + For locally attached video cameras ZoneMinder can check for + signal loss by looking at a number of random points on each + captured image. If all of these points are set to the same + fixed colour then the camera is assumed to have lost signal. + When this happens any open events are closed and a short one + frame signal loss event is generated, as is another when the + signal returns. This option defines how many points on each + image to check. Note that this is a maximum, any points found + to not have the check colour will abort any further checks so + in most cases on a couple of points will actually be checked. + Network and file based cameras are never checked. + `, type => $types{integer}, - category => "config", + category => 'config', }, { - name => "ZM_V4L_MULTI_BUFFER", - default => "yes", - description => "Use more than one buffer for Video 4 Linux devices", - help => qqq(" - Performance when using Video 4 Linux devices is usually best if - multiple buffers are used allowing the next image to be - captured while the previous one is being processed. If you have - multiple devices on a card sharing one input that requires - switching then this approach can sometimes cause frames from - one source to be mixed up with frames from another. Switching - this option off prevents multi buffering resulting in slower - but more stable image capture. This option is ignored for - non-local cameras or if only one input is present on a capture - chip. This option addresses a similar problem to the - ZM_CAPTURES_PER_FRAME option and you should normally change the - value of only one of the options at a time. If you have - different capture cards that need different values you can - ovveride them in each individual monitor on the source page. - "), + name => 'ZM_V4L_MULTI_BUFFER', + default => 'yes', + description => 'Use more than one buffer for Video 4 Linux devices', + help => q` + Performance when using Video 4 Linux devices is usually best if + multiple buffers are used allowing the next image to be + captured while the previous one is being processed. If you have + multiple devices on a card sharing one input that requires + switching then this approach can sometimes cause frames from + one source to be mixed up with frames from another. Switching + this option off prevents multi buffering resulting in slower + but more stable image capture. This option is ignored for + non-local cameras or if only one input is present on a capture + chip. This option addresses a similar problem to the + ZM_CAPTURES_PER_FRAME option and you should normally change the + value of only one of the options at a time. If you have + different capture cards that need different values you can + override them in each individual monitor on the source page. + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_CAPTURES_PER_FRAME", - default => "1", - description => "How many images are captured per returned frame, for shared local cameras", - help => qqq(" - If you are using cameras attached to a video capture card which - forces multiple inputs to share one capture chip, it can - sometimes produce images with interlaced frames reversed - resulting in poor image quality and a distinctive comb edge - appearance. Increasing this setting allows you to force - additional image captures before one is selected as the - captured frame. This allows the capture hardware to 'settle - down' and produce better quality images at the price of lesser - capture rates. This option has no effect on (a) network - cameras, or (b) where multiple inputs do not share a capture - chip. This option addresses a similar problem to the - ZM_V4L_MULTI_BUFFER option and you should normally change the - value of only one of the options at a time. If you have - different capture cards that need different values you can - ovveride them in each individual monitor on the source page. - "), + name => 'ZM_CAPTURES_PER_FRAME', + default => '1', + description => 'How many images are captured per returned frame, for shared local cameras', + help => q` + If you are using cameras attached to a video capture card which + forces multiple inputs to share one capture chip, it can + sometimes produce images with interlaced frames reversed + resulting in poor image quality and a distinctive comb edge + appearance. Increasing this setting allows you to force + additional image captures before one is selected as the + captured frame. This allows the capture hardware to 'settle + down' and produce better quality images at the price of lesser + capture rates. This option has no effect on (a) network + cameras, or (b) where multiple inputs do not share a capture + chip. This option addresses a similar problem to the + ZM_V4L_MULTI_BUFFER option and you should normally change the + value of only one of the options at a time. If you have + different capture cards that need different values you can + override them in each individual monitor on the source page. + `, type => $types{integer}, - category => "config", + category => 'config', }, { - name => "ZM_FILTER_RELOAD_DELAY", - default => "300", - description => "How often (in seconds) filters are reloaded in zmfilter", - help => qqq(" - ZoneMinder allows you to save filters to the database which - allow events that match certain criteria to be emailed, deleted - or uploaded to a remote machine etc. The zmfilter daemon loads - these and does the actual operation. This option determines how - often the filters are reloaded from the database to get the - latest versions or new filters. If you don't change filters - very often this value can be set to a large value. - "), + name => 'ZM_FILTER_RELOAD_DELAY', + default => '300', + description => 'How often (in seconds) filters are reloaded in zmfilter', + help => q` + ZoneMinder allows you to save filters to the database which + allow events that match certain criteria to be emailed, deleted + or uploaded to a remote machine etc. The zmfilter daemon loads + these and does the actual operation. This option determines how + often the filters are reloaded from the database to get the + latest versions or new filters. If you don't change filters + very often this value can be set to a large value. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_FILTER_EXECUTE_INTERVAL", - default => "60", - description => "How often (in seconds) to run automatic saved filters", - help => qqq(" - ZoneMinder allows you to save filters to the database which - allow events that match certain criteria to be emailed, deleted - or uploaded to a remote machine etc. The zmfilter daemon loads - these and does the actual operation. This option determines how - often the filters are executed on the saved event in the - database. If you want a rapid response to new events this - should be a smaller value, however this may increase the - overall load on the system and affect performance of other - elements. - "), + name => 'ZM_FILTER_EXECUTE_INTERVAL', + default => '60', + description => 'How often (in seconds) to run automatic saved filters', + help => q` + ZoneMinder allows you to save filters to the database which + allow events that match certain criteria to be emailed, deleted + or uploaded to a remote machine etc. The zmfilter daemon loads + these and does the actual operation. This option determines how + often the filters are executed on the saved event in the + database. If you want a rapid response to new events this + should be a smaller value, however this may increase the + overall load on the system and affect performance of other + elements. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_OPT_UPLOAD", - default => "no", - description => "Should ZoneMinder support uploading events from filters", - help => qqq(" - In ZoneMinder you can create event filters that specify whether - events that match certain criteria should be uploaded to a - remote server for archiving. This option specifies whether this - functionality should be available - "), + name => 'ZM_OPT_UPLOAD', + default => 'no', + description => 'Should ZoneMinder support uploading events from filters', + help => q` + In ZoneMinder you can create event filters that specify whether + events that match certain criteria should be uploaded to a + remote server for archiving. This option specifies whether this + functionality should be available + `, type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_ARCH_FORMAT", - default => "tar", - description => "What format the uploaded events should be created in.", - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], - help => qqq(" - Uploaded events may be stored in either .tar or .zip format, - this option specifies which. Note that to use this you will - need to have the Archive::Tar and/or Archive::Zip perl modules - installed. - "), + name => 'ZM_UPLOAD_ARCH_FORMAT', + default => 'tar', + description => 'What format the uploaded events should be created in.', + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], + help => q` + Uploaded events may be stored in either .tar or .zip format, + this option specifies which. Note that to use this you will + need to have the Archive::Tar and/or Archive::Zip perl modules + installed. + `, type => { - db_type =>"string", - hint =>"tar|zip", + db_type =>'string', + hint =>'tar|zip', pattern =>qr|^([tz])|i, - format =>q( $1 =~ /^t/ ? "tar" : "zip" ) + format =>q( $1 =~ /^t/ ? 'tar' : 'zip' ) }, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_ARCH_COMPRESS", - default => "no", - description => "Should archive files be compressed", - help => qqq(" - When the archive files are created they can be compressed. - However in general since the images are compressed already this - saves only a minimal amount of space versus utilising more CPU - in their creation. Only enable if you have CPU to waste and are - limited in disk space on your remote server or bandwidth. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_ARCH_COMPRESS', + default => 'no', + description => 'Should archive files be compressed', + help => q` + When the archive files are created they can be compressed. + However in general since the images are compressed already this + saves only a minimal amount of space versus utilising more CPU + in their creation. Only enable if you have CPU to waste and are + limited in disk space on your remote server or bandwidth. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_ARCH_ANALYSE", - default => "no", - description => "Include the analysis files in the archive", - help => qqq(" - When the archive files are created they can contain either just - the captured frames or both the captured frames and, for frames - that caused an alarm, the analysed image with the changed area - highlighted. This option controls files are included. Only - include analysed frames if you have a high bandwidth connection - to the remote server or if you need help in figuring out what - caused an alarm in the first place as archives with these files - in can be considerably larger. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_ARCH_ANALYSE', + default => 'no', + description => 'Include the analysis files in the archive', + help => q` + When the archive files are created they can contain either just + the captured frames or both the captured frames and, for frames + that caused an alarm, the analysed image with the changed area + highlighted. This option controls files are included. Only + include analysed frames if you have a high bandwidth connection + to the remote server or if you need help in figuring out what + caused an alarm in the first place as archives with these files + in can be considerably larger. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_PROTOCOL", - default => "ftp", - description => "What protocol to use to upload events", - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], - help => qqq(" - ZoneMinder can upload events to a remote server using either - FTP or SFTP. Regular FTP is widely supported but not - necessarily very secure whereas SFTP (Secure FTP) runs over an - ssh connection and so is encrypted and uses regular ssh ports. - Note that to use this you will need to have the appropriate - perl module, either Net::FTP or Net::SFTP installed depending - on your choice. - "), + name => 'ZM_UPLOAD_PROTOCOL', + default => 'ftp', + description => 'What protocol to use to upload events', + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], + help => q` + ZoneMinder can upload events to a remote server using either + FTP or SFTP. Regular FTP is widely supported but not + necessarily very secure whereas SFTP (Secure FTP) runs over an + ssh connection and so is encrypted and uses regular ssh ports. + Note that to use this you will need to have the appropriate + perl module, either Net::FTP or Net::SFTP installed depending + on your choice. + `, type => { - db_type =>"string", - hint =>"ftp|sftp", + db_type =>'string', + hint =>'ftp|sftp', pattern =>qr|^([tz])|i, - format =>q( $1 =~ /^f/ ? "ftp" : "sftp" ) + format =>q( $1 =~ /^f/ ? 'ftp' : 'sftp' ) }, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_HOST", - default => "", - description => "The remote server to upload to", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the name, or ip - address, of the server to use. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_HOST', + default => '', + description => 'The remote server to upload to', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the name, or ip + address, of the server to use. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{hostname}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_HOST", - default => "", - description => "The remote server to upload events to", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the name, or ip address, - of the server to use. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_HOST', + default => '', + description => 'The remote server to upload events to', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the name, or ip address, + of the server to use. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{hostname}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_PORT", - default => "", - description => "The port on the remote upload server, if not the default (SFTP only)", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. If you are using the SFTP protocol then this - option allows you to specify a particular port to use for - connection. If this option is left blank then the default, port - 22, is used. This option is ignored for FTP uploads. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_PORT', + default => '', + description => 'The port on the remote upload server, if not the default (SFTP only)', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. If you are using the SFTP protocol then this + option allows you to specify a particular port to use for + connection. If this option is left blank then the default, port + 22, is used. This option is ignored for FTP uploads. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{integer}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_USER", - default => "", - description => "Your ftp username", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the username that - ZoneMinder should use to log in for ftp transfer. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_USER', + default => '', + description => 'Your ftp username', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the username that + ZoneMinder should use to log in for ftp transfer. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{alphanum}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_USER", - default => "", - description => "Remote server username", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the username that - ZoneMinder should use to log in for transfer. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_USER', + default => '', + description => 'Remote server username', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the username that + ZoneMinder should use to log in for transfer. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{alphanum}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_PASS", - default => "", - description => "Your ftp password", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the password that - ZoneMinder should use to log in for ftp transfer. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_PASS', + default => '', + description => 'Your ftp password', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the password that + ZoneMinder should use to log in for ftp transfer. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{string}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_PASS", - default => "", - description => "Remote server password", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the password that - ZoneMinder should use to log in for transfer. If you are using - certificate based logins for SFTP servers you can leave this - option blank. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_PASS', + default => '', + description => 'Remote server password', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the password that + ZoneMinder should use to log in for transfer. If you are using + certificate based logins for SFTP servers you can leave this + option blank. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{string}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_LOC_DIR", - default => "@ZM_TMPDIR@", - description => "The local directory in which to create upload files", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the local directory - that ZoneMinder should use for temporary upload files. These - are files that are created from events, uploaded and then - deleted. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_LOC_DIR', + default => '@ZM_TMPDIR@', + description => 'The local directory in which to create upload files', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the local directory + that ZoneMinder should use for temporary upload files. These + are files that are created from events, uploaded and then + deleted. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{abs_path}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_LOC_DIR", - default => "@ZM_TMPDIR@", - description => "The local directory in which to create upload files", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the local directory that - ZoneMinder should use for temporary upload files. These are - files that are created from events, uploaded and then deleted. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_LOC_DIR', + default => '@ZM_TMPDIR@', + description => 'The local directory in which to create upload files', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the local directory that + ZoneMinder should use for temporary upload files. These are + files that are created from events, uploaded and then deleted. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{abs_path}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_REM_DIR", - default => "", - description => "The remote directory to upload to", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the remote directory - that ZoneMinder should use to upload event files to. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_REM_DIR', + default => '', + description => 'The remote directory to upload to', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the remote directory + that ZoneMinder should use to upload event files to. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{rel_path}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_REM_DIR", - default => "", - description => "The remote directory to upload to", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the remote directory - that ZoneMinder should use to upload event files to. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_REM_DIR', + default => '', + description => 'The remote directory to upload to', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the remote directory + that ZoneMinder should use to upload event files to. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{rel_path}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_TIMEOUT", - default => "120", - description => "How long to allow the transfer to take for each file", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates the maximum ftp - inactivity timeout (in seconds) that should be tolerated before - ZoneMinder determines that the transfer has failed and closes - down the connection. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_TIMEOUT', + default => '120', + description => 'How long to allow the transfer to take for each file', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates the maximum ftp + inactivity timeout (in seconds) that should be tolerated before + ZoneMinder determines that the transfer has failed and closes + down the connection. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{integer}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_TIMEOUT", - default => "120", - description => "How long to allow the transfer to take for each file", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. This option indicates the maximum inactivity - timeout (in seconds) that should be tolerated before ZoneMinder - determines that the transfer has failed and closes down the - connection. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_TIMEOUT', + default => '120', + description => 'How long to allow the transfer to take for each file', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. This option indicates the maximum inactivity + timeout (in seconds) that should be tolerated before ZoneMinder + determines that the transfer has failed and closes down the + connection. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{integer}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_STRICT", - default => "no", - description => "Require strict host key checking for SFTP uploads", - help => qqq(" - You can require SFTP uploads to verify the host key of the remote server - for protection against man-in-the-middle attacks. You will need to add the - server's key to the known_hosts file. On most systems, this will be - ~/.ssh/known_hosts, where ~ is the home directory of the web server running - ZoneMinder. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_STRICT', + default => 'no', + description => 'Require strict host key checking for SFTP uploads', + help => q` + You can require SFTP uploads to verify the host key of the remote server + for protection against man-in-the-middle attacks. You will need to add the + server's key to the known_hosts file. On most systems, this will be + ~/.ssh/known_hosts, where ~ is the home directory of the web server running + ZoneMinder. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_PASSIVE", - default => "yes", - description => "Use passive ftp when uploading", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. This option indicates that ftp transfers - should be done in passive mode. This uses a single connection - for all ftp activity and, whilst slower than active transfers, - is more robust and likely to work from behind filewalls. This - option is ignored for SFTP transfers. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], - help => qqq(" - If your computer is behind a firewall or proxy you may need to - set FTP to passive mode. In fact for simple transfers it makes - little sense to do otherwise anyway but you can set this to - 'No' if you wish. - "), + name => 'ZM_UPLOAD_FTP_PASSIVE', + default => 'yes', + description => 'Use passive ftp when uploading', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. This option indicates that ftp transfers + should be done in passive mode. This uses a single connection + for all ftp activity and, whilst slower than active transfers, + is more robust and likely to work from behind filewalls. This + option is ignored for SFTP transfers. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], + help => q` + If your computer is behind a firewall or proxy you may need to + set FTP to passive mode. In fact for simple transfers it makes + little sense to do otherwise anyway but you can set this to + 'No' if you wish. + `, type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_UPLOAD_FTP_DEBUG", - default => "no", - description => "Switch ftp debugging on", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote ftp server. If you are having (or expecting) troubles - with uploading events then setting this to 'yes' permits - additional information to be included in the zmfilter log file. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_FTP_DEBUG', + default => 'no', + description => 'Switch ftp debugging on', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote ftp server. If you are having (or expecting) troubles + with uploading events then setting this to 'yes' permits + additional information to be included in the zmfilter log file. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{boolean}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_UPLOAD_DEBUG", - default => "no", - description => "Switch upload debugging on", - help => qqq(" - You can use filters to instruct ZoneMinder to upload events to - a remote server. If you are having (or expecting) troubles with - uploading events then setting this to 'yes' permits additional - information to be generated by the underlying transfer modules - and included in the logs. - "), - requires => [ { name => "ZM_OPT_UPLOAD", value => "yes" } ], + name => 'ZM_UPLOAD_DEBUG', + default => 'no', + description => 'Switch upload debugging on', + help => q` + You can use filters to instruct ZoneMinder to upload events to + a remote server. If you are having (or expecting) troubles with + uploading events then setting this to 'yes' permits additional + information to be generated by the underlying transfer modules + and included in the logs. + `, + requires => [ { name => 'ZM_OPT_UPLOAD', value => 'yes' } ], type => $types{boolean}, - category => "upload", + category => 'upload', }, { - name => "ZM_OPT_EMAIL", - default => "no", - description => "Should ZoneMinder email you details of events that match corresponding filters", - help => qqq(" - In ZoneMinder you can create event filters that specify whether - events that match certain criteria should have their details - emailed to you at a designated email address. This will allow - you to be notified of events as soon as they occur and also to - quickly view the events directly. This option specifies whether - this functionality should be available. The email created with - this option can be any size and is intended to be sent to a - regular email reader rather than a mobile device. - "), + name => 'ZM_OPT_EMAIL', + default => 'no', + description => 'Should ZoneMinder email you details of events that match corresponding filters', + help => q` + In ZoneMinder you can create event filters that specify whether + events that match certain criteria should have their details + emailed to you at a designated email address. This will allow + you to be notified of events as soon as they occur and also to + quickly view the events directly. This option specifies whether + this functionality should be available. The email created with + this option can be any size and is intended to be sent to a + regular email reader rather than a mobile device. + `, type => $types{boolean}, - category => "mail", + category => 'mail', }, { - name => "ZM_EMAIL_ADDRESS", - default => "", - description => "The email address to send matching event details to", - requires => [ { name => "ZM_OPT_EMAIL", value => "yes" } ], - help => qqq(" - This option is used to define the email address that any events - that match the appropriate filters will be sent to. - "), + name => 'ZM_EMAIL_ADDRESS', + default => '', + description => 'The email address to send matching event details to', + requires => [ { name => 'ZM_OPT_EMAIL', value => 'yes' } ], + help => q` + This option is used to define the email address that any events + that match the appropriate filters will be sent to. + `, type => $types{email}, - category => "mail", + category => 'mail', }, { - name => "ZM_EMAIL_TEXT", + name => 'ZM_EMAIL_TEXT', default => 'subject = "ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)" body = " Hello, @@ -2262,30 +2256,30 @@ our @options = ( This alarm was matched by the %FN% filter and can be viewed at %EPS% ZoneMinder"', - description => "The text of the email used to send matching event details", - requires => [ { name => "ZM_OPT_EMAIL", value => "yes" } ], - help => qqq(" - This option is used to define the content of the email that is - sent for any events that match the appropriate filters. - "), + description => 'The text of the email used to send matching event details', + requires => [ { name => 'ZM_OPT_EMAIL', value => 'yes' } ], + help => q` + This option is used to define the content of the email that is + sent for any events that match the appropriate filters. + `, type => $types{text}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_EMAIL_SUBJECT", - default => "ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)", - description => "The subject of the email used to send matching event details", - requires => [ { name => "ZM_OPT_EMAIL", value => "yes" } ], - help => qqq(" - This option is used to define the subject of the email that is - sent for any events that match the appropriate filters. - "), + name => 'ZM_EMAIL_SUBJECT', + default => 'ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)', + description => 'The subject of the email used to send matching event details', + requires => [ { name => 'ZM_OPT_EMAIL', value => 'yes' } ], + help => q` + This option is used to define the subject of the email that is + sent for any events that match the appropriate filters. + `, type => $types{string}, - category => "mail", + category => 'mail', }, { - name => "ZM_EMAIL_BODY", - default => " + name => 'ZM_EMAIL_BODY', + default => ' Hello, An alarm has been detected on your installation of the ZoneMinder. @@ -2300,1601 +2294,1600 @@ our @options = ( This alarm was matched by the %FN% filter and can be viewed at %EPS% - ZoneMinder", - description => "The body of the email used to send matching event details", - requires => [ { name => "ZM_OPT_EMAIL", value => "yes" } ], - help => qqq(" - This option is used to define the content of the email that is - sent for any events that match the appropriate filters. - "), + ZoneMinder', + description => 'The body of the email used to send matching event details', + requires => [ { name => 'ZM_OPT_EMAIL', value => 'yes' } ], + help => q` + This option is used to define the content of the email that is + sent for any events that match the appropriate filters. + `, type => $types{text}, - category => "mail", + category => 'mail', }, { - name => "ZM_OPT_MESSAGE", - default => "no", - description => "Should ZoneMinder message you with details of events that match corresponding filters", - help => qqq(" - In ZoneMinder you can create event filters that specify whether - events that match certain criteria should have their details - sent to you at a designated short message email address. This - will allow you to be notified of events as soon as they occur. - This option specifies whether this functionality should be - available. The email created by this option will be brief and - is intended to be sent to an SMS gateway or a minimal mail - reader such as a mobile device or phone rather than a regular - email reader. - "), + name => 'ZM_OPT_MESSAGE', + default => 'no', + description => 'Should ZoneMinder message you with details of events that match corresponding filters', + help => q` + In ZoneMinder you can create event filters that specify whether + events that match certain criteria should have their details + sent to you at a designated short message email address. This + will allow you to be notified of events as soon as they occur. + This option specifies whether this functionality should be + available. The email created by this option will be brief and + is intended to be sent to an SMS gateway or a minimal mail + reader such as a mobile device or phone rather than a regular + email reader. + `, type => $types{boolean}, - category => "mail", + category => 'mail', }, { - name => "ZM_MESSAGE_ADDRESS", - default => "", - description => "The email address to send matching event details to", - requires => [ { name => "ZM_OPT_MESSAGE", value => "yes" } ], - help => qqq(" - This option is used to define the short message email address - that any events that match the appropriate filters will be sent - to. - "), + name => 'ZM_MESSAGE_ADDRESS', + default => '', + description => 'The email address to send matching event details to', + requires => [ { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], + help => q` + This option is used to define the short message email address + that any events that match the appropriate filters will be sent + to. + `, type => $types{email}, - category => "mail", + category => 'mail', }, { - name => "ZM_MESSAGE_TEXT", + name => 'ZM_MESSAGE_TEXT', default => 'subject = "ZoneMinder: Alarm - %MN%-%EI%" body = "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score."', - description => "The text of the message used to send matching event details", - requires => [ { name => "ZM_OPT_MESSAGE", value => "yes" } ], - help => qqq(" - This option is used to define the content of the message that - is sent for any events that match the appropriate filters. - "), + description => 'The text of the message used to send matching event details', + requires => [ { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], + help => q` + This option is used to define the content of the message that + is sent for any events that match the appropriate filters. + `, type => $types{text}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_MESSAGE_SUBJECT", - default => "ZoneMinder: Alarm - %MN%-%EI%", - description => "The subject of the message used to send matching event details", - requires => [ { name => "ZM_OPT_MESSAGE", value => "yes" } ], - help => qqq(" - This option is used to define the subject of the message that - is sent for any events that match the appropriate filters. - "), + name => 'ZM_MESSAGE_SUBJECT', + default => 'ZoneMinder: Alarm - %MN%-%EI%', + description => 'The subject of the message used to send matching event details', + requires => [ { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], + help => q` + This option is used to define the subject of the message that + is sent for any events that match the appropriate filters. + `, type => $types{string}, - category => "mail", + category => 'mail', }, { - name => "ZM_MESSAGE_BODY", - default => "ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.", - description => "The body of the message used to send matching event details", - requires => [ { name => "ZM_OPT_MESSAGE", value => "yes" } ], - help => qqq(" - This option is used to define the content of the message that - is sent for any events that match the appropriate filters. - "), + name => 'ZM_MESSAGE_BODY', + default => 'ZM alarm detected - %EL% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.', + description => 'The body of the message used to send matching event details', + requires => [ { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], + help => q` + This option is used to define the content of the message that + is sent for any events that match the appropriate filters. + `, type => $types{text}, - category => "mail", + category => 'mail', }, { - name => "ZM_NEW_MAIL_MODULES", - default => "no", - description => "Use a newer perl method to send emails", + name => 'ZM_NEW_MAIL_MODULES', + default => 'no', + description => 'Use a newer perl method to send emails', requires => [ - { name => "ZM_OPT_EMAIL", value => "yes" }, - { name => "ZM_OPT_MESSAGE", value => "yes" } + { name => 'ZM_OPT_EMAIL', value => 'yes' }, + { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], - help => qqq(" - Traditionally ZoneMinder has used the MIME::Entity perl module - to construct and send notification emails and messages. Some - people have reported problems with this module not being - present at all or flexible enough for their needs. If you are - one of those people this option allows you to select a new - mailing method using MIME::Lite and Net::SMTP instead. This - method was contributed by Ross Melin and should work for - everyone but has not been extensively tested so currently is - not selected by default. - "), + help => q` + Traditionally ZoneMinder has used the MIME::Entity perl module + to construct and send notification emails and messages. Some + people have reported problems with this module not being + present at all or flexible enough for their needs. If you are + one of those people this option allows you to select a new + mailing method using MIME::Lite and Net::SMTP instead. This + method was contributed by Ross Melin and should work for + everyone but has not been extensively tested so currently is + not selected by default. + `, type => $types{boolean}, - category => "mail", + category => 'mail', }, { - name => "ZM_EMAIL_HOST", - default => "localhost", - description => "The host address of your SMTP mail server", + name => 'ZM_EMAIL_HOST', + default => 'localhost', + description => 'The host address of your SMTP mail server', requires => [ - { name => "ZM_OPT_EMAIL", value => "yes" }, - { name => "ZM_OPT_MESSAGE", value => "yes" } + { name => 'ZM_OPT_EMAIL', value => 'yes' }, + { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], - help => qqq(" - If you have chosen SMTP as the method by which to send - notification emails or messages then this option allows you to - choose which SMTP server to use to send them. The default of - localhost may work if you have the sendmail, exim or a similar - daemon running however you may wish to enter your ISP's SMTP - mail server here. - "), + help => q` + If you have chosen SMTP as the method by which to send + notification emails or messages then this option allows you to + choose which SMTP server to use to send them. The default of + localhost may work if you have the sendmail, exim or a similar + daemon running however you may wish to enter your ISP's SMTP + mail server here. + `, type => $types{hostname}, - category => "mail", + category => 'mail', }, { - name => "ZM_FROM_EMAIL", - default => "", - description => "The email address you wish your event notifications to originate from", + name => 'ZM_FROM_EMAIL', + default => '', + description => 'The email address you wish your event notifications to originate from', requires => [ - { name => "ZM_OPT_EMAIL", value => "yes" }, - { name => "ZM_OPT_MESSAGE", value => "yes" } + { name => 'ZM_OPT_EMAIL', value => 'yes' }, + { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], - help => qqq(" - The emails or messages that will be sent to you informing you - of events can appear to come from a designated email address to - help you with mail filtering etc. An address of something like - ZoneMinder\@your.domain is recommended. - "), + help => q` + The emails or messages that will be sent to you informing you + of events can appear to come from a designated email address to + help you with mail filtering etc. An address of something like + ZoneMinder\@your.domain is recommended. + `, type => $types{email}, - category => "mail", + category => 'mail', }, { - name => "ZM_URL", - default => "", - description => "The URL of your ZoneMinder installation", + name => 'ZM_URL', + default => '', + description => 'The URL of your ZoneMinder installation', requires => [ - { name => "ZM_OPT_EMAIL", value => "yes" }, - { name => "ZM_OPT_MESSAGE", value => "yes" } + { name => 'ZM_OPT_EMAIL', value => 'yes' }, + { name => 'ZM_OPT_MESSAGE', value => 'yes' } ], - help => qqq(" - The emails or messages that will be sent to you informing you - of events can include a link to the events themselves for easy - viewing. If you intend to use this feature then set this option - to the url of your installation as it would appear from where - you read your email, e.g. http://host.your.domain/zm.php. - "), + help => q` + The emails or messages that will be sent to you informing you + of events can include a link to the events themselves for easy + viewing. If you intend to use this feature then set this option + to the url of your installation as it would appear from where + you read your email, e.g. http://host.your.domain/zm.php. + `, type => $types{url}, - category => "mail", + category => 'mail', }, { - name => "ZM_MAX_RESTART_DELAY", - default => "600", - description => "Maximum delay (in seconds) for daemon restart attempts.", - help => qqq(" - The zmdc (zm daemon control) process controls when processeses - are started or stopped and will attempt to restart any that - fail. If a daemon fails frequently then a delay is introduced - between each restart attempt. If the daemon stills fails then - this delay is increased to prevent extra load being placed on - the system by continual restarts. This option controls what - this maximum delay is. - "), + name => 'ZM_MAX_RESTART_DELAY', + default => '600', + description => 'Maximum delay (in seconds) for daemon restart attempts.', + help => q` + The zmdc (zm daemon control) process controls when processeses + are started or stopped and will attempt to restart any that + fail. If a daemon fails frequently then a delay is introduced + between each restart attempt. If the daemon stills fails then + this delay is increased to prevent extra load being placed on + the system by continual restarts. This option controls what + this maximum delay is. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_WATCH_CHECK_INTERVAL", - default => "10", - description => "How often to check the capture daemons have not locked up", - help => qqq(" - The zmwatch daemon checks the image capture performance of the - capture daemons to ensure that they have not locked up (rarely - a sync error may occur which blocks indefinitely). This option - determines how often the daemons are checked. - "), + name => 'ZM_WATCH_CHECK_INTERVAL', + default => '10', + description => 'How often to check the capture daemons have not locked up', + help => q` + The zmwatch daemon checks the image capture performance of the + capture daemons to ensure that they have not locked up (rarely + a sync error may occur which blocks indefinitely). This option + determines how often the daemons are checked. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_WATCH_MAX_DELAY", - default => "5", - description => "The maximum delay allowed since the last captured image", - help => qqq(" - The zmwatch daemon checks the image capture performance of the - capture daemons to ensure that they have not locked up (rarely - a sync error may occur which blocks indefinitely). This option - determines the maximum delay to allow since the last captured - frame. The daemon will be restarted if it has not captured any - images after this period though the actual restart may take - slightly longer in conjunction with the check interval value - above. - "), + name => 'ZM_WATCH_MAX_DELAY', + default => '5', + description => 'The maximum delay allowed since the last captured image', + help => q` + The zmwatch daemon checks the image capture performance of the + capture daemons to ensure that they have not locked up (rarely + a sync error may occur which blocks indefinitely). This option + determines the maximum delay to allow since the last captured + frame. The daemon will be restarted if it has not captured any + images after this period though the actual restart may take + slightly longer in conjunction with the check interval value + above. + `, type => $types{decimal}, - category => "system", + category => 'system', }, { - - name => "ZM_RUN_AUDIT", - default => "yes", - description => "Run zmaudit to check data consistency", - help => qqq(" - The zmaudit daemon exists to check that the saved information - in the database and on the filesystem match and are consistent - with each other. If an error occurs or if you are using 'fast - deletes' it may be that database records are deleted but files - remain. In this case, and similar, zmaudit will remove - redundant information to synchronise the two data stores. This - option controls whether zmaudit is run in the background and - performs these checks and fixes continuously. This is - recommended for most systems however if you have a very large - number of events the process of scanning the database and - filesystem may take a long time and impact performance. In this - case you may prefer to not have zmaudit running unconditionally - and schedule occasional checks at other, more convenient, - times. - "), + name => 'ZM_RUN_AUDIT', + default => 'yes', + description => 'Run zmaudit to check data consistency', + help => q` + The zmaudit daemon exists to check that the saved information + in the database and on the filesystem match and are consistent + with each other. If an error occurs or if you are using 'fast + deletes' it may be that database records are deleted but files + remain. In this case, and similar, zmaudit will remove + redundant information to synchronise the two data stores. This + option controls whether zmaudit is run in the background and + performs these checks and fixes continuously. This is + recommended for most systems however if you have a very large + number of events the process of scanning the database and + filesystem may take a long time and impact performance. In this + case you may prefer to not have zmaudit running unconditionally + and schedule occasional checks at other, more convenient, + times. + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_AUDIT_CHECK_INTERVAL", - default => "900", - description => "How often to check database and filesystem consistency", - help => qqq(" - The zmaudit daemon exists to check that the saved information - in the database and on the filesystem match and are consistent - with each other. If an error occurs or if you are using 'fast - deletes' it may be that database records are deleted but files - remain. In this case, and similar, zmaudit will remove - redundant information to synchronise the two data stores. The - default check interval of 900 seconds (15 minutes) is fine for - most systems however if you have a very large number of events - the process of scanning the database and filesystem may take a - long time and impact performance. In this case you may prefer - to make this interval much larger to reduce the impact on your - system. This option determines how often these checks are - performed. - "), + name => 'ZM_AUDIT_CHECK_INTERVAL', + default => '900', + description => 'How often to check database and filesystem consistency', + help => q` + The zmaudit daemon exists to check that the saved information + in the database and on the filesystem match and are consistent + with each other. If an error occurs or if you are using 'fast + deletes' it may be that database records are deleted but files + remain. In this case, and similar, zmaudit will remove + redundant information to synchronise the two data stores. The + default check interval of 900 seconds (15 minutes) is fine for + most systems however if you have a very large number of events + the process of scanning the database and filesystem may take a + long time and impact performance. In this case you may prefer + to make this interval much larger to reduce the impact on your + system. This option determines how often these checks are + performed. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_AUDIT_MIN_AGE", - default => "86400", - description => "The minimum age in seconds event data must be in order to be deleted.", - help => qqq(" - The zmaudit daemon exists to check that the saved information - in the database and on the filesystem match and are consistent - with each other. Event files or db records that are younger than - this setting will not be deleted and a warning will be given. - "), + name => 'ZM_AUDIT_MIN_AGE', + default => '86400', + description => 'The minimum age in seconds event data must be in order to be deleted.', + help => q` + The zmaudit daemon exists to check that the saved information + in the database and on the filesystem match and are consistent + with each other. Event files or db records that are younger than + this setting will not be deleted and a warning will be given. + `, type => $types{integer}, - category => "system", + category => 'system', }, { - name => "ZM_FORCED_ALARM_SCORE", - default => "255", - description => "Score to give forced alarms", - help => qqq(" - The 'zmu' utility can be used to force an alarm on a monitor - rather than rely on the motion detection algorithms. This - option determines what score to give these alarms to - distinguish them from regular ones. It must be 255 or less. - "), + name => 'ZM_FORCED_ALARM_SCORE', + default => '255', + description => 'Score to give forced alarms', + help => q` + The 'zmu' utility can be used to force an alarm on a monitor + rather than rely on the motion detection algorithms. This + option determines what score to give these alarms to + distinguish them from regular ones. It must be 255 or less. + `, type => $types{integer}, - category => "config", + category => 'config', }, { - name => "ZM_BULK_FRAME_INTERVAL", - default => "100", - description => "How often a bulk frame should be written to the database", - help => qqq(" - Traditionally ZoneMinder writes an entry into the Frames - database table for each frame that is captured and saved. This - works well in motion detection scenarios but when in a DVR - situation ('Record' or 'Mocord' mode) this results in a huge - number of frame writes and a lot of database and disk bandwidth - for very little additional information. Setting this to a - non-zero value will enabled ZoneMinder to group these non-alarm - frames into one 'bulk' frame entry which saves a lot of - bandwidth and space. The only disadvantage of this is that - timing information for individual frames is lost but in - constant frame rate situations this is usually not significant. - This setting is ignored in Modect mode and individual frames - are still written if an alarm occurs in Mocord mode also. - "), + name => 'ZM_BULK_FRAME_INTERVAL', + default => '100', + description => 'How often a bulk frame should be written to the database', + help => q` + Traditionally ZoneMinder writes an entry into the Frames + database table for each frame that is captured and saved. This + works well in motion detection scenarios but when in a DVR + situation ('Record' or 'Mocord' mode) this results in a huge + number of frame writes and a lot of database and disk bandwidth + for very little additional information. Setting this to a + non-zero value will enabled ZoneMinder to group these non-alarm + frames into one 'bulk' frame entry which saves a lot of + bandwidth and space. The only disadvantage of this is that + timing information for individual frames is lost but in + constant frame rate situations this is usually not significant. + This setting is ignored in Modect mode and individual frames + are still written if an alarm occurs in Mocord mode also. + `, type => $types{integer}, - category => "config", + category => 'config', }, { - name => "ZM_EVENT_CLOSE_MODE", - default => "idle", - description => "When continuous events are closed.", - help => qqq(" - When a monitor is running in a continuous recording mode - (Record or Mocord) events are usually closed after a fixed - period of time (the section length). However in Mocord mode it - is possible that motion detection may occur near the end of a - section. This option controls what happens when an alarm occurs - in Mocord mode. The 'time' setting means that the event will be - closed at the end of the section regardless of alarm activity. - The 'idle' setting means that the event will be closed at the - end of the section if there is no alarm activity occurring at - the time otherwise it will be closed once the alarm is over - meaning the event may end up being longer than the normal - section length. The 'alarm' setting means that if an alarm - occurs during the event, the event will be closed once the - alarm is over regardless of when this occurs. This has the - effect of limiting the number of alarms to one per event and - the events will be shorter than the section length if an alarm - has occurred. - "), + name => 'ZM_EVENT_CLOSE_MODE', + default => 'idle', + description => 'When continuous events are closed.', + help => q` + When a monitor is running in a continuous recording mode + (Record or Mocord) events are usually closed after a fixed + period of time (the section length). However in Mocord mode it + is possible that motion detection may occur near the end of a + section. This option controls what happens when an alarm occurs + in Mocord mode. The 'time' setting means that the event will be + closed at the end of the section regardless of alarm activity. + The 'idle' setting means that the event will be closed at the + end of the section if there is no alarm activity occurring at + the time otherwise it will be closed once the alarm is over + meaning the event may end up being longer than the normal + section length. The 'alarm' setting means that if an alarm + occurs during the event, the event will be closed once the + alarm is over regardless of when this occurs. This has the + effect of limiting the number of alarms to one per event and + the events will be shorter than the section length if an alarm + has occurred. + `, type => $types{boolean}, type => { - db_type =>"string", - hint =>"time|idle|alarm", + db_type =>'string', + hint =>'time|idle|alarm', pattern =>qr|^([tia])|i, format =>q( ($1 =~ /^t/) - ? "time" - : ($1 =~ /^i/ ? "idle" : "time" ) + ? 'time' + : ($1 =~ /^i/ ? 'idle' : 'time' ) ) }, - category => "config", + category => 'config', }, # Deprecated, superseded by event close mode { - name => "ZM_FORCE_CLOSE_EVENTS", - default => "no", - description => "Close events at section ends.", - help => qqq(" - When a monitor is running in a continuous recording mode - (Record or Mocord) events are usually closed after a fixed - period of time (the section length). However in Mocord mode it - is possible that motion detection may occur near the end of a - section and ordinarily this will prevent the event being closed - until the motion has ceased. Switching this option on will - force the event closed at the specified time regardless of any - motion activity. - "), + name => 'ZM_FORCE_CLOSE_EVENTS', + default => 'no', + description => 'Close events at section ends.', + help => q` + When a monitor is running in a continuous recording mode + (Record or Mocord) events are usually closed after a fixed + period of time (the section length). However in Mocord mode it + is possible that motion detection may occur near the end of a + section and ordinarily this will prevent the event being closed + until the motion has ceased. Switching this option on will + force the event closed at the specified time regardless of any + motion activity. + `, type => $types{boolean}, - category => "hidden", + category => 'hidden', }, { - name => "ZM_CREATE_ANALYSIS_IMAGES", - default => "yes", - description => "Create analysed alarm images with motion outlined", - help => qqq(" - By default during an alarm ZoneMinder records both the raw - captured image and one that has been analysed and had areas - where motion was detected outlined. This can be very useful - during zone configuration or in analysing why events occurred. - However it also incurs some overhead and in a stable system may - no longer be necessary. This parameter allows you to switch the - generation of these images off. - "), + name => 'ZM_CREATE_ANALYSIS_IMAGES', + default => 'yes', + description => 'Create analysed alarm images with motion outlined', + help => q` + By default during an alarm ZoneMinder records both the raw + captured image and one that has been analysed and had areas + where motion was detected outlined. This can be very useful + during zone configuration or in analysing why events occurred. + However it also incurs some overhead and in a stable system may + no longer be necessary. This parameter allows you to switch the + generation of these images off. + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_WEIGHTED_ALARM_CENTRES", - default => "no", - description => "Use a weighted algorithm to calculate the centre of an alarm", - help => qqq(" - ZoneMinder will always calculate the centre point of an alarm - in a zone to give some indication of where on the screen it is. - This can be used by the experimental motion tracking feature or - your own custom extensions. In the alarmed or filtered pixels - mode this is a simple midpoint between the extents of the - detected pixels. However in the blob method this can instead be - calculated using weighted pixel locations to give more accurate - positioning for irregularly shaped blobs. This method, while - more precise is also slower and so is turned off by default. - "), + name => 'ZM_WEIGHTED_ALARM_CENTRES', + default => 'no', + description => 'Use a weighted algorithm to calculate the centre of an alarm', + help => q` + ZoneMinder will always calculate the centre point of an alarm + in a zone to give some indication of where on the screen it is. + This can be used by the experimental motion tracking feature or + your own custom extensions. In the alarmed or filtered pixels + mode this is a simple midpoint between the extents of the + detected pixels. However in the blob method this can instead be + calculated using weighted pixel locations to give more accurate + positioning for irregularly shaped blobs. This method, while + more precise is also slower and so is turned off by default. + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_EVENT_IMAGE_DIGITS", - default => "5", - description => "How many significant digits are used in event image numbering", - help => qqq(" - As event images are captured they are stored to the filesystem - with a numerical index. By default this index has three digits - so the numbers start 001, 002 etc. This works works for most - scenarios as events with more than 999 frames are rarely - captured. However if you have extremely long events and use - external applications then you may wish to increase this to - ensure correct sorting of images in listings etc. Warning, - increasing this value on a live system may render existing - events unviewable as the event will have been saved with the - previous scheme. Decreasing this value should have no ill - effects. - "), + name => 'ZM_EVENT_IMAGE_DIGITS', + default => '5', + description => 'How many significant digits are used in event image numbering', + help => q` + As event images are captured they are stored to the filesystem + with a numerical index. By default this index has three digits + so the numbers start 001, 002 etc. This works works for most + scenarios as events with more than 999 frames are rarely + captured. However if you have extremely long events and use + external applications then you may wish to increase this to + ensure correct sorting of images in listings etc. Warning, + increasing this value on a live system may render existing + events unviewable as the event will have been saved with the + previous scheme. Decreasing this value should have no ill + effects. + `, type => $types{integer}, - category => "config", + category => 'config', }, { - name => "ZM_DEFAULT_ASPECT_RATIO", - default => "4:3", - description => "The default width:height aspect ratio used in monitors", - help => qqq(" - When specifying the dimensions of monitors you can click a - checkbox to ensure that the width stays in the correct ratio to - the height, or vice versa. This setting allows you to indicate - what the ratio of these settings should be. This should be - specified in the format : and the - default of 4:3 normally be acceptable but 11:9 is another - common setting. If the checkbox is not clicked when specifying - monitor dimensions this setting has no effect. - "), + name => 'ZM_DEFAULT_ASPECT_RATIO', + default => '4:3', + description => 'The default width:height aspect ratio used in monitors', + help => q` + When specifying the dimensions of monitors you can click a + checkbox to ensure that the width stays in the correct ratio to + the height, or vice versa. This setting allows you to indicate + what the ratio of these settings should be. This should be + specified in the format : and the + default of 4:3 normally be acceptable but 11:9 is another + common setting. If the checkbox is not clicked when specifying + monitor dimensions this setting has no effect. + `, type => $types{string}, - category => "config", + category => 'config', }, { - name => "ZM_USER_SELF_EDIT", - default => "no", - description => "Allow unprivileged users to change their details", - help => qqq(" - Ordinarily only users with system edit privilege are able to - change users details. Switching this option on allows ordinary - users to change their passwords and their language settings - "), + name => 'ZM_USER_SELF_EDIT', + default => 'no', + description => 'Allow unprivileged users to change their details', + help => q` + Ordinarily only users with system edit privilege are able to + change users details. Switching this option on allows ordinary + users to change their passwords and their language settings + `, type => $types{boolean}, - category => "config", + category => 'config', }, { - name => "ZM_OPT_CONTROL", - default => "no", - description => "Support controllable (e.g. PTZ) cameras", - help => qqq(" - ZoneMinder includes limited support for controllable cameras. A - number of sample protocols are included and others can easily - be added. If you wish to control your cameras via ZoneMinder - then select this option otherwise if you only have static - cameras or use other control methods then leave this option - off. - "), + name => 'ZM_OPT_CONTROL', + default => 'no', + description => 'Support controllable (e.g. PTZ) cameras', + help => q` + ZoneMinder includes limited support for controllable cameras. A + number of sample protocols are included and others can easily + be added. If you wish to control your cameras via ZoneMinder + then select this option otherwise if you only have static + cameras or use other control methods then leave this option + off. + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_OPT_TRIGGERS", - default => "no", - description => "Interface external event triggers via socket or device files", - help => qqq(" - ZoneMinder can interact with external systems which prompt or - cancel alarms. This is done via the zmtrigger.pl script. This - option indicates whether you want to use these external - triggers. Most people will say no here. - "), + name => 'ZM_OPT_TRIGGERS', + default => 'no', + description => 'Interface external event triggers via socket or device files', + help => q` + ZoneMinder can interact with external systems which prompt or + cancel alarms. This is done via the zmtrigger.pl script. This + option indicates whether you want to use these external + triggers. Most people will say no here. + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_CHECK_FOR_UPDATES", - default => "yes", - description => "Check with zoneminder.com for updated versions", - help => qqq(" - From ZoneMinder version 1.17.0 onwards new versions are - expected to be more frequent. To save checking manually for - each new version ZoneMinder can check with the zoneminder.com - website to determine the most recent release. These checks are - infrequent, about once per week, and no personal or system - information is transmitted other than your current version - number. If you do not wish these checks to take place or your - ZoneMinder system has no internet access you can switch these - check off with this configuration variable - "), + name => 'ZM_CHECK_FOR_UPDATES', + default => 'yes', + description => 'Check with zoneminder.com for updated versions', + help => q` + From ZoneMinder version 1.17.0 onwards new versions are + expected to be more frequent. To save checking manually for + each new version ZoneMinder can check with the zoneminder.com + website to determine the most recent release. These checks are + infrequent, about once per week, and no personal or system + information is transmitted other than your current version + number. If you do not wish these checks to take place or your + ZoneMinder system has no internet access you can switch these + check off with this configuration variable + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_TELEMETRY_DATA", - default => "yes", - description => "Send usage information to ZoneMinder", - help => qqq(" - Enable collection of usage information of the local system and send - it to the ZoneMinder development team. This data will be used to - determine things like who and where our customers are, how big their - systems are, the underlying hardware and operating system, etc. - This is being done for the sole purpoase of creating a better - product for our target audience. This script is intended to be - completely transparent to the end user, and can be disabled from - the web console under Options. - "), + name => 'ZM_TELEMETRY_DATA', + default => 'yes', + description => 'Send usage information to ZoneMinder', + help => q` + Enable collection of usage information of the local system and send + it to the ZoneMinder development team. This data will be used to + determine things like who and where our customers are, how big their + systems are, the underlying hardware and operating system, etc. + This is being done for the sole purpoase of creating a better + product for our target audience. This script is intended to be + completely transparent to the end user, and can be disabled from + the web console under Options. + `, type => $types{boolean}, - category => "system", + category => 'system', }, { - name => "ZM_TELEMETRY_UUID", - default => "", - description => "Unique identifier for ZoneMinder telemetry", - help => qqq(" - This variable is auto-generated once by the system and is used to - uniquely identify it among all other ZoneMinder systems in - existence. - "), + name => 'ZM_TELEMETRY_UUID', + default => '', + description => 'Unique identifier for ZoneMinder telemetry', + help => q` + This variable is auto-generated once by the system and is used to + uniquely identify it among all other ZoneMinder systems in + existence. + `, type => $types{string}, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_TELEMETRY_LAST_UPLOAD", - default => "", - description => "When the last ZoneMinder telemetry upload ocurred", - help => "", + name => 'ZM_TELEMETRY_LAST_UPLOAD', + default => '', + description => 'When the last ZoneMinder telemetry upload ocurred', + help => '', type => $types{integer}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_UPDATE_CHECK_PROXY", - default => "", - description => "Proxy url if required to access zoneminder.com", - help => qqq(" - If you use a proxy to access the internet then ZoneMinder needs - to know so it can access zoneminder.com to check for updates. - If you do use a proxy enter the full proxy url here in the form - of http://:/ - "), + name => 'ZM_UPDATE_CHECK_PROXY', + default => '', + description => 'Proxy url if required to access zoneminder.com', + help => q` + If you use a proxy to access the internet then ZoneMinder needs + to know so it can access zoneminder.com to check for updates. + If you do use a proxy enter the full proxy url here in the form + of http://:/ + `, type => $types{string}, - category => "system", + category => 'system', }, { - name => "ZM_SHM_KEY", - default => "0x7a6d0000", - description => "Shared memory root key to use", - help => qqq(" - ZoneMinder uses shared memory to speed up communication between - modules. To identify the right area to use shared memory keys - are used. This option controls what the base key is, each - monitor will have it's Id or'ed with this to get the actual key - used. You will not normally need to change this value unless it - clashes with another instance of ZoneMinder on the same - machine. Only the first four hex digits are used, the lower - four will be masked out and ignored. - "), + name => 'ZM_SHM_KEY', + default => '0x7a6d0000', + description => 'Shared memory root key to use', + help => q` + ZoneMinder uses shared memory to speed up communication between + modules. To identify the right area to use shared memory keys + are used. This option controls what the base key is, each + monitor will have it's Id or'ed with this to get the actual key + used. You will not normally need to change this value unless it + clashes with another instance of ZoneMinder on the same + machine. Only the first four hex digits are used, the lower + four will be masked out and ignored. + `, type => $types{hexadecimal}, - category => "system", + category => 'system', }, # Deprecated, really no longer necessary { - name => "ZM_WEB_REFRESH_METHOD", - default => "javascript", - description => "What method windows should use to refresh themselves", - help => qqq(" - Many windows in Javascript need to refresh themselves to keep - their information current. This option determines what method - they should use to do this. Choosing 'javascript' means that - each window will have a short JavaScript statement in with a - timer to prompt the refresh. This is the most compatible - method. Choosing 'http' means the refresh instruction is put in - the HTTP header. This is a cleaner method but refreshes are - interrupted or cancelled when a link in the window is clicked - meaning that the window will no longer refresh and this would - have to be done manually. - "), + name => 'ZM_WEB_REFRESH_METHOD', + default => 'javascript', + description => 'What method windows should use to refresh themselves', + help => q` + Many windows in Javascript need to refresh themselves to keep + their information current. This option determines what method + they should use to do this. Choosing 'javascript' means that + each window will have a short JavaScript statement in with a + timer to prompt the refresh. This is the most compatible + method. Choosing 'http' means the refresh instruction is put in + the HTTP header. This is a cleaner method but refreshes are + interrupted or cancelled when a link in the window is clicked + meaning that the window will no longer refresh and this would + have to be done manually. + `, type => { - db_type =>"string", - hint =>"javascript|http", + db_type =>'string', + hint =>'javascript|http', pattern =>qr|^([jh])|i, format =>q( $1 =~ /^j/ - ? "javascript" - : "http" + ? 'javascript' + : 'http' ) }, - category => "hidden", + category => 'hidden', }, { - name => "ZM_WEB_EVENT_SORT_FIELD", - default => "DateTime", - description => "Default field the event lists are sorted by", - help => qqq(" - Events in lists can be initially ordered in any way you want. - This option controls what field is used to sort them. You can - modify this ordering from filters or by clicking on headings in - the lists themselves. Bear in mind however that the 'Prev' and - 'Next' links, when scrolling through events, relate to the - ordering in the lists and so not always to time based ordering. - "), + name => 'ZM_WEB_EVENT_SORT_FIELD', + default => 'DateTime', + description => 'Default field the event lists are sorted by', + help => q` + Events in lists can be initially ordered in any way you want. + This option controls what field is used to sort them. You can + modify this ordering from filters or by clicking on headings in + the lists themselves. Bear in mind however that the 'Prev' and + 'Next' links, when scrolling through events, relate to the + ordering in the lists and so not always to time based ordering. + `, type => { - db_type =>"string", - hint =>"Id|Name|Cause|MonitorName|DateTime|Length|Frames|AlarmFrames|TotScore|AvgScore|MaxScore", + db_type =>'string', + hint =>'Id|Name|Cause|MonitorName|DateTime|Length|Frames|AlarmFrames|TotScore|AvgScore|MaxScore', pattern =>qr|.|, format =>q( $1 ) }, - category => "web", + category => 'web', }, { - name => "ZM_WEB_EVENT_SORT_ORDER", - default => "asc", - description => "Default order the event lists are sorted by", - help => qqq(" - Events in lists can be initially ordered in any way you want. - This option controls what order (ascending or descending) is - used to sort them. You can modify this ordering from filters or - by clicking on headings in the lists themselves. Bear in mind - however that the 'Prev' and 'Next' links, when scrolling - through events, relate to the ordering in the lists and so not - always to time based ordering. - "), + name => 'ZM_WEB_EVENT_SORT_ORDER', + default => 'asc', + description => 'Default order the event lists are sorted by', + help => q` + Events in lists can be initially ordered in any way you want. + This option controls what order (ascending or descending) is + used to sort them. You can modify this ordering from filters or + by clicking on headings in the lists themselves. Bear in mind + however that the 'Prev' and 'Next' links, when scrolling + through events, relate to the ordering in the lists and so not + always to time based ordering. + `, type => { - db_type =>"string", - hint =>"asc|desc", + db_type =>'string', + hint =>'asc|desc', pattern =>qr|^([ad])|i, - format =>q( $1 =~ /^a/i ? "asc" : "desc" ) + format =>q( $1 =~ /^a/i ? 'asc' : 'desc' ) }, - category => "web", + category => 'web', }, { - name => "ZM_WEB_EVENTS_PER_PAGE", - default => "25", - description => "How many events to list per page in paged mode", - help => qqq(" - In the event list view you can either list all events or just a - page at a time. This option controls how many events are listed - per page in paged mode and how often to repeat the column - headers in non-paged mode. - "), + name => 'ZM_WEB_EVENTS_PER_PAGE', + default => '25', + description => 'How many events to list per page in paged mode', + help => q` + In the event list view you can either list all events or just a + page at a time. This option controls how many events are listed + per page in paged mode and how often to repeat the column + headers in non-paged mode. + `, type => $types{integer}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_LIST_THUMBS", - default => "no", - description => "Display mini-thumbnails of event images in event lists", - help => qqq(" - Ordinarily the event lists just display text details of the - events to save space and time. By switching this option on you - can also display small thumbnails to help you identify events - of interest. The size of these thumbnails is controlled by the - following two options. - "), + name => 'ZM_WEB_LIST_THUMBS', + default => 'no', + description => 'Display mini-thumbnails of event images in event lists', + help => q` + Ordinarily the event lists just display text details of the + events to save space and time. By switching this option on you + can also display small thumbnails to help you identify events + of interest. The size of these thumbnails is controlled by the + following two options. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_LIST_THUMB_WIDTH", - default => "48", - description => "The width of the thumbnails that appear in the event lists", - help => qqq(" - This options controls the width of the thumbnail images that - appear in the event lists. It should be fairly small to fit in - with the rest of the table. If you prefer you can specify a - height instead in the next option but you should only use one - of the width or height and the other option should be set to - zero. If both width and height are specified then width will be - used and height ignored. - "), + name => 'ZM_WEB_LIST_THUMB_WIDTH', + default => '48', + description => 'The width of the thumbnails that appear in the event lists', + help => q` + This options controls the width of the thumbnail images that + appear in the event lists. It should be fairly small to fit in + with the rest of the table. If you prefer you can specify a + height instead in the next option but you should only use one + of the width or height and the other option should be set to + zero. If both width and height are specified then width will be + used and height ignored. + `, type => $types{integer}, - requires => [ { name => "ZM_WEB_LIST_THUMBS", value => "yes" } ], - category => "web", + requires => [ { name => 'ZM_WEB_LIST_THUMBS', value => 'yes' } ], + category => 'web', }, { - name => "ZM_WEB_LIST_THUMB_HEIGHT", - default => "0", - description => "The height of the thumbnails that appear in the event lists", - help => qqq(" - This options controls the height of the thumbnail images that - appear in the event lists. It should be fairly small to fit in - with the rest of the table. If you prefer you can specify a - width instead in the previous option but you should only use - one of the width or height and the other option should be set - to zero. If both width and height are specified then width will - be used and height ignored. - "), + name => 'ZM_WEB_LIST_THUMB_HEIGHT', + default => '0', + description => 'The height of the thumbnails that appear in the event lists', + help => q` + This options controls the height of the thumbnail images that + appear in the event lists. It should be fairly small to fit in + with the rest of the table. If you prefer you can specify a + width instead in the previous option but you should only use + one of the width or height and the other option should be set + to zero. If both width and height are specified then width will + be used and height ignored. + `, type => $types{integer}, - requires => [ { name => "ZM_WEB_LIST_THUMBS", value => "yes" } ], - category => "web", + requires => [ { name => 'ZM_WEB_LIST_THUMBS', value => 'yes' } ], + category => 'web', }, { - name => "ZM_WEB_USE_OBJECT_TAGS", - default => "yes", - description => "Wrap embed in object tags for media content", - help => qqq(" - There are two methods of including media content in web pages. - The most common way is use the EMBED tag which is able to give - some indication of the type of content. However this is not a - standard part of HTML. The official method is to use OBJECT - tags which are able to give more information allowing the - correct media viewers etc to be loaded. However these are less - widely supported and content may be specifically tailored to a - particular platform or player. This option controls whether - media content is enclosed in EMBED tags only or whether, where - appropriate, it is additionally wrapped in OBJECT tags. - Currently OBJECT tags are only used in a limited number of - circumstances but they may become more widespread in the - future. It is suggested that you leave this option on unless - you encounter problems playing some content. - "), + name => 'ZM_WEB_USE_OBJECT_TAGS', + default => 'yes', + description => 'Wrap embed in object tags for media content', + help => q` + There are two methods of including media content in web pages. + The most common way is use the EMBED tag which is able to give + some indication of the type of content. However this is not a + standard part of HTML. The official method is to use OBJECT + tags which are able to give more information allowing the + correct media viewers etc to be loaded. However these are less + widely supported and content may be specifically tailored to a + particular platform or player. This option controls whether + media content is enclosed in EMBED tags only or whether, where + appropriate, it is additionally wrapped in OBJECT tags. + Currently OBJECT tags are only used in a limited number of + circumstances but they may become more widespread in the + future. It is suggested that you leave this option on unless + you encounter problems playing some content. + `, type => $types{boolean}, - category => "web", + category => 'web', }, { - name => "ZM_WEB_H_REFRESH_MAIN", - default => "60", - introduction => qqq(" - There are now a number of options that are grouped into - bandwidth categories, this allows you to configure the - ZoneMinder client to work optimally over the various access - methods you might to access the client.\n\nThe next few options - control what happens when the client is running in 'high' - bandwidth mode. You should set these options for when accessing - the ZoneMinder client over a local network or high speed link. - In most cases the default values will be suitable as a starting - point. - "), - description => "How often (in seconds) the main console window should refresh itself", - help => qqq(" - The main console window lists a general status and the event - totals for all monitors. This is not a trivial task and should - not be repeated too frequently or it may affect the performance - of the rest of the system. - "), + name => 'ZM_WEB_H_REFRESH_MAIN', + default => '60', + introduction => q` + There are now a number of options that are grouped into + bandwidth categories, this allows you to configure the + ZoneMinder client to work optimally over the various access + methods you might to access the client.\n\nThe next few options + control what happens when the client is running in 'high' + bandwidth mode. You should set these options for when accessing + the ZoneMinder client over a local network or high speed link. + In most cases the default values will be suitable as a starting + point. + `, + description => 'How often (in seconds) the main console window should refresh itself', + help => q` + The main console window lists a general status and the event + totals for all monitors. This is not a trivial task and should + not be repeated too frequently or it may affect the performance + of the rest of the system. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_REFRESH_CYCLE", - default => "10", - description => "How often (in seconds) the cycle watch window swaps to the next monitor", - help => qqq(" - The cycle watch window is a method of continuously cycling - between images from all of your monitors. This option - determines how often to refresh with a new image. - "), + name => 'ZM_WEB_H_REFRESH_CYCLE', + default => '10', + description => 'How often (in seconds) the cycle watch window swaps to the next monitor', + help => q` + The cycle watch window is a method of continuously cycling + between images from all of your monitors. This option + determines how often to refresh with a new image. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_REFRESH_IMAGE", - default => "3", - description => "How often (in seconds) the watched image is refreshed (if not streaming)", - help => qqq(" - The live images from a monitor can be viewed in either streamed - or stills mode. This option determines how often a stills image - is refreshed, it has no effect if streaming is selected. - "), + name => 'ZM_WEB_H_REFRESH_IMAGE', + default => '3', + description => 'How often (in seconds) the watched image is refreshed (if not streaming)', + help => q` + The live images from a monitor can be viewed in either streamed + or stills mode. This option determines how often a stills image + is refreshed, it has no effect if streaming is selected. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_REFRESH_STATUS", - default => "1", - description => "How often (in seconds) the status refreshes itself in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - one in the middle merely contains a monitor status which needs - to refresh fairly frequently to give a true indication. This - option determines that frequency. - "), + name => 'ZM_WEB_H_REFRESH_STATUS', + default => '1', + description => 'How often (in seconds) the status refreshes itself in the watch window', + help => q` + The monitor window is actually made from several frames. The + one in the middle merely contains a monitor status which needs + to refresh fairly frequently to give a true indication. This + option determines that frequency. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_REFRESH_EVENTS", - default => "5", - description => "How often (in seconds) the event listing is refreshed in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - lower framme contains a listing of the last few events for easy - access. This option determines how often this is refreshed. - "), + name => 'ZM_WEB_H_REFRESH_EVENTS', + default => '5', + description => 'How often (in seconds) the event listing is refreshed in the watch window', + help => q` + The monitor window is actually made from several frames. The + lower framme contains a listing of the last few events for easy + access. This option determines how often this is refreshed. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_CAN_STREAM", - default => "auto", - description => "Override the automatic detection of browser streaming capability", - help => qqq(" - If you know that your browser can handle image streams of the - type 'multipart/x-mixed-replace' but ZoneMinder does not detect - this correctly you can set this option to ensure that the - stream is delivered with or without the use of the Cambozola - plugin. Selecting 'yes' will tell ZoneMinder that your browser - can handle the streams natively, 'no' means that it can't and - so the plugin will be used while 'auto' lets ZoneMinder decide. - "), + name => 'ZM_WEB_H_CAN_STREAM', + default => 'auto', + description => 'Override the automatic detection of browser streaming capability', + help => q` + If you know that your browser can handle image streams of the + type 'multipart/x-mixed-replace' but ZoneMinder does not detect + this correctly you can set this option to ensure that the + stream is delivered with or without the use of the Cambozola + plugin. Selecting 'yes' will tell ZoneMinder that your browser + can handle the streams natively, 'no' means that it can't and + so the plugin will be used while 'auto' lets ZoneMinder decide. + `, type => $types{tristate}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_STREAM_METHOD", - default => "jpeg", - description => "Which method should be used to send video streams to your browser.", - help => qqq(" - ZoneMinder can be configured to use either mpeg encoded video - or a series or still jpeg images when sending video streams. - This option defines which is used. If you choose mpeg you - should ensure that you have the appropriate plugins available - on your browser whereas choosing jpeg will work natively on - Mozilla and related browsers and with a Java applet on Internet - Explorer - "), + name => 'ZM_WEB_H_STREAM_METHOD', + default => 'jpeg', + description => 'Which method should be used to send video streams to your browser.', + help => q` + ZoneMinder can be configured to use either mpeg encoded video + or a series or still jpeg images when sending video streams. + This option defines which is used. If you choose mpeg you + should ensure that you have the appropriate plugins available + on your browser whereas choosing jpeg will work natively on + Mozilla and related browsers and with a Java applet on Internet + Explorer + `, type => { - db_type =>"string", - hint =>"mpeg|jpeg", + db_type =>'string', + hint =>'mpeg|jpeg', pattern =>qr|^([mj])|i, - format =>q( $1 =~ /^m/ ? "mpeg" : "jpeg" ) + format =>q( $1 =~ /^m/ ? 'mpeg' : 'jpeg' ) }, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_DEFAULT_SCALE", - default => "100", - description => "What the default scaling factor applied to 'live' or 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'live' or 'event' streams in - their native size. However if you have monitors with large - dimensions or a slow link you may prefer to reduce this size, - alternatively for small monitors you can enlarge it. This - options lets you specify what the default scaling factor will - be. It is expressed as a percentage so 100 is normal size, 200 - is double size etc. - "), + name => 'ZM_WEB_H_DEFAULT_SCALE', + default => '100', + description => 'What the default scaling factor applied to \'live\' or \'event\' views is (%)', + help => q` + Normally ZoneMinder will display 'live' or 'event' streams in + their native size. However if you have monitors with large + dimensions or a slow link you may prefer to reduce this size, + alternatively for small monitors you can enlarge it. This + options lets you specify what the default scaling factor will + be. It is expressed as a percentage so 100 is normal size, 200 + is double size etc. + `, type => { - db_type =>"integer", - hint =>"25|33|50|75|100|150|200|300|400", + db_type =>'integer', + hint =>'25|33|50|75|100|150|200|300|400', pattern =>qr|^(\d+)$|, format =>q( $1 ) }, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_DEFAULT_RATE", - default => "100", - description => "What the default replay rate factor applied to 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'event' streams at their - native rate, i.e. as close to real-time as possible. However if - you have long events it is often convenient to replay them at a - faster rate for review. This option lets you specify what the - default replay rate will be. It is expressed as a percentage so - 100 is normal rate, 200 is double speed etc. - "), + name => 'ZM_WEB_H_DEFAULT_RATE', + default => '100', + description => 'What the default replay rate factor applied to \'event\' views is (%)', + help => q` + Normally ZoneMinder will display 'event' streams at their + native rate, i.e. as close to real-time as possible. However if + you have long events it is often convenient to replay them at a + faster rate for review. This option lets you specify what the + default replay rate will be. It is expressed as a percentage so + 100 is normal rate, 200 is double speed etc. + `, type => { - db_type =>"integer", - hint =>"25|50|100|150|200|400|1000|2500|5000|10000", + db_type =>'integer', + hint =>'25|50|100|150|200|400|1000|2500|5000|10000', pattern =>qr|^(\d+)$|, format =>q( $1 ) }, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_VIDEO_BITRATE", - default => "150000", - description => "What the bitrate of the video encoded stream should be set to", - help => qqq(" - When encoding real video via the ffmpeg library a bit rate can - be specified which roughly corresponds to the available - bandwidth used for the stream. This setting effectively - corresponds to a 'quality' setting for the video. A low value - will result in a blocky image whereas a high value will produce - a clearer view. Note that this setting does not control the - frame rate of the video however the quality of the video - produced is affected both by this setting and the frame rate - that the video is produced at. A higher frame rate at a - particular bit rate result in individual frames being at a - lower quality. - "), + name => 'ZM_WEB_H_VIDEO_BITRATE', + default => '150000', + description => 'What the bitrate of the video encoded stream should be set to', + help => q` + When encoding real video via the ffmpeg library a bit rate can + be specified which roughly corresponds to the available + bandwidth used for the stream. This setting effectively + corresponds to a 'quality' setting for the video. A low value + will result in a blocky image whereas a high value will produce + a clearer view. Note that this setting does not control the + frame rate of the video however the quality of the video + produced is affected both by this setting and the frame rate + that the video is produced at. A higher frame rate at a + particular bit rate result in individual frames being at a + lower quality. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_VIDEO_MAXFPS", - default => "30", - description => "What the maximum frame rate for streamed video should be", - help => qqq(" - When using streamed video the main control is the bitrate which - determines how much data can be transmitted. However a lower - bitrate at high frame rates results in a lower quality image. - This option allows you to limit the maximum frame rate to - ensure that video quality is maintained. An additional - advantage is that encoding video at high frame rates is a - processor intensive task when for the most part a very high - frame rate offers little perceptible improvement over one that - has a more manageable resource requirement. Note, this option - is implemented as a cap beyond which binary reduction takes - place. So if you have a device capturing at 15fps and set this - option to 10fps then the video is not produced at 10fps, but - rather at 7.5fps (15 divided by 2) as the final frame rate must - be the original divided by a power of 2. - "), + name => 'ZM_WEB_H_VIDEO_MAXFPS', + default => '30', + description => 'What the maximum frame rate for streamed video should be', + help => q` + When using streamed video the main control is the bitrate which + determines how much data can be transmitted. However a lower + bitrate at high frame rates results in a lower quality image. + This option allows you to limit the maximum frame rate to + ensure that video quality is maintained. An additional + advantage is that encoding video at high frame rates is a + processor intensive task when for the most part a very high + frame rate offers little perceptible improvement over one that + has a more manageable resource requirement. Note, this option + is implemented as a cap beyond which binary reduction takes + place. So if you have a device capturing at 15fps and set this + option to 10fps then the video is not produced at 10fps, but + rather at 7.5fps (15 divided by 2) as the final frame rate must + be the original divided by a power of 2. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_SCALE_THUMBS", - default => "no", - description => "Scale thumbnails in events, bandwidth versus cpu in rescaling", - help => qqq(" - If unset, this option sends the whole image to the browser - which resizes it in the window. If set the image is scaled down - on the server before sending a reduced size image to the - browser to conserve bandwidth at the cost of cpu on the server. - Note that ZM can only perform the resizing if the appropriate - PHP graphics functionality is installed. This is usually - available in the php-gd package. - "), + name => 'ZM_WEB_H_SCALE_THUMBS', + default => 'no', + description => 'Scale thumbnails in events, bandwidth versus cpu in rescaling', + help => q` + If unset, this option sends the whole image to the browser + which resizes it in the window. If set the image is scaled down + on the server before sending a reduced size image to the + browser to conserve bandwidth at the cost of cpu on the server. + Note that ZM can only perform the resizing if the appropriate + PHP graphics functionality is installed. This is usually + available in the php-gd package. + `, type => $types{boolean}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_EVENTS_VIEW", - default => "events", - description => "What the default view of multiple events should be.", - help => qqq(" - Stored events can be viewed in either an events list format or - in a timeline based one. This option sets the default view that - will be used. Choosing one view here does not prevent the other - view being used as it will always be selectable from whichever - view is currently being used. - "), + name => 'ZM_WEB_H_EVENTS_VIEW', + default => 'events', + description => 'What the default view of multiple events should be.', + help => q` + Stored events can be viewed in either an events list format or + in a timeline based one. This option sets the default view that + will be used. Choosing one view here does not prevent the other + view being used as it will always be selectable from whichever + view is currently being used. + `, type => { - db_type =>"string", - hint =>"events|timeline", + db_type =>'string', + hint =>'events|timeline', pattern =>qr|^([lt])|i, - format =>q( $1 =~ /^e/ ? "events" : "timeline" ) + format =>q( $1 =~ /^e/ ? 'events' : 'timeline' ) }, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_SHOW_PROGRESS", - default => "yes", - description => "Show the progress of replay in event view.", - help => qqq(" - When viewing events an event navigation panel and progress bar - is shown below the event itself. This allows you to jump to - specific points in the event, but can can also dynamically - update to display the current progress of the event replay - itself. This progress is calculated from the actual event - duration and is not directly linked to the replay itself, so on - limited bandwidth connections may be out of step with the - replay. This option allows you to turn off the progress - display, whilst still keeping the navigation aspect, where - bandwidth prevents it functioning effectively. - "), + name => 'ZM_WEB_H_SHOW_PROGRESS', + default => 'yes', + description => 'Show the progress of replay in event view.', + help => q` + When viewing events an event navigation panel and progress bar + is shown below the event itself. This allows you to jump to + specific points in the event, but can can also dynamically + update to display the current progress of the event replay + itself. This progress is calculated from the actual event + duration and is not directly linked to the replay itself, so on + limited bandwidth connections may be out of step with the + replay. This option allows you to turn off the progress + display, whilst still keeping the navigation aspect, where + bandwidth prevents it functioning effectively. + `, type => $types{boolean}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_H_AJAX_TIMEOUT", - default => "3000", - description => "How long to wait for Ajax request responses (ms)", - help => qqq(" - The newer versions of the live feed and event views use Ajax to - request information from the server and populate the views - dynamically. This option allows you to specify a timeout if - required after which requests are abandoned. A timeout may be - necessary if requests would overwise hang such as on a slow - connection. This would tend to consume a lot of browser memory - and make the interface unresponsive. Ordinarily no requests - should timeout so this setting should be set to a value greater - than the slowest expected response. This value is in - milliseconds but if set to zero then no timeout will be used. - "), + name => 'ZM_WEB_H_AJAX_TIMEOUT', + default => '3000', + description => 'How long to wait for Ajax request responses (ms)', + help => q` + The newer versions of the live feed and event views use Ajax to + request information from the server and populate the views + dynamically. This option allows you to specify a timeout if + required after which requests are abandoned. A timeout may be + necessary if requests would overwise hang such as on a slow + connection. This would tend to consume a lot of browser memory + and make the interface unresponsive. Ordinarily no requests + should timeout so this setting should be set to a value greater + than the slowest expected response. This value is in + milliseconds but if set to zero then no timeout will be used. + `, type => $types{integer}, - category => "highband", + category => 'highband', }, { - name => "ZM_WEB_M_REFRESH_MAIN", - default => "300", - description => "How often (in seconds) the main console window should refresh itself", - help => qqq(" - The main console window lists a general status and the event - totals for all monitors. This is not a trivial task and should - not be repeated too frequently or it may affect the performance - of the rest of the system. - "), + name => 'ZM_WEB_M_REFRESH_MAIN', + default => '300', + description => 'How often (in seconds) the main console window should refresh itself', + help => q` + The main console window lists a general status and the event + totals for all monitors. This is not a trivial task and should + not be repeated too frequently or it may affect the performance + of the rest of the system. + `, type => $types{integer}, - introduction => qqq(" - The next few options control what happens when the client is - running in 'medium' bandwidth mode. You should set these - options for when accessing the ZoneMinder client over a slower - cable or DSL link. In most cases the default values will be - suitable as a starting point. - "), - category => "medband", + introduction => q` + The next few options control what happens when the client is + running in 'medium' bandwidth mode. You should set these + options for when accessing the ZoneMinder client over a slower + cable or DSL link. In most cases the default values will be + suitable as a starting point. + `, + category => 'medband', }, { - name => "ZM_WEB_M_REFRESH_CYCLE", - default => "20", - description => "How often (in seconds) the cycle watch window swaps to the next monitor", - help => qqq(" - The cycle watch window is a method of continuously cycling - between images from all of your monitors. This option - determines how often to refresh with a new image. - "), + name => 'ZM_WEB_M_REFRESH_CYCLE', + default => '20', + description => 'How often (in seconds) the cycle watch window swaps to the next monitor', + help => q` + The cycle watch window is a method of continuously cycling + between images from all of your monitors. This option + determines how often to refresh with a new image. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_REFRESH_IMAGE", - default => "10", - description => "How often (in seconds) the watched image is refreshed (if not streaming)", - help => qqq(" - The live images from a monitor can be viewed in either streamed - or stills mode. This option determines how often a stills image - is refreshed, it has no effect if streaming is selected. - "), + name => 'ZM_WEB_M_REFRESH_IMAGE', + default => '10', + description => 'How often (in seconds) the watched image is refreshed (if not streaming)', + help => q` + The live images from a monitor can be viewed in either streamed + or stills mode. This option determines how often a stills image + is refreshed, it has no effect if streaming is selected. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_REFRESH_STATUS", - default => "5", - description => "How often (in seconds) the status refreshes itself in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - one in the middle merely contains a monitor status which needs - to refresh fairly frequently to give a true indication. This - option determines that frequency. - "), + name => 'ZM_WEB_M_REFRESH_STATUS', + default => '5', + description => 'How often (in seconds) the status refreshes itself in the watch window', + help => q` + The monitor window is actually made from several frames. The + one in the middle merely contains a monitor status which needs + to refresh fairly frequently to give a true indication. This + option determines that frequency. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_REFRESH_EVENTS", - default => "60", - description => "How often (in seconds) the event listing is refreshed in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - lower framme contains a listing of the last few events for easy - access. This option determines how often this is refreshed. - "), + name => 'ZM_WEB_M_REFRESH_EVENTS', + default => '60', + description => 'How often (in seconds) the event listing is refreshed in the watch window', + help => q` + The monitor window is actually made from several frames. The + lower framme contains a listing of the last few events for easy + access. This option determines how often this is refreshed. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_CAN_STREAM", - default => "auto", - description => "Override the automatic detection of browser streaming capability", - help => qqq(" - If you know that your browser can handle image streams of the - type 'multipart/x-mixed-replace' but ZoneMinder does not detect - this correctly you can set this option to ensure that the - stream is delivered with or without the use of the Cambozola - plugin. Selecting 'yes' will tell ZoneMinder that your browser - can handle the streams natively, 'no' means that it can't and - so the plugin will be used while 'auto' lets ZoneMinder decide. - "), + name => 'ZM_WEB_M_CAN_STREAM', + default => 'auto', + description => 'Override the automatic detection of browser streaming capability', + help => q` + If you know that your browser can handle image streams of the + type 'multipart/x-mixed-replace' but ZoneMinder does not detect + this correctly you can set this option to ensure that the + stream is delivered with or without the use of the Cambozola + plugin. Selecting 'yes' will tell ZoneMinder that your browser + can handle the streams natively, 'no' means that it can't and + so the plugin will be used while 'auto' lets ZoneMinder decide. + `, type => $types{tristate}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_STREAM_METHOD", - default => "jpeg", - description => "Which method should be used to send video streams to your browser.", - help => qqq(" - ZoneMinder can be configured to use either mpeg encoded video - or a series or still jpeg images when sending video streams. - This option defines which is used. If you choose mpeg you - should ensure that you have the appropriate plugins available - on your browser whereas choosing jpeg will work natively on - Mozilla and related browsers and with a Java applet on Internet - Explorer - "), + name => 'ZM_WEB_M_STREAM_METHOD', + default => 'jpeg', + description => 'Which method should be used to send video streams to your browser.', + help => q` + ZoneMinder can be configured to use either mpeg encoded video + or a series or still jpeg images when sending video streams. + This option defines which is used. If you choose mpeg you + should ensure that you have the appropriate plugins available + on your browser whereas choosing jpeg will work natively on + Mozilla and related browsers and with a Java applet on Internet + Explorer + `, type => { - db_type =>"string", - hint =>"mpeg|jpeg", + db_type =>'string', + hint =>'mpeg|jpeg', pattern =>qr|^([mj])|i, - format =>q( $1 =~ /^m/ ? "mpeg" : "jpeg" ) + format =>q( $1 =~ /^m/ ? 'mpeg' : 'jpeg' ) }, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_DEFAULT_SCALE", - default => "100", - description => "What the default scaling factor applied to 'live' or 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'live' or 'event' streams in - their native size. However if you have monitors with large - dimensions or a slow link you may prefer to reduce this size, - alternatively for small monitors you can enlarge it. This - options lets you specify what the default scaling factor will - be. It is expressed as a percentage so 100 is normal size, 200 - is double size etc. - "), + name => 'ZM_WEB_M_DEFAULT_SCALE', + default => '100', + description => q`What the default scaling factor applied to 'live' or 'event' views is (%)`, + help => q` + Normally ZoneMinder will display 'live' or 'event' streams in + their native size. However if you have monitors with large + dimensions or a slow link you may prefer to reduce this size, + alternatively for small monitors you can enlarge it. This + options lets you specify what the default scaling factor will + be. It is expressed as a percentage so 100 is normal size, 200 + is double size etc. + `, type => { - db_type =>"integer", - hint =>"25|33|50|75|100|150|200|300|400", + db_type =>'integer', + hint =>'25|33|50|75|100|150|200|300|400', pattern =>qr|^(\d+)$|, format =>q( $1 ) }, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_DEFAULT_RATE", - default => "100", - description => "What the default replay rate factor applied to 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'event' streams at their - native rate, i.e. as close to real-time as possible. However if - you have long events it is often convenient to replay them at a - faster rate for review. This option lets you specify what the - default replay rate will be. It is expressed as a percentage so - 100 is normal rate, 200 is double speed etc. - "), + name => 'ZM_WEB_M_DEFAULT_RATE', + default => '100', + description => q`What the default replay rate factor applied to 'event' views is (%)`, + help => q` + Normally ZoneMinder will display 'event' streams at their + native rate, i.e. as close to real-time as possible. However if + you have long events it is often convenient to replay them at a + faster rate for review. This option lets you specify what the + default replay rate will be. It is expressed as a percentage so + 100 is normal rate, 200 is double speed etc. + `, type => { - db_type =>"integer", - hint =>"25|50|100|150|200|400|1000|2500|5000|10000", + db_type =>'integer', + hint =>'25|50|100|150|200|400|1000|2500|5000|10000', pattern =>qr|^(\d+)$|, format =>q( $1 ) }, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_VIDEO_BITRATE", - default => "75000", - description => "What the bitrate of the video encoded stream should be set to", - help => qqq(" - When encoding real video via the ffmpeg library a bit rate can - be specified which roughly corresponds to the available - bandwidth used for the stream. This setting effectively - corresponds to a 'quality' setting for the video. A low value - will result in a blocky image whereas a high value will produce - a clearer view. Note that this setting does not control the - frame rate of the video however the quality of the video - produced is affected both by this setting and the frame rate - that the video is produced at. A higher frame rate at a - particular bit rate result in individual frames being at a - lower quality. - "), + name => 'ZM_WEB_M_VIDEO_BITRATE', + default => '75000', + description => 'What the bitrate of the video encoded stream should be set to', + help => q` + When encoding real video via the ffmpeg library a bit rate can + be specified which roughly corresponds to the available + bandwidth used for the stream. This setting effectively + corresponds to a 'quality' setting for the video. A low value + will result in a blocky image whereas a high value will produce + a clearer view. Note that this setting does not control the + frame rate of the video however the quality of the video + produced is affected both by this setting and the frame rate + that the video is produced at. A higher frame rate at a + particular bit rate result in individual frames being at a + lower quality. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_VIDEO_MAXFPS", - default => "10", - description => "What the maximum frame rate for streamed video should be", - help => qqq(" - When using streamed video the main control is the bitrate which - determines how much data can be transmitted. However a lower - bitrate at high frame rates results in a lower quality image. - This option allows you to limit the maximum frame rate to - ensure that video quality is maintained. An additional - advantage is that encoding video at high frame rates is a - processor intensive task when for the most part a very high - frame rate offers little perceptible improvement over one that - has a more manageable resource requirement. Note, this option - is implemented as a cap beyond which binary reduction takes - place. So if you have a device capturing at 15fps and set this - option to 10fps then the video is not produced at 10fps, but - rather at 7.5fps (15 divided by 2) as the final frame rate must - be the original divided by a power of 2. - "), + name => 'ZM_WEB_M_VIDEO_MAXFPS', + default => '10', + description => 'What the maximum frame rate for streamed video should be', + help => q` + When using streamed video the main control is the bitrate which + determines how much data can be transmitted. However a lower + bitrate at high frame rates results in a lower quality image. + This option allows you to limit the maximum frame rate to + ensure that video quality is maintained. An additional + advantage is that encoding video at high frame rates is a + processor intensive task when for the most part a very high + frame rate offers little perceptible improvement over one that + has a more manageable resource requirement. Note, this option + is implemented as a cap beyond which binary reduction takes + place. So if you have a device capturing at 15fps and set this + option to 10fps then the video is not produced at 10fps, but + rather at 7.5fps (15 divided by 2) as the final frame rate must + be the original divided by a power of 2. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_SCALE_THUMBS", - default => "yes", - description => "Scale thumbnails in events, bandwidth versus cpu in rescaling", - help => qqq(" - If unset, this option sends the whole image to the browser - which resizes it in the window. If set the image is scaled down - on the server before sending a reduced size image to the - browser to conserve bandwidth at the cost of cpu on the server. - Note that ZM can only perform the resizing if the appropriate - PHP graphics functionality is installed. This is usually - available in the php-gd package. - "), + name => 'ZM_WEB_M_SCALE_THUMBS', + default => 'yes', + description => 'Scale thumbnails in events, bandwidth versus cpu in rescaling', + help => q` + If unset, this option sends the whole image to the browser + which resizes it in the window. If set the image is scaled down + on the server before sending a reduced size image to the + browser to conserve bandwidth at the cost of cpu on the server. + Note that ZM can only perform the resizing if the appropriate + PHP graphics functionality is installed. This is usually + available in the php-gd package. + `, type => $types{boolean}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_EVENTS_VIEW", - default => "events", - description => "What the default view of multiple events should be.", - help => qqq(" - Stored events can be viewed in either an events list format or - in a timeline based one. This option sets the default view that - will be used. Choosing one view here does not prevent the other - view being used as it will always be selectable from whichever - view is currently being used. - "), + name => 'ZM_WEB_M_EVENTS_VIEW', + default => 'events', + description => 'What the default view of multiple events should be.', + help => q` + Stored events can be viewed in either an events list format or + in a timeline based one. This option sets the default view that + will be used. Choosing one view here does not prevent the other + view being used as it will always be selectable from whichever + view is currently being used. + `, type => { - db_type =>"string", - hint =>"events|timeline", + db_type =>'string', + hint =>'events|timeline', pattern =>qr|^([lt])|i, - format =>q( $1 =~ /^e/ ? "events" : "timeline" ) + format =>q( $1 =~ /^e/ ? 'events' : 'timeline' ) }, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_SHOW_PROGRESS", - default => "yes", - description => "Show the progress of replay in event view.", - help => qqq(" - When viewing events an event navigation panel and progress bar - is shown below the event itself. This allows you to jump to - specific points in the event, but can can also dynamically - update to display the current progress of the event replay - itself. This progress is calculated from the actual event - duration and is not directly linked to the replay itself, so on - limited bandwidth connections may be out of step with the - replay. This option allows you to turn off the progress - display, whilst still keeping the navigation aspect, where - bandwidth prevents it functioning effectively. - "), + name => 'ZM_WEB_M_SHOW_PROGRESS', + default => 'yes', + description => 'Show the progress of replay in event view.', + help => q` + When viewing events an event navigation panel and progress bar + is shown below the event itself. This allows you to jump to + specific points in the event, but can can also dynamically + update to display the current progress of the event replay + itself. This progress is calculated from the actual event + duration and is not directly linked to the replay itself, so on + limited bandwidth connections may be out of step with the + replay. This option allows you to turn off the progress + display, whilst still keeping the navigation aspect, where + bandwidth prevents it functioning effectively. + `, type => $types{boolean}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_M_AJAX_TIMEOUT", - default => "5000", - description => "How long to wait for Ajax request responses (ms)", - help => qqq(" - The newer versions of the live feed and event views use Ajax to - request information from the server and populate the views - dynamically. This option allows you to specify a timeout if - required after which requests are abandoned. A timeout may be - necessary if requests would overwise hang such as on a slow - connection. This would tend to consume a lot of browser memory - and make the interface unresponsive. Ordinarily no requests - should timeout so this setting should be set to a value greater - than the slowest expected response. This value is in - milliseconds but if set to zero then no timeout will be used. - "), + name => 'ZM_WEB_M_AJAX_TIMEOUT', + default => '5000', + description => 'How long to wait for Ajax request responses (ms)', + help => q` + The newer versions of the live feed and event views use Ajax to + request information from the server and populate the views + dynamically. This option allows you to specify a timeout if + required after which requests are abandoned. A timeout may be + necessary if requests would overwise hang such as on a slow + connection. This would tend to consume a lot of browser memory + and make the interface unresponsive. Ordinarily no requests + should timeout so this setting should be set to a value greater + than the slowest expected response. This value is in + milliseconds but if set to zero then no timeout will be used. + `, type => $types{integer}, - category => "medband", + category => 'medband', }, { - name => "ZM_WEB_L_REFRESH_MAIN", - default => "300", - description => "How often (in seconds) the main console window should refresh itself", - introduction => qqq(" - The next few options control what happens when the client is - running in 'low' bandwidth mode. You should set these options - for when accessing the ZoneMinder client over a modem or slow - link. In most cases the default values will be suitable as a - starting point. - "), - help => qqq(" - The main console window lists a general status and the event - totals for all monitors. This is not a trivial task and should - not be repeated too frequently or it may affect the performance - of the rest of the system. - "), + name => 'ZM_WEB_L_REFRESH_MAIN', + default => '300', + description => 'How often (in seconds) the main console window should refresh itself', + introduction => q` + The next few options control what happens when the client is + running in 'low' bandwidth mode. You should set these options + for when accessing the ZoneMinder client over a modem or slow + link. In most cases the default values will be suitable as a + starting point. + `, + help => q` + The main console window lists a general status and the event + totals for all monitors. This is not a trivial task and should + not be repeated too frequently or it may affect the performance + of the rest of the system. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_REFRESH_CYCLE", - default => "30", - description => "How often (in seconds) the cycle watch window swaps to the next monitor", - help => qqq(" - The cycle watch window is a method of continuously cycling - between images from all of your monitors. This option - determines how often to refresh with a new image. - "), + name => 'ZM_WEB_L_REFRESH_CYCLE', + default => '30', + description => 'How often (in seconds) the cycle watch window swaps to the next monitor', + help => q` + The cycle watch window is a method of continuously cycling + between images from all of your monitors. This option + determines how often to refresh with a new image. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_REFRESH_IMAGE", - default => "15", - description => "How often (in seconds) the watched image is refreshed (if not streaming)", - help => qqq(" - The live images from a monitor can be viewed in either streamed - or stills mode. This option determines how often a stills image - is refreshed, it has no effect if streaming is selected. - "), + name => 'ZM_WEB_L_REFRESH_IMAGE', + default => '15', + description => 'How often (in seconds) the watched image is refreshed (if not streaming)', + help => q` + The live images from a monitor can be viewed in either streamed + or stills mode. This option determines how often a stills image + is refreshed, it has no effect if streaming is selected. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_REFRESH_STATUS", - default => "10", - description => "How often (in seconds) the status refreshes itself in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - one in the middle merely contains a monitor status which needs - to refresh fairly frequently to give a true indication. This - option determines that frequency. - "), + name => 'ZM_WEB_L_REFRESH_STATUS', + default => '10', + description => 'How often (in seconds) the status refreshes itself in the watch window', + help => q` + The monitor window is actually made from several frames. The + one in the middle merely contains a monitor status which needs + to refresh fairly frequently to give a true indication. This + option determines that frequency. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_REFRESH_EVENTS", - default => "180", - description => "How often (in seconds) the event listing is refreshed in the watch window", - help => qqq(" - The monitor window is actually made from several frames. The - lower framme contains a listing of the last few events for easy - access. This option determines how often this is refreshed. - "), + name => 'ZM_WEB_L_REFRESH_EVENTS', + default => '180', + description => 'How often (in seconds) the event listing is refreshed in the watch window', + help => q` + The monitor window is actually made from several frames. The + lower framme contains a listing of the last few events for easy + access. This option determines how often this is refreshed. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_CAN_STREAM", - default => "auto", - description => "Override the automatic detection of browser streaming capability", - help => qqq(" - If you know that your browser can handle image streams of the - type 'multipart/x-mixed-replace' but ZoneMinder does not detect - this correctly you can set this option to ensure that the - stream is delivered with or without the use of the Cambozola - plugin. Selecting 'yes' will tell ZoneMinder that your browser - can handle the streams natively, 'no' means that it can't and - so the plugin will be used while 'auto' lets ZoneMinder decide. - "), + name => 'ZM_WEB_L_CAN_STREAM', + default => 'auto', + description => 'Override the automatic detection of browser streaming capability', + help => q` + If you know that your browser can handle image streams of the + type 'multipart/x-mixed-replace' but ZoneMinder does not detect + this correctly you can set this option to ensure that the + stream is delivered with or without the use of the Cambozola + plugin. Selecting 'yes' will tell ZoneMinder that your browser + can handle the streams natively, 'no' means that it can't and + so the plugin will be used while 'auto' lets ZoneMinder decide. + `, type => $types{tristate}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_STREAM_METHOD", - default => "jpeg", - description => "Which method should be used to send video streams to your browser.", - help => qqq(" - ZoneMinder can be configured to use either mpeg encoded video - or a series or still jpeg images when sending video streams. - This option defines which is used. If you choose mpeg you - should ensure that you have the appropriate plugins available - on your browser whereas choosing jpeg will work natively on - Mozilla and related browsers and with a Java applet on Internet - Explorer - "), + name => 'ZM_WEB_L_STREAM_METHOD', + default => 'jpeg', + description => 'Which method should be used to send video streams to your browser.', + help => q` + ZoneMinder can be configured to use either mpeg encoded video + or a series or still jpeg images when sending video streams. + This option defines which is used. If you choose mpeg you + should ensure that you have the appropriate plugins available + on your browser whereas choosing jpeg will work natively on + Mozilla and related browsers and with a Java applet on Internet + Explorer + `, type => { - db_type =>"string", - hint =>"mpeg|jpeg", + db_type =>'string', + hint =>'mpeg|jpeg', pattern =>qr|^([mj])|i, - format =>q( $1 =~ /^m/ ? "mpeg" : "jpeg" ) + format =>q( $1 =~ /^m/ ? 'mpeg' : 'jpeg' ) }, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_DEFAULT_SCALE", - default => "100", - description => "What the default scaling factor applied to 'live' or 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'live' or 'event' streams in - their native size. However if you have monitors with large - dimensions or a slow link you may prefer to reduce this size, - alternatively for small monitors you can enlarge it. This - options lets you specify what the default scaling factor will - be. It is expressed as a percentage so 100 is normal size, 200 - is double size etc. - "), + name => 'ZM_WEB_L_DEFAULT_SCALE', + default => '100', + description => q`What the default scaling factor applied to 'live' or 'event' views is (%)`, + help => q` + Normally ZoneMinder will display 'live' or 'event' streams in + their native size. However if you have monitors with large + dimensions or a slow link you may prefer to reduce this size, + alternatively for small monitors you can enlarge it. This + options lets you specify what the default scaling factor will + be. It is expressed as a percentage so 100 is normal size, 200 + is double size etc. + `, type => { - db_type =>"integer", - hint =>"25|33|50|75|100|150|200|300|400", + db_type =>'integer', + hint =>'25|33|50|75|100|150|200|300|400', pattern =>qr|^(\d+)$|, format =>q( $1 ) }, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_DEFAULT_RATE", - default => "100", - description => "What the default replay rate factor applied to 'event' views is (%)", - help => qqq(" - Normally ZoneMinder will display 'event' streams at their - native rate, i.e. as close to real-time as possible. However if - you have long events it is often convenient to replay them at a - faster rate for review. This option lets you specify what the - default replay rate will be. It is expressed as a percentage so - 100 is normal rate, 200 is double speed etc. - "), + name => 'ZM_WEB_L_DEFAULT_RATE', + default => '100', + description => q`What the default replay rate factor applied to 'event' views is (%)`, + help => q` + Normally ZoneMinder will display 'event' streams at their + native rate, i.e. as close to real-time as possible. However if + you have long events it is often convenient to replay them at a + faster rate for review. This option lets you specify what the + default replay rate will be. It is expressed as a percentage so + 100 is normal rate, 200 is double speed etc. + `, type => { - db_type =>"integer", - hint =>"25|50|100|150|200|400|1000|2500|5000|10000", + db_type =>'integer', + hint =>'25|50|100|150|200|400|1000|2500|5000|10000', pattern =>qr|^(\d+)$|, format=>q( $1 ) }, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_VIDEO_BITRATE", - default => "25000", - description => "What the bitrate of the video encoded stream should be set to", - help => qqq(" - When encoding real video via the ffmpeg library a bit rate can - be specified which roughly corresponds to the available - bandwidth used for the stream. This setting effectively - corresponds to a 'quality' setting for the video. A low value - will result in a blocky image whereas a high value will produce - a clearer view. Note that this setting does not control the - frame rate of the video however the quality of the video - produced is affected both by this setting and the frame rate - that the video is produced at. A higher frame rate at a - particular bit rate result in individual frames being at a - lower quality. - "), + name => 'ZM_WEB_L_VIDEO_BITRATE', + default => '25000', + description => 'What the bitrate of the video encoded stream should be set to', + help => q` + When encoding real video via the ffmpeg library a bit rate can + be specified which roughly corresponds to the available + bandwidth used for the stream. This setting effectively + corresponds to a 'quality' setting for the video. A low value + will result in a blocky image whereas a high value will produce + a clearer view. Note that this setting does not control the + frame rate of the video however the quality of the video + produced is affected both by this setting and the frame rate + that the video is produced at. A higher frame rate at a + particular bit rate result in individual frames being at a + lower quality. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_VIDEO_MAXFPS", - default => "5", - description => "What the maximum frame rate for streamed video should be", - help => qqq(" - When using streamed video the main control is the bitrate which - determines how much data can be transmitted. However a lower - bitrate at high frame rates results in a lower quality image. - This option allows you to limit the maximum frame rate to - ensure that video quality is maintained. An additional - advantage is that encoding video at high frame rates is a - processor intensive task when for the most part a very high - frame rate offers little perceptible improvement over one that - has a more manageable resource requirement. Note, this option - is implemented as a cap beyond which binary reduction takes - place. So if you have a device capturing at 15fps and set this - option to 10fps then the video is not produced at 10fps, but - rather at 7.5fps (15 divided by 2) as the final frame rate must - be the original divided by a power of 2. - "), + name => 'ZM_WEB_L_VIDEO_MAXFPS', + default => '5', + description => 'What the maximum frame rate for streamed video should be', + help => q` + When using streamed video the main control is the bitrate which + determines how much data can be transmitted. However a lower + bitrate at high frame rates results in a lower quality image. + This option allows you to limit the maximum frame rate to + ensure that video quality is maintained. An additional + advantage is that encoding video at high frame rates is a + processor intensive task when for the most part a very high + frame rate offers little perceptible improvement over one that + has a more manageable resource requirement. Note, this option + is implemented as a cap beyond which binary reduction takes + place. So if you have a device capturing at 15fps and set this + option to 10fps then the video is not produced at 10fps, but + rather at 7.5fps (15 divided by 2) as the final frame rate must + be the original divided by a power of 2. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_SCALE_THUMBS", - default => "yes", - description => "Scale thumbnails in events, bandwidth versus cpu in rescaling", - help => qqq(" - If unset, this option sends the whole image to the browser - which resizes it in the window. If set the image is scaled down - on the server before sending a reduced size image to the - browser to conserve bandwidth at the cost of cpu on the server. - Note that ZM can only perform the resizing if the appropriate - PHP graphics functionality is installed. This is usually - available in the php-gd package. - "), + name => 'ZM_WEB_L_SCALE_THUMBS', + default => 'yes', + description => 'Scale thumbnails in events, bandwidth versus cpu in rescaling', + help => q` + If unset, this option sends the whole image to the browser + which resizes it in the window. If set the image is scaled down + on the server before sending a reduced size image to the + browser to conserve bandwidth at the cost of cpu on the server. + Note that ZM can only perform the resizing if the appropriate + PHP graphics functionality is installed. This is usually + available in the php-gd package. + `, type => $types{boolean}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_EVENTS_VIEW", - default => "events", - description => "What the default view of multiple events should be.", - help => qqq(" - Stored events can be viewed in either an events list format or - in a timeline based one. This option sets the default view that - will be used. Choosing one view here does not prevent the other - view being used as it will always be selectable from whichever - view is currently being used. - "), + name => 'ZM_WEB_L_EVENTS_VIEW', + default => 'events', + description => 'What the default view of multiple events should be.', + help => q` + Stored events can be viewed in either an events list format or + in a timeline based one. This option sets the default view that + will be used. Choosing one view here does not prevent the other + view being used as it will always be selectable from whichever + view is currently being used. + `, type => { - db_type =>"string", - hint =>"events|timeline", + db_type =>'string', + hint =>'events|timeline', pattern =>qr|^([lt])|i, - format =>q( $1 =~ /^e/ ? "events" : "timeline" ) + format =>q( $1 =~ /^e/ ? 'events' : 'timeline' ) }, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_SHOW_PROGRESS", - default => "no", - description => "Show the progress of replay in event view.", - help => qqq(" - When viewing events an event navigation panel and progress bar - is shown below the event itself. This allows you to jump to - specific points in the event, but can can also dynamically - update to display the current progress of the event replay - itself. This progress is calculated from the actual event - duration and is not directly linked to the replay itself, so on - limited bandwidth connections may be out of step with the - replay. This option allows you to turn off the progress - display, whilst still keeping the navigation aspect, where - bandwidth prevents it functioning effectively. - "), + name => 'ZM_WEB_L_SHOW_PROGRESS', + default => 'no', + description => 'Show the progress of replay in event view.', + help => q` + When viewing events an event navigation panel and progress bar + is shown below the event itself. This allows you to jump to + specific points in the event, but can can also dynamically + update to display the current progress of the event replay + itself. This progress is calculated from the actual event + duration and is not directly linked to the replay itself, so on + limited bandwidth connections may be out of step with the + replay. This option allows you to turn off the progress + display, whilst still keeping the navigation aspect, where + bandwidth prevents it functioning effectively. + `, type => $types{boolean}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_WEB_L_AJAX_TIMEOUT", - default => "10000", - description => "How long to wait for Ajax request responses (ms)", - help => qqq(" - The newer versions of the live feed and event views use Ajax to - request information from the server and populate the views - dynamically. This option allows you to specify a timeout if - required after which requests are abandoned. A timeout may be - necessary if requests would overwise hang such as on a slow - connection. This would tend to consume a lot of browser memory - and make the interface unresponsive. Ordinarily no requests - should timeout so this setting should be set to a value greater - than the slowest expected response. This value is in - milliseconds but if set to zero then no timeout will be used. - "), + name => 'ZM_WEB_L_AJAX_TIMEOUT', + default => '10000', + description => 'How long to wait for Ajax request responses (ms)', + help => q` + The newer versions of the live feed and event views use Ajax to + request information from the server and populate the views + dynamically. This option allows you to specify a timeout if + required after which requests are abandoned. A timeout may be + necessary if requests would overwise hang such as on a slow + connection. This would tend to consume a lot of browser memory + and make the interface unresponsive. Ordinarily no requests + should timeout so this setting should be set to a value greater + than the slowest expected response. This value is in + milliseconds but if set to zero then no timeout will be used. + `, type => $types{integer}, - category => "lowband", + category => 'lowband', }, { - name => "ZM_DYN_LAST_VERSION", - default => "", - description => "What the last version of ZoneMinder recorded from zoneminder.com is", - help => "", + name => 'ZM_DYN_LAST_VERSION', + default => '', + description => 'What the last version of ZoneMinder recorded from zoneminder.com is', + help => '', type => $types{string}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_CURR_VERSION", - default => "@VERSION@", - description => qqq(" - What the effective current version of ZoneMinder is, might be - different from actual if versions ignored - "), - help => "", + name => 'ZM_DYN_CURR_VERSION', + default => '@VERSION@', + description => q` + What the effective current version of ZoneMinder is, might be + different from actual if versions ignored + `, + help => '', type => $types{string}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_DB_VERSION", - default => "@VERSION@", - description => "What the version of the database is, from zmupdate", - help => "", + name => 'ZM_DYN_DB_VERSION', + default => '@VERSION@', + description => 'What the version of the database is, from zmupdate', + help => '', type => $types{string}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_LAST_CHECK", - default => "", - description => "When the last check for version from zoneminder.com was", - help => "", + name => 'ZM_DYN_LAST_CHECK', + default => '', + description => 'When the last check for version from zoneminder.com was', + help => '', type => $types{integer}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_NEXT_REMINDER", - default => "", - description => "When the earliest time to remind about versions will be", - help => "", + name => 'ZM_DYN_NEXT_REMINDER', + default => '', + description => 'When the earliest time to remind about versions will be', + help => '', type => $types{string}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_DONATE_REMINDER_TIME", + name => 'ZM_DYN_DONATE_REMINDER_TIME', default => 0, - description => "When the earliest time to remind about donations will be", - help => "", + description => 'When the earliest time to remind about donations will be', + help => '', type => $types{integer}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_DYN_SHOW_DONATE_REMINDER", - default => "yes", - description => "Remind about donations or not", - help => "", + name => 'ZM_DYN_SHOW_DONATE_REMINDER', + default => 'yes', + description => 'Remind about donations or not', + help => '', type => $types{boolean}, readonly => 1, - category => "dynamic", + category => 'dynamic', }, { - name => "ZM_SSMTP_MAIL", - default => "no", - description => qqq(" - Use a SSMTP mail server if available. - NEW_MAIL_MODULES must be enabled - "), + name => 'ZM_SSMTP_MAIL', + default => 'no', + description => q` + Use a SSMTP mail server if available. + NEW_MAIL_MODULES must be enabled + `, requires => [ - { name => "ZM_OPT_EMAIL", value => "yes" }, - { name => "ZM_OPT_MESSAGE", value => "yes" }, - { name => "ZM_NEW_MAIL_MODULES", value => "yes" } + { name => 'ZM_OPT_EMAIL', value => 'yes' }, + { name => 'ZM_OPT_MESSAGE', value => 'yes' }, + { name => 'ZM_NEW_MAIL_MODULES', value => 'yes' } ], - help => qqq(" - SSMTP is a lightweight and efficient method to send email. - The SSMTP application is not installed by default. - NEW_MAIL_MODULES must also be enabled. - Please visit: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder - for setup and configuration help. - "), + help => q` + SSMTP is a lightweight and efficient method to send email. + The SSMTP application is not installed by default. + NEW_MAIL_MODULES must also be enabled. + Please visit: http://www.zoneminder.com/wiki/index.php/How_to_get_ssmtp_working_with_Zoneminder + for setup and configuration help. + `, type => $types{boolean}, - category => "mail", + category => 'mail', }, { - name => "ZM_SSMTP_PATH", - default => "", - description => "SSMTP executable path", - requires => [{ name => "ZM_SSMTP_MAIL", value => "yes" }], - help => qqq(" - Recommend setting the path to the SSMTP application. - If path is not defined. Zoneminder will try to determine - the path via shell command. Example path: /usr/sbin/ssmtp. - "), + name => 'ZM_SSMTP_PATH', + default => '', + description => 'SSMTP executable path', + requires => [{ name => 'ZM_SSMTP_MAIL', value => 'yes' }], + help => q` + Recommend setting the path to the SSMTP application. + If path is not defined. Zoneminder will try to determine + the path via shell command. Example path: /usr/sbin/ssmtp. + `, type => $types{string}, - category => "mail", + category => 'mail', }, ); our %options_hash = map { ( $_->{name}, $_ ) } @options; -# This function should never need to be called explicitly, except if +# This function should never need to be called explicitly, except if # this module is 'require'd rather than 'use'd. See zmconfgen.pl. sub initialiseConfig { return if ( $configInitialised ); diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/SkyIPCam7xx.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/SkyIPCam7xx.pm index e5917536f..b3f9418ce 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/SkyIPCam7xx.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/SkyIPCam7xx.pm @@ -45,265 +45,239 @@ use ZoneMinder::Config qw(:all); use Time::HiRes qw( usleep ); -sub new -{ - my $class = shift; - my $id = shift; - my $self = ZoneMinder::Control->new( $id ); - bless( $self, $class ); - srand( time() ); - return $self; +sub new { + my $class = shift; + my $id = shift; + my $self = ZoneMinder::Control->new( $id ); + bless( $self, $class ); + srand( time() ); + return $self; } our $AUTOLOAD; -sub AUTOLOAD -{ - my $self = shift; - my $class = ref($self) || croak( "$self not object" ); - my $name = $AUTOLOAD; - $name =~ s/.*://; - if ( exists($self->{$name}) ) - { - return( $self->{$name} ); - } - Fatal( "Can't access $name member of object of class $class" ); +sub AUTOLOAD { + my $self = shift; + my $class = ref($self) || croak( "$self not object" ); + my $name = $AUTOLOAD; + $name =~ s/.*://; + if ( exists($self->{$name}) ) { + return( $self->{$name} ); + } + Fatal( "Can't access $name member of object of class $class" ); } -sub open -{ - my $self = shift; +sub open { + my $self = shift; - $self->loadMonitor(); + $self->loadMonitor(); - use LWP::UserAgent; - $self->{ua} = LWP::UserAgent->new; - $self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION ); + use LWP::UserAgent; + $self->{ua} = LWP::UserAgent->new; + $self->{ua}->agent( "ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION ); - $self->{state} = 'open'; + $self->{state} = 'open'; } -sub close -{ - my $self = shift; - $self->{state} = 'closed'; +sub close { + my $self = shift; + $self->{state} = 'closed'; } -sub printMsg -{ - my $self = shift; - my $msg = shift; - my $msg_len = length($msg); +sub printMsg { + my $self = shift; + my $msg = shift; + my $msg_len = length($msg); - Debug( $msg."[".$msg_len."]" ); + Debug( $msg."[".$msg_len."]" ); } -sub sendCmd -{ - my $self = shift; - my $cmd = shift; +sub sendCmd { + my $self = shift; + my $cmd = shift; - my $result = undef; + my $result = undef; - printMsg( $cmd, "Tx" ); + printMsg( $cmd, "Tx" ); - my $url; - if ( $self->{Monitor}->{ControlAddress} =~ /^http/ ) { - $url = $self->{Monitor}->{ControlAddress}.$cmd; - } else { - $url = 'http://'.$self->{Monitor}->{ControlAddress}.$cmd; - } # en dif - my $req = HTTP::Request->new( GET=>$url ); + my $url; + if ( $self->{Monitor}->{ControlAddress} =~ /^http/ ) { + $url = $self->{Monitor}->{ControlAddress}.$cmd; + } else { + $url = 'http://'.$self->{Monitor}->{ControlAddress}.$cmd; + } # en dif + my $req = HTTP::Request->new( GET=>$url ); - my $res = $self->{ua}->request($req); + my $res = $self->{ua}->request($req); - if ( $res->is_success ) - { - $result = !undef; - } - else - { - Error( "Error check failed: '".$res->status_line()."'" ); - } + if ( $res->is_success ) { + $result = !undef; + } else { + Error( "Error check failed: '".$res->status_line()."'" ); + } - return( $result ); + return( $result ); } -sub reset -{ - my $self = shift; - Debug( "Camera Reset" ); - my $cmd = "/admin/ptctl.cgi?move=reset"; - $self->sendCmd( $cmd ); +sub reset { + my $self = shift; + Debug( "Camera Reset" ); + my $cmd = "/admin/ptctl.cgi?move=reset"; + $self->sendCmd( $cmd ); } -sub moveMap -{ - my $self = shift; - my $params = shift; - my $xcoord = $self->getParam( $params, 'xcoord' ); - my $ycoord = $self->getParam( $params, 'ycoord' ); +sub moveMap { + my $self = shift; + my $params = shift; + my $xcoord = $self->getParam( $params, 'xcoord' ); + my $ycoord = $self->getParam( $params, 'ycoord' ); - my $hor = $xcoord * 100 / $self->{Monitor}->{Width}; - my $ver = $ycoord * 100 / $self->{Monitor}->{Height}; + my $hor = $xcoord * 100 / $self->{Monitor}->{Width}; + my $ver = $ycoord * 100 / $self->{Monitor}->{Height}; - my $maxver = 8; - my $maxhor = 30; - - my $horDir = "right"; - my $verDir = "up"; - my $horSteps = 0; - my $verSteps = 0; + my $maxver = 8; + my $maxhor = 30; - # Horizontal movement - if ($hor < 50) { - # left - $horSteps = ((50 - $hor) / 50) * $maxhor; - $horDir = "left"; - } - elsif ($hor > 50) { - # right - $horSteps = (($hor - 50) / 50) * $maxhor; - $horDir = "right"; - } - - # Vertical movement - if ($ver < 50) { - # up - $verSteps = ((50 - $ver) / 50) * $maxver; - $verDir = "up"; - } - elsif ($ver > 50) { - # down - $verSteps = (($ver - 50) / 50) * $maxver; - $verDir = "down"; - } + my $horDir = "right"; + my $verDir = "up"; + my $horSteps = 0; + my $verSteps = 0; - my $v = int($verSteps); - my $h = int($horSteps); +# Horizontal movement + if ( $hor < 50 ) { +# left + $horSteps = ((50 - $hor) / 50) * $maxhor; + $horDir = "left"; + } + elsif ( $hor > 50 ) { +# right + $horSteps = (($hor - 50) / 50) * $maxhor; + $horDir = "right"; + } - Debug( "Move Map to $xcoord,$ycoord, hor=$h $horDir, ver=$v $verDir"); - my $cmd = "/cgi/admin/ptctrl.cgi?action=movedegree&Cmd=$horDir&Degree=$h"; - $self->sendCmd( $cmd ); - $cmd = "/cgi/admin/ptctrl.cgi?action=movedegree&Cmd=$verDir&Degree=$v"; - $self->sendCmd( $cmd ); +# Vertical movement + if ( $ver < 50 ) { +# up + $verSteps = ((50 - $ver) / 50) * $maxver; + $verDir = "up"; + } + elsif ( $ver > 50 ) { +# down + $verSteps = (($ver - 50) / 50) * $maxver; + $verDir = "down"; + } + + my $v = int($verSteps); + my $h = int($horSteps); + + Debug( "Move Map to $xcoord,$ycoord, hor=$h $horDir, ver=$v $verDir"); + my $cmd = "/cgi/admin/ptctrl.cgi?action=movedegree&Cmd=$horDir&Degree=$h"; + $self->sendCmd( $cmd ); + $cmd = "/cgi/admin/ptctrl.cgi?action=movedegree&Cmd=$verDir&Degree=$v"; + $self->sendCmd( $cmd ); } -sub moveRelUp -{ - my $self = shift; - my $params = shift; - my $step = $self->getParam( $params, 'tiltstep' ); - Debug( "Step Up $step" ); - my $cmd = "/admin/ptctl.cgi?move=up"; - $self->sendCmd( $cmd ); +sub moveRelUp { + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Up $step" ); + my $cmd = "/admin/ptctl.cgi?move=up"; + $self->sendCmd( $cmd ); } -sub moveRelDown -{ - my $self = shift; - my $params = shift; - my $step = $self->getParam( $params, 'tiltstep' ); - Debug( "Step Down $step" ); - my $cmd = "/admin/ptctl.cgi?move=down"; - $self->sendCmd( $cmd ); +sub moveRelDown { + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'tiltstep' ); + Debug( "Step Down $step" ); + my $cmd = "/admin/ptctl.cgi?move=down"; + $self->sendCmd( $cmd ); } -sub moveRelLeft -{ - my $self = shift; - my $params = shift; - my $step = $self->getParam( $params, 'panstep' ); - Debug( "Step Left $step" ); - my $cmd = "/admin/ptctl.cgi?move=left"; - $self->sendCmd( $cmd ); +sub moveRelLeft { + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'panstep' ); + + if ( $self->{Monitor}->{Orientation} eq "hori" ) { + Debug( "Stepping Right because flipped horizontally " ); + $self->sendCmd( "/admin/ptctl.cgi?move=right" ); + } else { + Debug( "Step Left" ); + $self->sendCmd( "/admin/ptctl.cgi?move=left" ); + } } -sub moveRelRight -{ - my $self = shift; - my $params = shift; - my $step = $self->getParam( $params, 'panstep' ); - Debug( "Step Right $step" ); - my $cmd = "/admin/ptctl.cgi?move=right"; - $self->sendCmd( $cmd ); +sub moveRelRight { + my $self = shift; + my $params = shift; + my $step = $self->getParam( $params, 'panstep' ); + if ( $self->{Monitor}->{Orientation} eq "hori" ) { + Debug( "Stepping Left because flipped horizontally " ); + $self->sendCmd( "/admin/ptctl.cgi?move=left" ); + } else { + Debug( "Step Right" ); + $self->sendCmd( "/admin/ptctl.cgi?move=right" ); + } } -sub presetClear -{ - my $self = shift; - my $params = shift; - my $preset = $self->getParam( $params, 'preset' ); - Debug( "Clear Preset $preset" ); - #my $cmd = "/axis-cgi/com/ptz.cgi?removeserverpresetno=$preset"; - #$self->sendCmd( $cmd ); +sub presetClear { + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Debug( "Clear Preset $preset" ); +#my $cmd = "/axis-cgi/com/ptz.cgi?removeserverpresetno=$preset"; +#$self->sendCmd( $cmd ); } -sub presetSet -{ - my $self = shift; - my $params = shift; - my $preset = $self->getParam( $params, 'preset' ); - Debug( "Set Preset $preset" ); - my $cmd = "/admin/ptctl.cgi?position=" . ($preset - 1) . "&positionname=zm$preset"; - $self->sendCmd( $cmd ); +sub presetSet { + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Debug( "Set Preset $preset" ); + my $cmd = "/admin/ptctl.cgi?position=" . ($preset - 1) . "&positionname=zm$preset"; + $self->sendCmd( $cmd ); } -sub presetGoto -{ - my $self = shift; - my $params = shift; - my $preset = $self->getParam( $params, 'preset' ); - Debug( "Goto Preset $preset" ); - my $cmd = "/admin/ptctl.cgi?move=p" . ($preset - 1); - $self->sendCmd( $cmd ); +sub presetGoto { + my $self = shift; + my $params = shift; + my $preset = $self->getParam( $params, 'preset' ); + Debug( "Goto Preset $preset" ); + my $cmd = "/admin/ptctl.cgi?move=p" . ($preset - 1); + $self->sendCmd( $cmd ); } -sub presetHome -{ - my $self = shift; - Debug( "Home Preset" ); - my $cmd = "/admin/ptctl.cgi?move=h"; - $self->sendCmd( $cmd ); +sub presetHome { + my $self = shift; + Debug( "Home Preset" ); + my $cmd = "/admin/ptctl.cgi?move=h"; + $self->sendCmd( $cmd ); } 1; __END__ -# Below is stub documentation for your module. You'd better edit it! =head1 NAME -ZoneMinder::Database - Perl extension for blah blah blah +ZoneMinder::Control::SkyIPCam7xx.pm - Module for controlling AirLink101 SkyIPams =head1 SYNOPSIS - use ZoneMinder::Database; - blah blah blah +use ZoneMinder::Control::SkyIPCam7xx; =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. +Module for controlling AirLink101 Cameras. =head2 EXPORT None by default. - - =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. +ZoneMinder::Control =head1 AUTHOR @@ -318,5 +292,4 @@ 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. - =cut diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 71ca57680..d616d893f 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -28,30 +28,12 @@ use 5.006; use strict; use warnings; -require Exporter; require ZoneMinder::Base; +require ZoneMinder::Object; require Date::Manip; -our @ISA = qw(Exporter ZoneMinder::Base); - -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. - -# This allows declaration use ZoneMinder ':all'; -# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK -# will save memory. -our %EXPORT_TAGS = ( - 'functions' => [ qw( - ) ] - ); -push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; - -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); - -our @EXPORT = qw(); - -our $VERSION = $ZoneMinder::Base::VERSION; +#our @ISA = qw(ZoneMinder::Object); +use parent qw(ZoneMinder::Object); # ========================================================================== # @@ -62,39 +44,24 @@ our $VERSION = $ZoneMinder::Base::VERSION; use ZoneMinder::Config qw(:all); use ZoneMinder::Logger qw(:all); use ZoneMinder::Database qw(:all); +require Date::Parse; + +use vars qw/ $table $primary_key /; +$table = 'Events'; +$primary_key = 'Id'; use POSIX; -sub new { - my ( $parent, $id, $data ) = @_; - - my $self = {}; - bless $self, $parent; - $$self{dbh} = $ZoneMinder::Database::dbh; -#zmDbConnect(); - if ( ( $$self{Id} = $id ) or $data ) { -#$log->debug("loading $parent $id") if $debug or DEBUG_ALL; - $self->load( $data ); +sub Time { + if ( @_ > 1 ) { + $_[0]{Time} = $_[1]; } - return $self; -} # end sub new + if ( ! defined $_[0]{Time} ) { -sub load { - my ( $self, $data ) = @_; - my $type = ref $self; - if ( ! $data ) { -#$log->debug("Object::load Loading from db $type"); - $data = $$self{dbh}->selectrow_hashref( 'SELECT * FROM Events WHERE Id=?', {}, $$self{Id} ); - if ( ! $data ) { - Error( "Failure to load Event record for $$self{Id}: Reason: " . $$self{dbh}->errstr ); - } else { - Debug( 3, "Loaded Event $$self{Id}" ); - } # end if - } # end if ! $data - if ( $data and %$data ) { - @$self{keys %$data} = values %$data; - } # end if -} # end sub load + $_[0]{Time} = Date::Parse::str2time( $_[0]{StartTime} ); + } + return $_[0]{Time}; +} sub Name { if ( @_ > 1 ) { @@ -130,6 +97,7 @@ sub find { my $filter = new ZoneMinder::Event( $$db_filter{Id}, $db_filter ); push @results, $filter; } # end while + $sth->finish(); return @results; } @@ -138,36 +106,51 @@ sub find_one { return $results[0] if @results; } -sub getEventPath { +sub getPath { + return Path( @_ ); +} +sub Path { my $event = shift; - my $event_path = ""; - if ( $Config{ZM_USE_DEEP_STORAGE} ) { - $event_path = $Config{ZM_DIR_EVENTS} - .'/'.$event->{MonitorId} - .'/'.strftime( "%y/%m/%d/%H/%M/%S", - localtime($event->{Time}) - ) - ; - } else { - $event_path = $Config{ZM_DIR_EVENTS} - .'/'.$event->{MonitorId} - .'/'.$event->{Id} - ; + if ( @_ > 1 ) { + $$event{Path} = $_[1]; + if ( ! -e $$event{Path} ) { + Error("Setting path for event $$event{Id} to $_[1] but does not exist!"); + } } - if ( index($Config{ZM_DIR_EVENTS},'/') != 0 ){ - $event_path = $Config{ZM_PATH_WEB} - .'/'.$event_path - ; - } - return( $event_path ); + if ( ! $$event{Path} ) { + my $path = ($Config{ZM_DIR_EVENTS}=~/^\//) ? $Config{ZM_DIR_EVENTS} : $Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS}; + + if ( $Config{ZM_USE_DEEP_STORAGE} ) { + if ( $event->Time() ) { + $$event{Path} = join('/', + $path, + $event->{MonitorId}, + strftime( "%y/%m/%d/%H/%M/%S", + localtime($event->Time()) + ), + ); + } else { + Error("Event $$event{Id} has no value for Time(), unable to determine path"); + $$event{Path} = ''; + } + } else { + $$event{Path} = join('/', + $path, + $event->{MonitorId}, + $event->{Id}, + ); + } + } # end if + + return $$event{Path}; } sub GenerateVideo { my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_; - my $event_path = getEventPath( $self ); + my $event_path = $self->getPath( ); chdir( $event_path ); ( my $video_name = $self->{Name} ) =~ s/\s/_/g; @@ -228,9 +211,7 @@ sub GenerateVideo { my $command = $Config{ZM_PATH_FFMPEG} ." -y -r $frame_rate " .$Config{ZM_FFMPEG_INPUT_OPTIONS} - ." -i %0" - .$Config{ZM_EVENT_IMAGE_DIGITS} - ."d-capture.jpg -s $video_size " + .' -i ' . ( $$self{DefaultVideo} ? $$self{DefaultVideo} : '%0'.$Config{ZM_EVENT_IMAGE_DIGITS} .'d-capture.jpg' ) #. " -f concat -i /tmp/event_files.txt" ." -s $video_size " .$Config{ZM_FFMPEG_OUTPUT_OPTIONS} @@ -253,54 +234,143 @@ sub GenerateVideo { Info( "Video file $video_file already exists for event $self->{Id}\n" ); return $event_path.'/'.$video_file; } - return; + return; } # end sub GenerateVideo +sub delete { + my $event = $_[0]; + Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} $event->{StartTime}\n" ); + $ZoneMinder::Database::dbh->ping(); +# 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 Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + $sth->finish(); + + if ( ! $Config{ZM_OPT_FAST_DELETE} ) { + my $sql = 'delete from Frames where EventId = ?'; + my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + $sth->finish(); + + $sql = 'delete from Stats where EventId = ?'; + $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() ); + $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + $sth->finish(); + + $event->delete_files( ); + } else { + Debug('Not deleting frames, stats and files for speed.'); + } +} # end sub delete + + +sub delete_files { + + my $storage_path = ($Config{ZM_DIR_EVENTS}=~/^\//) ? $Config{ZM_DIR_EVENTS} : $Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS}; + + if ( ! $storage_path ) { + Fatal("Empty path when deleting files for event $_[0]{Id} "); + return; + } + + chdir ( $storage_path ); + + if ( $Config{ZM_USE_DEEP_STORAGE} ) { + if ( ! $_[0]{MonitorId} ) { + Error("No monitor id assigned to event $_[0]{Id}"); + return; + } + Debug("Deleting files for Event $_[0]{Id} from $storage_path."); + my $link_path = $_[0]{MonitorId}.'/*/*/*/.'.$_[0]{Id}; +#Debug( "LP1:$link_path" ); + my @links = glob($link_path); +#Debug( "L:".$links[0].": $!" ); + if ( @links ) { + ( $link_path ) = ( $links[0] =~ /^(.*)$/ ); # De-taint +#Debug( "LP2:$link_path" ); + + ( my $day_path = $link_path ) =~ s/\.\d+//; +#Debug( "DP:$day_path" ); + my $event_path = $day_path.readlink( $link_path ); + ( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint +#Debug( "EP:$event_path" ); + my $command = "/bin/rm -rf $event_path"; +#Debug( "C:$command" ); + ZoneMinder::General::executeShellCommand( $command ); + + unlink( $link_path ) or Error( "Unable to unlink '$link_path': $!" ); + + my @path_parts = split( /\//, $event_path ); + for ( my $i = int(@path_parts)-2; $i >= 1; $i-- ) { + my $delete_path = join( '/', @path_parts[0..$i] ); +#Debug( "DP$i:$delete_path" ); + my @has_files = glob( join('/', $storage_path,$delete_path,'*' ) ); +#Debug( "HF1:".$has_files[0] ) if ( @has_files ); + last if ( @has_files ); + @has_files = glob( join('/', $storage_path, $delete_path, '.[0-9]*' ) ); +#Debug( "HF2:".$has_files[0] ) if ( @has_files ); + last if ( @has_files ); + my $command = "/bin/rm -rf $storage_path/$delete_path"; + ZoneMinder::General::executeShellCommand( $command ); + } + } + } else { + my $command = "/bin/rm -rf $storage_path/$_[0]{MonitorId}/$_[0]{Id}"; + ZoneMinder::General::executeShellCommand( $command ); + } +} # end sub delete_files + +sub Storage { + return new ZoneMinder::Storage( $_[0]{StorageId} ); +} + +sub check_for_in_filesystem { + my $path = $_[0]->Path(); + if ( $path ) { + my @files = glob( $path . '/*' ); +Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files"); + return 1 if @files; + } +Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found no files"); + return 0; +} + +sub age { + if ( ! $_[0]{age} ) { + $_[0]{age} = (time() - ($^T - ((-M $_[0]->Path() ) * 24*60*60))); + } + return $_[0]{age}; +} + 1; __END__ -# Below is stub documentation for your module. You'd better edit it! =head1 NAME -ZoneMinder::Database - Perl extension for blah blah blah +ZoneMinder::Event - Perl Class for events =head1 SYNOPSIS use ZoneMinder::Event; -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. - -=head2 EXPORT - -None by default. - - - -=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. +The Event class has everything you need to deal with events from Perl. =head1 AUTHOR -Philip Coombes, Ephilip.coombes@zoneminder.comE +Isaac Connor, Eisaac@zoneminder.comE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2001-2008 Philip Coombes +Copyright (C) 2001-2017 ZoneMinder LLC 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, diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index 4bec2a062..75d0e6ad4 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -32,10 +32,9 @@ require ZoneMinder::Base; require Date::Manip; use parent qw(ZoneMinder::Object); -#our @ISA = qw(ZoneMinder::Object); use vars qw/ $table $primary_key /; -$table = 'Events'; +$table = 'Filters'; $primary_key = 'Id'; # ========================================================================== # @@ -99,7 +98,7 @@ sub Execute { my $sql = $self->Sql(); if ( $self->{HasDiskPercent} ) { - my $disk_percent = getDiskPercent( $$self{Storage} ? $$self{Storage}->Path() : () ); + my $disk_percent = getDiskPercent(); $sql =~ s/zmDiskPercent/$disk_percent/g; } if ( $self->{HasDiskBlocks} ) { @@ -195,9 +194,6 @@ sub Sql { # This gets used later, I forget for what $$self{Server} = new ZoneMinder::Server( $temp_value ); } - } elsif ( $term->{attr} eq 'StorageId' ) { - $value = "'$temp_value'"; - $$self{Storage} = new ZoneMinder::Storage( $temp_value ); } elsif ( $term->{attr} eq 'Name' || $term->{attr} eq 'Cause' || $term->{attr} eq 'Notes' @@ -253,14 +249,14 @@ sub Sql { } # end if terms if ( $self->{Sql} ) { - #if ( $self->{AutoMessage} ) { + if ( $self->{AutoMessage} ) { # Include all events, including events that are still ongoing # and have no EndTime yet $sql .= " and ( ".$self->{Sql}." )"; - #} else { + } else { # Only include closed events (events with valid EndTime) - #$sql .= " where not isnull(E.EndTime) and ( ".$self->{Sql}." )"; - #} + $sql .= " where not isnull(E.EndTime) and ( ".$self->{Sql}." )"; + } } my @auto_terms; if ( $self->{AutoArchive} ) { @@ -268,9 +264,9 @@ sub Sql { } # Don't do this, it prevents re-generation and concatenation. # If the file already exists, then the video won't be re-recreated - #if ( $self->{AutoVideo} ) { - #push @auto_terms, "E.Videoed = 0"; - #} + if ( $self->{AutoVideo} ) { + push @auto_terms, "E.Videoed = 0"; + } if ( $self->{AutoUpload} ) { push @auto_terms, "E.Uploaded = 0"; } diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 38a8d3b5c..91f2d0b54 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -41,7 +41,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 = ( - 'constants' => [ qw( + constants => [ qw( STATE_IDLE STATE_PREALARM STATE_ALARM @@ -56,7 +56,7 @@ our %EXPORT_TAGS = ( TRIGGER_ON TRIGGER_OFF ) ], - 'functions' => [ qw( + functions => [ qw( zmMemVerify zmMemInvalidate zmMemRead @@ -77,12 +77,12 @@ our %EXPORT_TAGS = ( zmTriggerEventOn zmTriggerEventOff zmTriggerEventCancel - zmTriggerShowtext + zmTriggerShowtext ) ], ); 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(); @@ -115,7 +115,7 @@ use constant TRIGGER_OFF => 2; use Storable qw( freeze thaw ); -if ( "@ENABLE_MMAP@" eq 'yes' ) { +if ( '@ENABLE_MMAP@' eq 'yes' ) { # 'yes' if memory is mmapped require ZoneMinder::Memory::Mapped; ZoneMinder::Memory::Mapped->import(); @@ -141,42 +141,42 @@ our $native = $arch/8; our $mem_seq = 0; our $mem_data = { - "shared_data" => { "type"=>"SharedData", "seq"=>$mem_seq++, "contents"=> { - "size" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "last_write_index" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "last_read_index" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "state" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "last_event" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "action" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "brightness" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "hue" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "colour" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "contrast" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "alarm_x" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "alarm_y" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "valid" => { "type"=>"uint8", "seq"=>$mem_seq++ }, - "active" => { "type"=>"uint8", "seq"=>$mem_seq++ }, - "signal" => { "type"=>"uint8", "seq"=>$mem_seq++ }, - "format" => { "type"=>"uint8", "seq"=>$mem_seq++ }, - "imagesize" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "epadding1" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "epadding2" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "last_write_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, - "last_read_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, - "control_state" => { "type"=>"uint8[256]", "seq"=>$mem_seq++ }, + shared_data => { type=>'SharedData', seq=>$mem_seq++, contents=> { + size => { type=>'uint32', seq=>$mem_seq++ }, + last_write_index => { type=>'uint32', seq=>$mem_seq++ }, + last_read_index => { type=>'uint32', seq=>$mem_seq++ }, + state => { type=>'uint32', seq=>$mem_seq++ }, + last_event => { type=>'uint32', seq=>$mem_seq++ }, + action => { type=>'uint32', seq=>$mem_seq++ }, + brightness => { type=>'int32', seq=>$mem_seq++ }, + hue => { type=>'int32', seq=>$mem_seq++ }, + colour => { type=>'int32', seq=>$mem_seq++ }, + contrast => { type=>'int32', seq=>$mem_seq++ }, + alarm_x => { type=>'int32', seq=>$mem_seq++ }, + alarm_y => { type=>'int32', seq=>$mem_seq++ }, + valid => { type=>'uint8', seq=>$mem_seq++ }, + active => { type=>'uint8', seq=>$mem_seq++ }, + signal => { type=>'uint8', seq=>$mem_seq++ }, + format => { type=>'uint8', seq=>$mem_seq++ }, + imagesize => { type=>'uint32', seq=>$mem_seq++ }, + epadding1 => { type=>'uint32', seq=>$mem_seq++ }, + epadding2 => { type=>'uint32', seq=>$mem_seq++ }, + last_write_time => { type=>'time_t64', seq=>$mem_seq++ }, + last_read_time => { type=>'time_t64', seq=>$mem_seq++ }, + control_state => { type=>'uint8[256]', seq=>$mem_seq++ }, } }, - "trigger_data" => { "type"=>"TriggerData", "seq"=>$mem_seq++, "contents"=> { - "size" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "trigger_state" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "trigger_score" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "padding" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "trigger_cause" => { "type"=>"int8[32]", "seq"=>$mem_seq++ }, - "trigger_text" => { "type"=>"int8[256]", "seq"=>$mem_seq++ }, - "trigger_showtext" => { "type"=>"int8[256]", "seq"=>$mem_seq++ }, + trigger_data => { type=>'TriggerData', seq=>$mem_seq++, 'contents'=> { + size => { type=>'uint32', seq=>$mem_seq++ }, + trigger_state => { type=>'uint32', seq=>$mem_seq++ }, + trigger_score => { type=>'uint32', seq=>$mem_seq++ }, + padding => { type=>'uint32', seq=>$mem_seq++ }, + trigger_cause => { type=>'int8[32]', seq=>$mem_seq++ }, + trigger_text => { type=>'int8[256]', seq=>$mem_seq++ }, + trigger_showtext => { type=>'int8[256]', seq=>$mem_seq++ }, } }, - "end" => { "seq"=>$mem_seq++, "size"=> 0 } + end => { seq=>$mem_seq++, size=>0 } }; our $mem_size = 0; @@ -195,28 +195,28 @@ sub zmMemInit { } } foreach my $member_data ( sort { $a->{seq} <=> $b->{seq} } values( %{$section_data->{contents}} ) ) { - if ( $member_data->{type} eq "long" - || $member_data->{type} eq "ulong" - || $member_data->{type} eq "size_t" + if ( $member_data->{type} eq 'long' + || $member_data->{type} eq 'ulong' + || $member_data->{type} eq 'size_t' ) { $member_data->{size} = $member_data->{align} = $native; - } elsif ( $member_data->{type} eq "int64" - || $member_data->{type} eq "uint64" - || $member_data->{type} eq "time_t64" + } elsif ( $member_data->{type} eq 'int64' + || $member_data->{type} eq 'uint64' + || $member_data->{type} eq 'time_t64' ) { $member_data->{size} = $member_data->{align} = 8; - } elsif ( $member_data->{type} eq "int32" - || $member_data->{type} eq "uint32" - || $member_data->{type} eq "bool4" + } elsif ( $member_data->{type} eq 'int32' + || $member_data->{type} eq 'uint32' + || $member_data->{type} eq 'bool4' ) { $member_data->{size} = $member_data->{align} = 4; - } elsif ($member_data->{type} eq "int16" - || $member_data->{type} eq "uint16" + } elsif ($member_data->{type} eq 'int16' + || $member_data->{type} eq 'uint16' ) { $member_data->{size} = $member_data->{align} = 2; - } elsif ( $member_data->{type} eq "int8" - || $member_data->{type} eq "uint8" - || $member_data->{type} eq "bool1" + } elsif ( $member_data->{type} eq 'int8' + || $member_data->{type} eq 'uint8' + || $member_data->{type} eq 'bool1' ) { $member_data->{size} = $member_data->{align} = 1; } elsif ( $member_data->{type} =~ /^u?int8\[(\d+)\]$/ ) { @@ -248,51 +248,51 @@ sub zmMemVerify { return( undef ); } - 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 " - .$monitor->{Name} - .", expected " - .$mem_data->{shared_data}->{size} - .", got " - .$sd_size - ); - } else { - Debug( "Shared data size conflict in shared_data for monitor " - .$monitor->{Name} - .", expected " - .$mem_data->{shared_data}->{size} - .", got ".$sd_size - ); - } - return( undef ); + 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 " + .$monitor->{Name} + .", expected " + .$mem_data->{shared_data}->{size} + .", got " + .$sd_size + ); + } else { + Debug( "Shared data size conflict in shared_data for monitor " + .$monitor->{Name} + .", expected " + .$mem_data->{shared_data}->{size} + .", got ".$sd_size + ); } - 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 " - .$monitor->{Name} - .", expected " - .$mem_data->{triggger_data}->{size} - .", got " - .$td_size - ); - } else { - Debug( "Shared data size conflict in trigger_data for monitor " - .$monitor->{Name} - .", expected " - .$mem_data->{triggger_data}->{size} - .", got " - .$td_size - ); - } - return( undef ); - } - if ( !zmMemRead($monitor, "shared_data:valid",1) ) { - Error( "Shared data not valid for monitor $$monitor{Id}" ); - return( undef ); + return( undef ); + } + 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 " + .$monitor->{Name} + .", expected " + .$mem_data->{triggger_data}->{size} + .", got " + .$td_size + ); + } else { + Debug( "Shared data size conflict in trigger_data for monitor " + .$monitor->{Name} + .", expected " + .$mem_data->{triggger_data}->{size} + .", got " + .$td_size + ); } + return( undef ); + } + if ( !zmMemRead($monitor, 'shared_data:valid',1) ) { + Error( "Shared data not valid for monitor $$monitor{Id}" ); + return( undef ); + } return( !undef ); } @@ -325,32 +325,32 @@ sub zmMemRead { return( undef ); } my $value; - if ( $type eq "long" ) { - ( $value ) = unpack( "l!", $data ); - } elsif ( $type eq "ulong" || $type eq "size_t" ) { - ( $value ) = unpack( "L!", $data ); - } elsif ( $type eq "int64" || $type eq "time_t64" ) { -# The "q" type is only available on 64bit platforms, so use native. - ( $value ) = unpack( "l!", $data ); - } elsif ( $type eq "uint64" ) { -# The "q" type is only available on 64bit platforms, so use native. - ( $value ) = unpack( "L!", $data ); - } elsif ( $type eq "int32" ) { - ( $value ) = unpack( "l", $data ); - } elsif ( $type eq "uint32" || $type eq "bool4" ) { - ( $value ) = unpack( "L", $data ); - } elsif ( $type eq "int16" ) { - ( $value ) = unpack( "s", $data ); - } elsif ( $type eq "uint16" ) { - ( $value ) = unpack( "S", $data ); - } elsif ( $type eq "int8" ) { - ( $value ) = unpack( "c", $data ); - } elsif ( $type eq "uint8" || $type eq "bool1" ) { - ( $value ) = unpack( "C", $data ); + if ( $type eq 'long' ) { + ( $value ) = unpack( 'l!', $data ); + } elsif ( $type eq 'ulong' || $type eq 'size_t' ) { + ( $value ) = unpack( 'L!', $data ); + } elsif ( $type eq 'int64' || $type eq 'time_t64' ) { +# The 'q' type is only available on 64bit platforms, so use native. + ( $value ) = unpack( 'l!', $data ); + } elsif ( $type eq 'uint64' ) { +# The 'q' type is only available on 64bit platforms, so use native. + ( $value ) = unpack( 'L!', $data ); + } elsif ( $type eq 'int32' ) { + ( $value ) = unpack( 'l', $data ); + } elsif ( $type eq 'uint32' || $type eq 'bool4' ) { + ( $value ) = unpack( 'L', $data ); + } elsif ( $type eq 'int16' ) { + ( $value ) = unpack( 's', $data ); + } elsif ( $type eq 'uint16' ) { + ( $value ) = unpack( 'S', $data ); + } elsif ( $type eq 'int8' ) { + ( $value ) = unpack( 'c', $data ); + } elsif ( $type eq 'uint8' || $type eq 'bool1' ) { + ( $value ) = unpack( 'C', $data ); } elsif ( $type =~ /^int8\[\d+\]$/ ) { - ( $value ) = unpack( "Z".$size, $data ); + ( $value ) = unpack( 'Z'.$size, $data ); } elsif ( $type =~ /^uint8\[\d+\]$/ ) { - ( $value ) = unpack( "C".$size, $data ); + ( $value ) = unpack( 'C'.$size, $data ); } else { Fatal( "Unexpected type '".$type."' found for '".$field."'" ); } @@ -394,34 +394,34 @@ sub zmMemWrite { my $size = $mem_data->{$section}->{contents}->{$element}->{size}; my $data; - if ( $type eq "long" ) { - $data = pack( "l!", $value ); - } elsif ( $type eq "ulong" || $type eq "size_t" ) { - $data = pack( "L!", $value ); - } elsif ( $type eq "int64" || $type eq "time_t64" ) { -# The "q" type is only available on 64bit platforms, so use native. - $data = pack( "l!", $value ); - } elsif ( $type eq "uint64" ) { -# The "q" type is only available on 64bit platforms, so use native. - $data = pack( "L!", $value ); - } elsif ( $type eq "int32" ) { - $data = pack( "l", $value ); - } elsif ( $type eq "uint32" || $type eq "bool4" ) { - $data = pack( "L", $value ); - } elsif ( $type eq "int16" ) { - $data = pack( "s", $value ); - } elsif ( $type eq "uint16" ) { - $data = pack( "S", $value ); - } elsif ( $type eq "int8" ) { - $data = pack( "c", $value ); - } elsif ( $type eq "uint8" || $type eq "bool1" ) { - $data = pack( "C", $value ); + if ( $type eq 'long' ) { + $data = pack( 'l!', $value ); + } elsif ( $type eq 'ulong' || $type eq 'size_t' ) { + $data = pack( 'L!', $value ); + } elsif ( $type eq 'int64' || $type eq 'time_t64' ) { +# The 'q' type is only available on 64bit platforms, so use native. + $data = pack( 'l!', $value ); + } elsif ( $type eq 'uint64' ) { +# The 'q' type is only available on 64bit platforms, so use native. + $data = pack( 'L!', $value ); + } elsif ( $type eq 'int32' ) { + $data = pack( 'l', $value ); + } elsif ( $type eq 'uint32' || $type eq 'bool4' ) { + $data = pack( 'L', $value ); + } elsif ( $type eq 'int16' ) { + $data = pack( 's', $value ); + } elsif ( $type eq 'uint16' ) { + $data = pack( 'S', $value ); + } elsif ( $type eq 'int8' ) { + $data = pack( 'c', $value ); + } elsif ( $type eq 'uint8' || $type eq 'bool1' ) { + $data = pack( 'C', $value ); } elsif ( $type =~ /^int8\[\d+\]$/ ) { - $data = pack( "Z".$size, $value ); + $data = pack( 'Z'.$size, $value ); } elsif ( $type =~ /^uint8\[\d+\]$/ ) { - $data = pack( "C".$size, $value ); + $data = pack( 'C'.$size, $value ); } else { - Fatal( "Unexpected type '".$type."' found for '".$field."'" ); + Fatal( "Unexpected type \"$type\" found for \"$field\"" ); } if ( !zmMemPut( $monitor, $offset, $size, $data ) ) { @@ -438,26 +438,26 @@ sub zmMemWrite { sub zmGetMonitorState { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:state" ) ); + return( zmMemRead( $monitor, 'shared_data:state' ) ); } sub zmGetAlarmLocation { my $monitor = shift; - return( zmMemRead( $monitor, [ "shared_data:alarm_x", "shared_data:alarm_y" ] ) ); + return( zmMemRead( $monitor, [ 'shared_data:alarm_x', 'shared_data:alarm_y' ] ) ); } sub zmSetControlState { my $monitor = shift; my $control_state = shift; - zmMemWrite( $monitor, { "shared_data:control_state" => $control_state } ); + zmMemWrite( $monitor, { 'shared_data:control_state' => $control_state } ); } sub zmGetControlState { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:control_state" ) ); + return( zmMemRead( $monitor, 'shared_data:control_state' ) ); } sub zmSaveControlState { @@ -493,8 +493,8 @@ sub zmHasAlarmed { my $monitor = shift; my $last_event_id = shift; - my ( $state, $last_event ) = zmMemRead( $monitor, [ "shared_data:state" - ,"shared_data:last_event" + my ( $state, $last_event ) = zmMemRead( $monitor, [ 'shared_data:state' + ,'shared_data:last_event' ] ); @@ -509,63 +509,63 @@ sub zmHasAlarmed { sub zmGetLastEvent { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:last_event" ) ); + return( zmMemRead( $monitor, 'shared_data:last_event' ) ); } sub zmGetLastWriteTime { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:last_write_time" ) ); + return( zmMemRead( $monitor, 'shared_data:last_write_time' ) ); } sub zmGetLastReadTime { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:last_read_time" ) ); + return( zmMemRead( $monitor, 'shared_data:last_read_time' ) ); } sub zmGetMonitorActions { my $monitor = shift; - return( zmMemRead( $monitor, "shared_data:action" ) ); + return( zmMemRead( $monitor, 'shared_data:action' ) ); } sub zmMonitorEnable { my $monitor = shift; - my $action = zmMemRead( $monitor, "shared_data:action" ); + my $action = zmMemRead( $monitor, 'shared_data:action' ); $action |= ACTION_SUSPEND; - zmMemWrite( $monitor, { "shared_data:action" => $action } ); + zmMemWrite( $monitor, { 'shared_data:action' => $action } ); } sub zmMonitorDisable { my $monitor = shift; - my $action = zmMemRead( $monitor, "shared_data:action" ); + my $action = zmMemRead( $monitor, 'shared_data:action' ); $action |= ACTION_RESUME; - zmMemWrite( $monitor, { "shared_data:action" => $action } ); + zmMemWrite( $monitor, { 'shared_data:action' => $action } ); } sub zmMonitorSuspend { my $monitor = shift; - my $action = zmMemRead( $monitor, "shared_data:action" ); + my $action = zmMemRead( $monitor, 'shared_data:action' ); $action |= ACTION_SUSPEND; - zmMemWrite( $monitor, { "shared_data:action" => $action } ); + zmMemWrite( $monitor, { 'shared_data:action' => $action } ); } sub zmMonitorResume { my $monitor = shift; - my $action = zmMemRead( $monitor, "shared_data:action" ); + my $action = zmMemRead( $monitor, 'shared_data:action' ); $action |= ACTION_RESUME; - zmMemWrite( $monitor, { "shared_data:action" => $action } ); + zmMemWrite( $monitor, { 'shared_data:action' => $action } ); } sub zmGetTriggerState { my $monitor = shift; - return( zmMemRead( $monitor, "trigger_data:trigger_state" ) ); + return( zmMemRead( $monitor, 'trigger_data:trigger_state' ) ); } sub zmTriggerEventOn { @@ -576,12 +576,12 @@ sub zmTriggerEventOn { my $showtext = shift; my $values = { - "trigger_data:trigger_score" => $score, - "trigger_data:trigger_cause" => $cause, + 'trigger_data:trigger_score' => $score, + 'trigger_data:trigger_cause' => $cause, }; - $values->{"trigger_data:trigger_text"} = $text if ( defined($text) ); - $values->{"trigger_data:trigger_showtext"} = $showtext if ( defined($showtext) ); - $values->{"trigger_data:trigger_state"} = TRIGGER_ON; # Write state last so event not read incomplete + $values->{'trigger_data:trigger_text'} = $text if ( defined($text) ); + $values->{'trigger_data:trigger_showtext'} = $showtext if ( defined($showtext) ); + $values->{'trigger_data:trigger_state'} = TRIGGER_ON; # Write state last so event not read incomplete zmMemWrite( $monitor, $values ); } @@ -590,11 +590,11 @@ sub zmTriggerEventOff { my $monitor = shift; my $values = { - "trigger_data:trigger_state" => TRIGGER_OFF, - "trigger_data:trigger_score" => 0, - "trigger_data:trigger_cause" => "", - "trigger_data:trigger_text" => "", - "trigger_data:trigger_showtext" => "", + 'trigger_data:trigger_state' => TRIGGER_OFF, + 'trigger_data:trigger_score' => 0, + 'trigger_data:trigger_cause' => '', + 'trigger_data:trigger_text' => '', + 'trigger_data:trigger_showtext' => '', }; zmMemWrite( $monitor, $values ); @@ -604,11 +604,11 @@ sub zmTriggerEventCancel { my $monitor = shift; my $values = { - "trigger_data:trigger_state" => TRIGGER_CANCEL, - "trigger_data:trigger_score" => 0, - "trigger_data:trigger_cause" => "", - "trigger_data:trigger_text" => "", - "trigger_data:trigger_showtext" => "", + 'trigger_data:trigger_state' => TRIGGER_CANCEL, + 'trigger_data:trigger_score' => 0, + 'trigger_data:trigger_cause' => '', + 'trigger_data:trigger_text' => '', + 'trigger_data:trigger_showtext' => '', }; zmMemWrite( $monitor, $values ); @@ -619,7 +619,7 @@ sub zmTriggerShowtext { my $showtext = shift; my $values = { - "trigger_data:trigger_showtext" => $showtext, + 'trigger_data:trigger_showtext' => $showtext, }; zmMemWrite( $monitor, $values ); @@ -648,7 +648,7 @@ if ( zmMemVerify( $monitor ) ) { "shared_data:last_write_index" ] ); -zmMemWrite( $monitor, { "trigger_data:trigger_showtext" => "Some Text" } ); +zmMemWrite( $monitor, { 'trigger_data:trigger_showtext' => "Some Text" } ); =head1 DESCRIPTION diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm index b6aaf68b5..bd826c9c7 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory/Mapped.pm @@ -40,15 +40,15 @@ 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( - zmMemKey - zmMemAttach - zmMemDetach - zmMemGet - zmMemPut - zmMemClean - ) ], -); + functions => [ qw( + zmMemKey + zmMemAttach + zmMemDetach + zmMemGet + zmMemPut + zmMemClean + ) ], + ); push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS; our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); @@ -68,134 +68,119 @@ use ZoneMinder::Logger qw(:all); use Sys::Mmap; -sub zmMemKey -{ - my $monitor = shift; - return( defined($monitor->{MMapAddr})?$monitor->{MMapAddr}:undef ); +sub zmMemKey { + my $monitor = shift; + return( defined($monitor->{MMapAddr})?$monitor->{MMapAddr}:undef ); } -sub zmMemAttach -{ - my ( $monitor, $size ) = @_; - if ( ! $size ) { - Error( "No size passed to zmMemAttach for monitor $$monitor{Id}\n" ); - return( undef ); +sub zmMemAttach { + my ( $monitor, $size ) = @_; + if ( ! $size ) { + Error( "No size passed to zmMemAttach for monitor $$monitor{Id}\n" ); + 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 ); } - 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; - 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': $!\n", $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 ( $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 ); } - return( !undef ); + my $MMAP; + if ( !open( $MMAP, '+<', $mmap_file ) ) { + Error( sprintf( "Can't open memory map file '%s': $!\n", $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; + } + return( !undef ); } -sub zmMemDetach -{ - my $monitor = shift; +sub zmMemDetach { + my $monitor = shift; - if ( $monitor->{MMap} ) - { - if ( ! munmap( ${$monitor->{MMap}} ) ) { - Warn( "Unable to munmap for monitor $$monitor{Id}\n"); - } - delete $monitor->{MMap}; - } - if ( $monitor->{MMapAddr} ) - { - delete $monitor->{MMapAddr}; - } - if ( $monitor->{MMapHandle} ) - { - close( $monitor->{MMapHandle} ); - delete $monitor->{MMapHandle}; + if ( $monitor->{MMap} ) { + if ( ! munmap( ${$monitor->{MMap}} ) ) { + Warn( "Unable to munmap for monitor $$monitor{Id}\n"); } + delete $monitor->{MMap}; + } + if ( $monitor->{MMapAddr} ) { + delete $monitor->{MMapAddr}; + } + if ( $monitor->{MMapHandle} ) { + close( $monitor->{MMapHandle} ); + delete $monitor->{MMapHandle}; + } } -sub zmMemGet -{ - my $monitor = shift; - my $offset = shift; - my $size = shift; +sub zmMemGet { + my $monitor = shift; + my $offset = shift; + my $size = shift; - my $mmap = $monitor->{MMap}; - if ( !$mmap || !$$mmap ) - { - Error( sprintf( "Can't read from mapped memory for monitor '%d', gone away?" - , $monitor->{Id} - ) + my $mmap = $monitor->{MMap}; + if ( !$mmap || !$$mmap ) { + Error( sprintf( "Can't read from mapped memory for monitor '%d', gone away?" + , $monitor->{Id} + ) ); - return( undef ); - } - my $data = substr( $$mmap, $offset, $size ); - return( $data ); + return( undef ); + } + my $data = substr( $$mmap, $offset, $size ); + return( $data ); } -sub zmMemPut -{ - my $monitor = shift; - my $offset = shift; - my $size = shift; - my $data = shift; +sub zmMemPut { + my $monitor = shift; + my $offset = shift; + my $size = shift; + my $data = shift; - my $mmap = $monitor->{MMap}; - if ( !$mmap || !$$mmap ) - { - Error( sprintf( "Can't write mapped memory for monitor '%d', gone away?" - , $monitor->{Id} - ) + my $mmap = $monitor->{MMap}; + if ( !$mmap || !$$mmap ) { + Error( sprintf( "Can't write mapped memory for monitor '%d', gone away?" + , $monitor->{Id} + ) ); - return( undef ); - } - substr( $$mmap, $offset, $size ) = $data; - return( !undef ); + return( undef ); + } + substr( $$mmap, $offset, $size ) = $data; + return( !undef ); } -sub zmMemClean -{ - Debug( "Removing memory map files\n" ); - my $mapPath = $Config{ZM_PATH_MAP}."/zm.mmap.*"; - foreach my $mapFile( glob( $mapPath ) ) - { - ( $mapFile ) = $mapFile =~ /^(.+)$/; - Debug( "Removing memory map file '$mapFile'\n" ); - unlink( $mapFile ); - } +sub zmMemClean { + Debug( "Removing memory map files\n" ); + my $mapPath = $Config{ZM_PATH_MAP}.'/zm.mmap.*'; + foreach my $mapFile( glob( $mapPath ) ) { + ( $mapFile ) = $mapFile =~ /^(.+)$/; + Debug( "Removing memory map file '$mapFile'\n" ); + unlink( $mapFile ); + } } 1; diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm new file mode 100644 index 000000000..d5b7d7f53 --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm @@ -0,0 +1,85 @@ +# ========================================================================== +# +# ZoneMinder Monitor 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ========================================================================== +# +# This module contains the common definitions and functions used by the rest +# of the ZoneMinder scripts +# +package ZoneMinder::Monitor; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; +require ZoneMinder::Object; +require ZoneMinder::Server; + +#our @ISA = qw(Exporter ZoneMinder::Base); +use parent qw(ZoneMinder::Object); + +# ========================================================================== +# +# General Utility Functions +# +# ========================================================================== + +use ZoneMinder::Config qw(:all); +use ZoneMinder::Logger qw(:all); +use ZoneMinder::Database qw(:all); + +use POSIX; +use vars qw/ $table $primary_key /; +$table = 'Monitors'; +$primary_key = 'Id'; + +sub Server { + return new ZoneMinder::Server( $_[0]{ServerId} ); +} # end sub Server + +1; +__END__ + +=head1 NAME + +ZoneMinder::Monitor - Perl Class for Monitors + +=head1 SYNOPSIS + +use ZoneMinder::Monitor; + +=head1 DESCRIPTION + + + +=head1 AUTHOR + +Isaac Connor, Eisaac@zoneminder.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2001-2017 ZoneMinder LLC + +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. + + +=cut diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Object.pm b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm new file mode 100644 index 000000000..b87e111a6 --- /dev/null +++ b/scripts/ZoneMinder/lib/ZoneMinder/Object.pm @@ -0,0 +1,150 @@ +# ========================================================================== +# +# ZoneMinder Object Module, $Date$, $Revision$ +# Copyright (C) 2001-2017 ZoneMinder LLC +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ========================================================================== +# +# This module contains the common definitions and functions used by the rest +# of the ZoneMinder scripts +# +package ZoneMinder::Object; + +use 5.006; +use strict; +use warnings; + +require ZoneMinder::Base; + +our @ISA = qw(ZoneMinder::Base); + +# ========================================================================== +# +# General Utility Functions +# +# ========================================================================== + +use ZoneMinder::Config qw(:all); +use ZoneMinder::Logger qw(:all); +use ZoneMinder::Database qw(:all); + +use vars qw/ $AUTOLOAD /; + +sub new { + my ( $parent, $id, $data ) = @_; + + my $self = {}; + bless $self, $parent; + no strict 'refs'; + my $primary_key = ${$parent.'::primary_key'}; + if ( ! $primary_key ) { + Error( 'NO primary_key for type ' . $parent ); + return; + } # end if + if ( ( $$self{$primary_key} = $id ) or $data ) { +#$log->debug("loading $parent $id") if $debug or DEBUG_ALL; + $self->load( $data ); + } + return $self; +} # end sub new + +sub load { + my ( $self, $data ) = @_; + my $type = ref $self; + if ( ! $data ) { + no strict 'refs'; + my $table = ${$type.'::table'}; + if ( ! $table ) { + Error( 'NO table for type ' . $type ); + return; + } # end if + my $primary_key = ${$type.'::primary_key'}; + if ( ! $primary_key ) { + Error( 'NO primary_key for type ' . $type ); + return; + } # end if + + if ( ! $$self{$primary_key} ) { + my ( $caller, undef, $line ) = caller; + Error( (ref $self) . "::load called without $primary_key from $caller:$line"); + } else { +#$log->debug("Object::load Loading from db $type"); + Debug("Loading $type from $table WHERE $primary_key = $$self{$primary_key}"); + $data = $ZoneMinder::Database::dbh->selectrow_hashref( "SELECT * FROM $table WHERE $primary_key=?", {}, $$self{$primary_key} ); + if ( ! $data ) { + if ( $ZoneMinder::Database::dbh->errstr ) { + Error( "Failure to load Object record for $$self{$primary_key}: Reason: " . $ZoneMinder::Database::dbh->errstr ); + } else { + Debug("No Results Loading $type from $table WHERE $primary_key = $$self{$primary_key}"); + } # end if + } # end if + } # end if + } # end if ! $data + if ( $data and %$data ) { + @$self{keys %$data} = values %$data; + } # end if +} # end sub load + +sub AUTOLOAD { + my ( $self, $newvalue ) = @_; + my $type = ref($_[0]); + my $name = $AUTOLOAD; + $name =~ s/.*://; + if ( @_ > 1 ) { + return $_[0]{$name} = $_[1]; + } + return $_[0]{$name}; +} + + +1; +__END__ + +# Below is stub documentation for your module. You'd better edit it! + +=head1 NAME + +ZoneMinder::Object + +=head1 SYNOPSIS + + use parent ZoneMinder::Object; + + This package should likely not be used directly, as it is meant mainly to be a parent for all other ZoneMinder classes. + +=head1 DESCRIPTION + + A base Object to act as parent for other ZoneMinder Objects. + +=head2 EXPORT + +None by default. + +=head1 AUTHOR + +Isaac Connor, Eisaac@zoneminder.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2001-2017 ZoneMinder LLC + +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. + + +=cut diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index eaf724366..6cf2af2e3 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -41,9 +41,9 @@ yet. =head1 OPTIONS - -r, --report - Just report don't actually do anything - -i, --interactive - Ask before applying any changes -c, --continuous - Run continuously + -i, --interactive - Ask before applying any changes + -r, --report - Just report don't actually do anything -v, --version - Print the installed version of ZoneMinder =cut @@ -57,8 +57,8 @@ use bytes; # ========================================================================== use constant MAX_AGED_DIRS => 10; # Number of event dirs to check age on -use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered -use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered +use constant RECOVER_TAG => '(r)'; # Tag to append to event name when recovered +use constant RECOVER_TEXT => 'Recovered.'; # Text to append to event notes when recovered # ========================================================================== # @@ -96,10 +96,10 @@ logInit(); logSetSignal(); GetOptions( - 'report' =>\$report, - 'interactive' =>\$interactive, - 'continuous' =>\$continuous, - 'version' =>\$version + continuous =>\$continuous, + interactive =>\$interactive, + report =>\$report, + version =>\$version ) or pod2usage(-exitstatus => -1); if ( $version ) { @@ -111,6 +111,10 @@ if ( ($report + $interactive + $continuous) > 1 ) { pod2usage(-exitstatus => -1); } +if ( ! exists $Config{ZM_AUDIT_MIN_AGE} ) { + Fatal('ZM_AUDIT_MIN_AGE is not set in config.'); +} + my $dbh = zmDbConnect(); chdir( EVENT_PATH ); @@ -126,13 +130,13 @@ MAIN: while( $loop ) { $dbh = zmDbConnect(); if ( $continuous ) { - Error("Unable to connect to database"); + Error('Unable to connect to database'); # if we are running continuously, then just skip to the next # interval, otherwise we are a one off run, so wait a second and # retry until someone kills us. sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} ); } else { - Fatal("Unable to connect to database"); + Fatal('Unable to connect to database'); } # end if } # end while can't connect to the db @@ -145,16 +149,12 @@ MAIN: while( $loop ) { sleep 1; } # end if - if ( ! exists $Config{ZM_AUDIT_MIN_AGE} ) { - Fatal("ZM_AUDIT_MIN_AGE is not set in config."); - } - my $db_monitors; - my $monitorSelectSql = "select Id from Monitors order by Id"; + my $monitorSelectSql = 'select Id from Monitors order by Id'; my $monitorSelectSth = $dbh->prepare_cached( $monitorSelectSql ) or Fatal( "Can't prepare '$monitorSelectSql': ".$dbh->errstr() ); - my $eventSelectSql = "SELECT Id, (unix_timestamp() - unix_timestamp(StartTime)) as Age - FROM Events WHERE MonitorId = ? ORDER BY Id"; + my $eventSelectSql = 'SELECT Id, (unix_timestamp() - unix_timestamp(StartTime)) as Age + FROM Events WHERE MonitorId = ? ORDER BY Id'; my $eventSelectSth = $dbh->prepare_cached( $eventSelectSql ) or Fatal( "Can't prepare '$eventSelectSql': ".$dbh->errstr() ); @@ -169,11 +169,11 @@ MAIN: while( $loop ) { while ( my $event = $eventSelectSth->fetchrow_hashref() ) { $db_events->{$event->{Id}} = $event->{Age}; } - Debug( "Got ".int(keys(%$db_events))." events\n" ); + Debug( 'Got '.int(keys(%$db_events))." events\n" ); } my $fs_monitors; - foreach my $monitor ( glob("[0-9]*") ) { + foreach my $monitor ( glob('[0-9]*') ) { # Thie glob above gives all files starting with a digit. So a monitor with a name starting with a digit will be in this list. next if $monitor =~ /\D/; Debug( "Found filesystem monitor '$monitor'" ); @@ -182,11 +182,17 @@ MAIN: while( $loop ) { if ( $Config{ZM_USE_DEEP_STORAGE} ) { foreach my $day_dir ( glob("$monitor_dir/*/*/*") ) { - Debug( "Checking $day_dir" ); + Debug( "Checking day dir $day_dir" ); ( $day_dir ) = ( $day_dir =~ /^(.*)$/ ); # De-taint - chdir( $day_dir ); - opendir( DIR, "." ) - or Fatal( "Can't open directory '$day_dir': $!" ); + if ( ! chdir( $day_dir ) ) { + Error( "Can't chdir to '$day_dir': $!" ); + next; + } + if ( ! opendir( DIR, '.' ) ) { + Error( "Can't open directory '$day_dir': $!" ); + next; + } + my @event_links = sort { $b <=> $a } grep { -l $_ } readdir( DIR ); closedir( DIR ); my $count = 0; @@ -226,7 +232,7 @@ MAIN: while( $loop ) { } chdir( EVENT_PATH ); } - Debug( "Got ".int(keys(%$fs_events))." events\n" ); + Debug( 'Got '.int(keys(%$fs_events))." events\n" ); } # end foreach monitor Id redo MAIN if ( $cleaned ); @@ -255,7 +261,7 @@ MAIN: while( $loop ) { } my $monitor_links; - foreach my $link ( glob("*") ) { + foreach my $link ( glob('*') ) { next if ( !-l $link ); next if ( -e $link ); @@ -270,16 +276,16 @@ MAIN: while( $loop ) { redo MAIN if ( $cleaned ); $cleaned = 0; - my $deleteMonitorSql = "delete low_priority from Monitors where Id = ?"; + my $deleteMonitorSql = 'delete low_priority from Monitors where Id = ?'; my $deleteMonitorSth = $dbh->prepare_cached( $deleteMonitorSql ) or Fatal( "Can't prepare '$deleteMonitorSql': ".$dbh->errstr() ); - my $deleteEventSql = "delete low_priority from Events where Id = ?"; + my $deleteEventSql = 'delete low_priority from Events where Id = ?'; my $deleteEventSth = $dbh->prepare_cached( $deleteEventSql ) or Fatal( "Can't prepare '$deleteEventSql': ".$dbh->errstr() ); - my $deleteFramesSql = "delete low_priority from Frames where EventId = ?"; + my $deleteFramesSql = 'delete low_priority from Frames where EventId = ?'; my $deleteFramesSth = $dbh->prepare_cached( $deleteFramesSql ) or Fatal( "Can't prepare '$deleteFramesSql': ".$dbh->errstr() ); - my $deleteStatsSql = "delete low_priority from Stats where EventId = ?"; + my $deleteStatsSql = 'delete low_priority from Stats where EventId = ?'; my $deleteStatsSth = $dbh->prepare_cached( $deleteStatsSql ) or Fatal( "Can't prepare '$deleteStatsSql': ".$dbh->errstr() ); while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) { @@ -319,9 +325,9 @@ MAIN: while( $loop ) { # Remove orphaned events (with no monitor) $cleaned = 0; - my $selectOrphanedEventsSql = "SELECT Events.Id, Events.Name + my $selectOrphanedEventsSql = 'SELECT Events.Id, Events.Name FROM Events LEFT JOIN Monitors ON (Events.MonitorId = Monitors.Id) - WHERE isnull(Monitors.Id)"; + WHERE isnull(Monitors.Id)'; my $selectOrphanedEventsSth = $dbh->prepare_cached( $selectOrphanedEventsSql ) or Fatal( "Can't prepare '$selectOrphanedEventsSql': ".$dbh->errstr() ); $res = $selectOrphanedEventsSth->execute() @@ -356,8 +362,8 @@ MAIN: while( $loop ) { # Remove orphaned frame records $cleaned = 0; - my $selectOrphanedFramesSql = "SELECT DISTINCT EventId FROM Frames - WHERE EventId NOT IN (SELECT Id FROM Events)"; + my $selectOrphanedFramesSql = 'SELECT DISTINCT EventId FROM Frames + WHERE EventId NOT IN (SELECT Id FROM Events)'; my $selectOrphanedFramesSth = $dbh->prepare_cached( $selectOrphanedFramesSql ) or Fatal( "Can't prepare '$selectOrphanedFramesSql': ".$dbh->errstr() ); $res = $selectOrphanedFramesSth->execute() @@ -374,8 +380,8 @@ MAIN: while( $loop ) { # Remove orphaned stats records $cleaned = 0; - my $selectOrphanedStatsSql = "SELECT DISTINCT EventId FROM Stats - WHERE EventId NOT IN (SELECT Id FROM Events)"; + my $selectOrphanedStatsSql = 'SELECT DISTINCT EventId FROM Stats + WHERE EventId NOT IN (SELECT Id FROM Events)'; my $selectOrphanedStatsSth = $dbh->prepare_cached( $selectOrphanedStatsSql ) or Fatal( "Can't prepare '$selectOrphanedStatsSql': ".$dbh->errstr() ); $res = $selectOrphanedStatsSth->execute() @@ -429,20 +435,13 @@ MAIN: while( $loop ) { aud_print( "Found open event '$event->{Id}'" ); if ( confirm( 'close', 'closing' ) ) { $res = $updateUnclosedEventsSth->execute( - sprintf("%s%d%s", - $event->{Prefix}, - $event->{Id}, - RECOVER_TAG - ), + sprintf('%s%d%s', $event->{Prefix}, $event->{Id}, RECOVER_TAG), $event->{EndTime}, $event->{Length}, $event->{Frames}, $event->{AlarmFrames}, $event->{TotScore}, - $event->{AlarmFrames} - ? int($event->{TotScore} / $event->{AlarmFrames}) - : 0 - , + $event->{AlarmFrames} ? int($event->{TotScore} / $event->{AlarmFrames}) : 0, $event->{MaxScore}, RECOVER_TEXT, $event->{Id} @@ -453,8 +452,8 @@ MAIN: while( $loop ) { # Now delete any old image files my @old_files = grep { -M > $max_image_age } <$image_path/*.{jpg,gif,wbmp}>; if ( @old_files ) { - aud_print( "Deleting ".int(@old_files)." old images\n" ); - my $untainted_old_files = join( ";", @old_files ); + aud_print( 'Deleting '.( scalar @old_files )." old images\n" ); + my $untainted_old_files = join( ';', @old_files ); ( $untainted_old_files ) = ( $untainted_old_files =~ /^(.*)$/ ); unlink( split( /;/, $untainted_old_files ) ); } @@ -467,7 +466,7 @@ MAIN: while( $loop ) { if ( $Config{ZM_LOG_DATABASE_LIMIT} ) { if ( $Config{ZM_LOG_DATABASE_LIMIT} =~ /^\d+$/ ) { # Number of rows - my $selectLogRowCountSql = "SELECT count(*) as Rows from Logs"; + my $selectLogRowCountSql = 'SELECT count(*) AS Rows FROM Logs'; my $selectLogRowCountSth = $dbh->prepare_cached( $selectLogRowCountSql ) or Fatal( "Can't prepare '$selectLogRowCountSql': ".$dbh->errstr() ); $res = $selectLogRowCountSth->execute() @@ -475,20 +474,20 @@ MAIN: while( $loop ) { my $row = $selectLogRowCountSth->fetchrow_hashref(); my $logRows = $row->{Rows}; if ( $logRows > $Config{ZM_LOG_DATABASE_LIMIT} ) { - my $deleteLogByRowsSql = "DELETE low_priority FROM Logs ORDER BY TimeKey ASC LIMIT ?"; + my $deleteLogByRowsSql = 'DELETE low_priority FROM Logs ORDER BY TimeKey ASC LIMIT ?'; my $deleteLogByRowsSth = $dbh->prepare_cached( $deleteLogByRowsSql ) or Fatal( "Can't prepare '$deleteLogByRowsSql': ".$dbh->errstr() ); $res = $deleteLogByRowsSth->execute( $logRows - $Config{ZM_LOG_DATABASE_LIMIT} ) or Fatal( "Can't execute: ".$deleteLogByRowsSth->errstr() ); if ( $deleteLogByRowsSth->rows() ) { - aud_print( "Deleted ".$deleteLogByRowsSth->rows() ." log table entries by count\n" ); + aud_print( 'Deleted '.$deleteLogByRowsSth->rows() ." log table entries by count\n" ); } } } else { # Time of record my $deleteLogByTimeSql = - "DELETE low_priority FROM Logs - WHERE TimeKey < unix_timestamp(now() - interval ".$Config{ZM_LOG_DATABASE_LIMIT}.")"; + 'DELETE low_priority FROM Logs + WHERE TimeKey < unix_timestamp(now() - interval '.$Config{ZM_LOG_DATABASE_LIMIT}.')'; my $deleteLogByTimeSth = $dbh->prepare_cached( $deleteLogByTimeSql ) or Fatal( "Can't prepare '$deleteLogByTimeSql': ".$dbh->errstr() ); $res = $deleteLogByTimeSth->execute() @@ -515,8 +514,8 @@ sub aud_print { } sub confirm { - my $prompt = shift || "delete"; - my $action = shift || "deleting"; + my $prompt = shift || 'delete'; + my $action = shift || 'deleting'; my $yesno = 0; if ( $report ) { diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index a60fc497e..c69ad57b1 100644 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -27,7 +27,7 @@ zmfilter.pl - ZoneMinder tool to filter events =head1 SYNOPSIS - zmfilter.pl [-f ,--filter=] | -v, --version +zmfilter.pl [-f ,--filter=] | -v, --version =head1 DESCRIPTION @@ -37,8 +37,8 @@ matching events. =head1 OPTIONS - -f{filter name}, --filter={filter name} - The name of a specific filter to run - -v, --version - Print ZoneMinder version +-f{filter name}, --filter={filter name} - The name of a specific filter to run +-v, --version - Print ZoneMinder version =cut use strict; @@ -60,7 +60,6 @@ use constant START_DELAY => 5; # How long to wait before starting @EXTRA_PERL_LIB@ use ZoneMinder; -require ZoneMinder::Filter; use DBI; use POSIX; use Time::HiRes qw/gettimeofday/; @@ -69,61 +68,61 @@ use Getopt::Long; use autouse 'Pod::Usage'=>qw(pod2usage); use autouse 'Data::Dumper'=>qw(Dumper); +my $filter_parm = ''; +my $version = 0; + +GetOptions( + 'filter=s' =>\$filter_parm, + 'version' =>\$version + ) or pod2usage(-exitstatus => -1); + +if ( $version ) { + print ZoneMinder::Base::ZM_VERSION . "\n"; + exit(0); +} + +require ZoneMinder::Filter; + use constant EVENT_PATH => ($Config{ZM_DIR_EVENTS}=~m|/|) - ? $Config{ZM_DIR_EVENTS} - : ($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS}) -; + ? $Config{ZM_DIR_EVENTS} + : ($Config{ZM_PATH_WEB}.'/'.$Config{ZM_DIR_EVENTS}) + ; logInit(); logSetSignal(); -if ( $Config{ZM_OPT_UPLOAD} ) -{ - # Comment these out if you don't have them and don't want to upload - # or don't want to use that format - if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "zip" ) - { - require Archive::Zip; - import Archive::Zip qw( :ERROR_CODES :CONSTANTS ); - } - else - { - require Archive::Tar; - } - if ( $Config{ZM_UPLOAD_PROTOCOL} eq "ftp" ) - { - require Net::FTP; - } - else - { - require Net::SFTP::Foreign; - } +if ( $Config{ZM_OPT_UPLOAD} ) { +# Comment these out if you don't have them and don't want to upload +# or don't want to use that format + if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq 'zip' ) { + require Archive::Zip; + import Archive::Zip qw( :ERROR_CODES :CONSTANTS ); + } else { + require Archive::Tar; + } + if ( $Config{ZM_UPLOAD_PROTOCOL} eq 'ftp' ) { + require Net::FTP; + } else { + require Net::SFTP::Foreign; + } } -if ( $Config{ZM_OPT_EMAIL} ) -{ - if ( $Config{ZM_NEW_MAIL_MODULES} ) - { - require MIME::Lite; - require Net::SMTP; - } - else - { - require MIME::Entity; - } +if ( $Config{ZM_OPT_EMAIL} ) { + if ( $Config{ZM_NEW_MAIL_MODULES} ) { + require MIME::Lite; + require Net::SMTP; + } else { + require MIME::Entity; + } } -if ( $Config{ZM_OPT_MESSAGE} ) -{ - if ( $Config{ZM_NEW_MAIL_MODULES} ) - { - require MIME::Lite; - require Net::SMTP; - } - else - { - require MIME::Entity; - } +if ( $Config{ZM_OPT_MESSAGE} ) { + if ( $Config{ZM_NEW_MAIL_MODULES} ) { + require MIME::Lite; + require Net::SMTP; + } else { + require MIME::Entity; + } } $| = 1; @@ -134,933 +133,795 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL}; my $event_id = 0; -my $filter_parm = ""; -my $version = 0; - -# - -GetOptions( - 'filter=s' =>\$filter_parm, - 'version' =>\$version -) or pod2usage(-exitstatus => -1); - -if ( $version ) { - print ZoneMinder::Base::ZM_VERSION . "\n"; - exit(0); -} if ( ! EVENT_PATH ) { - Error( "No event path defined. Config was $Config{ZM_DIR_EVENTS}\n" ); - die; + Error( "No event path defined. Config was $Config{ZM_DIR_EVENTS}\n" ); + die; } +# In future, should not be neccessary wrt StorageAreas chdir( EVENT_PATH ); +# SHould not be neccessary... but nice to get a local var. What if it fails? my $dbh = zmDbConnect(); -if ( $filter_parm ) -{ - Info( "Scanning for events using filter '$filter_parm'\n" ); -} -else -{ - Info( "Scanning for events\n" ); +if ( $filter_parm ) { + Info( "Scanning for events using filter '$filter_parm'\n" ); +} else { + Info( "Scanning for events\n" ); } -if ( !$filter_parm ) -{ - sleep( START_DELAY ); +if ( ! $filter_parm ) { + Debug("Sleeping due to start delay: " . START_DELAY . ' seconds...' ); + sleep( START_DELAY ); } -my $filters; +my @filters; my $last_action = 0; -while( 1 ) -{ - my $now = time; - if ( ($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} ) - { - Debug( "Reloading filters\n" ); - $last_action = $now; - $filters = getFilters( $filter_parm ); - } +while( 1 ) { + my $now = time; + if ( ($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} ) { + Debug( "Reloading filters\n" ); + $last_action = $now; + @filters = getFilters( $filter_parm ); + } - foreach my $filter ( @$filters ) - { - checkFilter( $filter ); - } + foreach my $filter ( @filters ) { + checkFilter( $filter ); + } - last if ( $filter_parm ); + last if $filter_parm; - Debug( "Sleeping for $delay seconds\n" ); - sleep( $delay ); + Debug( "Sleeping for $delay seconds\n" ); + sleep( $delay ); } -sub getFilters -{ - my $filter_name = shift; +sub getFilters { + my $filter_name = shift; - my @filters; - my $sql = "SELECT * FROM Filters WHERE"; - if ( $filter_name ) - { - $sql .= " Name = ? and"; + my @filters; + my $sql = 'SELECT * FROM Filters WHERE'; + if ( $filter_name ) { + $sql .= ' Name = ? and'; + } else { + $sql .= ' Background = 1 AND'; + } + $sql .= '( AutoArchive = 1 + or AutoVideo = 1 + or AutoUpload = 1 + or AutoEmail = 1 + or AutoMessage = 1 + or AutoExecute = 1 + or AutoDelete = 1 + ) ORDER BY Name'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res; + if ( $filter_name ) { + $res = $sth->execute( $filter_name ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + } else { + $res = $sth->execute() + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + } +FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) { + my $filter = new ZoneMinder::Filter( $$db_filter{Id}, $db_filter ); + Debug( "Found filter '$db_filter->{Name}'\n" ); + my $sql = $filter->Sql(); + + if ( ! $sql ) { + Error( "Error parsing Sql. skipping filter '$db_filter->{Name}'\n" ); + next FILTER; } - else - { - $sql .= " Background = 1 and"; - } - $sql .= "( AutoArchive = 1 - or AutoVideo = 1 - or AutoUpload = 1 - or AutoEmail = 1 - or AutoMessage = 1 - or AutoExecute = 1 - or AutoDelete = 1 - ) ORDER BY Name"; - my $sth = $dbh->prepare_cached( $sql ) + push( @filters, $filter ); + } + $sth->finish(); + Debug( 'Got ' . @filters . ' filters' ); + return( @filters ); +} + +sub checkFilter { + my $filter = shift; + + Debug( "Checking filter '$filter->{Name}'". + ($filter->{AutoDelete}?', delete':''). + ($filter->{AutoArchive}?', archive':''). + ($filter->{AutoVideo}?', video':''). + ($filter->{AutoUpload}?', upload':''). + ($filter->{AutoEmail}?', email':''). + ($filter->{AutoMessage}?', message':''). + ($filter->{AutoExecute}?', execute':''). + '\n' + ); + + foreach my $event ( $filter->Execute() ) { + Debug( "Checking event $event->{Id}\n" ); + my $delete_ok = !undef; + $dbh->ping(); + if ( $filter->{AutoArchive} ) { + Info( "Archiving event $event->{Id}\n" ); +# Do it individually to avoid locking up the table for new events + my $sql = 'update Events set Archived = 1 where Id = ?'; + my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res; - if ( $filter_name ) - { - $res = $sth->execute( $filter_name ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Error( "Can't execute '$sql': ".$sth->errstr() ); } - else - { - $res = $sth->execute() - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} ) { + if ( !$event->{Videoed} ) { + $delete_ok = undef if ( !generateVideo( $filter, $event ) ); + } } - FILTER: while( my $db_filter = $sth->fetchrow_hashref() ) - { - my $filter = new ZoneMinder::Filter( $$db_filter{Id}, $db_filter ); - Debug( "Found filter '$db_filter->{Name}'\n" ); - my $sql = $filter->Sql(); - - if ( ! $sql ) { - Error( "Error parsing Sql. skipping filter '$db_filter->{Name}'\n" ); - next FILTER; - } - push( @filters, $filter ); + if ( $Config{ZM_OPT_EMAIL} && $filter->{AutoEmail} ) { + if ( !$event->{Emailed} ) { + $delete_ok = undef if ( !sendEmail( $filter, $event ) ); + } } - $sth->finish(); - Debug( "Got " . @filters . " filters" ); - return( \@filters ); -} - -sub checkFilter -{ - my $filter = shift; - - Debug( "Checking filter '$filter->{Name}'". - ($filter->{AutoDelete}?", delete":""). - ($filter->{AutoArchive}?", archive":""). - ($filter->{AutoVideo}?", video":""). - ($filter->{AutoUpload}?", upload":""). - ($filter->{AutoEmail}?", email":""). - ($filter->{AutoMessage}?", message":""). - ($filter->{AutoExecute}?", execute":""). - "\n" - ); - - foreach my $event ( $filter->Execute() ) { - Debug( "Checking event $event->{Id}\n" ); - my $delete_ok = !undef; -$dbh->ping(); - if ( $filter->{AutoArchive} ) - { - Info( "Archiving event $event->{Id}\n" ); - # Do it individually to avoid locking up the table for new events - my $sql = "update Events set Archived = 1 where Id = ?"; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Error( "Can't execute '$sql': ".$sth->errstr() ); - } - if ( $Config{ZM_OPT_FFMPEG} && $filter->{AutoVideo} ) - { - if ( !$event->{Videoed} ) - { - $delete_ok = undef if ( !generateVideo( $filter, $event ) ); - } - } - if ( $Config{ZM_OPT_EMAIL} && $filter->{AutoEmail} ) - { - if ( !$event->{Emailed} ) - { - $delete_ok = undef if ( !sendEmail( $filter, $event ) ); - } - } - if ( $Config{ZM_OPT_MESSAGE} && $filter->{AutoMessage} ) - { - if ( !$event->{Messaged} ) - { - $delete_ok = undef if ( !sendMessage( $filter, $event ) ); - } - } - if ( $Config{ZM_OPT_UPLOAD} && $filter->{AutoUpload} ) - { - if ( !$event->{Uploaded} ) - { - $delete_ok = undef if ( !uploadArchFile( $filter, $event ) ); - } - } - if ( $filter->{AutoExecute} ) - { - if ( !$event->{Executed} ) - { - $delete_ok = undef if ( !executeCommand( $filter, $event ) ); - } - } - if ( $filter->{AutoDelete} ) - { - if ( $delete_ok ) - { - Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId}\n" ); - # Do it individually to avoid locking up the table for new events - my $sql = "delete from Events where Id = ?"; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - - if ( ! $Config{ZM_OPT_FAST_DELETE} ) - { - my $sql = "delete from Frames where EventId = ?"; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - - $sql = "delete from Stats where EventId = ?"; - $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - - deleteEventFiles( $event->{Id}, $event->{MonitorId} ); - } - } - else - { - Error( "Unable to delete event $event->{Id} as previous operations failed\n" ); - } - } + if ( $Config{ZM_OPT_MESSAGE} && $filter->{AutoMessage} ) { + if ( !$event->{Messaged} ) { + $delete_ok = undef if ( !sendMessage( $filter, $event ) ); + } } -} - -sub generateVideo -{ - my $filter = shift; - my $event = shift; - my $phone = shift; - - my $rate = $event->{DefaultRate}/100; - my $scale = $event->{DefaultScale}/100; - my $format; - - my @ffmpeg_formats = split( /\s+/, $Config{ZM_FFMPEG_FORMATS} ); - my $default_video_format; - my $default_phone_format; - foreach my $ffmpeg_format( @ffmpeg_formats ) - { - if ( $ffmpeg_format =~ /^(.+)\*\*$/ ) - { - $default_phone_format = $1; - } - elsif ( $ffmpeg_format =~ /^(.+)\*$/ ) - { - $default_video_format = $1; - } + if ( $Config{ZM_OPT_UPLOAD} && $filter->{AutoUpload} ) { + if ( !$event->{Uploaded} ) { + $delete_ok = undef if ( !uploadArchFile( $filter, $event ) ); + } } - - if ( $phone && $default_phone_format ) - { - $format = $default_phone_format; + if ( $filter->{AutoExecute} ) { + if ( !$event->{Executed} ) { + $delete_ok = undef if ( !executeCommand( $filter, $event ) ); + } } - elsif ( $default_video_format ) - { - $format = $default_video_format; - } - else - { - $format = $ffmpeg_formats[0]; - } - - my $command = $Config{ZM_PATH_BIN}."/zmvideo.pl -e " - .$event->{Id}." -r ".$rate." -s ".$scale." -f ".$format; - my $output = qx($command); - chomp( $output ); - my $status = $? >> 8; - if ( $status || logDebugging() ) - { - Debug( "Output: $output\n" ); - } - if ( $status ) - { - Error( "Video generation '$command' failed with status: $status\n" ); - if ( wantarray() ) - { - return( undef, undef ); - } - return( 0 ); - } - else - { - my $sql = "update Events set Videoed = 1 where Id = ?"; + if ( $filter->{AutoDelete} ) { + if ( $delete_ok ) { + Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId}\n" ); +# Do it individually to avoid locking up the table for new events + my $sql = 'delete from Events where Id = ?'; my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + + if ( ! $Config{ZM_OPT_FAST_DELETE} ) { + my $sql = 'delete from Frames where EventId = ?'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - if ( wantarray() ) - { - return( $format, $output ); + + $sql = 'delete from Stats where EventId = ?'; + $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + + deleteEventFiles( $event->{Id}, $event->{MonitorId} ); } + } else { + Error( "Unable to delete event $event->{Id} as previous operations failed\n" ); + } } - return( 1 ); + } +} + +sub generateVideo { + my $filter = shift; + my $event = shift; + my $phone = shift; + + my $rate = $event->{DefaultRate}/100; + my $scale = $event->{DefaultScale}/100; + my $format; + + my @ffmpeg_formats = split( /\s+/, $Config{ZM_FFMPEG_FORMATS} ); + my $default_video_format; + my $default_phone_format; + foreach my $ffmpeg_format( @ffmpeg_formats ) { + if ( $ffmpeg_format =~ /^(.+)\*\*$/ ) { + $default_phone_format = $1; + } elsif ( $ffmpeg_format =~ /^(.+)\*$/ ) { + $default_video_format = $1; + } + } + + if ( $phone && $default_phone_format ) { + $format = $default_phone_format; + } elsif ( $default_video_format ) { + $format = $default_video_format; + } else { + $format = $ffmpeg_formats[0]; + } + + my $command = join( '', + $Config{ZM_PATH_BIN}, + '/zmvideo.pl -e ', + $event->{Id}, + ' -r ', + $rate, + ' -s ', + $scale, + ' -f ', + $format, + ); + my $output = qx($command); + chomp( $output ); + my $status = $? >> 8; + if ( $status || logDebugging() ) { + Debug( "Output: $output\n" ); + } + if ( $status ) { + Error( "Video generation '$command' failed with status: $status\n" ); + if ( wantarray() ) { + return( undef, undef ); + } + return( 0 ); + } else { + my $sql = 'update Events set Videoed = 1 where Id = ?'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + if ( wantarray() ) { + return( $format, $output ); + } + } + return( 1 ); } # Returns an image absolute path for given event and frame # Optionally an analyse image path may be returned if an analyse image exists # If neither capture nor analyse image exists it will try to extract a frame from .mp4 file if exists # An empty string is returned if no one from methods above works -sub generateImage -{ - my $event = shift; - my $frame = shift; - my $analyse = do { @_ ? shift : 0 }; # don't return analyse image by default +sub generateImage { + my $event = shift; + my $frame = shift; + my $analyse = do { @_ ? shift : 0 }; # don't return analyse image by default - my $capture_image_path = sprintf("%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-capture.jpg", getEventPath($event), $frame->{FrameId}); - my $analyse_image_path = sprintf("%s/%0".$Config{ZM_EVENT_IMAGE_DIGITS}."d-analyse.jpg", getEventPath($event), $frame->{FrameId}) if $analyse; - my $video_path = sprintf("%s/%d-video.mp4", getEventPath($event), $event->{Id}); - my $image_path = ""; + my $capture_image_path = sprintf('%s/%0'.$Config{ZM_EVENT_IMAGE_DIGITS}.'d-capture.jpg', getEventPath($event), $frame->{FrameId}); + my $analyse_image_path = sprintf('%s/%0'.$Config{ZM_EVENT_IMAGE_DIGITS}.'d-analyse.jpg', getEventPath($event), $frame->{FrameId}) if $analyse; + my $video_path = sprintf('%s/%d-video.mp4', getEventPath($event), $event->{Id}); + my $image_path = ''; - # check if the image file exists. If the file doesn't exist and we use H264 try to extract it from .mp4 video - if ( $analyse && -r $analyse_image_path ) { - $image_path = $analyse_image_path; - } elsif ( -r $capture_image_path ) { - $image_path = $capture_image_path; - } elsif ( -e $video_path ) { - if ( !system("ffmpeg -y -v 0 -i ".$video_path." -vf 'select=gte(n\\,".$frame->{FrameId}."),setpts=PTS-STARTPTS' -vframes 1 -f image2 ".$capture_image_path) ) { - $image_path = $capture_image_path; - } +# check if the image file exists. If the file doesn't exist and we use H264 try to extract it from .mp4 video + if ( $analyse && -r $analyse_image_path ) { + $image_path = $analyse_image_path; + } elsif ( -r $capture_image_path ) { + $image_path = $capture_image_path; + } elsif ( -e $video_path ) { + if ( !system('ffmpeg -y -v 0 -i '.$video_path." -vf 'select=gte(n\\,".$frame->{FrameId}."),setpts=PTS-STARTPTS' -vframes 1 -f image2 ".$capture_image_path) ) { + $image_path = $capture_image_path; } - return $image_path; + } + return $image_path; } -sub uploadArchFile -{ - my $filter = shift; - my $event = shift; +sub uploadArchFile { + my $filter = shift; + my $event = shift; - if ( ! $Config{ZM_UPLOAD_HOST} ) - { - Error( "Cannot upload archive as no upload host defined" ); - return( 0 ); - } + if ( ! $Config{ZM_UPLOAD_HOST} ) { + Error( 'Cannot upload archive as no upload host defined' ); + return( 0 ); + } - my $archFile = $event->{MonitorName}.'-'.$event->{Id}; - my $archImagePath = getEventPath( $event ) - ."/" - .( - ( $Config{ZM_UPLOAD_ARCH_ANALYSE} ) - ? '{*analyse,*capture}' - : '*capture' - ) - .".jpg" + my $archFile = $event->{MonitorName}.'-'.$event->{Id}; + my $archImagePath = getEventPath( $event ) + .'/' + .( + ( $Config{ZM_UPLOAD_ARCH_ANALYSE} ) + ? '{*analyse,*capture}' + : '*capture' + ) + .'.jpg' ; - my @archImageFiles = glob($archImagePath); - my $archLocPath; + my @archImageFiles = glob($archImagePath); + my $archLocPath; - my $archError = 0; - if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "zip" ) - { - $archFile .= '.zip'; - $archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile; - my $zip = Archive::Zip->new(); - Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" ); + my $archError = 0; + if ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq 'zip' ) { + $archFile .= '.zip'; + $archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile; + my $zip = Archive::Zip->new(); + Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" ); - my $status = &AZ_OK; - foreach my $imageFile ( @archImageFiles ) - { - Debug( "Adding $imageFile\n" ); - my $member = $zip->addFile( $imageFile ); - if ( !$member ) - { - Error( "Unable to add image file $imageFile to zip archive $archLocPath" ); - $archError = 1; - last; - } - $member->desiredCompressionMethod( $Config{ZM_UPLOAD_ARCH_COMPRESS} - ? &COMPRESSION_DEFLATED - : &COMPRESSION_STORED - ); - } - if ( !$archError ) - { - $status = $zip->writeToFileNamed( $archLocPath ); - - if ( $archError = ($status != &AZ_OK) ) - { - Error( "Zip error: $status\n " ); - } - } - else - { - Error( "Error adding images to zip archive $archLocPath, not writing" ); - } + my $status = &AZ_OK; + foreach my $imageFile ( @archImageFiles ) { + Debug( "Adding $imageFile\n" ); + my $member = $zip->addFile( $imageFile ); + if ( !$member ) { + Error( "Unable to add image file $imageFile to zip archive $archLocPath" ); + $archError = 1; + last; + } + $member->desiredCompressionMethod( $Config{ZM_UPLOAD_ARCH_COMPRESS} + ? &COMPRESSION_DEFLATED + : &COMPRESSION_STORED + ); } - elsif ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq "tar" ) - { - if ( $Config{ZM_UPLOAD_ARCH_COMPRESS} ) - { - $archFile .= '.tar.gz'; - } - else - { - $archFile .= '.tar'; - } - $archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile; - Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" ); + if ( !$archError ) { + $status = $zip->writeToFileNamed( $archLocPath ); - if ( $archError = !Archive::Tar->create_archive( - $archLocPath, - $Config{ZM_UPLOAD_ARCH_COMPRESS}, - @archImageFiles - ) - ) - { - Error( "Tar error: ".Archive::Tar->error()."\n " ); - } + if ( $archError = ($status != &AZ_OK) ) { + Error( "Zip error: $status\n " ); + } + } else { + Error( "Error adding images to zip archive $archLocPath, not writing" ); } + } elsif ( $Config{ZM_UPLOAD_ARCH_FORMAT} eq 'tar' ) { + if ( $Config{ZM_UPLOAD_ARCH_COMPRESS} ) { + $archFile .= '.tar.gz'; + } else { + $archFile .= '.tar'; + } + $archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile; + Info( "Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n" ); - if ( $archError ) - { + if ( $archError = !Archive::Tar->create_archive( + $archLocPath, + $Config{ZM_UPLOAD_ARCH_COMPRESS}, + @archImageFiles + ) + ) { + Error( 'Tar error: '.Archive::Tar->error()."\n " ); + } + } + + if ( $archError ) { + return( 0 ); + } else { + if ( $Config{ZM_UPLOAD_PROTOCOL} eq 'ftp' ) { + Info( 'Uploading to '.$Config{ZM_UPLOAD_HOST}." using FTP\n" ); + my $ftp = Net::FTP->new( + $Config{ZM_UPLOAD_HOST}, + Timeout=>$Config{ZM_UPLOAD_TIMEOUT}, + Passive=>$Config{ZM_UPLOAD_FTP_PASSIVE}, + Debug=>$Config{ZM_UPLOAD_DEBUG} + ); + if ( !$ftp ) { + Error( "Can't create FTP connection: $@" ); return( 0 ); - } - else - { - if ( $Config{ZM_UPLOAD_PROTOCOL} eq "ftp" ) - { - Info( "Uploading to ".$Config{ZM_UPLOAD_HOST}." using FTP\n" ); - my $ftp = Net::FTP->new( - $Config{ZM_UPLOAD_HOST}, - Timeout=>$Config{ZM_UPLOAD_TIMEOUT}, - Passive=>$Config{ZM_UPLOAD_FTP_PASSIVE}, - Debug=>$Config{ZM_UPLOAD_DEBUG} - ); - if ( !$ftp ) - { - Error( "Can't create FTP connection: $@" ); - return( 0 ); - } - $ftp->login( $Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS} ) - or Error( "FTP - Can't login" ); - $ftp->binary() - or Error( "FTP - Can't go binary" ); - $ftp->cwd( $Config{ZM_UPLOAD_REM_DIR} ) - or Error( "FTP - Can't cwd" ) - if ( $Config{ZM_UPLOAD_REM_DIR} ); - $ftp->put( $archLocPath ) - or Error( "FTP - Can't upload '$archLocPath'" ); - $ftp->quit() - or Error( "FTP - Can't quit" ); - } - else - { - my $host = $Config{ZM_UPLOAD_HOST}; - $host .= ":".$Config{ZM_UPLOAD_PORT} - if $Config{ZM_UPLOAD_PORT}; - Info( "Uploading to ".$host." using SFTP\n" ); - my %sftpOptions = ( host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER} ); - $sftpOptions{password} = $Config{ZM_UPLOAD_PASS} - if $Config{ZM_UPLOAD_PASS}; - $sftpOptions{port} = $Config{ZM_UPLOAD_PORT} - if $Config{ZM_UPLOAD_PORT}; - $sftpOptions{timeout} = $Config{ZM_UPLOAD_TIMEOUT} - if $Config{ZM_UPLOAD_TIMEOUT}; - my @more_ssh_args; - push @more_ssh_args, '-o'=>'StrictHostKeyChecking=no' - if ! $Config{ZM_UPLOAD_STRICT}; - push @more_ssh_args, '-v' - if $Config{ZM_UPLOAD_DEBUG}; - $sftpOptions{more} = [@more_ssh_args]; - my $sftp = Net::SFTP::Foreign->new( $Config{ZM_UPLOAD_HOST}, %sftpOptions ); - if ( $sftp->error ) - { - Error( "Can't create SFTP connection: ".$sftp->error ); - return( 0 ); - } - $sftp->setcwd( $Config{ZM_UPLOAD_REM_DIR} ) - or Error( "SFTP - Can't setcwd: ".$sftp->error ) - if $Config{ZM_UPLOAD_REM_DIR}; - $sftp->put( $archLocPath, $archFile ) - or Error( "SFTP - Can't upload '$archLocPath': ".$sftp->error ); - } - unlink( $archLocPath ); - my $sql = "update Events set Uploaded = 1 where Id = ?"; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - } - return( 1 ); -} - -sub substituteTags -{ - my $text = shift; - my $filter = shift; - my $event = shift; - my $attachments_ref = shift; - - # First we'd better check what we need to get - # We have a filter and an event, do we need any more - # monitor information? - my $need_monitor = $text =~ /%(?:MET|MEH|MED|MEW|MEN|MEA)%/; - - my $monitor = {}; - if ( $need_monitor ) - { - my $db_now = strftime( "%Y-%m-%d %H:%M:%S", localtime() ); - my $sql = "SELECT - M.Id, - count(E.Id) as EventCount, - count(if(E.Archived,1,NULL)) - as ArchEventCount, - count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) - as HourEventCount, - count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) - as DayEventCount, - count(if(E.StartTime>'$db_now' - INTERVAL 7 DAY && E.Archived = 0,1,NULL)) - as WeekEventCount, - count(if(E.StartTime>'$db_now' - INTERVAL 1 MONTH && E.Archived = 0,1,NULL)) - as MonthEventCount - FROM Monitors as M LEFT JOIN Events as E on E.MonitorId = M.Id - WHERE MonitorId = ? - GROUP BY E.MonitorId - ORDER BY Id" - ; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{MonitorId} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - $monitor = $sth->fetchrow_hashref(); - $sth->finish(); - return() if ( !$monitor ); - } - - # Do we need the image information too? - my $need_images = $text =~ /%(?:EPI1|EPIM|EI1|EIM|EI1A|EIMA)%/; - my $first_alarm_frame; - my $max_alarm_frame; - my $max_alarm_score = 0; - if ( $need_images ) - { - my $sql = "SELECT * FROM Frames - WHERE EventId = ? AND Type = 'Alarm' - ORDER BY FrameId" - ; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - while( my $frame = $sth->fetchrow_hashref() ) - { - if ( !$first_alarm_frame ) - { - $first_alarm_frame = $frame; - } - if ( $frame->{Score} > $max_alarm_score ) - { - $max_alarm_frame = $frame; - $max_alarm_score = $frame->{Score}; - } - } - $sth->finish(); - } - - my $url = $Config{ZM_URL}; - $text =~ s/%ZP%/$url/g; - $text =~ s/%MN%/$event->{MonitorName}/g; - $text =~ s/%MET%/$monitor->{EventCount}/g; - $text =~ s/%MEH%/$monitor->{HourEventCount}/g; - $text =~ s/%MED%/$monitor->{DayEventCount}/g; - $text =~ s/%MEW%/$monitor->{WeekEventCount}/g; - $text =~ s/%MEM%/$monitor->{MonthEventCount}/g; - $text =~ s/%MEA%/$monitor->{ArchEventCount}/g; - $text =~ s/%MP%/$url?view=watch&mid=$event->{MonitorId}/g; - $text =~ s/%MPS%/$url?view=watchfeed&mid=$event->{MonitorId}&mode=stream/g; - $text =~ s/%MPI%/$url?view=watchfeed&mid=$event->{MonitorId}&mode=still/g; - $text =~ s/%EP%/$url?view=event&mid=$event->{MonitorId}&eid=$event->{Id}/g; - $text =~ s/%EPS%/$url?view=event&mode=stream&mid=$event->{MonitorId}&eid=$event->{Id}/g; - $text =~ s/%EPI%/$url?view=event&mode=still&mid=$event->{MonitorId}&eid=$event->{Id}/g; - $text =~ s/%EI%/$event->{Id}/g; - $text =~ s/%EN%/$event->{Name}/g; - $text =~ s/%EC%/$event->{Cause}/g; - $text =~ s/%ED%/$event->{Notes}/g; - $text =~ s/%ET%/$event->{StartTime}/g; - $text =~ s/%EL%/$event->{Length}/g; - $text =~ s/%EF%/$event->{Frames}/g; - $text =~ s/%EFA%/$event->{AlarmFrames}/g; - $text =~ s/%EST%/$event->{TotScore}/g; - $text =~ s/%ESA%/$event->{AvgScore}/g; - $text =~ s/%ESM%/$event->{MaxScore}/g; - if ( $first_alarm_frame ) - { - $text =~ s/%EPI1%/$url?view=frame&mid=$event->{MonitorId}&eid=$event->{Id}&fid=$first_alarm_frame->{FrameId}/g; - $text =~ s/%EPIM%/$url?view=frame&mid=$event->{MonitorId}&eid=$event->{Id}&fid=$max_alarm_frame->{FrameId}/g; - if ( $attachments_ref && $text =~ s/%EI1%//g ) - { - my $path = generateImage( $event, $first_alarm_frame); - if ( -e $path ) { - push( @$attachments_ref, - { - type=>"image/jpeg", - path=>$path - } - ); - } - } - if ( $attachments_ref && $text =~ s/%EIM%//g ) - { - # Don't attach the same image twice - if ( !@$attachments_ref - || ($first_alarm_frame->{FrameId} != $max_alarm_frame->{FrameId} ) - ) - { - my $path = generateImage( $event, $max_alarm_frame); - if ( -e $path ) { - push( @$attachments_ref, - { - type=>"image/jpeg", - path=>$path - } - ); - } - } - } - if ( $attachments_ref && $text =~ s/%EI1A%//g ) - { - my $path = generateImage( $event, $first_alarm_frame, "analyse" ); - if ( -e $path ) { - push( @$attachments_ref, - { - type=>"image/jpeg", - path=>$path - } - ); - } - } - if ( $attachments_ref && $text =~ s/%EIMA%//g ) - { - # Don't attach the same image twice - if ( !@$attachments_ref - || ($first_alarm_frame->{FrameId} != $max_alarm_frame->{FrameId} ) - ) - { - my $path = generateImage( $event, $max_alarm_frame, "analyse"); - if ( -e $path ) { - push( @$attachments_ref, - { - type=>"image/jpeg", - path=>$path - } - ); - } - } - } - } - if ( $attachments_ref && $Config{ZM_OPT_FFMPEG} ) - { - if ( $text =~ s/%EV%//g ) - { - my ( $format, $path ) = generateVideo( $filter, $event ); - if ( !$format ) - { - return( undef ); - } - push( @$attachments_ref, { type=>"video/$format", path=>$path } ); - } - if ( $text =~ s/%EVM%//g ) - { - my ( $format, $path ) = generateVideo( $filter, $event, 1 ); - if ( !$format ) - { - return( undef ); - } - push( @$attachments_ref, { type=>"video/$format", path=>$path } ); - } - } - $text =~ s/%FN%/$filter->{Name}/g; - ( my $filter_name = $filter->{Name} ) =~ s/ /+/g; - $text =~ s/%FP%/$url?view=filter&mid=$event->{MonitorId}&filter_name=$filter_name/g; - - return( $text ); -} - -sub sendEmail -{ - my $filter = shift; - my $event = shift; - - if ( ! $Config{ZM_FROM_EMAIL} ) - { - Error( "No 'from' email address defined, not sending email" ); + } + $ftp->login( $Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS} ) + or Error( "FTP - Can't login" ); + $ftp->binary() + or Error( "FTP - Can't go binary" ); + $ftp->cwd( $Config{ZM_UPLOAD_REM_DIR} ) + or Error( "FTP - Can't cwd" ) + if ( $Config{ZM_UPLOAD_REM_DIR} ); + $ftp->put( $archLocPath ) + or Error( "FTP - Can't upload '$archLocPath'" ); + $ftp->quit() + or Error( "FTP - Can't quit" ); + } else { + my $host = $Config{ZM_UPLOAD_HOST}; + $host .= ':'.$Config{ZM_UPLOAD_PORT} + if $Config{ZM_UPLOAD_PORT}; + Info( 'Uploading to '.$host." using SFTP\n" ); + my %sftpOptions = ( host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER} ); + $sftpOptions{password} = $Config{ZM_UPLOAD_PASS} + if $Config{ZM_UPLOAD_PASS}; + $sftpOptions{port} = $Config{ZM_UPLOAD_PORT} + if $Config{ZM_UPLOAD_PORT}; + $sftpOptions{timeout} = $Config{ZM_UPLOAD_TIMEOUT} + if $Config{ZM_UPLOAD_TIMEOUT}; + my @more_ssh_args; + push @more_ssh_args, '-o'=>'StrictHostKeyChecking=no' + if ! $Config{ZM_UPLOAD_STRICT}; + push @more_ssh_args, '-v' + if $Config{ZM_UPLOAD_DEBUG}; + $sftpOptions{more} = [@more_ssh_args]; + my $sftp = Net::SFTP::Foreign->new( $Config{ZM_UPLOAD_HOST}, %sftpOptions ); + if ( $sftp->error ) { + Error( "Can't create SFTP connection: ".$sftp->error ); return( 0 ); + } + $sftp->setcwd( $Config{ZM_UPLOAD_REM_DIR} ) + or Error( "SFTP - Can't setcwd: ".$sftp->error ) + if $Config{ZM_UPLOAD_REM_DIR}; + $sftp->put( $archLocPath, $archFile ) + or Error( "SFTP - Can't upload '$archLocPath': ".$sftp->error ); } - if ( ! $Config{ZM_EMAIL_ADDRESS} ) - { - Error( "No email address defined, not sending email" ); - return( 0 ); - } - - Info( "Creating notification email\n" ); - - my $subject = substituteTags( $Config{ZM_EMAIL_SUBJECT}, $filter, $event ); - return( 0 ) if ( !$subject ); - my @attachments; - my $body = substituteTags( $Config{ZM_EMAIL_BODY}, $filter, $event, \@attachments ); - return( 0 ) if ( !$body ); - - Info( "Sending notification email '$subject'\n" ); - - eval - { - if ( $Config{ZM_NEW_MAIL_MODULES} ) - { - ### Create the multipart container - my $mail = MIME::Lite->new ( - From => $Config{ZM_FROM_EMAIL}, - To => $Config{ZM_EMAIL_ADDRESS}, - Subject => $subject, - Type => "multipart/mixed" - ); - ### Add the text message part - $mail->attach ( - Type => "TEXT", - Data => $body - ); - ### Add the attachments - foreach my $attachment ( @attachments ) - { - Info( "Attaching '$attachment->{path}\n" ); - $mail->attach( - Path => $attachment->{path}, - Type => $attachment->{type}, - Disposition => "attachment" - ); - } - ### Send the Message - if ( $Config{ZM_SSMTP_MAIL} ) { - my $ssmtp_location = $Config{ZM_SSMTP_PATH}; - if ( !$ssmtp_location ) { - if ( logDebugging() ) { - Debug( "which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message\n" ); - } - $ssmtp_location = qx('which ssmtp'); - } - if ( !$ssmtp_location ) { - Debug( "Can't find ssmtp, trying MIME::Lite->send" ); - MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); - $mail->send(); - } else { - ### Send using SSMTP - $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} ); - } - } else { - MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); - $mail->send(); - } - } - else - { - my $mail = MIME::Entity->build( - From => $Config{ZM_FROM_EMAIL}, - To => $Config{ZM_EMAIL_ADDRESS}, - Subject => $subject, - Type => (($body=~//)?'text/html':'text/plain'), - Data => $body - ); - - foreach my $attachment ( @attachments ) - { - Info( "Attaching '$attachment->{path}\n" ); - $mail->attach( - Path => $attachment->{path}, - Type => $attachment->{type}, - Encoding => "base64" - ); - } - $mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, MailFrom => $Config{ZM_FROM_EMAIL} ); - } - }; - if ( $@ ) - { - Error( "Can't send email: $@" ); - return( 0 ); - } - else - { - Info( "Notification email sent\n" ); - } - my $sql = "update Events set Emailed = 1 where Id = ?"; + unlink( $archLocPath ); + my $sql = 'update Events set Uploaded = 1 where Id = ?'; my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - - return( 1 ); + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + } + return( 1 ); } -sub sendMessage -{ - my $filter = shift; - my $event = shift; +sub substituteTags { + my $text = shift; + my $filter = shift; + my $event = shift; + my $attachments_ref = shift; - if ( ! $Config{ZM_FROM_EMAIL} ) - { - Error( "No 'from' email address defined, not sending message" ); - return( 0 ); - } - if ( ! $Config{ZM_MESSAGE_ADDRESS} ) - { - Error( "No message address defined, not sending message" ); - return( 0 ); - } +# First we'd better check what we need to get +# We have a filter and an event, do we need any more +# monitor information? + my $need_monitor = $text =~ /%(?:MET|MEH|MED|MEW|MEN|MEA)%/; - Info( "Creating notification message\n" ); - - my $subject = substituteTags( $Config{ZM_MESSAGE_SUBJECT}, $filter, $event ); - return( 0 ) if ( !$subject ); - my @attachments; - my $body = substituteTags( $Config{ZM_MESSAGE_BODY}, $filter, $event, \@attachments ); - return( 0 ) if ( !$body ); - - Info( "Sending notification message '$subject'\n" ); - - eval - { - if ( $Config{ZM_NEW_MAIL_MODULES} ) - { - ### Create the multipart container - my $mail = MIME::Lite->new ( - From => $Config{ZM_FROM_EMAIL}, - To => $Config{ZM_MESSAGE_ADDRESS}, - Subject => $subject, - Type => "multipart/mixed" - ); - ### Add the text message part - $mail->attach ( - Type => "TEXT", - Data => $body - ); - ### Add the attachments - foreach my $attachment ( @attachments ) - { - Info( "Attaching '$attachment->{path}\n" ); - $mail->attach( - Path => $attachment->{path}, - Type => $attachment->{type}, - Disposition => "attachment" - ); - } - ### Send the Message - if ( $Config{ZM_SSMTP_MAIL} ) { - my $ssmtp_location = $Config{ZM_SSMTP_PATH}; - if ( !$ssmtp_location ) { - if ( logDebugging() ) { - Debug( "which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message\n" ); - } - $ssmtp_location = qx('which ssmtp'); - } - if ( !$ssmtp_location ) { - Debug( "Can't find ssmtp, trying MIME::Lite->send" ); - MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); - $mail->send(); - } else { - ### Send using SSMTP - $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_MESSAGE_ADDRESS} ); - } - } else { - MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 ); - $mail->send(); - } - } - else - { - my $mail = MIME::Entity->build( - From => $Config{ZM_FROM_EMAIL}, - To => $Config{ZM_MESSAGE_ADDRESS}, - Subject => $subject, - Type => (($body=~//)?'text/html':'text/plain'), - Data => $body - ); - - foreach my $attachment ( @attachments ) - { - Info( "Attaching '$attachment->{path}\n" ); - $mail->attach( - Path => $attachment->{path}, - Type => $attachment->{type}, - Encoding => "base64" - ); - } - $mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, - MailFrom => $Config{ZM_FROM_EMAIL} - ); - } - }; - if ( $@ ) - { - Error( "Can't send email: $@" ); - return( 0 ); - } - else - { - Info( "Notification message sent\n" ); - } - my $sql = "update Events set Messaged = 1 where Id = ?"; + my $monitor = {}; + if ( $need_monitor ) { + my $db_now = strftime( "%Y-%m-%d %H:%M:%S", localtime() ); + my $sql = "SELECT + M.Id, + count(E.Id) as EventCount, + count(if(E.Archived,1,NULL)) + as ArchEventCount, + count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) + as HourEventCount, + count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) + as DayEventCount, + count(if(E.StartTime>'$db_now' - INTERVAL 7 DAY && E.Archived = 0,1,NULL)) + as WeekEventCount, + count(if(E.StartTime>'$db_now' - INTERVAL 1 MONTH && E.Archived = 0,1,NULL)) + as MonthEventCount + FROM Monitors as M LEFT JOIN Events as E on E.MonitorId = M.Id + WHERE MonitorId = ? + GROUP BY E.MonitorId + ORDER BY Id" + ; my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{MonitorId} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + $monitor = $sth->fetchrow_hashref(); + $sth->finish(); + return() if ( !$monitor ); + } + +# Do we need the image information too? + my $need_images = $text =~ /%(?:EPI1|EPIM|EI1|EIM|EI1A|EIMA)%/; + my $first_alarm_frame; + my $max_alarm_frame; + my $max_alarm_score = 0; + if ( $need_images ) { + my $sql = "SELECT * FROM Frames + WHERE EventId = ? AND Type = 'Alarm' + ORDER BY FrameId" + ; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + while( my $frame = $sth->fetchrow_hashref() ) { + if ( !$first_alarm_frame ) { + $first_alarm_frame = $frame; + } + if ( $frame->{Score} > $max_alarm_score ) { + $max_alarm_frame = $frame; + $max_alarm_score = $frame->{Score}; + } + } + $sth->finish(); + } - return( 1 ); + my $url = $Config{ZM_URL}; + $text =~ s/%ZP%/$url/g; + $text =~ s/%MN%/$event->{MonitorName}/g; + $text =~ s/%MET%/$monitor->{EventCount}/g; + $text =~ s/%MEH%/$monitor->{HourEventCount}/g; + $text =~ s/%MED%/$monitor->{DayEventCount}/g; + $text =~ s/%MEW%/$monitor->{WeekEventCount}/g; + $text =~ s/%MEM%/$monitor->{MonthEventCount}/g; + $text =~ s/%MEA%/$monitor->{ArchEventCount}/g; + $text =~ s/%MP%/$url?view=watch&mid=$event->{MonitorId}/g; + $text =~ s/%MPS%/$url?view=watchfeed&mid=$event->{MonitorId}&mode=stream/g; + $text =~ s/%MPI%/$url?view=watchfeed&mid=$event->{MonitorId}&mode=still/g; + $text =~ s/%EP%/$url?view=event&mid=$event->{MonitorId}&eid=$event->{Id}/g; + $text =~ s/%EPS%/$url?view=event&mode=stream&mid=$event->{MonitorId}&eid=$event->{Id}/g; + $text =~ s/%EPI%/$url?view=event&mode=still&mid=$event->{MonitorId}&eid=$event->{Id}/g; + $text =~ s/%EI%/$event->{Id}/g; + $text =~ s/%EN%/$event->{Name}/g; + $text =~ s/%EC%/$event->{Cause}/g; + $text =~ s/%ED%/$event->{Notes}/g; + $text =~ s/%ET%/$event->{StartTime}/g; + $text =~ s/%EL%/$event->{Length}/g; + $text =~ s/%EF%/$event->{Frames}/g; + $text =~ s/%EFA%/$event->{AlarmFrames}/g; + $text =~ s/%EST%/$event->{TotScore}/g; + $text =~ s/%ESA%/$event->{AvgScore}/g; + $text =~ s/%ESM%/$event->{MaxScore}/g; + + if ( $first_alarm_frame ) { + $text =~ s/%EPI1%/$url?view=frame&mid=$event->{MonitorId}&eid=$event->{Id}&fid=$first_alarm_frame->{FrameId}/g; + $text =~ s/%EPIM%/$url?view=frame&mid=$event->{MonitorId}&eid=$event->{Id}&fid=$max_alarm_frame->{FrameId}/g; + if ( $attachments_ref && $text =~ s/%EI1%//g ) { + my $path = generateImage( $event, $first_alarm_frame ); + if ( -e $path ) { + push( @$attachments_ref, { type=>'image/jpeg', path=>$path } ); + } + } + + if ( $attachments_ref && $text =~ s/%EIM%//g ) { + # Don't attach the same image twice + if ( !@$attachments_ref + || ($first_alarm_frame->{FrameId} != $max_alarm_frame->{FrameId} ) + ) { + my $path = generateImage( $event, $max_alarm_frame ); + if ( -e $path ) { + push( @$attachments_ref, { type=>'image/jpeg', path=>$path } ); + } + } + } + if ( $attachments_ref && $text =~ s/%EI1A%//g ) { + my $path = generateImage( $event, $first_alarm_frame, 'analyse' ); + if ( -e $path ) { + push( @$attachments_ref, { type=>'image/jpeg', path=>$path } ); + } + } + if ( $attachments_ref && $text =~ s/%EIMA%//g ) { + # Don't attach the same image twice + if ( !@$attachments_ref + || ($first_alarm_frame->{FrameId} != $max_alarm_frame->{FrameId} ) + ) { + my $path = generateImage( $event, $max_alarm_frame, 'analyse'); + if ( -e $path ) { + push( @$attachments_ref, { type=>'image/jpeg', path=>$path } ); + } + } + } + } # end if $first_alarm_frame + + if ( $attachments_ref && $Config{ZM_OPT_FFMPEG} ) { + if ( $text =~ s/%EV%//g ) { + my ( $format, $path ) = generateVideo( $filter, $event ); + if ( !$format ) { + return( undef ); + } + push( @$attachments_ref, { type=>"video/$format", path=>$path } ); + } + if ( $text =~ s/%EVM%//g ) { + my ( $format, $path ) = generateVideo( $filter, $event, 1 ); + if ( !$format ) { + return( undef ); + } + push( @$attachments_ref, { type=>"video/$format", path=>$path } ); + } + } + $text =~ s/%FN%/$filter->{Name}/g; + ( my $filter_name = $filter->{Name} ) =~ s/ /+/g; + $text =~ s/%FP%/$url?view=filter&mid=$event->{MonitorId}&filter_name=$filter_name/g; + + return( $text ); +} # end subsitituteTags + +sub sendEmail { + my $filter = shift; + my $event = shift; + + if ( ! $Config{ZM_FROM_EMAIL} ) { + Error( "No 'from' email address defined, not sending email" ); + return( 0 ); + } + if ( ! $Config{ZM_EMAIL_ADDRESS} ) { + Error( 'No email address defined, not sending email' ); + return( 0 ); + } + + Info( "Creating notification email\n" ); + + my $subject = substituteTags( $Config{ZM_EMAIL_SUBJECT}, $filter, $event ); + return( 0 ) if ( !$subject ); + my @attachments; + my $body = substituteTags( $Config{ZM_EMAIL_BODY}, $filter, $event, \@attachments ); + return( 0 ) if ( !$body ); + + Info( "Sending notification email '$subject'\n" ); + + eval { + if ( $Config{ZM_NEW_MAIL_MODULES} ) { +### Create the multipart container + my $mail = MIME::Lite->new ( + From => $Config{ZM_FROM_EMAIL}, + To => $Config{ZM_EMAIL_ADDRESS}, + Subject => $subject, + Type => 'multipart/mixed' + ); +### Add the text message part + $mail->attach ( + Type => 'TEXT', + Data => $body + ); +### Add the attachments + foreach my $attachment ( @attachments ) { + Info( "Attaching '$attachment->{path}\n" ); + $mail->attach( + Path => $attachment->{path}, + Type => $attachment->{type}, + Disposition => 'attachment' + ); + } +### Send the Message + if ( $Config{ZM_SSMTP_MAIL} ) { + my $ssmtp_location = $Config{ZM_SSMTP_PATH}; + if ( !$ssmtp_location ) { + if ( logDebugging() ) { + Debug( "which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message\n" ); + } + $ssmtp_location = qx('which ssmtp'); + } + if ( !$ssmtp_location ) { + Debug( "Can't find ssmtp, trying MIME::Lite->send" ); + MIME::Lite->send( 'smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + $mail->send(); + } else { +### Send using SSMTP + $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_EMAIL_ADDRESS} ); + } + } else { + MIME::Lite->send( 'smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + $mail->send(); + } + } else { + my $mail = MIME::Entity->build( + From => $Config{ZM_FROM_EMAIL}, + To => $Config{ZM_EMAIL_ADDRESS}, + Subject => $subject, + Type => (($body=~//)?'text/html':'text/plain'), + Data => $body + ); + + foreach my $attachment ( @attachments ) { + Info( "Attaching '$attachment->{path}\n" ); + $mail->attach( + Path => $attachment->{path}, + Type => $attachment->{type}, + Encoding => 'base64' + ); + } + $mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, MailFrom => $Config{ZM_FROM_EMAIL} ); + } + }; + if ( $@ ) { + Error( "Can't send email: $@" ); + return( 0 ); + } else { + Info( "Notification email sent\n" ); + } + my $sql = 'update Events set Emailed = 1 where Id = ?'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + + return( 1 ); } -sub executeCommand -{ - my $filter = shift; - my $event = shift; +sub sendMessage { + my $filter = shift; + my $event = shift; - my $event_path = getEventPath( $event ); + if ( ! $Config{ZM_FROM_EMAIL} ) { + Error( "No 'from' email address defined, not sending message" ); + return( 0 ); + } + if ( ! $Config{ZM_MESSAGE_ADDRESS} ) { + Error( 'No message address defined, not sending message' ); + return( 0 ); + } - my $command = $filter->{AutoExecuteCmd}; - $command .= " $event_path"; - $command = substituteTags( $command, $filter, $event ); + Info( "Creating notification message\n" ); - Info( "Executing '$command'\n" ); - my $output = qx($command); - my $status = $? >> 8; - if ( $status || logDebugging() ) - { - chomp( $output ); - Debug( "Output: $output\n" ); + my $subject = substituteTags( $Config{ZM_MESSAGE_SUBJECT}, $filter, $event ); + return( 0 ) if ( !$subject ); + my @attachments; + my $body = substituteTags( $Config{ZM_MESSAGE_BODY}, $filter, $event, \@attachments ); + return( 0 ) if ( !$body ); + + Info( "Sending notification message '$subject'\n" ); + + eval { + if ( $Config{ZM_NEW_MAIL_MODULES} ) { +### Create the multipart container + my $mail = MIME::Lite->new ( + From => $Config{ZM_FROM_EMAIL}, + To => $Config{ZM_MESSAGE_ADDRESS}, + Subject => $subject, + Type => 'multipart/mixed' + ); +### Add the text message part + $mail->attach ( + Type => 'TEXT', + Data => $body + ); +### Add the attachments + foreach my $attachment ( @attachments ) { + Info( "Attaching '$attachment->{path}\n" ); + $mail->attach( + Path => $attachment->{path}, + Type => $attachment->{type}, + Disposition => 'attachment' + ); + } +### Send the Message + if ( $Config{ZM_SSMTP_MAIL} ) { + my $ssmtp_location = $Config{ZM_SSMTP_PATH}; + if ( !$ssmtp_location ) { + if ( logDebugging() ) { + Debug( "which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message\n" ); + } + $ssmtp_location = qx('which ssmtp'); + } + if ( !$ssmtp_location ) { + Debug( "Can't find ssmtp, trying MIME::Lite->send" ); + MIME::Lite->send( 'smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + $mail->send(); + } else { +### Send using SSMTP + $mail->send( 'sendmail', $ssmtp_location, $Config{ZM_MESSAGE_ADDRESS} ); + } + } else { + MIME::Lite->send( 'smtp', $Config{ZM_EMAIL_HOST}, Timeout=>60 ); + $mail->send(); + } + } else { + my $mail = MIME::Entity->build( + From => $Config{ZM_FROM_EMAIL}, + To => $Config{ZM_MESSAGE_ADDRESS}, + Subject => $subject, + Type => (($body=~//)?'text/html':'text/plain'), + Data => $body + ); + + foreach my $attachment ( @attachments ) { + Info( "Attaching '$attachment->{path}\n" ); + $mail->attach( + Path => $attachment->{path}, + Type => $attachment->{type}, + Encoding => 'base64' + ); + } + $mail->smtpsend( Host => $Config{ZM_EMAIL_HOST}, + MailFrom => $Config{ZM_FROM_EMAIL} + ); } - if ( $status ) - { - Error( "Command '$command' exited with status: $status\n" ); - return( 0 ); - } - else - { - my $sql = "update Events set Executed = 1 where Id = ?"; - my $sth = $dbh->prepare_cached( $sql ) - or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); - my $res = $sth->execute( $event->{Id} ) - or Fatal( "Can't execute '$sql': ".$sth->errstr() ); - } - return( 1 ); + }; + if ( $@ ) { + Error( "Can't send email: $@" ); + return( 0 ); + } else { + Info( "Notification message sent\n" ); + } + my $sql = 'update Events set Messaged = 1 where Id = ?'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + + return( 1 ); +} + +sub executeCommand { + my $filter = shift; + my $event = shift; + + my $event_path = getEventPath( $event ); + + my $command = $filter->{AutoExecuteCmd}; + $command .= " $event_path"; + $command = substituteTags( $command, $filter, $event ); + + Info( "Executing '$command'\n" ); + my $output = qx($command); + my $status = $? >> 8; + if ( $status || logDebugging() ) { + chomp( $output ); + Debug( "Output: $output\n" ); + } + if ( $status ) { + Error( "Command '$command' exited with status: $status\n" ); + return( 0 ); + } else { + my $sql = 'update Events set Executed = 1 where Id = ?'; + my $sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( $event->{Id} ) + or Fatal( "Can't execute '$sql': ".$sth->errstr() ); + } + return( 1 ); } diff --git a/src/zm_event.cpp b/src/zm_event.cpp index aff8bb597..e50009c76 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -643,7 +643,7 @@ bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_fra bool EventStream::loadEventData( int event_id ) { static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "select MonitorId, Frames, unix_timestamp( StartTime ) as StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) as Duration, DefaultVideo from Events Id = %d", event_id ); + snprintf( sql, sizeof(sql), "SELECT MonitorId, Frames, unix_timestamp( StartTime ) AS StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) AS Duration, DefaultVideo FROM Events WHERE Id = %d", event_id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 4c7f4cff0..7ebbeae07 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -23,7 +23,7 @@ #include "zm_ffmpeg_camera.h" -extern "C"{ +extern "C" { #include "libavutil/time.h" } #ifndef AV_ERROR_MAX_STRING_SIZE @@ -125,8 +125,7 @@ int FfmpegCamera::PreCapture() return( 0 ); } -int FfmpegCamera::Capture( Image &image ) -{ +int FfmpegCamera::Capture( Image &image ) { if (!mCanCapture){ return -1; } @@ -167,11 +166,8 @@ int FfmpegCamera::Capture( Image &image ) Debug( 5, "Got packet from stream %d dts (%d) pts(%d)", packet.stream_index, packet.pts, packet.dts ); // What about audio stream? Maybe someday we could do sound detection... if ( packet.stream_index == mVideoStreamId ) { -#if LIBAVCODEC_VERSION_CHECK(52, 23, 0, 23, 0) - if (avcodec_decode_video2(mVideoCodecContext, mRawFrame, &frameComplete, &packet) < 0) -#else - if (avcodec_decode_video(mVideoCodecContext, mRawFrame, &frameComplete, packet.data, packet.size) < 0) -#endif + int ret = zm_avcodec_decode_video( mVideoCodecContext, mRawFrame, &frameComplete, &packet ); + if ( ret < 0 ) Fatal( "Unable to decode frame at frame %d", frameCount ); Debug( 4, "Decoded video packet at frame %d", frameCount ); @@ -364,7 +360,7 @@ int FfmpegCamera::OpenFfmpeg() { Fatal( "Unable to open codec for video stream from %s", mPath.c_str() ); } - if (mAudioStreamId >= 0) { + if ( mAudioStreamId >= 0 ) { mAudioCodecContext = mFormatContext->streams[mAudioStreamId]->codec; if ((mAudioCodec = avcodec_find_decoder(mAudioCodecContext->codec_id)) == NULL) { Debug(1, "Can't find codec for audio stream from %s", mPath.c_str()); @@ -437,7 +433,7 @@ int FfmpegCamera::OpenFfmpeg() { mCanCapture = true; return 0; -} +} // int FfmpegCamera::OpenFfmpeg() int FfmpegCamera::ReopenFfmpeg() { @@ -462,8 +458,7 @@ int FfmpegCamera::CloseFfmpeg(){ av_frame_free( &mRawFrame ); #if HAVE_LIBSWSCALE - if ( mConvertContext ) - { + if ( mConvertContext ) { sws_freeContext( mConvertContext ); mConvertContext = NULL; } @@ -490,8 +485,7 @@ int FfmpegCamera::CloseFfmpeg(){ return 0; } -int FfmpegCamera::FfmpegInterruptCallback(void *ctx) -{ +int FfmpegCamera::FfmpegInterruptCallback(void *ctx) { FfmpegCamera* camera = reinterpret_cast(ctx); if (camera->mIsOpening){ int now = time(NULL); @@ -529,14 +523,14 @@ void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){ //Function to handle capture and store int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event_file ) { - if (!mCanCapture){ + if ( ! mCanCapture ) { return -1; } int ret; static char errbuf[AV_ERROR_MAX_STRING_SIZE]; // If the reopen thread has a value, but mCanCapture != 0, then we have just reopened the connection to the ffmpeg device, and we can clean up the thread. - if (mReopenThread != 0) { + if ( mReopenThread != 0 ) { void *retval = 0; ret = pthread_join(mReopenThread, &retval); @@ -548,7 +542,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event mReopenThread = 0; } - if (mVideoCodecContext->codec_id != AV_CODEC_ID_H264) { + if ( mVideoCodecContext->codec_id != AV_CODEC_ID_H264 ) { Error( "Input stream is not h264. The stored event file may not be viewable in browser." ); } @@ -639,6 +633,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event unsigned int packet_count = 0; ZMPacket *queued_packet; + // Clear all packets that predate the moment when the recording began packetqueue.clear_unwanted_packets( &recording, mVideoStreamId ); while ( ( queued_packet = packetqueue.popPacket() ) ) { @@ -673,7 +668,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event // Buffer video packets, since we are not recording. // All audio packets are keyframes, so only if it's a video keyframe - if ( packet.stream_index == mVideoStreamId) { + if ( packet.stream_index == mVideoStreamId ) { if ( key_frame ) { Debug(3, "Clearing queue"); packetqueue.clearQueue( monitor->GetPreEventCount(), mVideoStreamId ); @@ -688,18 +683,22 @@ else if ( packet.pts && video_last_pts > packet.pts ) { } #endif } - - if ( - ( packet.stream_index != mAudioStreamId || record_audio ) - && - ( key_frame || packetqueue.size() ) - ) { - packetqueue.queuePacket( &packet ); + + // The following lines should ensure that the queue always begins with a video keyframe + if ( packet.stream_index == mAudioStreamId ) { +//Debug(2, "Have audio packet, reocrd_audio is (%d) and packetqueue.size is (%d)", record_audio, packetqueue.size() ); + if ( record_audio && packetqueue.size() ) { + // if it's audio, and we are doing audio, and there is already something in the queue + packetqueue.queuePacket( &packet ); + } + } else if ( packet.stream_index == mVideoStreamId ) { + if ( key_frame || packetqueue.size() ) // it's a keyframe or we already have something in the queue + packetqueue.queuePacket( &packet ); } } // end if recording or not if ( packet.stream_index == mVideoStreamId ) { - if ( videoStore ) { + if ( videoStore ) { //Write the packet to our video store int ret = videoStore->writeVideoFramePacket( &packet ); if ( ret < 0 ) { //Less than zero and we skipped a frame @@ -779,8 +778,10 @@ else if ( packet.pts && video_last_pts > packet.pts ) { return 0; } } else { - Debug(4, "Not recording audio packet" ); + Debug(4, "Not doing recording of audio packet" ); } + } else { + Debug(4, "Have audio packet, but not recording atm" ); } } else { #if LIBAVUTIL_VERSION_CHECK(56, 23, 0, 23, 0) diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index f60b11df5..d4520caba 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -60,14 +60,12 @@ ZMPacket* zm_packetqueue::popPacket( ) { unsigned int zm_packetqueue::clearQueue( unsigned int frames_to_keep, int stream_id ) { - Debug(3, "Clearing all but %d frames", frames_to_keep ); + Debug(3, "Clearing all but %d frames, queue has %d", frames_to_keep, pktQueue.size() ); frames_to_keep += 1; if ( pktQueue.empty() ) { Debug(3, "Queue is empty"); return 0; - } else { - Debug(3, "Queue has (%d)", pktQueue.size() ); } list::reverse_iterator it; @@ -77,18 +75,19 @@ unsigned int zm_packetqueue::clearQueue( unsigned int frames_to_keep, int stream ZMPacket *zm_packet = *it; AVPacket *av_packet = &(zm_packet->packet); - Debug(3, "Looking at packet with stream index (%d) with keyframe (%d), frames_to_keep is (%d)", av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ), frames_to_keep ); + Debug(4, "Looking at packet with stream index (%d) with keyframe (%d), frames_to_keep is (%d)", av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ), frames_to_keep ); // Want frames_to_keep video keyframes. Otherwise, we may not have enough if ( ( av_packet->stream_index == stream_id) && ( av_packet->flags & AV_PKT_FLAG_KEY ) ) { - if (!frames_to_keep) - break; frames_to_keep --; } } + if ( frames_to_keep ) { + Debug(3, "Hit end of queue, still need (%d) video keyframes", frames_to_keep ); + } unsigned int delete_count = 0; while ( it != pktQueue.rend() ) { - Debug(3, "Deleting a packet from the front, count is (%d)", delete_count ); + Debug(4, "Deleting a packet from the front, count is (%d)", delete_count ); packet = pktQueue.front(); pktQueue.pop_front(); @@ -96,6 +95,7 @@ unsigned int zm_packetqueue::clearQueue( unsigned int frames_to_keep, int stream delete_count += 1; } + Debug(3, "Deleted (%d) packets", delete_count ); return delete_count; } // end unsigned int zm_packetqueue::clearQueue( unsigned int frames_to_keep, int stream_id ) @@ -123,10 +123,10 @@ void zm_packetqueue::clear_unwanted_packets( timeval *recording_started, int mVi // Step 2 - pop packets until we get to the packet in step 2 list::reverse_iterator it; + Debug(3, "Looking for keyframe after start recording stream id (%d)", mVideoStreamId ); for ( it = pktQueue.rbegin(); it != pktQueue.rend(); ++ it ) { ZMPacket *zm_packet = *it; AVPacket *av_packet = &(zm_packet->packet); -Debug(1, "Looking for keyframe after start" ); if ( ( av_packet->flags & AV_PKT_FLAG_KEY ) && @@ -134,7 +134,7 @@ Debug(1, "Looking for keyframe after start" ); && timercmp( &(zm_packet->timestamp), recording_started, < ) ) { -Debug(1, "Found keyframe before start" ); + Debug(3, "Found keyframe before start with stream index (%d) with keyframe (%d)", av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ) ); break; } } @@ -143,10 +143,29 @@ Debug(1, "Found keyframe before start" ); return; } + ZMPacket *zm_packet = *it; + AVPacket *av_packet = &(zm_packet->packet); + Debug(3, "Found packet before start with stream index (%d) with keyframe (%d), distance(%d), size(%d)", + av_packet->stream_index, + ( av_packet->flags & AV_PKT_FLAG_KEY ), + distance( it, pktQueue.rend() ), + pktQueue.size() ); + + unsigned int deleted_frames = 0; ZMPacket *packet = NULL; - while ( pktQueue.rend() != it ) { + while ( distance( it, pktQueue.rend() ) > 1 ) { + //while ( pktQueue.rend() != it ) { packet = pktQueue.front(); pktQueue.pop_front(); delete packet; + deleted_frames += 1; + } + + zm_packet = pktQueue.front(); + av_packet = &(zm_packet->packet); + if ( ( ! ( av_packet->flags & AV_PKT_FLAG_KEY ) ) || ( av_packet->stream_index != mVideoStreamId ) ) { + Error( "Done looking for keyframe. Deleted %d frames. Remaining frames in queue: %d stream of head packet is (%d), keyframe (%d), distance(%d), packets(%d)", deleted_frames, pktQueue.size(), av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ), distance( it, pktQueue.rend() ), pktQueue.size() ); + } else { + Debug(1, "Done looking for keyframe. Deleted %d frames. Remaining frames in queue: %d stream of head packet is (%d), keyframe (%d), distance(%d), packets(%d)", deleted_frames, pktQueue.size(), av_packet->stream_index, ( av_packet->flags & AV_PKT_FLAG_KEY ), distance( it, pktQueue.rend() ), pktQueue.size() ); } } diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 99b521c3c..e7ad821d9 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -27,7 +27,7 @@ #include "zm.h" #include "zm_videostore.h" -extern "C"{ +extern "C" { #include "libavutil/time.h" } @@ -37,23 +37,23 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, int64_t nStartTime, Monitor * monitor ) { + video_input_stream = p_video_input_stream; audio_input_stream = p_audio_input_stream; +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + video_input_context = avcodec_alloc_context3( NULL ); + avcodec_parameters_to_context( video_input_context, video_input_stream->codecpar ); +#else video_input_context = video_input_stream->codec; +#endif //store inputs in variables local to class filename = filename_in; format = format_in; - keyframeMessage = false; - keyframeSkipNumber = 0; - Info("Opening video storage stream %s format: %s\n", filename, format); - //Init everything we need, shouldn't have to do this, ffmpeg_camera or something else will call it. - //av_register_all(); - ret = avformat_alloc_output_context2(&oc, NULL, NULL, filename); if ( ret < 0 ) { Warning("Could not create video storage stream %s as no output context" @@ -62,11 +62,11 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, av_make_error_string(ret).c_str() ); } else { - Debug(2, "Success alocateing output context"); + Debug(2, "Success allocating output context"); } //Couldn't deduce format from filename, trying from format name - if (!oc) { + if ( ! oc ) { avformat_alloc_output_context2(&oc, NULL, format, filename); if (!oc) { Fatal("Could not create video storage stream %s as no output context" @@ -82,29 +82,47 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, if (dsr < 0) Warning("%s:%d: title set failed", __FILE__, __LINE__ ); oc->metadata = pmetadata; - output_format = oc->oformat; - video_output_stream = avformat_new_stream(oc, (AVCodec*)video_input_context->codec); - if (!video_output_stream) { +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + // Since we are not re-encoding, all we have to do is copy the parameters + video_output_context = avcodec_alloc_context3( NULL ); + + // Copy params from inputstream to context + ret = avcodec_parameters_to_context( video_output_context, video_input_stream->codecpar ); + if ( ret < 0 ) { + Error( "Could not initialize context parameteres"); + return; + } else { + Debug( 2, "Success getting parameters"); + } + + video_output_stream = avformat_new_stream( oc, NULL ); + if ( ! video_output_stream ) { Fatal("Unable to create video out stream\n"); } else { Debug(2, "Success creating video out stream" ); } - video_output_context = video_output_stream->codec; - -#if LIBAVCODEC_VERSION_CHECK(58, 0, 0, 0, 0) - Debug(2, "setting parameters"); - ret = avcodec_parameters_to_context( video_output_context, video_input_stream->codecpar ); + // Now copy them to the output stream + ret = avcodec_parameters_from_context( video_output_stream->codecpar, video_output_context ); if ( ret < 0 ) { Error( "Could not initialize stream parameteres"); return; } else { - Debug(2, "Success getting parameters"); + Debug(2, "Success setting parameters"); } + + zm_dump_stream_format( oc, 0, 0, 1 ); #else - ret = avcodec_copy_context(video_output_context, video_input_context ); + video_output_stream = avformat_new_stream(oc, (AVCodec*)video_input_context->codec ); + if ( ! video_output_stream ) { + Fatal("Unable to create video out stream\n"); + } else { + Debug(2, "Success creating video out stream" ); + } + video_output_context = video_output_stream->codec; + ret = avcodec_copy_context( video_output_context, video_input_context ); if (ret < 0) { Fatal("Unable to copy input video context to output video context %s\n", av_make_error_string(ret).c_str()); @@ -130,7 +148,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, // WHY? //video_output_context->codec_tag = 0; - if (!video_output_context->codec_tag) { + if ( ! video_output_context->codec_tag ) { Debug(2, "No codec_tag"); if (! oc->oformat->codec_tag || av_codec_get_id (oc->oformat->codec_tag, video_input_context->codec_tag) == video_output_context->codec_id @@ -145,6 +163,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, } Monitor::Orientation orientation = monitor->getOrientation(); + Debug(3, "Have orientation" ); if ( orientation ) { if ( orientation == Monitor::ROTATE_0 ) { @@ -169,13 +188,22 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, resample_context = NULL; #endif - if (audio_input_stream) { + if ( audio_input_stream ) { + Debug(3, "Have audio stream" ); +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + + audio_input_context = avcodec_alloc_context3( NULL ); + ret = avcodec_parameters_to_context( audio_input_context, audio_input_stream->codecpar ); +#else audio_input_context = audio_input_stream->codec; +#endif if ( audio_input_context->codec_id != AV_CODEC_ID_AAC ) { static char error_buffer[256]; avcodec_string(error_buffer, sizeof(error_buffer), audio_input_context, 0 ); - Debug(3, "Got something other than AAC (%s)", error_buffer ); + Debug(2, "Got something other than AAC (%s)", error_buffer ); + + if ( ! setup_resampler() ) { return; } @@ -187,9 +215,16 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, Error("Unable to create audio out stream\n"); audio_output_stream = NULL; } else { - audio_output_context = audio_output_stream->codec; + Debug(2, "setting parameters"); +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + audio_output_context = avcodec_alloc_context3( NULL ); + // Copy params from inputstream to context + ret = avcodec_parameters_to_context( audio_output_context, audio_input_stream->codecpar ); +#else + audio_output_context = audio_output_stream->codec; ret = avcodec_copy_context(audio_output_context, audio_input_context); +#endif if (ret < 0) { Error("Unable to copy audio context %s\n", av_make_error_string(ret).c_str()); audio_output_stream = NULL; @@ -233,7 +268,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, //av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0); //av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0); //av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov+default_base_moof", 0); - if ((ret = avformat_write_header(oc, &opts)) < 0) { + if ((ret = avformat_write_header(oc, NULL)) < 0) { + //if ((ret = avformat_write_header(oc, &opts)) < 0) { Warning("Unable to set movflags to frag_custom+dash+delay_moov"); /* Write the stream header, if any. */ ret = avformat_write_header(oc, NULL); @@ -252,8 +288,10 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, video_last_dts = 0; audio_last_pts = 0; audio_last_dts = 0; - previous_pts = 0; - previous_dts = 0; + video_previous_pts = 0; + video_previous_dts = 0; + audio_previous_pts = 0; + audio_previous_dts = 0; } // VideoStore::VideoStore @@ -262,14 +300,14 @@ VideoStore::~VideoStore(){ if ( audio_output_codec ) { // Do we need to flush the outputs? I have no idea. AVPacket pkt; - int got_packet; + int got_packet = 0; av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; int64_t size; while(1) { -#if LIBAVCODEC_VERSION_CHECK(58, 0, 0, 0, 0) +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) ret = avcodec_receive_packet( audio_output_context, &pkt ); #else ret = avcodec_encode_audio2( audio_output_context, &pkt, NULL, &got_packet ); @@ -341,6 +379,18 @@ bool VideoStore::setup_resampler() { #ifdef HAVE_LIBAVRESAMPLE static char error_buffer[256]; +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + // Newer ffmpeg wants to keep everything separate... so have to lookup our own decoder, can't reuse the one from the camera. + AVCodec *audio_input_codec = avcodec_find_decoder(audio_input_stream->codecpar->codec_id); +#else + AVCodec *audio_input_codec = avcodec_find_decoder(audio_input_context->codec_id); +#endif + ret = avcodec_open2( audio_input_context, audio_input_codec, NULL ); + if ( ret < 0 ) { + Error("Can't open input codec!"); + return false; + } + audio_output_codec = avcodec_find_encoder(AV_CODEC_ID_AAC); if ( ! audio_output_codec ) { Error("Could not find codec for AAC"); @@ -348,8 +398,8 @@ bool VideoStore::setup_resampler() { } Debug(2, "Have audio output codec"); - audio_output_stream = avformat_new_stream( oc, audio_output_codec ); - audio_output_context = audio_output_stream->codec; + //audio_output_context = audio_output_stream->codec; + audio_output_context = avcodec_alloc_context3( audio_output_codec ); if ( ! audio_output_context ) { Error( "could not allocate codec context for AAC\n"); @@ -359,18 +409,15 @@ bool VideoStore::setup_resampler() { Debug(2, "Have audio_output_context"); - AVDictionary *opts = NULL; - av_dict_set(&opts, "strict", "experimental", 0); - /* put sample parameters */ audio_output_context->bit_rate = audio_input_context->bit_rate; audio_output_context->sample_rate = audio_input_context->sample_rate; audio_output_context->channels = audio_input_context->channels; audio_output_context->channel_layout = audio_input_context->channel_layout; audio_output_context->sample_fmt = audio_input_context->sample_fmt; - //audio_output_context->refcounted_frames = 1; + audio_output_context->refcounted_frames = 1; - if (audio_output_codec->supported_samplerates) { + if ( audio_output_codec->supported_samplerates ) { int found = 0; for ( unsigned int i = 0; audio_output_codec->supported_samplerates[i]; i++) { if ( audio_output_context->sample_rate == audio_output_codec->supported_samplerates[i] ) { @@ -387,36 +434,14 @@ bool VideoStore::setup_resampler() { } /* check that the encoder supports s16 pcm input */ - if (!check_sample_fmt( audio_output_codec, audio_output_context->sample_fmt)) { + if ( ! check_sample_fmt( audio_output_codec, audio_output_context->sample_fmt ) ) { Debug( 3, "Encoder does not support sample format %s, setting to FLTP", av_get_sample_fmt_name( audio_output_context->sample_fmt)); audio_output_context->sample_fmt = AV_SAMPLE_FMT_FLTP; } - //audio_output_stream->time_base = audio_input_stream->time_base; audio_output_context->time_base = (AVRational){ 1, audio_output_context->sample_rate }; - Debug(3, "Audio Time bases input stream (%d/%d) input codec: (%d/%d) output_stream (%d/%d) output codec (%d/%d)", - audio_input_stream->time_base.num, - audio_input_stream->time_base.den, - audio_input_context->time_base.num, - audio_input_context->time_base.den, - audio_output_stream->time_base.num, - audio_output_stream->time_base.den, - audio_output_context->time_base.num, - audio_output_context->time_base.den - ); - - ret = avcodec_open2(audio_output_context, audio_output_codec, &opts ); - av_dict_free(&opts); - if ( ret < 0 ) { - av_strerror(ret, error_buffer, sizeof(error_buffer)); - Fatal( "could not open codec (%d) (%s)\n", ret, error_buffer ); - audio_output_codec = NULL; - audio_output_context = NULL; - audio_output_stream = NULL; - return false; - } Debug(1, "Audio output bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) layout(%d) frame_size(%d)", audio_output_context->bit_rate, @@ -427,7 +452,30 @@ bool VideoStore::setup_resampler() { audio_output_context->frame_size ); - output_frame_size = audio_output_context->frame_size; + // Now copy them to the output stream + audio_output_stream = avformat_new_stream( oc, audio_output_codec ); + +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + ret = avcodec_parameters_from_context( audio_output_stream->codecpar, audio_output_context ); + if ( ret < 0 ) { + Error( "Could not initialize stream parameteres"); + return false; + } +#endif + + AVDictionary *opts = NULL; + av_dict_set( &opts, "strict", "experimental", 0); + ret = avcodec_open2( audio_output_context, audio_output_codec, &opts ); + av_dict_free(&opts); + if ( ret < 0 ) { + av_strerror(ret, error_buffer, sizeof(error_buffer)); + Fatal( "could not open codec (%d) (%s)\n", ret, error_buffer ); + audio_output_codec = NULL; + audio_output_context = NULL; + audio_output_stream = NULL; + return false; + } + /** Create a new frame to store the audio samples. */ if (!(input_frame = zm_av_frame_alloc())) { Error("Could not allocate input frame"); @@ -562,9 +610,9 @@ int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) { if ( ipkt->pts < video_last_pts ) { Debug(1, "Resetting video_last_pts from (%d) to (%d)", video_last_pts, ipkt->pts ); // wrap around, need to figure out the distance FIXME having this wrong should cause a jump, but then play ok? - opkt.pts = previous_pts + av_rescale_q( ipkt->pts, video_input_stream->time_base, video_output_stream->time_base); + opkt.pts = video_previous_pts + av_rescale_q( ipkt->pts, video_input_stream->time_base, video_output_stream->time_base); } else { - opkt.pts = previous_pts + av_rescale_q( ipkt->pts - video_last_pts, video_input_stream->time_base, video_output_stream->time_base); + opkt.pts = video_previous_pts + av_rescale_q( ipkt->pts - video_last_pts, video_input_stream->time_base, video_output_stream->time_base); } } Debug(3, "opkt.pts = %d from ipkt->pts(%d) - last_pts(%d)", opkt.pts, ipkt->pts, video_last_pts ); @@ -588,24 +636,20 @@ int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) { // why are we using cur_dts instead of packet.dts? I think cur_dts is in AV_TIME_BASE_Q, but ipkt.dts is in video_input_stream->time_base if ( video_input_stream->cur_dts < video_last_dts ) { Debug(1, "Resetting video_last_dts from (%d) to (%d) p.dts was (%d)", video_last_dts, video_input_stream->cur_dts, ipkt->dts ); - opkt.dts = previous_dts + av_rescale_q(video_input_stream->cur_dts, AV_TIME_BASE_Q, video_output_stream->time_base); + opkt.dts = video_previous_dts + av_rescale_q(video_input_stream->cur_dts, AV_TIME_BASE_Q, video_output_stream->time_base); } else { - opkt.dts = previous_dts + av_rescale_q(video_input_stream->cur_dts - video_last_dts, AV_TIME_BASE_Q, video_output_stream->time_base); + opkt.dts = video_previous_dts + av_rescale_q(video_input_stream->cur_dts - video_last_dts, AV_TIME_BASE_Q, video_output_stream->time_base); } - Debug(3, "opkt.dts = %d from video_input_stream->cur_dts(%d) - previus_dts(%d)", - opkt.dts, video_input_stream->cur_dts, video_last_dts - ); + Debug(3, "opkt.dts = %d from video_input_stream->cur_dts(%d) - previus_dts(%d)", opkt.dts, video_input_stream->cur_dts, video_last_dts ); video_last_dts = video_input_stream->cur_dts; } else { if ( ipkt->dts < video_last_dts ) { Debug(1, "Resetting video_last_dts from (%d) to (%d)", video_last_dts, ipkt->dts ); - opkt.dts = previous_dts + av_rescale_q( ipkt->dts, video_input_stream->time_base, video_output_stream->time_base); + opkt.dts = video_previous_dts + av_rescale_q( ipkt->dts, video_input_stream->time_base, video_output_stream->time_base); } else { - opkt.dts = previous_dts + av_rescale_q( ipkt->dts - video_last_dts, video_input_stream->time_base, video_output_stream->time_base); + opkt.dts = video_previous_dts + av_rescale_q( ipkt->dts - video_last_dts, video_input_stream->time_base, video_output_stream->time_base); } - Debug(3, "opkt.dts = %d from ipkt.dts(%d) - previus_dts(%d)", - opkt.dts, ipkt->dts, video_last_dts - ); + Debug(3, "opkt.dts = %d from ipkt.dts(%d) - previus_dts(%d)", opkt.dts, ipkt->dts, video_last_dts ); video_last_dts = ipkt->dts; } } @@ -642,15 +686,15 @@ Debug(1, "writing video packet pts(%d) dts(%d) duration(%d)", opkt.pts, opkt.dts dumpPacket( ipkt); dumpPacket(&opkt); - } else if ((previous_dts > 0) && (previous_dts > opkt.dts)) { - Warning("%s:%d: DTS out of order: %lld \u226E %lld; discarding frame", __FILE__, __LINE__, previous_dts, opkt.dts); - previous_dts = opkt.dts; + } else if ((video_previous_dts > 0) && (video_previous_dts > opkt.dts)) { + Warning("%s:%d: DTS out of order: %lld \u226E %lld; discarding frame", __FILE__, __LINE__, video_previous_dts, opkt.dts); + video_previous_dts = opkt.dts; dumpPacket(&opkt); } else { - previous_dts = opkt.dts; // Unsure if av_interleaved_write_frame() clobbers opkt.dts when out of order, so storing in advance - previous_pts = opkt.pts; + video_previous_dts = opkt.dts; // Unsure if av_interleaved_write_frame() clobbers opkt.dts when out of order, so storing in advance + video_previous_pts = opkt.pts; ret = av_interleaved_write_frame(oc, &opkt); if(ret<0){ // There's nothing we can really do if the frame is rejected, just drop it and get on with the next @@ -663,21 +707,20 @@ Debug(1, "writing video packet pts(%d) dts(%d) duration(%d)", opkt.pts, opkt.dts return 0; -} +} // end int VideoStore::writeVideoFramePacket( AVPacket *ipkt ) int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { Debug(4, "writeAudioFrame"); - if(!audio_output_stream) { + if ( ! audio_output_stream ) { Debug(1, "Called writeAudioFramePacket when no audio_output_stream"); return 0;//FIXME -ve return codes do not free packet in ffmpeg_camera at the moment } - if ( audio_output_codec ) { #ifdef HAVE_LIBAVRESAMPLE -#if 0 +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) ret = avcodec_send_packet( audio_input_context, ipkt ); if ( ret < 0 ) { Error("avcodec_send_packet fail %s", av_make_error_string(ret).c_str()); @@ -696,26 +739,7 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { input_frame->channel_layout, audio_output_context->refcounted_frames ); - - ret = avcodec_send_frame( audio_output_context, input_frame ); - if ( ret < 0 ) { - av_frame_unref( input_frame ); - Error("avcodec_send_frame fail(%d), %s codec is open(%d) is_encoder(%d)", ret, av_make_error_string(ret).c_str(), - avcodec_is_open( audio_output_context ), - av_codec_is_encoder( audio_output_context->codec) - ); - return 0; - } - ret = avcodec_receive_packet( audio_output_context, &opkt ); - if ( ret < 0 ) { - av_frame_unref( input_frame ); - Error("avcodec_receive_packet fail %s", av_make_error_string(ret).c_str()); - return 0; - } - av_frame_unref( input_frame ); #else - - /** * Decode the audio frame stored in the packet. * The input audio stream decoder is used to do this. @@ -728,15 +752,13 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { av_make_error_string(ret).c_str()); dumpPacket( ipkt ); av_frame_free( &input_frame ); - zm_av_packet_unref( &opkt ); return 0; } if ( ! data_present ) { Debug(2, "Not ready to transcode a frame yet."); - zm_av_packet_unref(&opkt); return 0; } - +#endif int frame_size = input_frame->nb_samples; Debug(4, "Frame size: %d", frame_size ); @@ -778,11 +800,22 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { * Encode the audio frame and store it in the temporary packet. * The output audio stream encoder is used to do this. */ -#if LIBAVCODEC_VERSION_CHECK(58, 0, 0, 0, 0) +#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0) + if (( ret = avcodec_send_frame( audio_output_context, output_frame ) ) < 0 ) { + Error( "Could not send frame (error '%s')", + av_make_error_string(ret).c_str()); + zm_av_packet_unref(&opkt); + return 0; + } + if (( ret = avcodec_receive_packet( audio_output_context, &opkt )) < 0 ) { + Error( "Could not recieve packet (error '%s')", + av_make_error_string(ret).c_str()); + zm_av_packet_unref(&opkt); + return 0; + } #else if (( ret = avcodec_encode_audio2( audio_output_context, &opkt, output_frame, &data_present )) < 0) { -#endif Error( "Could not encode frame (error '%s')", av_make_error_string(ret).c_str()); zm_av_packet_unref(&opkt); @@ -793,8 +826,8 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { zm_av_packet_unref(&opkt); return 0; } - #endif + #endif } else { av_init_packet(&opkt); @@ -807,14 +840,17 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { //Scale the PTS of the outgoing packet to be the correct time base if ( ipkt->pts != AV_NOPTS_VALUE ) { - if ( !audio_last_pts ) { + if ( ! audio_last_pts ) { opkt.pts = 0; + Debug(1, "No audio_last_pts"); } else { if ( audio_last_pts > ipkt->pts ) { Debug(1, "Resetting audeo_start_pts from (%d) to (%d)", audio_last_pts, ipkt->pts ); + opkt.pts = audio_previous_pts + av_rescale_q(ipkt->pts, audio_input_stream->time_base, audio_output_stream->time_base); + } else { + opkt.pts = audio_previous_pts + av_rescale_q(ipkt->pts - audio_last_pts, audio_input_stream->time_base, audio_output_stream->time_base); } - opkt.pts = previous_pts + av_rescale_q(ipkt->pts - audio_last_pts, audio_input_stream->time_base, audio_output_stream->time_base); - Debug(2, "opkt.pts = %d from ipkt->pts(%d) - last_pts(%d)", opkt.pts, ipkt->pts, audio_last_pts ); + Debug(2, "audio opkt.pts = %d from ipkt->pts(%d) - last_pts(%d)", opkt.pts, ipkt->pts, audio_last_pts ); } audio_last_pts = ipkt->pts; } else { @@ -825,28 +861,30 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { //Scale the DTS of the outgoing packet to be the correct time base if ( ! audio_last_dts ) { opkt.dts = 0; + } else { if( ipkt->dts == AV_NOPTS_VALUE ) { // So if the input has no dts assigned... still need an output dts... so we use cur_dts? if ( audio_last_dts > audio_input_stream->cur_dts ) { - Debug(1, "Resetting audio_last_pts from (%d) to cur_dts (%d)", audio_last_dts, audio_input_stream->cur_dts ); - opkt.dts = previous_dts + av_rescale_q( audio_input_stream->cur_dts, AV_TIME_BASE_Q, audio_output_stream->time_base); + Debug(1, "Resetting audio_last_dts from (%d) to cur_dts (%d)", audio_last_dts, audio_input_stream->cur_dts ); + opkt.dts = audio_previous_dts + av_rescale_q( audio_input_stream->cur_dts, AV_TIME_BASE_Q, audio_output_stream->time_base); } else { - opkt.dts = previous_dts + av_rescale_q( audio_input_stream->cur_dts - audio_last_dts, AV_TIME_BASE_Q, audio_output_stream->time_base); + opkt.dts = audio_previous_dts + av_rescale_q( audio_input_stream->cur_dts - audio_last_dts, AV_TIME_BASE_Q, audio_output_stream->time_base); } audio_last_dts = audio_input_stream->cur_dts; Debug(2, "opkt.dts = %d from video_input_stream->cur_dts(%d) - last_dts(%d)", opkt.dts, audio_input_stream->cur_dts, audio_last_dts ); } else { if ( audio_last_dts > ipkt->dts ) { Debug(1, "Resetting audio_last_dts from (%d) to (%d)", audio_last_dts, ipkt->dts ); - opkt.dts = previous_dts + av_rescale_q(ipkt->dts, audio_input_stream->time_base, audio_output_stream->time_base); + opkt.dts = audio_previous_dts + av_rescale_q(ipkt->dts, audio_input_stream->time_base, audio_output_stream->time_base); } else { - opkt.dts = previous_dts + av_rescale_q(ipkt->dts - audio_last_dts, audio_input_stream->time_base, audio_output_stream->time_base); + opkt.dts = audio_previous_dts + av_rescale_q(ipkt->dts - audio_last_dts, audio_input_stream->time_base, audio_output_stream->time_base); } Debug(2, "opkt.dts = %d from ipkt->dts(%d) - last_dts(%d)", opkt.dts, ipkt->dts, audio_last_dts ); } } + audio_last_dts = ipkt->dts; if ( opkt.dts > opkt.pts ) { Debug(1,"opkt.dts(%d) must be <= opkt.pts(%d). Decompression must happen before presentation.", opkt.dts, opkt.pts ); opkt.dts = opkt.pts; @@ -854,15 +892,17 @@ int VideoStore::writeAudioFramePacket( AVPacket *ipkt ) { // I wonder if we could just use duration instead of all the hoop jumping above? opkt.duration = av_rescale_q(ipkt->duration, audio_input_stream->time_base, audio_output_stream->time_base); + Debug( 2, "opkt.pts (%d), opkt.dts(%d) opkt.duration = (%d)", opkt.pts, opkt.dts, opkt.duration ); // pkt.pos: byte position in stream, -1 if unknown opkt.pos = -1; - opkt.flags = ipkt->flags; opkt.stream_index = ipkt->stream_index; Debug(2, "Stream index is %d", opkt.stream_index ); AVPacket safepkt; memcpy(&safepkt, &opkt, sizeof(AVPacket)); + audio_previous_dts = opkt.dts; // Unsure if av_interleaved_write_frame() clobbers opkt.dts when out of order, so storing in advance + audio_previous_pts = opkt.pts; ret = av_interleaved_write_frame(oc, &opkt); if(ret!=0){ Error("Error writing audio frame packet: %s\n", av_make_error_string(ret).c_str()); diff --git a/src/zm_videostore.h b/src/zm_videostore.h index b76153cb8..e4d337df0 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -61,8 +61,10 @@ AVAudioResampleContext* resample_context; int64_t audio_last_dts; // These are for output, should start at zero. We assume they do not wrap because we just aren't going to save files that big. - int64_t previous_pts; - int64_t previous_dts; + int64_t video_previous_pts; + int64_t video_previous_dts; + int64_t audio_previous_pts; + int64_t audio_previous_dts; int64_t filter_in_rescale_delta_last; diff --git a/src/zma.cpp b/src/zma.cpp index 4479b4f78..e59a0e65d 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -163,7 +163,7 @@ int main( int argc, char *argv[] ) if ( analysis_update_delay ) { cur_time = time( 0 ); - if ( ( cur_time - last_analysis_update_time ) > analysis_update_delay ) + if ( (unsigned int)( cur_time - last_analysis_update_time ) > analysis_update_delay ) { analysis_rate = monitor->GetAnalysisRate(); monitor->UpdateAdaptiveSkip(); diff --git a/src/zmu.cpp b/src/zmu.cpp index 21b623c4b..c3a795ad4 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -95,8 +95,7 @@ Options for use with monitors: #include "zm_monitor.h" #include "zm_local_camera.h" -void Usage( int status=-1 ) -{ +void Usage( int status=-1 ) { fprintf( stderr, "zmu <-d device_path> [-v] [function] [-U -P]\n" ); fprintf( stderr, "zmu <-m monitor_id> [-v] [function] [-U -P]\n" ); fprintf( stderr, "General options:\n" ); @@ -167,48 +166,38 @@ typedef enum { ZMU_LIST = 0x10000000, } Function; -bool ValidateAccess( User *user, int mon_id, int function ) -{ +bool ValidateAccess( User *user, int mon_id, int function ) { bool allowed = true; - if ( function & (ZMU_STATE|ZMU_IMAGE|ZMU_TIME|ZMU_READ_IDX|ZMU_WRITE_IDX|ZMU_FPS) ) - { + if ( function & (ZMU_STATE|ZMU_IMAGE|ZMU_TIME|ZMU_READ_IDX|ZMU_WRITE_IDX|ZMU_FPS) ) { if ( user->getStream() < User::PERM_VIEW ) allowed = false; } - if ( function & ZMU_EVENT ) - { + if ( function & ZMU_EVENT ) { if ( user->getEvents() < User::PERM_VIEW ) allowed = false; } - if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST) ) - { + if ( function & (ZMU_ZONES|ZMU_QUERY|ZMU_LIST) ) { if ( user->getMonitors() < User::PERM_VIEW ) allowed = false; } - if ( function & (ZMU_ALARM|ZMU_NOALARM|ZMU_CANCEL|ZMU_RELOAD|ZMU_ENABLE|ZMU_DISABLE|ZMU_SUSPEND|ZMU_RESUME|ZMU_BRIGHTNESS|ZMU_CONTRAST|ZMU_HUE|ZMU_COLOUR) ) - { + if ( function & (ZMU_ALARM|ZMU_NOALARM|ZMU_CANCEL|ZMU_RELOAD|ZMU_ENABLE|ZMU_DISABLE|ZMU_SUSPEND|ZMU_RESUME|ZMU_BRIGHTNESS|ZMU_CONTRAST|ZMU_HUE|ZMU_COLOUR) ) { if ( user->getMonitors() < User::PERM_EDIT ) allowed = false; } - if ( mon_id > 0 ) - { - if ( !user->canAccess( mon_id ) ) - { + if ( mon_id > 0 ) { + if ( !user->canAccess( mon_id ) ) { allowed = false; } } - if ( !allowed ) - { + if ( !allowed ) { fprintf( stderr, "Error, insufficient privileges for requested action\n" ); exit( -1 ); } return( allowed ); } -int main( int argc, char *argv[] ) -{ - if ( access(ZM_CONFIG, R_OK) != 0 ) - { +int main( int argc, char *argv[] ) { + if ( access(ZM_CONFIG, R_OK) != 0 ) { fprintf( stderr, "Can't open %s: %s\n", ZM_CONFIG, strerror(errno) ); exit( -1 ); } @@ -274,18 +263,15 @@ int main( int argc, char *argv[] ) int v4lVersion = 1; #endif // ZM_HAS_V4L2/1 #endif // ZM_HAS_V4L - while (1) - { + while (1) { int option_index = 0; int c = getopt_long (argc, argv, "d:m:vsEDLurwei::S:t::fz::ancqhlB::C::H::O::U:P:A:V:", long_options, &option_index); - if (c == -1) - { + if (c == -1) { break; } - switch (c) - { + switch (c) { case 'd': if ( optarg ) device = optarg; @@ -405,8 +391,7 @@ int main( int argc, char *argv[] ) } } - if (optind < argc) - { + if (optind < argc) { fprintf( stderr, "Extraneous options, " ); while (optind < argc) fprintf( stderr, "%s ", argv[optind++]); @@ -414,13 +399,11 @@ int main( int argc, char *argv[] ) Usage(); } - if ( device && !(function&ZMU_QUERY) ) - { + if ( device && !(function&ZMU_QUERY) ) { fprintf( stderr, "Error, -d option cannot be used with this option\n" ); Usage(); } - if ( scale != -1 && !(function&ZMU_IMAGE) ) - { + if ( scale != -1 && !(function&ZMU_IMAGE) ) { fprintf( stderr, "Error, -S option cannot be used with this option\n" ); Usage(); } @@ -435,46 +418,36 @@ int main( int argc, char *argv[] ) User *user = 0; - if ( config.opt_use_auth ) - { - if ( strcmp( config.auth_relay, "none" ) == 0 ) - { - if ( !username ) - { + if ( config.opt_use_auth ) { + if ( strcmp( config.auth_relay, "none" ) == 0 ) { + if ( !username ) { fprintf( stderr, "Error, username must be supplied\n" ); exit( -1 ); } - if ( username ) - { + if ( username ) { user = zmLoadUser( username ); } - } - else - { - if ( !(username && password) && !auth ) - { + } else { + if ( !(username && password) && !auth ) { fprintf( stderr, "Error, username and password or auth string must be supplied\n" ); exit( -1 ); } //if ( strcmp( config.auth_relay, "hashed" ) == 0 ) { - if ( auth ) - { + if ( auth ) { user = zmLoadAuthUser( auth, false ); } } //else if ( strcmp( config.auth_relay, "plain" ) == 0 ) { - if ( username && password ) - { + if ( username && password ) { user = zmLoadUser( username, password ); } } } - if ( !user ) - { + if ( !user ) { fprintf( stderr, "Error, unable to authenticate user\n" ); exit( -1 ); } @@ -482,13 +455,10 @@ int main( int argc, char *argv[] ) } - if ( mon_id > 0 ) - { + if ( mon_id > 0 ) { Monitor *monitor = Monitor::Load( mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY ); - if ( monitor ) - { - if ( verbose ) - { + if ( monitor ) { + if ( verbose ) { printf( "Monitor %d(%s)\n", monitor->Id(), monitor->Name() ); } if ( ! monitor->connect() ) { @@ -498,23 +468,19 @@ int main( int argc, char *argv[] ) char separator = ' '; bool have_output = false; - if ( function & ZMU_STATE ) - { + if ( function & ZMU_STATE ) { Monitor::State state = monitor->GetState(); 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; } } - if ( function & ZMU_TIME ) - { + if ( function & ZMU_TIME ) { struct timeval timestamp = monitor->GetTimestamp( image_idx ); - if ( verbose ) - { + if ( verbose ) { char timestamp_str[64] = "None"; if ( timestamp.tv_sec ) strftime( timestamp_str, sizeof(timestamp_str), "%Y-%m-%d %H:%M:%S", localtime( ×tamp.tv_sec ) ); @@ -522,62 +488,50 @@ int main( int argc, char *argv[] ) printf( "Time of last image capture: %s.%02ld\n", timestamp_str, timestamp.tv_usec/10000 ); else printf( "Time of image %d capture: %s.%02ld\n", image_idx, timestamp_str, timestamp.tv_usec/10000 ); - } - else - { + } else { if ( have_output ) printf( "%c", separator ); printf( "%ld.%02ld", timestamp.tv_sec, timestamp.tv_usec/10000 ); have_output = true; } } - if ( function & ZMU_READ_IDX ) - { + if ( function & ZMU_READ_IDX ) { if ( verbose ) printf( "Last read index: %d\n", monitor->GetLastReadIndex() ); - else - { + else { if ( have_output ) printf( "%c", separator ); printf( "%d", monitor->GetLastReadIndex() ); have_output = true; } } - if ( function & ZMU_WRITE_IDX ) - { + if ( function & ZMU_WRITE_IDX ) { if ( verbose ) printf( "Last write index: %d\n", monitor->GetLastWriteIndex() ); - else - { + else { if ( have_output ) printf( "%c", separator ); printf( "%d", monitor->GetLastWriteIndex() ); have_output = true; } } - if ( function & ZMU_EVENT ) - { + if ( function & ZMU_EVENT ) { if ( verbose ) printf( "Last event id: %d\n", monitor->GetLastEvent() ); - else - { + else { if ( have_output ) printf( "%c", separator ); printf( "%d", monitor->GetLastEvent() ); have_output = true; } } - if ( function & ZMU_FPS ) - { + if ( function & ZMU_FPS ) { if ( verbose ) printf( "Current capture rate: %.2f frames per second\n", monitor->GetFPS() ); - else - { + else { if ( have_output ) printf( "%c", separator ); printf( "%.2f", monitor->GetFPS() ); have_output = true; } } - if ( function & ZMU_IMAGE ) - { - if ( verbose ) - { + if ( function & ZMU_IMAGE ) { + if ( verbose ) { if ( image_idx == -1 ) printf( "Dumping last image captured to Monitor%d.jpg", monitor->Id() ); else @@ -588,77 +542,63 @@ int main( int argc, char *argv[] ) } monitor->GetImage( image_idx, scale>0?scale:100 ); } - if ( function & ZMU_ZONES ) - { + if ( function & ZMU_ZONES ) { if ( verbose ) printf( "Dumping zone image to Zones%d.jpg\n", monitor->Id() ); monitor->DumpZoneImage( zoneString ); } - if ( function & ZMU_ALARM ) - { + if ( function & ZMU_ALARM ) { if ( verbose ) printf( "Forcing alarm on\n" ); monitor->ForceAlarmOn( config.forced_alarm_score, "Forced Web" ); } - if ( function & ZMU_NOALARM ) - { + if ( function & ZMU_NOALARM ) { if ( verbose ) printf( "Forcing alarm off\n" ); monitor->ForceAlarmOff(); } - if ( function & ZMU_CANCEL ) - { + if ( function & ZMU_CANCEL ) { if ( verbose ) printf( "Cancelling forced alarm on/off\n" ); monitor->CancelForced(); } - if ( function & ZMU_RELOAD ) - { + if ( function & ZMU_RELOAD ) { if ( verbose ) printf( "Reloading monitor settings\n" ); monitor->actionReload(); } - if ( function & ZMU_ENABLE ) - { + if ( function & ZMU_ENABLE ) { if ( verbose ) printf( "Enabling event generation\n" ); monitor->actionEnable(); } - if ( function & ZMU_DISABLE ) - { + if ( function & ZMU_DISABLE ) { if ( verbose ) printf( "Disabling event generation\n" ); monitor->actionDisable(); } - if ( function & ZMU_SUSPEND ) - { + if ( function & ZMU_SUSPEND ) { if ( verbose ) printf( "Suspending event generation\n" ); monitor->actionSuspend(); } - if ( function & ZMU_RESUME ) - { + if ( function & ZMU_RESUME ) { if ( verbose ) printf( "Resuming event generation\n" ); monitor->actionResume(); } - if ( function & ZMU_QUERY ) - { + if ( function & ZMU_QUERY ) { char monString[16382] = ""; monitor->DumpSettings( monString, verbose ); printf( "%s\n", monString ); } - if ( function & ZMU_BRIGHTNESS ) - { - if ( verbose ) - { + if ( function & ZMU_BRIGHTNESS ) { + if ( verbose ) { if ( brightness >= 0 ) printf( "New brightness: %d\n", monitor->actionBrightness( brightness ) ); else printf( "Current brightness: %d\n", monitor->actionBrightness() ); - } - else - { + } else { if ( have_output ) printf( "%c", separator ); if ( brightness >= 0 ) printf( "%d", monitor->actionBrightness( brightness ) ); @@ -667,17 +607,13 @@ int main( int argc, char *argv[] ) have_output = true; } } - if ( function & ZMU_CONTRAST ) - { - if ( verbose ) - { + if ( function & ZMU_CONTRAST ) { + if ( verbose ) { if ( contrast >= 0 ) printf( "New brightness: %d\n", monitor->actionContrast( contrast ) ); else printf( "Current contrast: %d\n", monitor->actionContrast() ); - } - else - { + } else { if ( have_output ) printf( "%c", separator ); if ( contrast >= 0 ) printf( "%d", monitor->actionContrast( contrast ) ); @@ -686,17 +622,13 @@ int main( int argc, char *argv[] ) have_output = true; } } - if ( function & ZMU_HUE ) - { - if ( verbose ) - { + if ( function & ZMU_HUE ) { + if ( verbose ) { if ( hue >= 0 ) printf( "New hue: %d\n", monitor->actionHue( hue ) ); else printf( "Current hue: %d\n", monitor->actionHue() ); - } - else - { + } else { if ( have_output ) printf( "%c", separator ); if ( hue >= 0 ) printf( "%d", monitor->actionHue( hue ) ); @@ -705,17 +637,13 @@ int main( int argc, char *argv[] ) have_output = true; } } - if ( function & ZMU_COLOUR ) - { - if ( verbose ) - { + if ( function & ZMU_COLOUR ) { + if ( verbose ) { if ( colour >= 0 ) printf( "New colour: %d\n", monitor->actionColour( colour ) ); else printf( "Current colour: %d\n", monitor->actionColour() ); - } - else - { + } else { if ( have_output ) printf( "%c", separator ); if ( colour >= 0 ) printf( "%d", monitor->actionColour( colour ) ); @@ -724,26 +652,19 @@ int main( int argc, char *argv[] ) have_output = true; } } - if ( have_output ) - { + if ( have_output ) { printf( "\n" ); } - if ( !function ) - { + if ( !function ) { Usage(); } delete monitor; - } - else - { + } else { fprintf( stderr, "Error, invalid monitor id %d\n", mon_id ); exit( -1 ); } - } - else - { - if ( function & ZMU_QUERY ) - { + } else { + if ( function & ZMU_QUERY ) { #if ZM_HAS_V4L char vidString[0x10000] = ""; bool ok = LocalCamera::GetCurrentSettings( device, vidString, v4lVersion, verbose ); @@ -755,24 +676,20 @@ int main( int argc, char *argv[] ) #endif // ZM_HAS_V4L } - if ( function & ZMU_LIST ) - { + if ( function & ZMU_LIST ) { std::string sql = "select Id, Function+0 from Monitors"; - if ( !verbose ) - { + if ( !verbose ) { sql += "where Function != 'None'"; } sql += " order by Id asc"; - if ( mysql_query( &dbconn, sql.c_str() ) ) - { + if ( mysql_query( &dbconn, sql.c_str() ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { + if ( !result ) { Error( "Can't use query result: %s", mysql_error( &dbconn ) ); exit( mysql_errno( &dbconn ) ); } @@ -780,17 +697,13 @@ int main( int argc, char *argv[] ) Debug( 1, "Got %d monitors", n_monitors ); printf( "%4s%5s%6s%9s%14s%6s%6s%8s%8s\n", "Id", "Func", "State", "TrgState", "LastImgTim", "RdIdx", "WrIdx", "LastEvt", "FrmRate" ); - for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) - { + for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { int mon_id = atoi(dbrow[0]); int function = atoi(dbrow[1]); - if ( !user || user->canAccess( mon_id ) ) - { - if ( function > 1 ) - { + if ( !user || user->canAccess( mon_id ) ) { + if ( function > 1 ) { Monitor *monitor = Monitor::Load( mon_id, false, Monitor::QUERY ); - if ( monitor && monitor->connect() ) - { + if ( monitor && monitor->connect() ) { struct timeval tv = monitor->GetTimestamp(); printf( "%4d%5d%6d%9d%11ld.%02ld%6d%6d%8d%8.2f\n", monitor->Id(), @@ -805,9 +718,7 @@ int main( int argc, char *argv[] ) ); delete monitor; } - } - else - { + } else { struct timeval tv = { 0, 0 }; printf( "%4d%5d%6d%9d%11ld.%02ld%6d%6d%8d%8.2f\n", mon_id, diff --git a/utils/packpack/startpackpack.sh b/utils/packpack/startpackpack.sh index 51b6c4a58..a64be651a 100755 --- a/utils/packpack/startpackpack.sh +++ b/utils/packpack/startpackpack.sh @@ -39,6 +39,23 @@ checksanity () { } +# Check key variables before calling packpack +checkvars () { + if [ -z ${VERSION} ]; then + echo + echo "FATAL: VERSION variable was null. Cannot continue." + echo + exit 98 + fi + + if [ -z ${RELEASE} ]; then + echo + echo "FATAL: RELEASE variable was null. Cannot Continue" + echo + exit 98 + fi +} + # Steps common to all builds commonprep () { mkdir -p build @@ -46,7 +63,7 @@ commonprep () { echo "Checking packpack github repo for changes..." git -C packpack pull origin master else - echo "Cloning pakcpack github repo..." + echo "Cloning packpack github repo..." git clone https://github.com/packpack/packpack.git packpack fi @@ -116,7 +133,7 @@ installtrusty () { # This sets the naming convention for the deb packages setdebpkgver () { - + # Set VERSION to x.xx.x+x e.g. 1.30.2+15 # the last x is number of commits since release # Creates zoneminder packages in the format: zoneminder-{version}-{release} @@ -125,6 +142,8 @@ setdebpkgver () { export VERSION="$zmver+$commitnum" export RELEASE="${DIST}" + checkvars + echo echo "Packpack VERSION has been set to: ${VERSION}" echo "Packpack RELEASE has been set to: ${RELEASE}" @@ -132,6 +151,16 @@ setdebpkgver () { } +# This adds an entry to the debian changelog +setdebchangelog () { +DATE=`date -R` +cat < debian/changelog +zoneminder ($VERSION-${DIST}-1) unstable; urgency=low + * + -- Isaac Connor $DATE +EOF +} + ################ # MAIN PROGRAM # ################ @@ -154,6 +183,8 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then export VERSION=$(git describe --long --always | sed -n 's/^\([0-9\.]*\)-\([0-9]*\)-\([a-z0-9]*\)/\1/p') export RELEASE=$(git describe --long --always | sed -n 's/^\([0-9\.]*\)-\([0-9]*\)-\([a-z0-9]*\)/\2/p') + checkvars + echo echo "Packpack VERSION has been set to: ${VERSION}" echo "Packpack RELEASE has been set to: ${RELEASE}" @@ -199,7 +230,9 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then else ln -sfT distros/ubuntu1604 debian fi - + + setdebchangelog + echo "Starting packpack..." packpack/packpack @@ -218,6 +251,8 @@ elif [ "${OS}" == "ubuntu" ] && [ "${DIST}" == "trusty" ] && [ "${ARCH}" == "x86 ln -sfT distros/ubuntu1204 debian + setdebchangelog + echo "Starting packpack..." packpack/packpack diff --git a/version b/version index 593d72103..34aae156b 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.30.4 +1.31.0 diff --git a/web/api/app/Config/bootstrap.php.in b/web/api/app/Config/bootstrap.php.in index ac3bcb62c..a2bfe9c26 100644 --- a/web/api/app/Config/bootstrap.php.in +++ b/web/api/app/Config/bootstrap.php.in @@ -100,12 +100,12 @@ App::uses('CakeLog', 'Log'); CakeLog::config('debug', array( 'engine' => 'File', 'types' => array('notice', 'info', 'debug'), - 'file' => 'cake_debug', + 'file' => '@ZM_LOGDIR@/cake_debug', )); CakeLog::config('error', array( 'engine' => 'File', 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), - 'file' => 'cake_error', + 'file' => '@ZM_LOGDIR@/cake_error', )); CakeLog::config('custom_path', array( 'engine' => 'File', diff --git a/web/includes/Event.php b/web/includes/Event.php index 0e072fb33..f4bf4a3da 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -29,12 +29,15 @@ class Event { Error('No row for Event ' . $IdOrRow ); } } // end function __construct + public function Storage() { return new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL ); } + public function Monitor() { return new Monitor( isset($this->{'MonitorId'}) ? $this->{'MonitorId'} : NULL ); } + public function __call( $fn, array $args){ if ( array_key_exists( $fn, $this ) ) { return $this->{$fn}; @@ -54,6 +57,7 @@ class Event { $Storage = $this->Storage(); return $Storage->Path().'/'.$this->Relative_Path(); } + public function Relative_Path() { $event_path = ''; @@ -197,20 +201,26 @@ class Event { return( $thumbData ); } // end function createListThumbnail + // frame is an array representing the db row for a frame. function getImageSrc( $frame, $scale=SCALE_BASE, $captureOnly=false, $overwrite=false ) { $Storage = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL ); $Event = $this; $eventPath = $Event->Path(); - if ( !is_array($frame) ) + if ( $frame and ! is_array($frame) ) { + # Must be an Id + Debug("Assuming that $frame is an Id"); $frame = array( 'FrameId'=>$frame, 'Type'=>'' ); + } - if ( file_exists( $eventPath.'/snapshot.jpg' ) ) { - $captImage = "snapshot.jpg"; + if ( ( ! $frame ) and file_exists( $eventPath.'/snapshot.jpg' ) ) { + # No frame specified, so look for a snapshot to use + $captImage = 'snapshot.jpg'; + Debug("Frame not specified, using snapshot"); } else { $captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId'] ); if ( ! file_exists( $eventPath.'/'.$captImage ) ) { - # Generate the frame JPG + # Generate the frame JPG if ( $Event->DefaultVideo() ) { $videoPath = $eventPath.'/'.$Event->DefaultVideo(); @@ -275,8 +285,7 @@ class Event { } $thumbFile = $thumbPath; - if ( $overwrite || !file_exists( $thumbFile ) || !filesize( $thumbFile ) ) - { + if ( $overwrite || ! file_exists( $thumbFile ) || ! filesize( $thumbFile ) ) { // Get new dimensions list( $imageWidth, $imageHeight ) = getimagesize( $imagePath ); $thumbWidth = $imageWidth * $fraction; @@ -290,7 +299,7 @@ class Event { if ( !imagejpeg( $thumbImage, $thumbPath ) ) Error( "Can't create thumbnail '$thumbPath'" ); } - } + } # Create thumbnails $imageData = array( 'eventPath' => $eventPath, @@ -298,7 +307,7 @@ class Event { 'thumbPath' => $thumbPath, 'imageFile' => $imagePath, 'thumbFile' => $thumbFile, - 'imageClass' => $alarmFrame?"alarm":"normal", + 'imageClass' => $alarmFrame?'alarm':'normal', 'isAnalImage' => $isAnalImage, 'hasAnalImage' => $hasAnalImage, ); diff --git a/web/includes/Frame.php b/web/includes/Frame.php index eaec94c58..5a31b3dc3 100644 --- a/web/includes/Frame.php +++ b/web/includes/Frame.php @@ -27,9 +27,11 @@ class Frame { Error("No row for Frame " . $IdOrRow ); } } // end function __construct + public function Storage() { return $this->Event()->Storage(); } + public function Event() { return new Event( $this->{'EventId'} ); } @@ -70,7 +72,9 @@ class Frame { } public function getImageSrc( $show='capture' ) { - return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'Id'}.'&show='.$show.'&filename='.$this->Event()->MonitorId().'_'.$this->{'EventId'}.'_'.$this->{'FrameId'}.'.jpg'; + + return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'FrameId'}.'&eid='.$this->{'EventId'}.'&show='.$show; + #return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'Id'}.'&show='.$show.'&filename='.$this->Event()->MonitorId().'_'.$this->{'EventId'}.'_'.$this->{'FrameId'}.'.jpg'; } // end function getImageSrc public static function find( $parameters = array(), $limit = NULL ) { diff --git a/web/includes/functions.php b/web/includes/functions.php index 993d40a9b..8e0004ea9 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -19,7 +19,7 @@ // // Compatibility functions -if ( version_compare( phpversion(), "4.3.0", "<") ) { +if ( version_compare( phpversion(), '4.3.0', '<') ) { function ob_get_clean() { $buffer = ob_get_contents(); ob_end_clean(); @@ -27,27 +27,28 @@ if ( version_compare( phpversion(), "4.3.0", "<") ) { } } +# We are requiring these because this file is getting included from the api, which hasn't already included them. require_once( 'logger.php' ); require_once( 'database.php' ); -function userLogin( $username, $password="", $passwordHashed=false ) { +function userLogin( $username, $password='', $passwordHashed=false ) { global $user, $cookies; - $sql = "select * from Users where Enabled = 1"; + $sql = 'SELECT * FROM Users WHERE Enabled = 1'; $sql_values = NULL; - if ( ZM_AUTH_TYPE == "builtin" ) { + if ( ZM_AUTH_TYPE == 'builtin' ) { if ( $passwordHashed ) { - $sql .= " AND Username=? AND Password=?"; + $sql .= ' AND Username=? AND Password=?'; } else { - $sql .= " AND Username=? AND Password=password(?)"; + $sql .= ' AND Username=? AND Password=password(?)'; } $sql_values = array( $username, $password ); } else { - $sql .= " AND Username = ?"; + $sql .= ' AND Username = ?'; $sql_values = array( $username ); } $_SESSION['username'] = $username; - if ( ZM_AUTH_RELAY == "plain" ) { + if ( ZM_AUTH_RELAY == 'plain' ) { // Need to save this in session $_SESSION['password'] = $password; } @@ -56,7 +57,7 @@ function userLogin( $username, $password="", $passwordHashed=false ) { Info( "Login successful for user \"$username\"" ); $_SESSION['user'] = $user = $dbUser; unset($_SESSION['loginFailed']); - if ( ZM_AUTH_TYPE == "builtin" ) { + if ( ZM_AUTH_TYPE == 'builtin' ) { $_SESSION['passwordHash'] = $user['Password']; } session_regenerate_id(); @@ -82,11 +83,11 @@ function userLogout() { } function noCacheHeaders() { - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past - header("Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT"); // always modified - header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); // HTTP/1.0 + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past + header('Last-Modified: '.gmdate( 'D, d M Y H:i:s' ).' GMT'); // always modified + header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 + header('Cache-Control: post-check=0, pre-check=0', false); + header('Pragma: no-cache'); // HTTP/1.0 } function CORSHeaders() { @@ -103,28 +104,28 @@ function CORSHeaders() { $Server = new Server( $row ); if ( $_SERVER['HTTP_ORIGIN'] == $Server->Url() ) { $valid = true; - header("Access-Control-Allow-Origin: " . $Server->Url() ); - header("Access-Control-Allow-Headers: x-requested-with,x-request"); + header('Access-Control-Allow-Origin: ' . $Server->Url() ); + header('Access-Control-Allow-Headers: x-requested-with,x-request'); } } if ( ! $valid ) { - Warning( $_SERVER['HTTP_ORIGIN'] . " is not found in servers list." ); + Warning( $_SERVER['HTTP_ORIGIN'] . ' is not found in servers list.' ); } } } function getAuthUser( $auth ) { - if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" && !empty($auth) ) { - $remoteAddr = ""; + if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' && !empty($auth) ) { + $remoteAddr = ''; if ( ZM_AUTH_HASH_IPS ) { $remoteAddr = $_SERVER['REMOTE_ADDR']; if ( !$remoteAddr ) { Error( "Can't determine remote address for authentication, using empty string" ); - $remoteAddr = ""; + $remoteAddr = ''; } } - $sql = "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Enabled = 1"; + $sql = 'select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Enabled = 1'; foreach ( dbFetchAll( $sql ) as $user ) { $now = time(); for ( $i = 0; $i < 2; $i++, $now -= (60*60) ) { // Try for last two hours @@ -143,7 +144,7 @@ function getAuthUser( $auth ) { } function generateAuthHash( $useRemoteAddr ) { - if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == "hashed" ) { + if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) { $time = localtime(); if ( $useRemoteAddr ) { $authKey = ZM_AUTH_HASH_SECRET.$_SESSION['username'].$_SESSION['passwordHash'].$_SESSION['remoteAddr'].$time[2].$time[3].$time[4].$time[5]; @@ -152,7 +153,7 @@ function generateAuthHash( $useRemoteAddr ) { } $auth = md5( $authKey ); } else { - $auth = ""; + $auth = ''; } return( $auth ); } @@ -161,24 +162,24 @@ function getStreamSrc( $args, $querySep='&' ) { $streamSrc = ZM_BASE_URL.ZM_PATH_ZMS; if ( ZM_OPT_USE_AUTH ) { - if ( ZM_AUTH_RELAY == "hashed" ) { - $args[] = "auth=".generateAuthHash( ZM_AUTH_HASH_IPS ); - } elseif ( ZM_AUTH_RELAY == "plain" ) { - $args[] = "user=".$_SESSION['username']; - $args[] = "pass=".$_SESSION['password']; - } elseif ( ZM_AUTH_RELAY == "none" ) { - $args[] = "user=".$_SESSION['username']; + if ( ZM_AUTH_RELAY == 'hashed' ) { + $args[] = 'auth='.generateAuthHash( ZM_AUTH_HASH_IPS ); + } elseif ( ZM_AUTH_RELAY == 'plain' ) { + $args[] = 'user='.$_SESSION['username']; + $args[] = 'pass='.$_SESSION['password']; + } elseif ( ZM_AUTH_RELAY == 'none' ) { + $args[] = 'user='.$_SESSION['username']; } } - if ( !in_array( "mode=single", $args ) && !empty($GLOBALS['connkey']) ) { - $args[] = "connkey=".$GLOBALS['connkey']; + if ( !in_array( 'mode=single', $args ) && !empty($GLOBALS['connkey']) ) { + $args[] = 'connkey='.$GLOBALS['connkey']; } if ( ZM_RAND_STREAM ) { - $args[] = "rand=".time(); + $args[] = 'rand='.time(); } if ( count($args) ) { - $streamSrc .= "?".join( $querySep, $args ); + $streamSrc .= '?'.join( $querySep, $args ); } return( $streamSrc ); @@ -196,11 +197,11 @@ function getMimeType( $file ) { return( trim( exec( 'file -bi '.escapeshellarg( $file ).' 2>/dev/null' ) ) ); } -function outputVideoStream( $id, $src, $width, $height, $format, $title="" ) { +function outputVideoStream( $id, $src, $width, $height, $format, $title='' ) { echo getVideoStreamHTML( $id, $src, $width, $height, $format, $title ); } -function getVideoStreamHTML( $id, $src, $width, $height, $format, $title="" ) { +function getVideoStreamHTML( $id, $src, $width, $height, $format, $title='' ) { $html = ''; $width = validInt($width); $height = validInt($height); @@ -211,24 +212,24 @@ function getVideoStreamHTML( $id, $src, $width, $height, $format, $title="" ) { } else { switch( $format ) { case 'asf' : - $mimeType = "video/x-ms-asf"; + $mimeType = 'video/x-ms-asf'; break; case 'avi' : case 'wmv' : - $mimeType = "video/x-msvideo"; + $mimeType = 'video/x-msvideo'; break; case 'mov' : - $mimeType = "video/quicktime"; + $mimeType = 'video/quicktime'; break; case 'mpg' : case 'mpeg' : - $mimeType = "video/mpeg"; + $mimeType = 'video/mpeg'; break; case 'swf' : - $mimeType = "application/x-shockwave-flash"; + $mimeType = 'application/x-shockwave-flash'; break; case '3gp' : - $mimeType = "video/3gpp"; + $mimeType = 'video/3gpp'; break; default : $mimeType = "video/$format"; @@ -239,9 +240,9 @@ function getVideoStreamHTML( $id, $src, $width, $height, $format, $title="" ) { $mimeType = 'video/'.$format; if ( ZM_WEB_USE_OBJECT_TAGS ) { switch( $mimeType ) { - case "video/x-ms-asf" : - case "video/x-msvideo" : - case "video/mp4" : + case 'video/x-ms-asf' : + case 'video/x-msvideo' : + case 'video/mp4' : { if ( isWindows() ) { return ''; } } - case "video/quicktime" : + case 'video/quicktime' : { return ' '; } - case "application/x-shockwave-flash" : + case 'application/x-shockwave-flash' : { return ''; } -function outputImageStream( $id, $src, $width, $height, $title="" ) { +function outputImageStream( $id, $src, $width, $height, $title='' ) { echo getImageStream( $id, $src, $width, $height, $title ); } -function getImageStream( $id, $src, $width, $height, $title="" ) { +function getImageStream( $id, $src, $width, $height, $title='' ) { if ( canStreamIframe() ) { - return '