function addEventToZip($eid, $mid, $zip) { $query = "SELECT Id, MonitorId, StartTime, Frames FROM Events WHERE Id={$eid}"; $results = dbFetchAll($query); $scale = max(reScale(SCALE_BASE, '100', ZM_WEB_DEFAULT_SCALE), SCALE_BASE); foreach ($results as $result) { for ($counter = 1; $counter <= $result['Frames']; $counter++) { $event['Id'] = $result['Id']; $event['StartTime'] = $result['StartTime']; $event['MonitorId'] = $result['MonitorId']; $imageData = getImageSrc($event, $counter, $scale, isset($_REQUEST['show']) && $_REQUEST['show'] == "capt"); $imagePath = $imageData['thumbPath']; $eventPath = $imageData['eventPath']; $dImagePath = sprintf("%s/%0" . ZM_EVENT_IMAGE_DIGITS . "d-diag-d.jpg", $eventPath, $counter); $rImagePath = sprintf("%s/%0" . ZM_EVENT_IMAGE_DIGITS . "d-diag-r.jpg", $eventPath, $counter); $frames[] = viewImagePath($imagePath); } $zip->addDirectory("events/" . $event['MonitorId']); $zip->addDirectory("events/" . $event['MonitorId'] . "/" . $event['Id']); } $i = 0; $filesString = ""; foreach ($frames as $frame) { $i++; $filesName = sprintf("%0" . ZM_EVENT_IMAGE_DIGITS . "d-capture.jpg", $i); $filesString .= "\nframes.push(\"events/" . $mid . "/" . $eid . "/" . $filesName . "\");"; $zip->addLargeFile($frame, "events/" . $mid . "/" . $eid . "/" . $filesName); } return $filesString; }
public static function find($parameters = array(), $limit = NULL) { $sql = 'SELECT * FROM Servers'; $values = array(); if (sizeof($parameters)) { $sql .= ' WHERE ' . implode(' AND ', array_map(function ($v) { return $v . '=?'; }, array_keys($parameters))); $values = array_values($parameters); } if ($limit) { $sql .= ' LIMIT ' . $limit; } $results = dbFetchAll($sql, NULL, $values); if ($results) { return array_map(function ($id) { return new Server($id); }, $results); } }
function getAccountingCategory($selInfo) { $sql = "Select c.category_id,category_name,b.category_detail_id,b.category_detail_name,sum(money) as money from " . $this->table['consumeDetail'] . " a,accounting.consume_category_detail b,accounting.consume_category c Where uid = " . $selInfo['userid'] . " and consume_date >= '" . $selInfo['start_date'] . "' and consume_date <= '" . $selInfo['end_date'] . "'" . " and a.category_detail_id = b.category_detail_id and b.category_id = c.category_id group by c.category_id,category_name,b.category_detail_id,b.category_detail_name Order by money desc"; try { $categoryRet = dbFetchAll($this->DB, $sql); foreach ($categoryRet as $v) { $categoryMoney[$v['category_id']]['category_name'] = $v['category_name']; $categoryMoney[$v['category_id']]['category_id'] = $v['category_id']; if (!isset($categoryMoney[$v['category_id']]['category_detail'])) { $categoryMoney[$v['category_id']]['category_detail'] = array(); } array_push($categoryMoney[$v['category_id']]['category_detail'], array('category_detail_name' => $v['category_detail_name'], 'category_detail_id' => $v['category_detail_id'], 'money' => $v['money'])); //[$v['category_detail_id']]['money'] = $v['money']; // $categoryMoney[$v['category_id']]['category_detail'][$v['category_detail_id']]['category_detail_name'] = $v['category_detail_name']; $categoryMoney[$v['category_id']]['money'] += $v['money']; } } catch (PDOException $e) { } foreach ($categoryMoney as $category_id => $v) { $money[$category_id] = $v['money']; } array_multisort($money, SORT_DESC, $categoryMoney); return array('status' => 200, 'data' => $categoryMoney); }
function controlPresets($monitor, $cmds) { global $SLANG; define("MAX_PRESETS", "12"); $sql = "select * from ControlPresets where MonitorId = '" . $monitor['Id'] . "'"; $labels = array(); foreach (dbFetchAll($sql) as $row) { $labels[$row['Preset']] = $row['Label']; } $presetBreak = (int) (($monitor['NumPresets'] + 1) / ((int) (($monitor['NumPresets'] - 1) / MAX_PRESETS) + 1)); ob_start(); ?> <div class="presetControls"> <!--<div><?php echo $SLANG['Presets']; ?> </div>--> <div> <?php for ($i = 1; $i <= $monitor['NumPresets']; $i++) { ?> <input type="button" class="ptzNumBtn" title="<?php echo isset($labels[$i]) ? $labels[$i] : ""; ?> " value="<?php echo $i; ?> " onclick="controlCmd('<?php echo $cmds['PresetGoto']; echo $i; ?> ');"/><?php if ($i && $i % $presetBreak == 0) { ?> <br/><?php } } ?> </div> <div> <?php if ($monitor['HasHomePreset']) { ?> <input type="button" class="ptzTextBtn" value="<?php echo $SLANG['Home']; ?> " onclick="controlCmd('<?php echo $cmds['PresetHome']; ?> ');"/> <?php } if (canEdit('Monitors') && $monitor['CanSetPresets']) { ?> <input type="button" class="ptzTextBtn" value="<?php echo $SLANG['Set']; ?> " onclick="createPopup( '?view=controlpreset&mid=<?php echo $monitor['Id']; ?> ', 'zmPreset', 'preset' );"/> <?php } ?> </div> </div> <?php return ob_get_clean(); }
// 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. // $sql = "select * from Groups order by Name"; $groups = array(); $selected = false; foreach (dbFetchAll($sql) as $row) { if (!empty($_COOKIE['zmGroup']) && $row['Id'] == $_COOKIE['zmGroup']) { $row['selected'] = true; $selected = true; } else { $row['selected'] = false; } $groups[] = $row; } xhtmlHeaders(__FILE__, translate('Groups')); ?> <body> <div id="page"> <div id="header"> <h2><?php echo translate('Groups');
$exportExt = "html"; break; case 'xml': $exportExt = "xml"; break; default: Fatal("Unrecognised log export format '{$format}'"); } $exportKey = substr(md5(rand()), 0, 8); $exportFile = "zm-log.{$exportExt}"; $exportPath = ZM_PATH_SWAP . "/zm-log-{$exportKey}.{$exportExt}"; if (!($exportFP = fopen($exportPath, "w"))) { Fatal("Unable to open log export file {$exportPath}"); } $logs = array(); foreach (dbFetchAll($sql, NULL, $values) as $log) { $log['DateTime'] = preg_replace('/^\\d+/', strftime("%Y-%m-%d %H:%M:%S", intval($log['TimeKey'])), $log['TimeKey']); $logs[] = $log; } switch ($format) { case 'text': foreach ($logs as $log) { if ($log['Line']) { fprintf($exportFP, "%s %s[%d].%s-%s/%d [%s]\n", $log['DateTime'], $log['Component'], $log['Pid'], $log['Code'], $log['File'], $log['Line'], $log['Message']); } else { fprintf($exportFP, "%s %s[%d].%s-%s [%s]\n", $log['DateTime'], $log['Component'], $log['Pid'], $log['Code'], $log['File'], $log['Message']); } } break; case 'tsv': fprintf($exportFP, translate('DateTime') . "\t" . translate('Component') . "\t" . translate('Pid') . "\t" . translate('Level') . "\t" . translate('Message') . "\t" . translate('File') . "\t" . translate('Line') . "\n");
/** * Do step of gathering of the database configuration * * @param array $params * * @return bool */ function module_cfg_install_db(&$params) { global $error, $lcSettings; global $report_uid, $reportFName; global $checkRequirements; global $requirements; global $isDBConnected; $pdoErrorMsg = ''; $output = ''; $clrNumber = 1; $requirements = doCheckRequirements(); // Remove report file if it was created on the previous step if (@file_exists($reportFName)) { @unlink($reportFName); $report_uid = ''; } $paramFields = array('mysqlhost' => array('title' => xtr('MySQL server name'), 'description' => xtr('Hostname or IP address of your MySQL server.'), 'required' => true), 'mysqlbase' => array('title' => xtr('MySQL database name'), 'description' => xtr('The name of the existing database to use (if the database does not exist on the server, you should create it to continue the installation).'), 'required' => true), 'mysqluser' => array('title' => xtr('MySQL username'), 'description' => xtr('MySQL username. The user must have full access to the database specified above.'), 'required' => true, 'disableAutofill' => true), 'mysqlpass' => array('title' => xtr('MySQL password'), 'description' => xtr('Password for the above MySQL username.'), 'required' => false, 'type' => 'password', 'disableAutofill' => true), 'demo' => array('title' => xtr('Install sample catalog'), 'description' => xtr('Specify whether you would like to setup sample categories and products?'), 'required' => false, 'type' => 'checkbox'), 'mysqlport' => array('title' => xtr('MySQL server port'), 'description' => xtr('If your database server is listening to a non-standard port, specify its number (e.g. 3306).'), 'required' => false, 'section' => 'advanced-mysql'), 'mysqlsock' => array('title' => xtr('MySQL server socket'), 'description' => xtr('If your database server is used a non-standard socket, specify it (e.g. /tmp/mysql-5.1.34.sock).'), 'required' => false, 'section' => 'advanced-mysql'), 'mysqlprefix' => array('title' => xtr('MySQL tables prefix'), 'description' => xtr('The prefix of the shop tables in database'), 'required' => true, 'section' => 'advanced-mysql'), 'xlite_http_host' => array('title' => xtr('Web server name'), 'description' => xtr('Hostname of your web server (E.g.: www.example.com).'), 'required' => true, 'section' => 'advanced-server'), 'xlite_https_host' => array('title' => xtr('Secure web server name'), 'description' => xtr('Hostname of your secure (HTTPS-enabled) web server (E.g.: secure.example.com). If omitted, it is assumed to be the same as the web server name.'), 'required' => false, 'section' => 'advanced-server'), 'xlite_web_dir' => array('title' => xtr('X-Cart web directory'), 'description' => xtr('Path to X-Cart files within the web space of your web server (E.g.: /shop).'), 'required' => false, 'section' => 'advanced-server'), 'date_default_timezone' => array('title' => xtr('Default time zone'), 'description' => xtr('By default, dates in this site will be displayed in the chosen time zone.'), 'select_data' => getTimeZones(true), 'required' => false, 'type' => 'select', 'section' => 'advanced-server')); // Initialize default values for parameters applySuggestedDefValues($paramFields); $messageText = ''; $displayConfigForm = false; foreach ($paramFields as $fieldName => $fieldData) { // Prepare first step data if we came from the second step back if (isset($_POST['go_back']) && $_POST['go_back'] === '1') { if (empty($fieldData['step']) && isset($params[$fieldName])) { $paramFields[$fieldName]['def_value'] = $params[$fieldName]; unset($params[$fieldName]); } } // Unset parameter if its empty if (isset($params[$fieldName])) { $params[$fieldName] = trim($params[$fieldName]); if (empty($params[$fieldName])) { unset($params[$fieldName]); } } // Check if all required parameters presented if (!isset($params[$fieldName])) { $displayConfigForm = $displayConfigForm || $fieldData['required']; } } // Display form to enter host data and database settings if ($displayConfigForm) { ob_start(); foreach ($paramFields as $fieldName => $fieldData) { if (isset($fieldData['step']) && $fieldData['step'] != 1) { continue; } $fieldData['value'] = isset($params[$fieldName]) ? $params[$fieldName] : $fieldData['def_value']; displayFormElement($fieldName, $fieldData, $clrNumber); $clrNumber = $clrNumber == 2 ? 1 : 2; } $output = ob_get_contents(); ob_end_clean(); ?> <input type="hidden" name="cfg_install_db_step" value="1" /> <?php // Display second step: review parameters and enter additional data } else { // Now checking if database named $params[mysqlbase] already exists $checkError = false; $checkWarning = false; if (strstr($params['xlite_http_host'], ':')) { list($_host, $_port) = explode(':', $params['xlite_http_host']); } else { $_host = $params['xlite_http_host']; } if (!$_host) { fatal_error(xtr('The web server name and/or web drectory is invalid (:host). Press \'BACK\' button and review web server settings you provided', array(':host' => $_host)), 'params', 'wrong web server or webdir'); $checkError = true; // Check if database settings provided are valid } else { $connection = dbConnect($params, $pdoErrorMsg); if (!$connection && preg_match('/SQLSTATE.*\\[1049\\].*' . preg_quote($params['mysqlbase']) . '/', $pdoErrorMsg)) { // The specified database not found, try to create x_install_log('The specified database "' . $params['mysqlbase'] . '" not found'); $paramsNoDb = $params; unset($paramsNoDb['mysqlbase']); $pdoErrorMsg = null; $connection = dbConnect($paramsNoDb, $pdoErrorMsg); if ($connection) { $pdoErrorMsg = null; dbExecute('CREATE DATABASE `' . $params['mysqlbase'] . '`;', $pdoErrorMsg); if (empty($pdoErrorMsg)) { x_install_log('The database "' . $params['mysqlbase'] . '" successfully created.'); // Reconnect... $connection = dbConnect($params, $pdoErrorMsg); } else { $connection = null; x_install_log('The database "' . $params['mysqlbase'] . '" cannot be created: ' . $pdoErrorMsg); fatal_error_extended(xtr('The database <i>:dbname</i> cannot be created automatically:pdoerr.<br /> Please go back, create it manually and then proceed with the installation process again.', array(':dbname' => $params['mysqlbase'], ':pdoerr' => ': ' . $pdoErrorMsg)), 'pdo', @$pdoErrorMsg, xtr('kb_note_mysql_issue')); $checkError = true; } } } if ($connection) { $isDBConnected = true; $requirements = doCheckRequirements(); // Check MySQL version $mysqlVersionErr = $currentMysqlVersion = ''; if (!checkMysqlVersion($mysqlVersionErr, $currentMysqlVersion, true)) { fatal_error_extended($mysqlVersionErr . (!empty($currentMysqlVersion) ? '<br />(current version is ' . $currentMysqlVersion . ')' : ''), 'reqs', 'mysql version', xtr('kb_note_mysql_issue')); $checkError = true; } // Check if config.php file is writeable if (!$checkError && !@is_writable(LC_DIR_CONFIG . constant('LC_CONFIG_FILE'))) { fatal_error(xtr('Cannot open file \':filename\' for writing. To install the software, please correct the problem and start the installation again...', array(':filename' => constant('LC_CONFIG_FILE'))), 'file', 'config write failed'); $checkError = true; } elseif (!$checkError) { // Check if X-Cart tables is already exists $mystring = ''; $first = true; $res = dbFetchAll('SHOW TABLES LIKE \'' . get_db_tables_prefix() . '%\''); if (is_array($res)) { foreach ($res as $row) { if (in_array(get_db_tables_prefix() . 'products', $row)) { warning_error(xtr('Installation Wizard has detected X-Cart tables'), 're-install'); $checkWarning = true; break; } } } } } elseif (!$checkError) { preg_match('/SQLSTATE.*\\[(\\d+)\\].*/', $pdoErrorMsg, $match); $code = intval(!empty($match[1]) ? $match[1] : 0); if ('1045' == $code) { fatal_error_extended(xtr('pdo-error-1045', array(':pdoerr' => !empty($pdoErrorMsg) ? $pdoErrorMsg : '')), 'pdo', @$pdoErrorMsg, xtr('kb_note_mysql_issue')); } elseif ('1044' == $code) { fatal_error_extended(xtr('pdo-error-1044', array(':dbuser' => $params['mysqluser'], ':dbname' => $params['mysqlbase'], ':pdoerr' => !empty($pdoErrorMsg) ? $pdoErrorMsg : '')), 'pdo', @$pdoErrorMsg, xtr('kb_note_mysql_issue')); } elseif ('2005' == $code) { fatal_error_extended(xtr('pdo-error-2005', array(':pdoerr' => !empty($pdoErrorMsg) ? $pdoErrorMsg : '')), 'pdo', @$pdoErrorMsg, xtr('kb_note_mysql_issue')); } else { fatal_error_extended(xtr('pdo-error-common', array(':pdoerr' => !empty($pdoErrorMsg) ? $pdoErrorMsg : '')), 'pdo', @$pdoErrorMsg, xtr('kb_note_mysql_issue')); } $checkError = true; } } if (!$checkError && !$checkWarning) { global $autoPost; $autoPost = true; } else { $output = ''; } $error = $checkError; } ?> <?php echo $messageText; ?> <table width="100%" border="0" cellpadding="10"> <?php echo $output; ?> </table> <?php return $displayConfigForm; }
function collectData() { global $statusData; if (isset($_REQUEST['MainFrameID']) && $_REQUEST['MainFrameID'] == "1") { $statusData["event"]["elements"]["MainFrameID"] = array("sql" => "(select FrameID from Frames where EventId=Events.id order by Score desc,FrameId limit 1)"); $statusData["events"]["elements"]["MainFrameID"] = array("sql" => "(select FrameID from Frames where EventId=Events.id order by Score desc,FrameId limit 1)"); } $entitySpec =& $statusData[strtolower(validJsStr($_REQUEST['entity']))]; #print_r( $entitySpec ); if (!canView($entitySpec['permission'])) { ajaxError('Unrecognised action or insufficient permissions'); } if (!empty($entitySpec['func'])) { $data = eval("return( " . $entitySpec['func'] . " );"); } else { $data = array(); $postFuncs = array(); $fieldSql = array(); $joinSql = array(); $groupSql = array(); $elements =& $entitySpec['elements']; $lc_elements = array_change_key_case($elements); $id = false; if (isset($_REQUEST['id'])) { if (!is_array($_REQUEST['id'])) { $id = array(validJsStr($_REQUEST['id'])); } else { $id = array_values($_REQUEST['id']); } } if (!isset($_REQUEST['element'])) { $_REQUEST['element'] = array_keys($elements); } else { if (!is_array($_REQUEST['element'])) { $_REQUEST['element'] = array(validJsStr($_REQUEST['element'])); } } if (isset($entitySpec['selector'])) { if (!is_array($entitySpec['selector'])) { $entitySpec['selector'] = array($entitySpec['selector']); } foreach ($entitySpec['selector'] as $selector) { if (is_array($selector) && isset($selector['table']) && isset($selector['join'])) { $joinSql[] = "left join " . $selector['table'] . " on " . $selector['join']; } } } foreach ($_REQUEST['element'] as $element) { if (!($elementData = $lc_elements[strtolower($element)])) { ajaxError("Bad " . validJsStr($_REQUEST['entity']) . " element " . $element); } if (isset($elementData['func'])) { $data[$element] = eval("return( " . $elementData['func'] . " );"); } else { if (isset($elementData['postFunc'])) { $postFuncs[$element] = $elementData['postFunc']; } else { if (isset($elementData['zmu'])) { $data[$element] = exec(escapeshellcmd(getZmuCommand(" " . $elementData['zmu']))); } else { if (isset($elementData['sql'])) { $fieldSql[] = $elementData['sql'] . " as " . $element; } else { $fieldSql[] = $element; } if (isset($elementData['table']) && isset($elementData['join'])) { $joinSql[] = "left join " . $elementData['table'] . " on " . $elementData['join']; } if (isset($elementData['group'])) { $groupSql[] = $elementData['group']; } } } } } if (count($fieldSql)) { $sql = "select " . join(", ", $fieldSql) . " from " . $entitySpec['table']; if ($joinSql) { $sql .= " " . join(" ", array_unique($joinSql)); } if ($id && !empty($entitySpec['selector'])) { $index = 0; $where = array(); $values = array(); foreach ($entitySpec['selector'] as $selector) { if (is_array($selector)) { $where[] = $selector['selector'] . ' = ?'; $values[] = validInt($id[$index]); } else { $where[] = $selector . ' = ?'; $values[] = validInt($id[$index]); } $index++; } $sql .= " where " . join(" and ", $where); } if ($groupSql) { $sql .= " group by " . join(",", array_unique($groupSql)); } if (!empty($_REQUEST['sort'])) { $arr = explode(' ', $_REQUEST['sort']); $col = validCol($arr[0]); $dir = ""; if (count($arr) == 2) { if ($arr[1] == "desc") { $dir = $arr[1]; } } $sql .= " order by {$col} {$dir}"; } if (!empty($entitySpec['limit'])) { $limit = $entitySpec['limit']; } elseif (!empty($_REQUEST['count'])) { $limit = validInt($_REQUEST['count']); } $limit_offset = ""; if (!empty($_REQUEST['offset'])) { $limit_offset = validInt($_REQUEST['offset']) . ", "; } if (!empty($limit)) { $sql .= " limit " . $limit_offset . $limit; } if (isset($limit) && $limit == 1) { if ($sqlData = dbFetchOne($sql, NULL, $values)) { foreach ($postFuncs as $element => $func) { $sqlData[$element] = eval('return( ' . $func . '( $sqlData ) );'); } $data = array_merge($data, $sqlData); } } else { $count = 0; foreach (dbFetchAll($sql, NULL, $values) as $sqlData) { foreach ($postFuncs as $element => $func) { $sqlData[$element] = eval('return( ' . $func . '( $sqlData ) );'); } $data[] = $sqlData; if (isset($limi) && ++$count >= $limit) { break; } } } } } #print_r( $data ); return $data; }
$camera['monitor']['Port'] = $matches[2]; } elseif ($matches[1] == 'network_rtsp_s0_accessname') { $camera['monitor']['Path'] = $matches[2]; } } } } return $camera; } function probeWansview($ip) { $camera = array('model' => "Wansview Camera", 'monitor' => array('Type' => 'Remote', 'Protocol' => 'http', 'Host' => 'admin:123456@' . $ip, 'Port' => 80, 'Path' => 'videostream.cgi', 'Width' => 640, 'Height' => 480, 'Palette' => 3)); return $camera; } $monitors = array(); foreach (dbFetchAll("select Id, Name, Host from Monitors where Type = 'Remote' order by Host") as $monitor) { if (preg_match('/^(.+)@(.+)$/', $monitor['Host'], $matches)) { //echo "1: ".$matches[2]." = ".gethostbyname($matches[2])."<br/>"; $monitors[gethostbyname($matches[2])] = $monitor; } else { //echo "2: ".$monitor['Host']." = ".gethostbyname($monitor['Host'])."<br/>"; $monitors[gethostbyname($monitor['Host'])] = $monitor; } } $macBases = array('00:40:8c' => array('type' => 'Axis', 'probeFunc' => 'probeAxis'), '00:80:f0' => array('type' => 'Panasonic', 'probeFunc' => 'probePana'), '00:0f:7c' => array('type' => 'ACTi', 'probeFunc' => 'probeACTi'), '00:02:d1' => array('type' => 'Vivotek', 'probeFunc' => 'probeVivotek'), '7c:dd:90' => array('type' => 'Wansview', 'probeFunc' => 'probeWansview'), '78:a5:dd' => array('type' => 'Wansview', 'probeFunc' => 'probeWansview')); unset($output); // Calling arp without the full path was reported to fail on some systems // Use the builtin unix command "type" to tell us where the command is $arp_command = ''; $result = explode(" ", ZM_PATH_ARP); if (!is_executable($result[0])) {
function xhtmlHeaders($file, $title) { $basename = basename($file, '.php'); $viewCssFile = getSkinFile('views/assets/css/' . $basename . '.css'); $viewCssPhpFile = getSkinFile('views/assets/css/' . $basename . '.css.php'); $viewJsFile = getSkinFile('views/assets/js/' . $basename . '.js'); $viewJsPhpFile = getSkinFile('views/assets/js/' . $basename . '.js.php'); extract($GLOBALS, EXTR_OVERWRITE); ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="UTF-8"> <title><?php echo ZM_WEB_TITLE_PREFIX; ?> - <?php echo validHtmlStr($title); ?> </title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/ico" href="skins/<?php echo $skin; ?> /views/assets/images/favicon.ico"> <link rel="shortcut icon" href="skins/<?php echo $skin; ?> /views/assets/images/favicon.ico"> <link rel="apple-touch-icon" href="skins/<?php echo $skin; ?> /views/assets/images/apple-touch-icon-precomposed.png"> <!-- jquery --> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery.min.js"></script> <!-- font awesome --> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/font-awesome.min.css"> <!-- bootstrap --> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/bootstrap.min.js"></script> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/bootstrap.min.css"> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/bootstrap-theme.min.css"> <!-- jqueryui --> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery-ui.min.js"></script> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/jquery/jquery-ui-1.10.4.custom.min.css" type="text/css" media="all" /> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery-ui-timepicker-addon.js"></script> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/jquery-ui-timepicker-addon.css" type="text/css" media="screen"/> <!-- noty --> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/noty/jquery.noty.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/noty/themes/default.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/noty/layouts/top.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/noty/layouts/topRight.js"></script> <!-- colorbox --> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/js/colorbox/colorbox.css"> <script type="text/javascript" src="skins/<?php echo $skin; ?> /views/assets/vendor/js/colorbox/jquery.colorbox-min.js"></script> <!-- main css --> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/css/main.css"> <?php if ($title == "Admin" || $title == "Events" || $title == "Console") { ?> <script type="text/javascript"> var skinVersion = "<?php echo file_get_contents('skins/modern/VERSION'); ?> "; </script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/chartjs/chart.min.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery.cookie.js"></script> <?php if ($title == "Events" || $title == "Console") { ?> <script src="skins/<?php echo $skin; ?> /views/assets/js/admin.js"></script> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/css/admin.css"> <?php } } ?> <?php if ($view == "playback" || ($view = "events")) { ?> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/moment.min.js"></script> <?php } if ($view == "playback") { ?> <style type="text/css"> <?php foreach (dbFetchAll("SELECT Monitors.Id, Monitors.WebColour FROM Monitors") as $monitor) { echo ".timeline-event.monitor" . $monitor['Id'] . " { background: " . $monitor['WebColour'] . "; }\n"; echo "#monitor-stream-" . $monitor['Id'] . " .fa-stop { color: " . $monitor['WebColour'] . "; }\n"; } ?> </style> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/js/timeline/timeline.css" type="text/css" media="screen"/> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/timeline/timeline-min.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery.mousewheel.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery.panzoom.min.js"></script> <script src="skins/<?php echo $skin; ?> /views/assets/vendor/js/jquery.capty.min.js"></script> <link rel="stylesheet" href="skins/<?php echo $skin; ?> /views/assets/vendor/css/jquery.capty.min.css"> <?php } ?> <?php if ($viewCssFile) { ?> <link rel="stylesheet" href="<?php echo $viewCssFile; ?> " type="text/css" media="screen"/> <?php } if ($viewCssPhpFile) { ?> <style type="text/css"> <?php require_once $viewCssPhpFile; ?> </style> <?php } if ($viewJsPhpFile) { ?> <script type="text/javascript"> <?php require_once $viewJsPhpFile; ?> </script> <?php } ?> <?php if ($viewJsFile) { ?> <script type="text/javascript" src="<?php echo $viewJsFile; ?> "></script> <?php } ?> </head> <?php }
// 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. // if (!canView('Events')) { $view = "error"; return; } $sql = "select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = '" . dbEscape($_REQUEST['eid']) . "'"; $event = dbFetchOne($sql); $sql = "select *, unix_timestamp( TimeStamp ) as UnixTimeStamp from Frames where EventID = '" . dbEscape($_REQUEST['eid']) . "' order by FrameId"; $frames = dbFetchAll($sql); $focusWindow = true; xhtmlHeaders(__FILE__, $SLANG['Frames'] . " - " . $event['Id']); ?> <body> <div id="page"> <div id="header"> <div id="headerButtons"><a href="#" onclick="closeWindow();"><?php echo $SLANG['Close']; ?> </a></div> <h2><?php echo $SLANG['Frames']; ?> - <?php echo $event['Id'];
if (isset($_REQUEST['eid'])) { $mode = 'single'; $eid = validInt($_REQUEST['eid']); $newEvent = dbFetchOne('SELECT E.* FROM Events AS E WHERE E.Id = ?', NULL, array($eid)); } elseif (isset($_REQUEST['eids'])) { $mode = 'multi'; $sql = 'SELECT E.* FROM Events AS E WHERE '; $sqlWhere = array(); $sqlValues = array(); foreach ($_REQUEST['eids'] as $eid) { $sqlWhere[] = 'E.Id = ?'; $sqlValues[] = $eid; } unset($eid); $sql .= join(" or ", $sqlWhere); foreach (dbFetchAll($sql, NULL, $sqlValues) as $row) { if (!isset($newEvent)) { $newEvent = $row; } else { if ($newEvent['Cause'] && $newEvent['Cause'] != $row['Cause']) { $newEvent['Cause'] = ""; } if ($newEvent['Notes'] && $newEvent['Notes'] != $row['Notes']) { $newEvent['Notes'] = ""; } } } } else { $mode = ''; } $focusWindow = true;
} else { $view = "error"; return; } $monitor = dbFetchMonitor($mid); $plugin = $_REQUEST['pl']; $plugin_path = dirname(ZM_PLUGINS_CONFIG_PATH) . "/" . $plugin; $focusWindow = true; xhtmlHeaders(__FILE__, translate('Plugin')); $pluginOptions = array('Enabled' => array('Type' => 'select', 'Name' => 'Enabled', 'Choices' => 'yes,no', 'Value' => 'no')); $optionNames = array(); if (file_exists($plugin_path . "/config.php")) { include_once $plugin_path . "/config.php"; } $sql = 'SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?'; foreach (dbFetchAll($sql, NULL, array($mid, $zid, $plugin)) as $popt) { if (array_key_exists($popt['Name'], $pluginOptions) && $popt['Type'] == $pluginOptions[$popt['Name']]['Type'] && $popt['Choices'] == $pluginOptions[$popt['Name']]['Choices']) { $pluginOptions[$popt['Name']] = $popt; array_push($optionNames, $popt['Name']); } else { dbQuery('DELETE FROM PluginsConfig WHERE Id=?', array($popt['Id'])); } } foreach ($pluginOptions as $name => $values) { if (!in_array($name, $optionNames)) { $popt = $pluginOptions[$name]; $sql = "INSERT INTO PluginsConfig VALUES ('',?,?,?,?,?,?,?)"; dbQuery($sql, array($popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin)); } } $PLANG = array();
$result = mysql_query($query); // Get all of the mids in a group $row = mysql_result($result, 0); $mids = explode(",", $row); # Put them into an array foreach ($mids as $mid) { # Foreach item in the array $query = "select Id, Name, Width, Height from Monitors where Id = " . $mid; foreach (dbFetchAll($query) as $monitor) { # Query the database displayMonitor($monitor, $bandwidth); # And call displayMonitor with the result } } } else { $monitors = dbFetchAll("select Id, Name, Width, Height from Monitors order by Sequence asc"); foreach ($monitors as $monitor) { displayMonitor($monitor, $bandwidth); } } ?> </ul> <?php function displayMonitor($monitor, $bandwidth) { if (!defined(ZM_WEB_DEFAULT_SCALE)) { $scale = 40; } else { $scale = ZM_WEB_DEFAULT_SCALE; } if ($bandwidth == 'high') {
<th>Max Bandwidth</th> <td> <select name="MaxBandwidth" id="MaxBandwidth" class="form-control new-user-form-value"> <option value="" selected="selected"></option> <option value="high">High</option> <option value="medium">Medium</option> <option value="low">Low</option> </select> </td> </tr> <tr> <th>Restricted Monitors</th> <td> <select id="monitorIds" name="monitorIds" multiple="multiple" class="form-control new-user-form-value"> <?php $response = dbFetchAll("SELECT Id, Name FROM Monitors"); if (!$response) { echo "<option value=\"null\">Error fetching list</option>"; } else { foreach ($response as $row) { echo "<option value=\"{$row['Id']}\">{$row['Name']}</option>"; } } ?> </select> </td> </tr> </tbody> </table> <a href="#" class="btn btn-primary back-to-preset-management" data-calledfrom="userlist"><span class="fa fa-arrow-circle-left"></span> Back To Preset Mangement</a> <button id="add-new-user" class="btn btn-success"><span class="fa fa-save"></span> Save User</button>
<tr> <th>Enabled</th> <td><input type="checkbox" id="Enabled" name="Enabled" class="monitor-form-value"<?php if ($response['Enabled'] === "1") { echo " checked"; } ?> ></td> </tr> <tr> <th>Linked Monitors</th> <td> <select id="LinkedMonitors" name="LinkedMonitors" multiple="multiple" class="form-control monitor-form-value"> <?php $query = "SELECT Id, Name FROM Monitors"; $response2 = dbFetchAll($query); if (!$response2) { echo "<option>Failed to fetch monitor list</option>"; } if (strlen($response['LinkedMonitors']) > 0) { $linkedMonitors = explode(",", $response['LinkedMonitors']); } foreach ($response2 as $monitor) { echo "<option value=\"{$monitor['Id']}\""; if (isset($linkedMonitors) && in_array($monitor['Id'], $linkedMonitors)) { echo " selected"; } echo ">{$monitor['Name']}</option>"; } ?> </select>
if ($dbUser['Username'] == $user['Username']) { userLogin($dbUser['Username'], $dbUser['Password']); } } $view = 'none'; } elseif ($action == "state") { if (!empty($_REQUEST['runState'])) { //if ( $cookies ) session_write_close(); packageControl($_REQUEST['runState']); $refreshParent = true; } } elseif ($action == "save") { if (!empty($_REQUEST['runState']) || !empty($_REQUEST['newState'])) { $sql = "select Id,Function,Enabled from Monitors order by Id"; $definitions = array(); foreach (dbFetchAll($sql) as $monitor) { $definitions[] = $monitor['Id'] . ":" . $monitor['Function'] . ":" . $monitor['Enabled']; } $definition = join(',', $definitions); if ($_REQUEST['newState']) { $_REQUEST['runState'] = $_REQUEST['newState']; } dbQuery("replace into States set Name=?, Definition=?", array($_REQUEST['runState'], $definition)); } } elseif ($action == "group") { # Should probably verfy that each monitor id is a valid monitor, that we have access to. HOwever at the moment, you have to have System permissions to do this $monitors = empty($_POST['newGroup']['MonitorIds']) ? NULL : implode(',', $_POST['newGroup']['MonitorIds']); if (!empty($_POST['gid'])) { dbQuery("UPDATE Groups SET Name=?, MonitorIds=? WHERE Id=?", array($_POST['newGroup']['Name'], $monitors, $_POST['gid'])); } else { dbQuery("INSERT INTO Groups SET Name=?, MonitorIds=?", array($_POST['newGroup']['Name'], $monitors));
// // 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. // if (!canView('Control')) { $view = "error"; return; } $sql = "select * from Controls order by Id"; $controls = dbFetchAll($sql); $focusWindow = true; xhtmlHeaders(__FILE__, $SLANG['ControlCaps']); ?> <body> <div id="page"> <div id="header"> <div id="headerButtons"> <a href="#" onclick="closeWindow();"><?php echo $SLANG['Close']; ?> </a> </div> <h2><?php echo $SLANG['ControlCaps']; ?>
function getTableDescription($table, $asString = 1) { $columns = array(); foreach (dbFetchAll("describe {$table}") as $row) { $desc = array('name' => $row['Field'], 'required' => $row['Null'] == 'NO' ? true : false, 'default' => $row['Default'], 'db' => $row); if (preg_match("/^varchar\\((\\d+)\\)\$/", $row['Type'], $matches)) { $desc['type'] = 'text'; $desc['typeAttrib'] = 'varchar'; $desc['maxLength'] = $matches[1]; } elseif (preg_match("/^(\\w+)?text\$/", $row['Type'], $matches)) { $desc['type'] = 'text'; if (!empty($matches[1])) { $desc['typeAttrib'] = $matches[1]; } switch ($matches[1]) { case 'tiny': $desc['maxLength'] = 255; break; case 'medium': $desc['maxLength'] = 32768; break; case '': case 'big': //$desc['minLength'] = -128; break; default: Error("Unexpected text qualifier '" . $matches[1] . "' found for field '" . $row['Field'] . "' in table '" . $table . "'"); break; } } elseif (preg_match("/^(enum|set)\\((.*)\\)\$/", $row['Type'], $matches)) { $desc['type'] = 'text'; $desc['typeAttrib'] = $matches[1]; preg_match_all("/'([^']+)'/", $matches[2], $matches); $desc['values'] = $matches[1]; } elseif (preg_match("/^(\\w+)?int\\(\\d+\\)(?:\\s+(unsigned))?\$/", $row['Type'], $matches)) { $desc['type'] = 'integer'; switch ($matches[1]) { case 'tiny': $desc['minValue'] = -128; $desc['maxValue'] = 127; break; case 'small': $desc['minValue'] = -32768; $desc['maxValue'] = 32767; break; case 'medium': $desc['minValue'] = -8388608; $desc['maxValue'] = 8388607; break; case '': $desc['minValue'] = -2147483648; $desc['maxValue'] = 2147483647; break; case 'big': //$desc['minValue'] = -128; //$desc['maxValue'] = 127; break; default: Error("Unexpected integer qualifier '" . $matches[1] . "' found for field '" . $row['Field'] . "' in table '" . $table . "'"); break; } if (!empty($matches[1])) { $desc['typeAttrib'] = $matches[1]; } if ($desc['unsigned'] = isset($matches[2]) && $matches[2] == 'unsigned') { $desc['maxValue'] += -$desc['minValue']; $desc['minValue'] = 0; } } elseif (preg_match("/^(?:decimal|numeric)\\((\\d+)(?:,(\\d+))?\\)(?:\\s+(unsigned))?\$/", $row['Type'], $matches)) { $desc['type'] = 'fixed'; $desc['range'] = $matches[1]; if (isset($matches[2])) { $desc['precision'] = $matches[2]; } else { $desc['precision'] = 0; } $desc['unsigned'] = isset($matches[3]) && $matches[3] == 'unsigned'; } elseif (preg_match("/^(datetime|timestamp|date|time)\$/", $row['Type'], $matches)) { $desc['type'] = 'datetime'; switch ($desc['typeAttrib'] = $matches[1]) { case 'datetime': case 'timestamp': $desc['hasDate'] = true; $desc['hasTime'] = true; break; case 'date': $desc['hasDate'] = true; $desc['hasTime'] = false; break; case 'time': $desc['hasDate'] = false; $desc['hasTime'] = true; break; } } else { Error("Can't parse database type '" . $row['Type'] . "' found for field '" . $row['Field'] . "' in table '" . $table . "'"); } if ($asString) { $columns[$row['Field']] = $desc; } else { $columns[] = $desc; } } return $columns; }
</td> <?php } elseif ($_REQUEST['filter']['terms'][$i]['attr'] == "Weekday") { ?> <td><?php echo buildSelect("filter[terms][{$i}][op]", $opTypes); ?> </td> <td><?php echo buildSelect("filter[terms][{$i}][val]", $weekdays); ?> </td> <?php } elseif (false && $_REQUEST['filter']['terms'][$i]['attr'] == "MonitorName") { $monitors = array(); foreach (dbFetchAll("select Id,Name from Monitors order by Sequence asc") as $monitor) { if (visibleMonitor($monitor['Id'])) { $monitors[$monitor['Name']] = $monitor['Name']; } } ?> <td><?php echo buildSelect("filter[terms][{$i}][op]", $opTypes); ?> </td> <td><?php echo buildSelect("filter[terms][{$i}][val]", $monitors); ?> </td> <?php } else {
<?php foreach (dbFetchAll("SELECT * FROM Groups") as $index => $cameras) { $groups[] = array('value' => $cameras['Id'], 'text' => $cameras['Name']); } echo json_encode($groups);
/* If pageOffset is greater than we actually have, * we need to adjust it */ $pageOffset = validInteger($_GET['pageOff' . $monitor['Id']]); if ($pageOffset >= ceil($monitor['EventCount0'] / $numEvents)) { $pageOffset = 0; } $offset = $pageOffset * $numEvents; } $eventsSql .= " offset " . $offset; } else { unset($eventsSql); } xml_tag_val("PAGEOFF", $pageOffset); xml_tag_sec("EVENTS", 1); if (canView('Events') && isset($eventsSql)) { foreach (dbFetchAll(escapeSql($eventsSql)) as $event) { xml_tag_sec("EVENT", 1); xml_tag_val("ID", $event['Id']); xml_tag_val("NAME", $event['Name']); xml_tag_val("TIME", strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event['StartTime']))); xml_tag_val("DURATION", $event['Length']); xml_tag_val("FRAMES", $event['Frames']); xml_tag_val("FPS", $event['Length'] > 0 ? ceil($event['Frames'] / $event['Length']) : 0); xml_tag_val("TOTSCORE", $event['TotScore']); xml_tag_val("AVGSCORE", $event['AvgScore']); xml_tag_val("MAXSCORE", $event['MaxScore']); /* Grab the max frame-id from Frames table. If AlarmFrames = 0, don't try * to grab any frames, and just signal the max frame index as index 0 */ $fridx = 1; $alarmFrames = 1; if ($event['AlarmFrames']) {
] = '<?php echo translate('Preset') . ' ' . $i; ?> '; <?php } } } ?> <?php if (empty($_REQUEST['mid'])) { ?> var monitorNames = new Object(); <?php foreach (dbFetchAll("select Name from Monitors order by Name asc", "Name") as $name) { ?> monitorNames['<?php echo validJsStr($name); ?> '] = true; <?php } } ?> function validateForm( form ) { var errors = new Array(); if ( form.elements['newMonitor[Name]'].value.search( /[^\w-]/ ) >= 0 )
// 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. // if (!canEdit('Events')) { $view = "error"; return; } $selectName = "filterName"; $newSelectName = "new" . ucfirst($selectName); foreach (dbFetchAll("select * from Filters order by Name") as $row) { $filterNames[$row['Name']] = $row['Name']; if ($_REQUEST['filterName'] == $row['Name']) { $filterData = $row; } } $focusWindow = true; $filter = $_REQUEST['filter']; parseFilter($filter); xhtmlHeaders(__FILE__, translate('SaveFilter')); ?> <body> <div id="page"> <div id="header"> <h2><?php echo translate('SaveFilter');
// // 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. // if (!canEdit('System')) { $view = "error"; return; } $running = daemonCheck(); $states = dbFetchAll("select * from States"); $focusWindow = true; xhtmlHeaders(__FILE__, translate('RunState')); ?> <body> <div id="page"> <div id="header"> <h2><?php echo translate('RunState'); ?> </h2> </div> <div id="content"> <form name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>
$framesPerLine = 3; $maxShortcuts = 3; $paged = $event['Frames'] > $framesPerPage; if ($paged && !empty($_REQUEST['page'])) { $loFrameId = ($_REQUEST['page'] - 1) * $framesPerPage + 1; $hiFrameId = min($_REQUEST['page'] * $framesPerPage, $event['Frames']); } else { $loFrameId = 1; $hiFrameId = $event['Frames']; } $sql = 'SELECT * FROM Frames WHERE EventID = ?'; if ($paged && !empty($_REQUEST['page'])) { $sql .= " and FrameId between {$loFrameId} and {$hiFrameId}"; } $sql .= " order by FrameId"; $frames = dbFetchAll($sql, NULL, array($_REQUEST['eid'])); $scale = getDeviceScale($event['Width'], $event['Height'], $framesPerLine + 0.3); $pages = (int) ceil($event['Frames'] / $framesPerPage); if (!empty($_REQUEST['fid'])) { $_REQUEST['page'] = $_REQUEST['fid'] / $framesPerPage + 1; } $pagination = getPagination($pages, $_REQUEST['page'], $maxShortcuts, '&eid=' . $_REQUEST['eid'] . $filterQuery . $sortQuery, '&'); xhtmlHeaders(__FILE__, translate('Event') . ' - ' . $event['Name']); ?> <body> <div id="page"> <div id="header"> <?php if (canEdit('Events')) { ?> <div id="headerButtons">
$monitor_str .= make_tag("method", $monitor['Function']); $monitor_str .= make_tag("enabled", $monitor['Enabled']); $monitor_str .= make_tag("width", $monitor['Width']); $monitor_str .= make_tag("height", $monitor['Height']); print make_tag("monitor", $monitor_str); } } else { if ($_REQUEST['action'] == "get_connkey") { print make_tag("connkey", generateConnKey()); } else { if ($_REQUEST['action'] == "event_stats") { if (!canView("Events")) { ajaxError('Unrecognised action or insufficient permissions'); } $eid = validInt($_REQUEST['eid']); $stats = dbFetchAll("select S.*,E.*,Z.Name as ZoneName,Z.Units,Z.Area,M.Name as MonitorName,M.Width,M.Height from Stats as S left join Events as E on S.EventId = E.Id left join Zones as Z on S.ZoneId = Z.Id left join Monitors as M on E.MonitorId = M.Id where S.EventId = '" . $eid . "' order by S.FrameId, S.ZoneId"); for ($i = 0; $i < count($stats); $i++) { $stat = $stats[$i]; $stat_str = ""; $stat_str .= make_tag("FrameId", $stat["FrameId"]); $stat_str .= make_tag("PixelDiff", $stat["PixelDiff"]); $stat_str .= make_tag("AlarmPixels", $stat["AlarmPixels"]); $stat_str .= make_tag("FilterPixels", $stat["FilterPixels"]); $stat_str .= make_tag("BlobPixels", $stat["BlobPixels"]); $stat_str .= make_tag("Blobs", $stat["Blobs"]); $stat_str .= make_tag("ZoneName", $stat["ZoneName"]); $stat_str .= make_tag("Score", $stat["Score"]); print make_tag("stat", $stat_str); } } }
function exportEventImagesMaster($eids) { global $SLANG; ob_start(); exportHeader(translate('Images') . ' Master'); ?> <body> <h2><?php echo translate('Images'); ?> Master</h2> <?php foreach ($eids as $eid) { //get monitor id and event id $sql = 'SELECT E.MonitorId, E.StartTime, E.Id FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ? '; $event = dbFetchOne($sql, NULL, array($eid)); $eventMonitorId[$eid] = $event['MonitorId']; $eventPath[$eid] = mygetEventPath($event); } $monitors = array_values(array_flip(array_flip($eventMonitorId))); //unique monitors and reindex the array $monitorNames = array(); //* if (!empty($monitors)) { $tmp = dbFetchAll("SELECT Id,Name FROM Monitors WHERE Id IN (" . implode(',', $monitors) . ") "); foreach ($tmp as $row) { $monitorNames[$row['Id']] = $row['Name']; } } //*/ //trigger_error(print_r($monitorNames,1)); ?> <div id= 'tabs'> <ul class= 'tabs'> <li class = 'active' ><a href='#all' > All </a></li> <?php foreach ($monitors as $monitor) { # code... echo "<li><a href='#tab{$monitor}'>" . $monitorNames[$monitor] . "</a></li>"; } ?> </ul> </div> <table width="100%" height="100%" ><tr> <td valign="top" bgcolor="#dddddd" style="padding:10px;"> <div class='tab_content' id='all'> <h2> All </h2> <?php if (!is_array($eids)) { echo "<div><a href=\"javascript:switchevent('{$eids}/zm/EventImages.html');\"> {$eids} </div>"; } ?> <?php foreach ($eids as $eid) { ?> <div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?> /zmEventImages.html');"><?php echo $eid; ?> </a></div> <?php } ?> </div> <?php foreach ($monitors as $monitor) { echo "<div class='tab_content' id='tab{$monitor}'>"; echo "<h2>Monitor: " . $monitorNames[$monitor] . " </h2>"; foreach ($eids as $eid) { if ($eventMonitorId[$eid] == $monitor) { ?> <div><a href="javascript:switchevent('<?php echo $eventPath[$eid]; ?> /zmEventImages.html');"><?php echo $eid; ?> </a></div> <?php } } echo '</div>'; } ?> </td><td> <iframe id="myframe" onload="resizeCaller();" name="myframe" src="#" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"> </iframe> </td> </tr></table> <script type="text/javascript"> function switchevent(src) { if(document.all) document.all.myframe.src = src; else window.frames['myframe'].location.href = src; } /*********************************************** * IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com) * Visit DynamicDrive.com for hundreds of original DHTML scripts * This notice must stay intact for legal use ***********************************************/ //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["myframe"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="yes" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller() { var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]); //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false); else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt; var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url; } //if (window.addEventListener) window.addEventListener("load", resizeCaller, false) //else if (window.attachEvent) window.attachEvent("onload", resizeCaller) //else window.onload=resizeCaller </script> </body> </html> <?php return ob_get_clean(); }
if (empty($limit)) { $limitAmount = ZM_WEB_EVENTS_PER_PAGE; } else { $limitLeft = $limit - $limitStart; $limitAmount = $limitLeft > ZM_WEB_EVENTS_PER_PAGE ? ZM_WEB_EVENTS_PER_PAGE : $limitLeft; } $eventsSql .= " limit {$limitStart}, {$limitAmount}"; } elseif (!empty($limit)) { $eventsSql .= " limit 0, " . $limit; } $maxWidth = 0; $maxHeight = 0; $archived = false; $unarchived = false; $events = array(); foreach (dbFetchAll($eventsSql) as $event) { $events[] = $event; $scale = max(reScale(SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE), SCALE_BASE); $eventWidth = reScale($event['Width'], $scale); $eventHeight = reScale($event['Height'], $scale); if ($maxWidth < $eventWidth) { $maxWidth = $eventWidth; } if ($maxHeight < $eventHeight) { $maxHeight = $eventHeight; } if ($event['Archived']) { $archived = true; } else { $unarchived = true; }
?> </th> <td><input type="text" name="newGroup[Name]" value="<?php echo validHtmlStr($newGroup['Name']); ?> "/></td> </tr> <tr> <th scope="row"><?php echo translate('MonitorIds'); ?> </th> <td> <select name="newGroup[MonitorIds][]" size="4" multiple="multiple"> <?php $monitors = dbFetchAll("select Id,Name from Monitors order by Sequence asc"); $monitorIds = array_flip(explode(',', $newGroup['MonitorIds'])); foreach ($monitors as $monitor) { if (visibleMonitor($monitor['Id'])) { ?> <option value="<?php echo $monitor['Id']; ?> "<?php if (array_key_exists($monitor['Id'], $monitorIds)) { ?> selected="selected"<?php } ?> ><?php echo validHtmlStr($monitor['Name']);