diff --git a/web/includes/Frame.php b/web/includes/Frame.php index 5973cd1bfd..7075691576 100644 --- a/web/includes/Frame.php +++ b/web/includes/Frame.php @@ -70,7 +70,7 @@ public function Relative_Path() { } public function getImageSrc( ) { - return ZM_BASE_URL.'/index.php?view=image&fid='.$this->{'Id'}; + return $_SERVER['PHP_SELF'].'?view=image&fid='.$this->{'Id'}; } // end function getImageSrc public static function find( $parameters = array(), $limit = NULL ) { diff --git a/web/skins/classic/views/frame.php b/web/skins/classic/views/frame.php index 9edaa0371d..29ddcc1d62 100644 --- a/web/skins/classic/views/frame.php +++ b/web/skins/classic/views/frame.php @@ -24,6 +24,8 @@ return; } +require_once('includes/Frame.php'); + $eid = validInt($_REQUEST['eid']); if ( !empty($_REQUEST['fid']) ) $fid = validInt($_REQUEST['fid']); @@ -38,52 +40,57 @@ } else { $frame = dbFetchOne( 'SELECT * FROM Frames WHERE EventId = ? AND Score = ?', NULL, array( $eid, $event['MaxScore'] ) ); } +$frame = new Frame( $frame ); $maxFid = $event['Frames']; $firstFid = 1; -$prevFid = $frame['FrameId']-1; -$nextFid = $frame['FrameId']+1; +$prevFid = $frame->FrameId()-1; +$nextFid = $frame->FrameId()+1; $lastFid = $maxFid; -$alarmFrame = $frame['Type']=='Alarm'; +$alarmFrame = $frame->Type()=='Alarm'; if ( isset( $_REQUEST['scale'] ) ) $scale = validInt($_REQUEST['scale']); else $scale = max( reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ), SCALE_BASE ); -$imageData = getImageSrc( $event, $frame, $scale, (isset($_REQUEST['show']) && $_REQUEST['show']=="capt") ); +$imageData = getImageSrc( $event, $frame->FrameId(), $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, $frame['FrameId'] ); -$rImagePath = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-diag-r.jpg", $eventPath, $frame['FrameId'] ); +$dImagePath = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-diag-d.jpg", $eventPath, $frame->FrameId() ); +$rImagePath = sprintf( "%s/%0".ZM_EVENT_IMAGE_DIGITS."d-diag-r.jpg", $eventPath, $frame->FrameId() ); $focusWindow = true; -xhtmlHeaders(__FILE__, translate('Frame')." - ".$event['Id']." - ".$frame['FrameId'] ); +xhtmlHeaders(__FILE__, translate('Frame')." - ".$event['Id']." - ".$frame->FrameId() ); ?>
-

"><?php echo $frame['EventId']." class=""/>

+

+"> +<?php echo $frame->EventId().FrameId() ?>" class=""/> + +

- 1 ) { ?> +FrameId() > 1 ) { ?> - 1 ) { ?> +FrameId() > 1 ) { ?> - +FrameId() < $maxFid ) { ?> - +FrameId() < $maxFid ) { ?>

diff --git a/web/views/image.php b/web/views/image.php index cbaf2f7314..9bc2422447 100644 --- a/web/views/image.php +++ b/web/views/image.php @@ -37,6 +37,8 @@ $view = "error"; return; } +require_once('includes/Event.php'); +require_once('includes/Frame.php'); header( 'Content-type: image/jpeg' ); @@ -58,11 +60,27 @@ function imagescale($image, $new_width, $new_height = -1, $mode = 0) $errorText = false; if ( empty($_REQUEST['path']) ) { + if ( ! empty($_REQUEST['fid']) ) { + if ( ! empty($_REQUEST['eid'] ) ) { + $Event = new Event( $_REQUEST['eid'] ); + $Frame = Frame::find_one( array( 'EventId' => $_REQUEST['eid'], 'FrameId' => $_REQUEST['fid'] ) ); + if ( ! $Frame ) { + Fatal("No Frame found for event(".$_REQUEST['eid'].") and frame id(".$_REQUEST['fid'].")"); + } + $path = $Event->Path().'/'.sprintf("%'.0".ZM_EVENT_IMAGE_DIGITS.'d',$_REQUEST['fid']).'-capture.jpg'; + } else { +# If we are only specifying fid, then the fid must be the primary key into the frames table. But when the event is specified, then it is the frame # + $Frame = new Frame( $_REQUEST['fid'] ); + $Event = new Event( $Frame->EventId() ); + $path = $Event->Path().'/'.sprintf("%'.0".ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-capture.jpg'; + } + } else { $errorText = "No image path"; + } } else { - $path = $_REQUEST['path']; + $path = ZM_DIR_EVENTS . '/' . $_REQUEST['path']; if ( !empty($user['MonitorIds']) ) { $imageOk = false; @@ -111,10 +129,10 @@ function imagescale($image, $new_width, $new_height = -1, $mode = 0) Error( $errorText ); else if( ($scale==0 || $scale==100) && $width==0 && $height==0 ) - readfile( ZM_DIR_EVENTS.'/'.$path ); + readfile( $path ); else { - $i = imagecreatefromjpeg ( ZM_DIR_EVENTS.'/'.$path ); + $i = imagecreatefromjpeg ( $path ); $oldWidth=imagesx($i); $oldHeight=imagesy($i); if($width==0 && $height==0) // scale has to be set to get here with both zero