MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/public_html/images/fotos.php
<?php
// header("Content-Type: image/jpeg");
ini_set('display_errors', 1);
// header('Content-Type: image/jpeg');
$url =  "https://machen.azureedge.net/".$_GET["img"];

// $url = 'https://images.nga.gov/en/web_images/constable.jpg';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11');
$res = curl_exec($ch);
$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
// echo $rescode;
curl_close($ch) ;
// echo $res;

// $foto = file_get_contents($res);

// print_r($res);
// exit;

function getImage( $fileCr, $output_file ) {
    $ifp = fopen( $output_file, "wb" ); 
    fwrite( $ifp,  $fileCr ); 
    fclose( $ifp ); 
    return( $ifp ); 
}
$foto = getImage($res,'tmp.jpg');
$fotoLocal ='./tmp.jpg'
$info = pathinfo($fotoLocal);

//  print_r($info);

//  exit;

$tsstring = gmdate("D, d M Y H ", time()) . "GMT";

$etag = md5($_GET["img"].$_GET["l"].$_GET["a"].$_GET["q"].$_GET["x"].$_GET["y"].$_GET["rotate"]."2022");

$if_modified_since = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? $_SERVER["HTTP_IF_MODIFIED_SINCE"] : false;

$if_none_match = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] : false;

if ((($if_none_match && $if_none_match == $etag) || (!$if_none_match)) &&
    ($if_modified_since && $if_modified_since == $tsstring))
{
    header("HTTP/1.1 304 Not Modified");
    exit();
}
else
{
    header("Last-Modified: $tsstring");
    header("ETag: \"{$etag}\"");
}
switch($info["extension"]){ 
    case "jpg": 
        $mime = "image/jpeg"; 
        break; 
    case "gif": 
        $mime = "image/gif"; 
        break; 
    case "png": 
        $mime = "image/png"; 
        break; 
}
header("content-type: ".$mime);

	include("php/classes/canvas.php"); 
	$x = $_GET["x"];
	$y = $_GET["y"];
	
	if($_GET["rotate"]>0 && $_GET["rotate"]<360){
		$rotate = $_GET["rotate"];
	}else{
		$rotate = 0;
	}
	
	$oImg = new canvas($fotoLocal);
	$tam_img = getimagesize($fotoLocal);
	
	if($_GET["q"]){
		$q=$_GET["q"];	
	}else{
		$q=60;	
	}
	if($q=="" || $q==NULL){$q=70;}  
	
	$lio = $tam_img[0];
	$aio = $tam_img[1];
	
	if(($_GET["l"]=="" && $_GET["a"]=="")||($_GET["l"]=="0" && $_GET["a"]=="0")||($_GET["l"]=="" && $_GET["a"]=="0")||($_GET["l"]=="0" && $_GET["a"]=="")){
		$l=$lio;
		$a=$aio;
	}
	
	if($_GET["l"]=="" && $_GET["a"]!=""){
		$a= $_GET["a"];
		$l = ceil(($a*$lio)/$aio);
	}
	if($_GET["l"]!="" && $_GET["a"]==""){
		$l=$_GET["l"];
		$a = ceil(($l*$aio)/$lio);
	}
	
	if($_GET["l"]!="" && $_GET["a"]!=""){
		$l=$_GET["l"];
		$a=$_GET["a"];
			
		if($x>0){
			$pWc = ceil($x*($aio/(($l*$aio)/$lio)));
		}else if($x==0){
			$pWc=0;
		}else{
			$pWc = "meio";
		}
		
		
		if($y>0){
			$pHc=$y;
		}else if($y==0){
			$pHc=0;
		}else{
			$pHc = "meio";
		}
	}
	
	if($lio>$aio){
		$aP = $a/(($aio*$l)/$lio);
		$lP = $l/(($lio*$a)/$aio);
		if($lP<1){
			$crop_L = $lio/$aP;	
		}else{
			$crop_L = $lio;	
			$crop_A = $aio/$lP;
		}
	}
	if($aio>$lio){
		$aP = (($lio*$a)/$aio)/$l;
		$lP = $l/(($lio*$a)/$aio);
		if($aP<1){
			$crop_A = $aio*$aP;	
		}else{
			$crop_A = $aP;	
			$crop_L = $lio/$aP;
		}	
	}
	
	if($x>0 || $y>0){	
		$oImg->posicaoCrop($pWc,$pHc,$crop_L,$crop_A);	
	}
		if($a!=1){
			if($l!=1){
				$oImg->redimensiona($l,$a, "crop");
			}else{
				$oImg->redimensiona("",$a, "crop");
			}				
		}else{
			if($l!="1"){
				$oImg->redimensiona($l,"", "crop");
			}else{
				$oImg->redimensiona($lio,$aio, "crop");
			}
		}
	$oImg2=$oImg;
	if($rotate!=""){
		$oImg2->gira($rotate);
	}
	$oImg2->grava("", $q);
	exit;
?>