function Conectar(){
// $server="localhost";
// $user="alimentaria_user";
// $passw="alimentaria_pass";
// $dbname="bd_alimentaria";
$server="localhost";
$user="db_360a.360alimentaria";
$passw="yU8icmNwpm";
$dbname="360alimentaria";
$link=mysql_connect($server,$user,$passw) or die("ERROR: Could not connect to Server!");
mysql_select_db($dbname,$link) or die("ERROR: Could not connect to Data Base!");
mysql_query (" SET sql_mode = '' ");
return $link;
}
function executeQuery($link, $sql){
return mysql_query($sql,$link);
}
$link = Conectar();
$id = $_GET["id"];
$size = $_GET["size"];
$ver= is_numeric($id);
$ver2= is_numeric($size);
if($ver==1 && $ver2 == 1){
$sql = "SELECT * FROM archivo WHERE idarchivo = $id AND size = $size";
$result = executeQuery($link, $sql);
if($row=mysql_fetch_assoc($result)){
$tipo = $row["formato"];
$imagen = $row["info"];
$size = $row["size"];
$path = $row["path"];
$name = $row["nombre"];
}else{
header('location:../no_encontrada.html');
}
}
else{
header('location:../no_encontrada.html');
}
header("Content-type: ".$tipo);
if($size > 4096464){
header("Content-Disposition: attachment; filename=\"$name\"\n");
}
readfile("/home/360alimentaria/public_html/web/".$path);
die();
$img = imagecreatefromstring($imagen);
$new_w = imagesx($img);
$new_h = imagesy($img);
// echo "Ancho = " . $new_w . "
";
// echo "Alto = " . $new_h . "
";
$aspect_ratio = $new_h / $new_w;
$new_w = $picsize;
$new_h = abs($new_w * $aspect_ratio);
//echo "Nuevo Ancho = " . $new_w . "
";
//echo "Nuevo Alto = " . $new_h . "
";
//die ();
$dst_img = @ImageCreateTrueColor($new_w,$new_h)or die("Cannot Initialize new GD image stream");
imagecopyresampled($dst_img,$img,0,0,0,0,$new_w,$new_h,imagesx($img),imagesy($img));
header('Content-type: '.$tipo.'');
imagejpeg($dst_img,NULL,100);
imagedestroy($dst_img);
?>