Merge branch 'master' into storageareas

This commit is contained in:
Isaac Connor 2017-08-22 09:52:14 -04:00
commit 676c4b7ddc
16 changed files with 327 additions and 155 deletions

View File

@ -26,9 +26,10 @@ addons:
env:
matrix:
- OS=el DIST=6
- OS=el DIST=6 ARCH=i386 DOCKER_REPO=knnniggett/packpack
- OS=el DIST=7
- OS=fedora DIST=24
- OS=fedora DIST=25
- OS=fedora DIST=26 DOCKER_REPO=knnniggett/packpack
- OS=ubuntu DIST=trusty
- OS=ubuntu DIST=xenial
- OS=ubuntu DIST=trusty ARCH=i386

View File

@ -69,20 +69,38 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# GCC below 6.0 doesn't support __target__("fpu=neon") attribute, required for compiling ARM Neon code, otherwise compilation fails.
# Must use -mfpu=neon compiler flag instead, but only do that for processors that support neon, otherwise strip the neon code alltogether,
# because passing -fmpu=neon is unsafe to processors that don't support neon
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
EXEC_PROGRAM(grep ARGS " neon " "/proc/cpuinfo" OUTPUT_VARIABLE neonoutput RETURN_VALUE neonresult)
IF(neonresult EQUAL 0)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfpu=neon")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon")
ELSE(neonresult EQUAL 0)
add_definitions(-DZM_STRIP_NEON=1)
message(STATUS "ARM Neon is not available on this processor. Neon functions will be absent")
ENDIF(neonresult EQUAL 0)
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
# Arm neon support only tested on Linux. If your arm hardware is running a non-Linux distro and is using gcc then contact us.
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ZM_SYSTEM_PROC)
IF((ZM_SYSTEM_PROC STREQUAL "") OR (ZM_SYSTEM_PROC STREQUAL "unknown"))
execute_process(COMMAND uname -m OUTPUT_VARIABLE ZM_SYSTEM_PROC ERROR_VARIABLE ZM_SYSTEM_PROC_ERR)
# maybe make the following error checks fatal
IF(ZM_SYSTEM_PROC_ERR)
message(WARNING "\nAn error occurred while attempting to determine the system processor:\n${ZM_SYSTEM_PROC_ERR}")
ENDIF(ZM_SYSTEM_PROC_ERR)
IF(NOT ZM_SYSTEM_PROC)
message(WARNING "\nUnable to determine the system processor. This may cause a build failure.\n")
ENDIF(ZM_SYSTEM_PROC)
ENDIF((ZM_SYSTEM_PROC STREQUAL "") OR (ZM_SYSTEM_PROC STREQUAL "unknown"))
IF(ZM_SYSTEM_PROC MATCHES "^arm")
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
EXEC_PROGRAM(grep ARGS " neon " "/proc/cpuinfo" OUTPUT_VARIABLE neonoutput RETURN_VALUE neonresult)
IF(neonresult EQUAL 0)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfpu=neon")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon")
ELSE(neonresult EQUAL 0)
add_definitions(-DZM_STRIP_NEON=1)
message(STATUS "ARM Neon is not available on this processor. Neon functions will be absent")
ENDIF(neonresult EQUAL 0)
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
ENDIF(ZM_SYSTEM_PROC MATCHES "^arm")
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
# Modules that we need:
include (GNUInstallDirs)

View File

@ -61,7 +61,7 @@ In *general* a good estimate of memory required would be:
::
Min Memory = 1.2 * ((image-width*image-height*image buffer size*target color space*number of cameras/8/1024/1024 )
Min Bits of Memory = 20% overhead * (image-width*image-height*image buffer size*target color space*number of cameras)
Where:
* image-width and image-height are the width and height of images that your camera is configured for (in my case, 1280x960). This value is in the Source tab for each monitor
@ -69,11 +69,18 @@ Where:
* target color space is the color depth - 8bit, 24bit or 32bit. It's again in the source tab of each monitor
The 1.2 at the start is basically adding 20% on top of the calculation to account for image/stream overheads (this is an estimate)
So let's do the math. If we have 4 cameras running at 1280x960 with 32bit color space and one camera running at 640x480 with 8bit greyscale color space, the system would require:
The math breakdown for 4 cameras running at 1280x960 capture, 50 frame buffer, 24 bit color space:
::
1280*960 = 1,228,800 (bits)
1,228,800 * 24 = 2,359,296,000 (bits)
2,359,296,000 * 50 = 5,898,240,000 (bits)
5,898,240,000 * 4 = 7,077,888,000 (bits)
7,077,888,000 / 8 = 884,736,000 (bytes)
884,736,000 / 1000 = 884,736 (Kilobytes)
884,736 / 1000 = 864 (Megabytes)
864 / 1000 = 0.9 (Gigabyte)
``1.2 * ((1280*960*50*32*4/8/1024/1024 ) + (640 *480 *50*8/8 /1024/1024))``
Or, around 900MB of memory.
Around 900MB of memory.
So if you have 2GB of memory, you should be all set. Right? **Not, really**:

View File

@ -6,6 +6,7 @@ Contents:
.. toctree::
:maxdepth: 2
packpack
ubuntu
debian
redhat

View File

@ -0,0 +1,105 @@
All Distros - A Simpler Way to Build ZoneMinder
===============================================
.. contents::
These instructions represent an alternative way to build ZoneMinder for any supported distro.
Advantages:
- Fewer steps and therefore much simpler
- Target distro agnostic - the steps are the same regardless of the target distro
- Host distro agnostic - the steps described here should work on any host Linux distro capable of running Bash and Docker
Background
------------------------------------
These instructions leverage the power of the automated build system recently implemented in the ZoneMinder project. Behind the scenes, a project called `packpack <https://github.com/packpack/packpack>`_ is utilized, to build ZoneMinder inside a Docker container.
Procedure
------------------------------------
**Step 1:** Verify the target distro.
- Open the project's `.travis.yml file <https://github.com/ZoneMinder/ZoneMinder/blob/master/.travis.yml#L27>`_ and verify the distro you want to build ZoneMinder for appears in the build matrix. The distros shown in the matrix are those known to build on ZoneMinder. If the distro you desire is in the list then continue to step two.
- If the desired distro is not in the first list, then open the `packpack project README <https://github.com/packpack/packpack/blob/master/README.md>`_ and check if the desired distro is theoretically supported. If it is, then continue to step 2 with the understanding that you are heading out into uncharted territory. There could be problems.
- If the desired distro does not appear in either list, then unfortuantely you cannot use the procedure described here.
**Step 2:** Install Docker.
You need to have a working installation of Docker so head over to the `Docker site <https://docs.docker.com/engine/installation/>`_ and get it working. Before continuing to the next step, verify you can run the Docker "Hello World" container as a normal user. To run a Docker container as a normal user, issue the following:
::
sudo gpasswd -a <username> docker
newgrp docker
Where <username> is, you guessed it, the user name you log in with.
**Step 3:** Git clone the ZoneMinder project.
Clone the ZoneMinder project if you have not done so already.
::
git clone ZoneMinder
cd ZoneMinder
Alternatively, if you have already cloned the repo and wish to update it, do the following.
::
cd ZoneMinder
git checkout master
git pull origin master
**Step 4:** Checkout the revision of ZoneMinder you wish to build.
A freshly cloned ZoneMinder git repo already points to the most recent commit in the master branch. If you want the latest development code then continue to the next step. If instead, you want to build a stable release then perform the following step.
::
git checkout <releasename>
Where <releasename> is one of the official ZoneMinder releases shown on the `releases page <https://github.com/ZoneMinder/ZoneMinder/releases>`_, such as 1.30.4.
**Step 5:** Build ZoneMinder
To start the build, simply execute the following command from the root folder of the local git repo:
::
OS=<distroname> DIST=<distrorel> utils/packpack/startpackpack.sh
Where <distroname> is the name of the distro you wish to build on, such as fedora, and <distrorev> is release name or number of the distro you wish to build on. Redhat distros expect a number for <distrorev> while Debian and Ubuntu distros expect a name. For example:
::
OS=fedora DIST=25 utils/packpack/startpackpack.sh
::
OS=ubuntu DIST=xenial utils/packpack/startpackpack.sh
Once you enter the appropriate command, go get a coffee while a ZoneMinder package is built. When the build finished, you can find the resulting packages under a subfolder called "build".
Note that this will build packages with x86_64 architecture. This build method can also build on some distros (debian & ubuntu only at the moment) using i386 architecture. You can do that by adding "ARCH=i386" parameter.
::
OS=ubuntu DIST=xenial ARCH=i386 utils/packpack/startpackpack.sh
For advanced users who really want to go out into uncharted waters, it is theoretically possible to build arm packages as well, as long as the host architecture is compatible.
::
OS=ubuntu DIST=xenial ARCH=armhfp utils/packpack/startpackpack.sh
Building arm packages in this manner has not been tested by us, however.

View File

@ -86,7 +86,7 @@ As mentioned above, the place to get the latest ZoneMinder release is now `RPM F
Note that RHEL/CentOS 7 users should use yum instead of dnf.
How to Build a Your Own ZoneMinder Package
How to Build Your Own ZoneMinder Package
------------------------------------------
If you are looking to do development or the available packages just don't suit you, then you can follow these steps to build your own ZoneMinder RPM.
@ -132,7 +132,7 @@ Your build environment is now set up.
Build from SRPM
***************
To continue, you need a ZoneMinder SRPM. If you wish to rebuild a ZoneMinder release, then browse the `RPM Fusion site <http://zmrepo.zoneminder.com/>`_. If instead you wish to rebuild the latest source rpm from our master branch then browse the `Zmrepo site <http://zmrepo.zoneminder.com/>`_.
To continue, you need a ZoneMinder SRPM. If you wish to rebuild a ZoneMinder release, then browse the `RPM Fusion site <https://rpmfusion.org/>`_. If instead you wish to rebuild the latest source rpm from our master branch then browse the `Zmrepo site <http://zmrepo.zoneminder.com/>`_.
For this example, I'll use one of the source rpms from zmrepo:

View File

@ -715,6 +715,25 @@ our @options = (
type => $types{boolean},
category => 'config',
},
{
name => 'ZM_TIMESTAMP_CODE_CHAR',
default => '%',
description => 'Character to used to identify timestamp codes',
help => q`
There are a few codes one can use to tell ZoneMinder to insert
data into the timestamp of each image. Traditionally, the
percent (%) character has been used to identify these codes since
the current character codes do not conflict with the strftime
codes, which can also be used in the timestamp. While this works
well for Linux, this does not work well for BSD operating systems.
Changing the default character to something else, such as an
exclamation point (!), resolves the issue. Note this only affects
the timestamp codes built into ZoneMinder. It has no effect on
the family of strftime codes one can use.
`,
type => $types{string},
category => 'config',
},
{
name => 'ZM_CPU_EXTENSIONS',
default => 'yes',

View File

@ -405,6 +405,7 @@ void EventStream::processCommand( const CmdMsg *msg ) {
}
send_frame = true;
break;
send_frame = true;
}
case CMD_PAN :
{
@ -785,6 +786,7 @@ void EventStream::runStream() {
}
// Figure out if we should send this frame
// If we are streaming and this frame is due to be sent
if ( ((curr_frame_id-1)%frame_mod) == 0 ) {
delta_us = (unsigned int)(frame_data->delta * 1000000);
@ -798,7 +800,7 @@ void EventStream::runStream() {
// We are paused and are just stepping forward or backward one frame
step = 0;
send_frame = true;
} else {
} else if ( !send_frame ) {
// We are paused, and doing nothing
double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent;
if ( actual_delta_time > MAX_STREAM_DELAY ) {

View File

@ -2996,7 +2996,7 @@ void Monitor::TimestampImage( Image *ts_image, const struct timeval *ts_time ) c
const char *s_ptr = label_time_text;
char *d_ptr = label_text;
while ( *s_ptr && ((d_ptr-label_text) < (unsigned int)sizeof(label_text)) ) {
if ( *s_ptr == '%' ) {
if ( *s_ptr == config.timestamp_code_char[0] ) {
bool found_macro = false;
switch ( *(s_ptr+1) ) {
case 'N' :

View File

@ -4,5 +4,5 @@
redhat_package: redhat_bootstrap package
redhat_bootstrap:
sudo yum install -y --nogpgcheck build/zmrepo.noarch.rpm
sudo yum install -y --nogpgcheck build/external-repo.noarch.rpm

View File

@ -9,7 +9,7 @@
# General sanity checks
checksanity () {
# Check to see if this script has access to all the commands it needs
for CMD in set echo curl repoquery git ln mkdir rmdir cat patch; do
for CMD in set echo curl git ln mkdir rmdir cat patch; do
type $CMD 2>&1 > /dev/null
if [ $? -ne 0 ]; then
@ -20,6 +20,19 @@ checksanity () {
fi
done
if [ "${OS}" == "el" ] && [ "${DIST}" == "6" ]; then
type repoquery 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo
echo "ERROR: The script cannot find the required command \"reqoquery\"."
echo "This command is required in order to build ZoneMinder on el6."
echo "Please install the \"yum-utils\" package then try again."
echo
exit 1
fi
fi
# Verify OS & DIST environment variables have been set before calling this script
if [ -z "${OS}" ] || [ -z "${DIST}" ]; then
echo "ERROR: both OS and DIST environment variables must be set"
@ -211,6 +224,26 @@ zoneminder ($VERSION-${DIST}-1) unstable; urgency=low
EOF
}
# start packpack, filter the output if we are running in travis
execpackpack () {
if [ "${OS}" == "el" ] || [ "${OS}" == "fedora" ]; then
parms="-f utils/packpack/redhat_package.mk redhat_package"
else
parms=""
fi
if [ "${TRAVIS}" == "true" ]; then
utils/packpack/heartbeat.sh &
mypid=$!
packpack/packpack $parms > buildlog.txt 2>&1
kill $mypid
tail -n 3000 buildlog.txt | grep -v ONVIF
else
packpack/packpack $parms
fi
}
################
# MAIN PROGRAM #
################
@ -235,31 +268,31 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then
rm -rf web/api/app/Plugin/Crud
mkdir web/api/app/Plugin/Crud
if [ "${OS}" == "el" ]; then
zmrepodistro=${OS}
# We use zmrepo to build el6 only. All other redhat distros use rpm fusion
if [ "${OS}" == "el" ] && [ "${DIST}" == "6" ]; then
baseurl="https://zmrepo.zoneminder.com/el/${DIST}/x86_64/"
reporpm="zmrepo"
# Let repoquery determine the full url and filename to the latest zmrepo package
dlurl=`repoquery --archlist=noarch --repofrompath=zmpackpack,${baseurl} --repoid=zmpackpack --qf="%{location}" ${reporpm} 2> /dev/null`
else
zmrepodistro="f"
reporpm="rpmfusion-free-release"
dlurl="https://download1.rpmfusion.org/free/${OS}/${reporpm}-${DIST}.noarch.rpm"
fi
# Let repoquery determine the full url and filename of the zmrepo rpm we are interested in
result=`repoquery --repofrompath=zmpackpack,https://zmrepo.zoneminder.com/${zmrepodistro}/"${DIST}"/x86_64/ --repoid=zmpackpack --qf="%{location}" zmrepo 2> /dev/null`
if [ -n "$result" ] && [ $? -eq 0 ]; then
echo "Retrieving ZMREPO rpm..."
curl $result > build/zmrepo.noarch.rpm
# Give our downloaded repo rpm a common name so redhat_package.mk can find it
if [ -n "$dlurl" ] && [ $? -eq 0 ]; then
echo "Retrieving ${reporpm} repo rpm..."gd
curl $dlurl > build/external-repo.noarch.rpm
else
echo "ERROR: Failed to retrieve zmrepo rpm..."
echo "ERROR: Failed to retrieve ${reporpm} repo rpm..."
echo "Download url was: $dlurl"
exit 1
fi
setrpmchangelog
echo "Starting packpack..."
utils/packpack/heartbeat.sh &
mypid=$!
packpack/packpack -f utils/packpack/redhat_package.mk redhat_package > buildlog.txt 2>&1
kill $mypid
tail -n 3000 buildlog.txt | grep -v ONVIF
execpackpack
# Steps common to Debian based distros
elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ]; then
@ -279,11 +312,7 @@ if [ "${TRAVIS_EVENT_TYPE}" == "cron" ] || [ "${TRAVIS}" != "true" ]; then
setdebchangelog
echo "Starting packpack..."
utils/packpack/heartbeat.sh &
mypid=$!
packpack/packpack > buildlog.txt 2>&1
kill $mypid
tail -n 3000 buildlog.txt | grep -v ONVIF
execpackpack
if [ "${OS}" == "ubuntu" ] && [ "${DIST}" == "trusty" ] && [ "${ARCH}" == "x86_64" ] && [ "${TRAVIS}" == "true" ]; then
installtrusty
@ -303,11 +332,7 @@ elif [ "${OS}" == "ubuntu" ] && [ "${DIST}" == "trusty" ] && [ "${ARCH}" == "x86
setdebchangelog
echo "Starting packpack..."
utils/packpack/heartbeat.sh &
mypid=$!
packpack/packpack > buildlog.txt 2>&1
kill $mypid
tail -n 3000 buildlog.txt | grep -v ONVIF
execpackpack
# If we are running inside Travis then attempt to install the deb we just built
if [ "${TRAVIS}" == "true" ]; then

View File

@ -29,13 +29,12 @@ define( "ZM_DIR_TEMP", "@ZM_TMPDIR@" );
$configFile = ZM_CONFIG;
$localConfigFile = basename($configFile);
if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 )
{
if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) )
print( "Warning, overriding installed $localConfigFile file with local copy\n" );
else
error_log( "Warning, overriding installed $localConfigFile file with local copy" );
$configFile = $localConfigFile;
if ( file_exists( $localConfigFile ) && filesize( $localConfigFile ) > 0 ) {
if ( php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']) )
print( "Warning, overriding installed $localConfigFile file with local copy\n" );
else
error_log( "Warning, overriding installed $localConfigFile file with local copy" );
$configFile = $localConfigFile;
}
# Process name, value pairs from the main config file first
@ -45,19 +44,19 @@ $configvals = process_configfile($configFile);
# update our config value array with those values
$configSubFolder = ZM_CONFIG_SUBDIR;
if ( is_dir($configSubFolder) ) {
if ( is_readable($configSubFolder) ) {
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
$configvals = array_replace($configvals, process_configfile($filename) );
}
} else {
error_log( "WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder." );
if ( is_readable($configSubFolder) ) {
foreach ( glob("$configSubFolder/*.conf") as $filename ) {
$configvals = array_replace($configvals, process_configfile($filename) );
}
} else {
error_log( "WARNING: ZoneMinder configuration subfolder found but is not readable. Check folder permissions on $configSubFolder." );
}
}
# Now that our array our finalized, define each key => value
# pair in the array as a constant
foreach( $configvals as $key => $value) {
define( $key, $value );
define( $key, $value );
}
//
@ -135,92 +134,87 @@ require_once( 'database.php' );
loadConfig();
$GLOBALS['defaultUser'] = array(
"Username" => "admin",
"Password" => "",
"Language" => "",
"Enabled" => 1,
"Stream" => 'View',
"Events" => 'Edit',
"Control" => 'Edit',
"Monitors" => 'Edit',
"Groups" => 'Edit',
"Devices" => 'Edit',
"System" => 'Edit',
"MaxBandwidth" => "",
"MonitorIds" => false
"Username" => "admin",
"Password" => "",
"Language" => "",
"Enabled" => 1,
"Stream" => 'View',
"Events" => 'Edit',
"Control" => 'Edit',
"Monitors" => 'Edit',
"Groups" => 'Edit',
"Devices" => 'Edit',
"System" => 'Edit',
"MaxBandwidth" => "",
"MonitorIds" => false
);
function loadConfig( $defineConsts=true )
{
global $config;
global $configCats;
global $dbConn;
function loadConfig( $defineConsts=true ) {
global $config;
global $configCats;
global $dbConn;
$config = array();
$configCat = array();
$config = array();
$configCat = array();
$result = $dbConn->query( 'select * from Config order by Id asc' );
if ( !$result )
echo mysql_error();
$monitors = array();
while( $row = dbFetchNext( $result ) )
{
if ( $defineConsts )
define( $row['Name'], $row['Value'] );
$config[$row['Name']] = $row;
if ( !($configCat = &$configCats[$row['Category']]) )
{
$configCats[$row['Category']] = array();
$configCat = &$configCats[$row['Category']];
}
$configCat[$row['Name']] = $row;
$result = $dbConn->query( 'select * from Config order by Id asc' );
if ( !$result )
echo mysql_error();
$monitors = array();
while( $row = dbFetchNext( $result ) ) {
if ( $defineConsts )
define( $row['Name'], $row['Value'] );
$config[$row['Name']] = $row;
if ( !($configCat = &$configCats[$row['Category']]) ) {
$configCats[$row['Category']] = array();
$configCat = &$configCats[$row['Category']];
}
//print_r( $config );
//print_r( $configCats );
$configCat[$row['Name']] = $row;
}
//print_r( $config );
//print_r( $configCats );
}
require_once( 'logger.php' );
// For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID
if ( ! defined('ZM_SERVER_ID') ) {
if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME));
if ( ! $server_id ) {
Error("Invalid Multi-Server configration detected. ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in zm.conf, but no corresponding entry found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
} else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST));
if ( ! $server_id ) {
Error("Invalid Multi-Server configration detected. ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in zm.conf, but no corresponding entry found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
}
if ( defined('ZM_SERVER_NAME') and ZM_SERVER_NAME ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_NAME));
if ( ! $server_id ) {
Error("Invalid Multi-Server configration detected. ZM_SERVER_NAME set to " . ZM_SERVER_NAME . " in zm.conf, but no corresponding entry found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
} else if ( defined('ZM_SERVER_HOST') and ZM_SERVER_HOST ) {
$server_id = dbFetchOne('SELECT Id FROM Servers WHERE Name=?', 'Id', array(ZM_SERVER_HOST));
if ( ! $server_id ) {
Error("Invalid Multi-Server configration detected. ZM_SERVER_HOST set to " . ZM_SERVER_HOST . " in zm.conf, but no corresponding entry found in Servers table.");
} else {
define( 'ZM_SERVER_ID', $server_id );
}
}
}
function process_configfile($configFile) {
if ( is_readable( $configFile ) ) {
$configvals = array();
if ( is_readable( $configFile ) ) {
$configvals = array();
$cfg = fopen( $configFile, "r") or die("Could not open config file.");
while ( !feof($cfg) )
{
$str = fgets( $cfg, 256 );
if ( preg_match( '/^\s*$/', $str ))
continue;
elseif ( preg_match( '/^\s*#/', $str ))
continue;
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches )) {
$configvals[$matches[1]] = $matches[2];
}
}
fclose( $cfg );
return( $configvals );
} else {
error_log( "WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile." );
return( false );
$cfg = fopen( $configFile, 'r') or Error("Could not open config file: $configFile.");
while ( !feof($cfg) ) {
$str = fgets( $cfg, 256 );
if ( preg_match( '/^\s*$/', $str ))
continue;
elseif ( preg_match( '/^\s*#/', $str ))
continue;
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
$configvals[$matches[1]] = $matches[2];
}
fclose( $cfg );
return( $configvals );
} else {
error_log( "WARNING: ZoneMinder configuration file found but is not readable. Check file permissions on $configFile." );
return( false );
}
}
?>

View File

@ -18,9 +18,9 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
define( "DB_LOG_OFF", 0 );
define( "DB_LOG_ONLY", 1 );
define( "DB_LOG_DEBUG", 2 );
define( 'DB_LOG_OFF', 0 );
define( 'DB_LOG_ONLY', 1 );
define( 'DB_LOG_DEBUG', 2 );
$GLOBALS['dbLogLevel'] = DB_LOG_OFF;
@ -42,7 +42,6 @@ function dbConnect() {
}
try {
$dbOptions = null;
if ( defined( 'ZM_DB_SSL_CA_CERT' ) and ZM_DB_SSL_CA_CERT ) {
$dbOptions = array(
@ -54,11 +53,12 @@ function dbConnect() {
} else {
$dbConn = new PDO( ZM_DB_TYPE . $socket . ';dbname='.ZM_DB_NAME, ZM_DB_USER, ZM_DB_PASS );
}
$dbConn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $ex ) {
echo "Unable to connect to ZM db." . $ex->getMessage();
error_log("Unable to connect to ZM DB " . $ex->getMessage() );
echo 'Unable to connect to ZM db.' . $ex->getMessage();
error_log('Unable to connect to ZM DB ' . $ex->getMessage() );
$dbConn = null;
}
}
@ -103,7 +103,7 @@ function dbError( $sql ) {
function dbEscape( $string ) {
global $dbConn;
if ( version_compare( phpversion(), "4.3.0", "<") )
if ( version_compare( phpversion(), '4.3.0', '<') )
if ( get_magic_quotes_gpc() )
return( $dbConn->quote( stripslashes( $string ) ) );
else
@ -229,7 +229,7 @@ function getTableColumns( $table, $asString=1 ) {
}
function getTableAutoInc( $table ) {
$row = dbFetchOne( "show table status where Name=?", NULL, array($table) );
$row = dbFetchOne( 'show table status where Name=?', NULL, array($table) );
return( $row['Auto_increment'] );
}
@ -341,11 +341,11 @@ function getTableDescription( $table, $asString=1 ) {
}
function dbFetchMonitor( $mid ) {
return( dbFetchOne( "select * from Monitors where Id = ?", NULL, array($mid) ) );
return( dbFetchOne( 'select * from Monitors where Id = ?', NULL, array($mid) ) );
}
function dbFetchGroup( $gid ) {
return( dbFetchOne( "select * from Groups where Id = ?", NULL, array($gid) ) );
return( dbFetchOne( 'select * from Groups where Id = ?', NULL, array($gid) ) );
}
?>

View File

@ -52,15 +52,15 @@
}
#imageFrame div {
background-image: url(../../../graphics/point-g.gif);
background-image: url(../../../graphics/point-g.png);
}
#imageFrame div.highlight {
background-image: url(../../../graphics/point-o.gif);
background-image: url(../../../graphics/point-o.png);
}
#imageFrame div.active {
background-image: url(../../../graphics/point-r.gif);
background-image: url(../../../graphics/point-r.png);
}
#zonePoints {

View File

@ -52,15 +52,15 @@
}
#imageFrame div {
background-image: url(../../../graphics/point-g.gif);
background-image: url(../../../graphics/point-g.png);
}
#imageFrame div.highlight {
background-image: url(../../../graphics/point-o.gif);
background-image: url(../../../graphics/point-o.png);
}
#imageFrame div.active {
background-image: url(../../../graphics/point-r.gif);
background-image: url(../../../graphics/point-r.png);
}
#zonePoints {

View File

@ -52,15 +52,15 @@
}
#imageFrame div {
background-image: url(../../../graphics/point-g.gif);
background-image: url(../../../graphics/point-g.png);
}
#imageFrame div.highlight {
background-image: url(../../../graphics/point-o.gif);
background-image: url(../../../graphics/point-o.png);
}
#imageFrame div.active {
background-image: url(../../../graphics/point-r.gif);
background-image: url(../../../graphics/point-r.png);
}
#zonePoints {