2008-07-14 21:54:50 +08:00
< ? php
//
// ZoneMinder web configuration file, $Date$, $Revision$
2008-07-25 17:48:16 +08:00
// Copyright (C) 2001-2008 Philip Coombes
2008-07-14 21:54:50 +08:00
//
// 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
2016-12-26 23:23:16 +08:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2008-07-14 21:54:50 +08:00
//
//
// This section contains options substituted by the zmconfig.pl utility, do not edit these directly
//
define ( " ZM_CONFIG " , " @ZM_CONFIG@ " ); // Path to config file
2013-11-01 21:47:28 +08:00
// Define, and override any given in config file
define ( " ZM_VERSION " , " @VERSION@ " ); // Version
2017-05-17 23:30:39 +08:00
define ( " ZM_DIR_TEMP " , " @ZM_TMPDIR@ " );
2008-07-14 21:54:50 +08:00
2011-06-21 17:19:10 +08:00
$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 ;
}
$cfg = fopen ( $configFile , " r " ) or die ( " Could not open config file. " );
2008-07-14 21:54:50 +08:00
while ( ! feof ( $cfg ) )
{
$str = fgets ( $cfg , 256 );
if ( preg_match ( '/^\s*$/' , $str ))
continue ;
elseif ( preg_match ( '/^\s*#/' , $str ))
continue ;
2013-11-04 04:52:37 +08:00
elseif ( preg_match ( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/' , $str , $matches ))
2008-07-14 21:54:50 +08:00
define ( $matches [ 1 ], $matches [ 2 ] );
}
fclose ( $cfg );
//
// This section is options normally derived from other options or configuration
//
define ( " ZMU_PATH " , ZM_PATH_BIN . " /zmu " ); // Local path to the ZoneMinder Utility
2008-10-28 22:25:12 +08:00
//
2011-02-16 05:59:06 +08:00
// If setup supports Video 4 Linux v2 and/or v1
2008-10-28 22:25:12 +08:00
//
2011-02-16 05:59:06 +08:00
define ( " ZM_HAS_V4L2 " , " @ZM_HAS_V4L2@ " ); // V4L2 support enabled
define ( " ZM_HAS_V4L1 " , " @ZM_HAS_V4L1@ " ); // V4L1 support enabled
define ( " ZM_HAS_V4L " , " @ZM_HAS_V4L@ " ); // V4L support enabled
2008-10-28 22:25:12 +08:00
2015-02-22 01:12:07 +08:00
//
// If ONVIF support has been built in
//
define ( " ZM_HAS_ONVIF " , " @ZM_HAS_ONVIF@ " ); // ONVIF support enabled
2008-12-06 02:41:14 +08:00
//
// If PCRE dev libraries are installed
//
define ( " ZM_PCRE " , " @ZM_PCRE@ " ); // PCRE support enabled
2008-07-14 21:54:50 +08:00
//
// Alarm states
//
define ( " STATE_IDLE " , 0 );
define ( " STATE_PREALARM " , 1 );
define ( " STATE_ALARM " , 2 );
define ( " STATE_ALERT " , 3 );
define ( " STATE_TAPE " , 4 );
//
// DVR Control Commands
//
define ( " MSG_CMD " , 1 );
define ( " MSG_DATA_WATCH " , 2 );
define ( " MSG_DATA_EVENT " , 3 );
define ( " CMD_NONE " , 0 );
define ( " CMD_PAUSE " , 1 );
define ( " CMD_PLAY " , 2 );
define ( " CMD_STOP " , 3 );
define ( " CMD_FASTFWD " , 4 );
define ( " CMD_SLOWFWD " , 5 );
define ( " CMD_SLOWREV " , 6 );
define ( " CMD_FASTREV " , 7 );
define ( " CMD_ZOOMIN " , 8 );
define ( " CMD_ZOOMOUT " , 9 );
define ( " CMD_PAN " , 10 );
define ( " CMD_SCALE " , 11 );
define ( " CMD_PREV " , 12 );
define ( " CMD_NEXT " , 13 );
define ( " CMD_SEEK " , 14 );
2008-11-03 21:16:47 +08:00
define ( " CMD_VARPLAY " , 15 );
2016-04-11 04:33:55 +08:00
define ( " CMD_QUIT " , 17 );
2008-07-14 21:54:50 +08:00
define ( " CMD_QUERY " , 99 );
//
// These are miscellaneous options you won't normally need to change
//
define ( " MAX_EVENTS " , 10 ); // The maximum number of events to show in the monitor event listing
define ( " RATE_BASE " , 100 ); // The additional scaling factor used to help get fractional rates in integer format
define ( " SCALE_BASE " , 100 ); // The additional scaling factor used to help get fractional scales in integer format
//
2014-02-26 23:14:04 +08:00
// Date and time formats, not to be modified by language files
2008-07-14 21:54:50 +08:00
//
2014-02-26 23:14:04 +08:00
define ( " STRF_FMT_DATETIME_DB " , " %Y-%m-%d %H:%M:%S " ); // Strftime format for database queries, don't change
define ( " MYSQL_FMT_DATETIME_SHORT " , " %y/%m/%d %H:%i:%S " ); // MySQL date_format shorter format for dates with time
2008-07-14 21:54:50 +08:00
require_once ( 'database.php' );
loadConfig ();
$GLOBALS [ 'defaultUser' ] = array (
" Username " => " admin " ,
" Password " => " " ,
" Language " => " " ,
" Enabled " => 1 ,
" Stream " => 'View' ,
" Events " => 'Edit' ,
" Control " => 'Edit' ,
" Monitors " => 'Edit' ,
2015-08-16 05:47:07 +08:00
" Groups " => 'Edit' ,
2008-07-14 21:54:50 +08:00
" Devices " => 'Edit' ,
" System " => 'Edit' ,
2008-09-29 21:15:13 +08:00
" MaxBandwidth " => " " ,
2008-09-30 23:29:14 +08:00
" MonitorIds " => false
2008-07-14 21:54:50 +08:00
);
function loadConfig ( $defineConsts = true )
{
global $config ;
global $configCats ;
2013-10-18 04:57:05 +08:00
global $dbConn ;
2008-07-14 21:54:50 +08:00
$config = array ();
$configCat = array ();
2013-10-18 04:57:05 +08:00
$result = $dbConn -> query ( 'select * from Config order by Id asc' );
2008-07-14 21:54:50 +08:00
if ( ! $result )
echo mysql_error ();
$monitors = array ();
2013-10-18 04:57:05 +08:00
while ( $row = dbFetchNext ( $result ) )
2008-07-14 21:54:50 +08:00
{
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 ;
}
//print_r( $config );
//print_r( $configCats );
}
2015-09-15 03:57:22 +08:00
require_once ( 'logger.php' );
2015-07-09 23:45:19 +08:00
// For Human-readability, user ZM_SERVER in zm.conf, and convert it here to a ZM_SERVER_ID
2015-07-17 22:12:44 +08:00
if ( ! defined ( 'ZM_SERVER_ID' ) ) {
2015-09-16 23:12:04 +08:00
if ( defined ( 'ZM_SERVER_NAME' ) and ZM_SERVER_NAME ) {
2015-07-17 22:12:44 +08:00
$server_id = dbFetchOne ( 'SELECT Id FROM Servers WHERE Name=?' , 'Id' , array ( ZM_SERVER_NAME ));
if ( ! $server_id ) {
2016-03-02 01:12:54 +08:00
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. " );
2015-07-17 22:12:44 +08:00
} else {
define ( 'ZM_SERVER_ID' , $server_id );
}
2015-09-16 23:12:04 +08:00
} else if ( defined ( 'ZM_SERVER_HOST' ) and ZM_SERVER_HOST ) {
2015-07-17 22:12:44 +08:00
$server_id = dbFetchOne ( 'SELECT Id FROM Servers WHERE Name=?' , 'Id' , array ( ZM_SERVER_HOST ));
if ( ! $server_id ) {
2016-03-02 01:12:54 +08:00
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. " );
2015-07-17 22:12:44 +08:00
} else {
define ( 'ZM_SERVER_ID' , $server_id );
}
}
2015-07-09 23:45:19 +08:00
}
2008-07-14 21:54:50 +08:00
?>