take fid and eid as alternate parameters

This commit is contained in:
Isaac Connor 2016-05-12 11:55:48 -04:00
parent 4cd510c438
commit ed3e975e5a
1 changed files with 21 additions and 3 deletions

View File

@ -37,6 +37,8 @@ if ( !canView( 'Events' ) )
$view = "error"; $view = "error";
return; return;
} }
require_once('includes/Event.php');
require_once('includes/Frame.php');
header( 'Content-type: image/jpeg' ); header( 'Content-type: image/jpeg' );
@ -58,11 +60,27 @@ if (!function_exists('imagescale'))
$errorText = false; $errorText = false;
if ( empty($_REQUEST['path']) ) 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"; $errorText = "No image path";
}
} }
else else
{ {
$path = $_REQUEST['path']; $path = ZM_DIR_EVENTS . '/' . $_REQUEST['path'];
if ( !empty($user['MonitorIds']) ) if ( !empty($user['MonitorIds']) )
{ {
$imageOk = false; $imageOk = false;
@ -111,10 +129,10 @@ if ( $errorText )
Error( $errorText ); Error( $errorText );
else else
if( ($scale==0 || $scale==100) && $width==0 && $height==0 ) if( ($scale==0 || $scale==100) && $width==0 && $height==0 )
readfile( ZM_DIR_EVENTS.'/'.$path ); readfile( $path );
else else
{ {
$i = imagecreatefromjpeg ( ZM_DIR_EVENTS.'/'.$path ); $i = imagecreatefromjpeg ( $path );
$oldWidth=imagesx($i); $oldWidth=imagesx($i);
$oldHeight=imagesy($i); $oldHeight=imagesy($i);
if($width==0 && $height==0) // scale has to be set to get here with both zero if($width==0 && $height==0) // scale has to be set to get here with both zero