Storage(); $path = $Event->Relative_Path().'/'.sprintf("%'.0".ZM_EVENT_IMAGE_DIGITS.'d',$_REQUEST['fid']).'-capture.jpg'; } } else { $errorText = "No image path"; } } else { $Storage = new Storage(); $path = $_REQUEST['path']; if ( !empty($user['MonitorIds']) ) { $imageOk = false; $pathMonId = substr( $path, 0, strspn( $path, "1234567890" ) ); foreach ( preg_split( '/["\'\s]*,["\'\s]*/', $user['MonitorIds'] ) as $monId ) { if ( $pathMonId == $monId ) { $imageOk = true; break; } } if ( !$imageOk ) $errorText = "No image permissions"; } } $scale=0; if( !empty($_REQUEST['scale']) ) if (is_numeric($_REQUEST['scale'])) { $x = $_REQUEST['scale']; if($x >= 1 and $x <= 400) $scale=$x; } $width=0; if( !empty($_REQUEST['width']) ) if (is_numeric($_REQUEST['width'])) { $x = $_REQUEST['width']; if($x >= 10 and $x <= 8000) $width=$x; } $height=0; if( !empty($_REQUEST['height']) ) if (is_numeric($_REQUEST['height'])) { $x = $_REQUEST['height']; if($x >= 10 and $x <= 8000) $height=$x; } if ( $errorText ) Error( $errorText ); else if( ($scale==0 || $scale==100) && $width==0 && $height==0 ) if ( ! readfile( $Storage->Path().'/'.$path ) ) { Error("No bytes read from ". $Storage->Path() . '/'.$path ); } else { $i = imagecreatefromjpeg ( $Storage->Path().'/'.$path ); $oldWidth=imagesx($i); $oldHeight=imagesy($i); if($width==0 && $height==0) // scale has to be set to get here with both zero { $width = $oldWidth * $scale / 100.0; $height= $oldHeight * $scale / 100.0; } elseif ($width==0 && $height!=0) { $width = ($height * $oldWidth) / $oldHeight; } elseif ($width!=0 && $height==0) { $height = ($width * $oldHeight) / $oldWidth; } if($width==$oldWidth && $height==$oldHeight) // See if we really need to scale { imagejpeg($i); imagedestroy($i); } else // we do need to scale { $iScale = imagescale($i, $width, $height); imagejpeg($iScale); imagedestroy($i); imagedestroy($iScale); } } ?>