Example #1
0
 if (isset($changes['Name'])) {
     $saferOldName = basename($monitor['Name']);
     $saferNewName = basename($_REQUEST['newMonitor']['Name']);
     rename(ZM_DIR_EVENTS . "/" . $saferOldName, ZM_DIR_EVENTS . "/" . $saferNewName);
 }
 if (isset($changes['Width']) || isset($changes['Height'])) {
     $newW = $_REQUEST['newMonitor']['Width'];
     $newH = $_REQUEST['newMonitor']['Height'];
     $newA = $newW * $newH;
     $oldW = $monitor['Width'];
     $oldH = $monitor['Height'];
     $oldA = $oldW * $oldH;
     $zones = dbFetchAll("select * from Zones where MonitorId=?", NULL, array($mid));
     foreach ($zones as $zone) {
         $newZone = $zone;
         $points = coordsToPoints($zone['Coords']);
         for ($i = 0; $i < count($points); $i++) {
             $points[$i]['x'] = intval($points[$i]['x'] * ($newW - 1) / ($oldW - 1));
             $points[$i]['y'] = intval($points[$i]['y'] * ($newH - 1) / ($oldH - 1));
         }
         $newZone['Coords'] = pointsToCoords($points);
         $newZone['Area'] = intval(round($zone['Area'] * $newA / $oldA));
         $newZone['MinAlarmPixels'] = intval(round($newZone['MinAlarmPixels'] * $newA / $oldA));
         $newZone['MaxAlarmPixels'] = intval(round($newZone['MaxAlarmPixels'] * $newA / $oldA));
         $newZone['MinFilterPixels'] = intval(round($newZone['MinFilterPixels'] * $newA / $oldA));
         $newZone['MaxFilterPixels'] = intval(round($newZone['MaxFilterPixels'] * $newA / $oldA));
         $newZone['MinBlobPixels'] = intval(round($newZone['MinBlobPixels'] * $newA / $oldA));
         $newZone['MaxBlobPixels'] = intval(round($newZone['MaxBlobPixels'] * $newA / $oldA));
         $changes = getFormChanges($zone, $newZone, $types);
         if (count($changes)) {
             dbQuery("update Zones set " . implode(", ", $changes) . " WHERE MonitorId=? AND Id=?", array($mid, $zone['Id']));
Example #2
0
$optCheckMethods = array();
foreach (getEnumValues('Zones', 'CheckMethod') as $optCheckMethod) {
    $optCheckMethods[$optCheckMethod] = $optCheckMethod;
}
$monitor = dbFetchMonitor($mid);
$minX = 0;
$maxX = $monitor['Width'] - 1;
$minY = 0;
$maxY = $monitor['Height'] - 1;
if (!isset($newZone)) {
    if ($zid > 0) {
        $zone = dbFetchOne('SELECT * FROM Zones WHERE MonitorId = ? AND Id=?', NULL, array($monitor['Id'], $zid));
    } else {
        $zone = array('Name' => translate('New'), 'Id' => 0, 'MonitorId' => $monitor['Id'], 'NumCoords' => 4, 'Coords' => sprintf("%d,%d %d,%d, %d,%d %d,%d", $minX, $minY, $maxX, $minY, $maxX, $maxY, $minX, $maxY), 'Area' => $monitor['Width'] * $monitor['Height'], 'AlarmRGB' => 0xff0000, 'CheckMethod' => 'Blobs', 'MinPixelThreshold' => '', 'MaxPixelThreshold' => '', 'MinAlarmPixels' => '', 'MaxAlarmPixels' => '', 'FilterX' => '', 'FilterY' => '', 'MinFilterPixels' => '', 'MaxFilterPixels' => '', 'MinBlobPixels' => '', 'MaxBlobPixels' => '', 'MinBlobs' => '', 'MaxBlobs' => '', 'OverloadFrames' => '', 'ExtendAlarmFrames' => '');
    }
    $zone['Points'] = coordsToPoints($zone['Coords']);
    $newZone = $zone;
}
//if ( !$points )
//{
//$points = $zone['Points'];
//}
ksort($newZone['Points'], SORT_NUMERIC);
$newZone['Coords'] = pointsToCoords($newZone['Points']);
$newZone['Area'] = getPolyArea($newZone['Points']);
$selfIntersecting = isSelfIntersecting($newZone['Points']);
$wd = getcwd();
chdir(ZM_DIR_IMAGES);
$command = getZmuCommand(" -m " . $mid . " -z");
$command .= '"' . $zid . ' ' . $hicolor . ' ' . $newZone['Coords'] . '"';
$status = exec(escapeshellcmd($command));
Example #3
0
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
if (!canView('Monitors')) {
    $view = "error";
    return;
}
$mid = validInt($_REQUEST['mid']);
$wd = getcwd();
chdir(ZM_DIR_IMAGES);
$status = exec(escapeshellcmd(getZmuCommand(" -m " . $mid . " -z")));
chdir($wd);
$monitor = dbFetchMonitor($mid);
$sql = "select * from Zones where MonitorId = '" . $mid . "' order by Area desc";
$zones = array();
foreach (dbFetchAll($sql) as $row) {
    if ($row['Points'] = coordsToPoints($row['Coords'])) {
        $row['AreaCoords'] = preg_replace('/\\s+/', ',', $row['Coords']);
        $zones[] = $row;
    }
}
$image = 'Zones' . $monitor['Id'] . '.jpg';
xhtmlHeaders(__FILE__, $SLANG['Zones']);
?>
<body>
  <div id="page">
    <div id="header">
      <h2><?php 
echo $SLANG['Zones'];
?>
</h2>
    </div>
Example #4
0
<?php

if (empty($_REQUEST['mid'])) {
    ajaxError('No monitor id supplied');
} elseif (!isset($_REQUEST['zid'])) {
    ajaxError('No zone id(s) supplied');
}
if (canView('Monitors')) {
    switch ($_REQUEST['action']) {
        case "zoneImage":
            $wd = getcwd();
            chdir(ZM_DIR_IMAGES);
            $hiColor = '0x00ff00';
            $command = getZmuCommand(" -m " . $_REQUEST['mid'] . " -z");
            if (!isset($_REQUEST['zid'])) {
                $_REQUEST['zid'] = 0;
            }
            $command .= "'" . $_REQUEST['zid'] . ' ' . $hiColor . ' ' . $_REQUEST['coords'] . "'";
            $status = exec(escapeshellcmd($command));
            chdir($wd);
            $monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($_REQUEST['mid']));
            $points = coordsToPoints($_REQUEST['coords']);
            ajaxResponse(array('zoneImage' => ZM_DIR_IMAGES . '/Zones' . $monitor['Id'] . '.jpg?' . time(), 'selfIntersecting' => isSelfIntersecting($points), 'area' => getPolyArea($points)));
            break;
    }
}
ajaxError('Unrecognised action or insufficient permissions');