I wrote a script who upload a picture to a folder and now i wrote another to load the picture, but they had a lot of bugs and started to fix them, the file who uploads the picture works fine, but the one in charge of loading the picture, example script.php?picture=1.jpg doesn't seem to work the way it should.
This is my old script.
- Code: Select all
<?php
$imagen = "SECRETO".$_GET['imagen'];
$servidor = "redr2k.com";
$referer = $_SERVER['HTTP_REFERER'];
$dominio = substr_count("$referer", "$servidor");
if ($dominio != "0"){
readfile($imagen);
exit;
}
else{
readfile("error.jpg");
exit;
}
?>
And this is the new one:
- Code: Select all
<?php
$imagen = "SECRETO/".$_GET['imagen'];
$dominio = substr_count($_SERVER['HTTP_REFERER'],"redr2k.com");
if (!file_exists($imagen)){$dominio = 0;}
$dominio = 1;
if($dominio == "0" OR empty($_GET['imagen'])){
if(!empty($_SERVER['HTTP_REFERER']) AND !empty($_GET['imagen'])){
$sql = "";
@mysql_query($sql);
}
$len = filesize("error.jpg");
header('Content-type: image/jpeg');
header('Content-Length: $len');
header('Content-Disposition: inline; filename=\"error.jpg\"');
readfile("error.jpg");
exit;
}
else{
$len = filesize($imagen);
header('Content-type: image/jpeg');
header('Content-Length: $len');
header('Content-Disposition: inline; filename=\"$imagen\"');
readfile($imagen);
exit;
}
?>
The old script works fine, ok let's say it works because even if the browser loads the picture correctly if a access the url directly it shows a lot os symbold, thats because the server tells the browser to load the file, so i tried to fix it using the header sentence, this way i tell the browser he is loading a picture.
The second script, when you load a picture they are all broken (corrupted data) and i don't know how to fix it.
Thanks for your help and sorry if the variables are al in spanish.


