"graphics/point-g.gif", "hisrc"=>"graphics/point-o.gif", "actsrc"=>"graphics/point-r.gif", "width"=>7, "height"=>7, ); $result = mysql_query( "select *, Units-1 as UnitsIndex, CheckMethod-1 as CheckMethodIndex from ZonePresets order by Id asc" ); if ( !$result ) die( mysql_error() ); $presets = array(); $preset_names = array(); $preset_names[0] = $zmSlangChoosePreset; while ( $preset = mysql_fetch_assoc( $result ) ) { $preset_names[$preset['Id']] = $preset['Name']; $presets[] = $preset; } mysql_free_result( $result ); $result = mysql_query( "select * from Monitors where Id = '$mid'" ); if ( !$result ) die( mysql_error() ); $monitor = mysql_fetch_assoc( $result ); mysql_free_result( $result ); $min_x = 0; $max_x = $monitor['Width']-1; $min_y = 0; $max_y = $monitor['Height']-1; if ( !isset($new_zone) ) { if ( $zid > 0 ) { $result = mysql_query( "select * from Zones where MonitorId = '$mid' and Id = '$zid'" ); if ( !$result ) die( mysql_error() ); $zone = mysql_fetch_assoc( $result ); mysql_free_result( $result ); } else { $zone = array(); $zone['Name'] = $zmSlangNew; $zone['CheckMethod'] = 'Blobs'; $zone['AlarmRGB'] = 0xff0000; $zone['NumCoords'] = 4; $zone['Coords'] = sprintf( "%d,%d %d,%d, %d,%d %d,%d", $min_x, $min_y, $max_x, $min_y, $max_x, $max_y, $min_x, $max_y ); $zone['Area'] = $monitor['Width'] * $monitor['Height']; } $zone['Points'] = coordsToPoints( $zone['Coords'] ); $new_zone = $zone; } //if ( !$points ) //{ //$points = $zone['Points']; //} ksort( $new_zone['Points'], SORT_NUMERIC ); if ( isset($action) ) { if ( $action == "loc_addpoint" ) { if ( $subaction < (count($new_zone['Points'])-1) ) { $new_x = intval(round(($new_zone['Points'][$subaction]['x']+$new_zone['Points'][$subaction+1]['x'])/2)); $new_y = intval(round(($new_zone['Points'][$subaction]['y']+$new_zone['Points'][$subaction+1]['y'])/2)); } else { $new_x = intval(round(($new_zone['Points'][$subaction]['x']+$new_zone['Points'][0]['x'])/2)); $new_y = intval(round(($new_zone['Points'][$subaction]['y']+$new_zone['Points'][0]['y'])/2)); } array_splice( $new_zone['Points'], $subaction+1, 0, array( array( 'x'=>$new_x, 'y'=>$new_y ) ) ); } elseif ( $action == "loc_delpoint" ) { array_splice( $new_zone['Points'], $subaction, 1 ); } } $new_zone['Coords'] = pointsToCoords( $new_zone['Points'] ); $new_zone['Area'] = getPolyArea( $new_zone['Points'] ); $self_intersecting = isSelfIntersecting( $new_zone['Points'] ); chdir( ZM_DIR_IMAGES ); $command = getZmuCommand( " -m $mid -z" ); if ( !$zid ) $zid = 0; $command .= "\"$zid $hicolor ".$new_zone['Coords']."\""; $status = exec( escapeshellcmd( $command ) ); chdir( '..' ); $zone_image = ZM_DIR_IMAGES.'/'.$monitor['Name']."-Zones.jpg?".time(); ?>