PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Outputting Images
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Outputting Images

Réponse
 
LinkBack Outils de la discussion
Vieux 27/02/2008, 23h14   #1
MichaelD
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Outputting Images

So I'm making a hotlink prevention script, which verifies if the
requestor should be able to see the image, or not, and does one of the
following operations depending:

if(USERISVALID)
{
// header("Content-Type: image/jpeg");
// include $_SERVER['DOCUMENT_ROOT'].'/images/directory/hats1.jpg';
header("Content-Type: ".$array[$id][0]);
include $_SERVER['DOCUMENT_ROOT'].'/gallery/'.$gal.'/'.$array[$id]
[1];
exit;
}
else
{
header("Content-Type: image/png");
include $_SERVER['DOCUMENT_ROOT']."/template/imageFail.png";
exit;
}

The imageFail.png file which I made in Photoshop works perfectly, but
when I try any other image (png's or jpg's) that I got off the web, it
fails (just prints the url, as if the image was corrupted - which it's
not). I'm still experimenting, trying to determine exactly what kind
of images work and don't, but I'm wondering if anyone else has run
into this problem, or have any solutions?
  Réponse avec citation
Vieux 28/02/2008, 00h28   #2
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Outputting Images

Hi,

Try readfile instead of include.

You can also set error_reporting(E_ALL) to see if you have any
notices.

On Feb 27, 6:14 pm, MichaelD <dimo...@gmail.com> wrote:
> So I'm making a hotlink prevention script, which verifies if the
> requestor should be able to see the image, or not, and does one of the
> following operations depending:
>
> if(USERISVALID)
> {
> // header("Content-Type: image/jpeg");
> // include $_SERVER['DOCUMENT_ROOT'].'/images/directory/hats1.jpg';
> header("Content-Type: ".$array[$id][0]);
> include $_SERVER['DOCUMENT_ROOT'].'/gallery/'.$gal.'/'.$array[$id]
> [1];
> exit;}
>
> else
> {
> header("Content-Type: image/png");
> include $_SERVER['DOCUMENT_ROOT']."/template/imageFail.png";
> exit;
>
> }
>
> The imageFail.png file which I made in Photoshop works perfectly, but
> when I try any other image (png's or jpg's) that I got off the web, it
> fails (just prints the url, as if the image was corrupted - which it's
> not). I'm still experimenting, trying to determine exactly what kind
> of images work and don't, but I'm wondering if anyone else has run
> into this problem, or have any solutions?


  Réponse avec citation
Vieux 28/02/2008, 00h29   #3
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Outputting Images

One thing to check, when you output a png or jpg, the Content-Type
should always match.

On Feb 27, 6:14 pm, MichaelD <dimo...@gmail.com> wrote:
> So I'm making a hotlink prevention script, which verifies if the
> requestor should be able to see the image, or not, and does one of the
> following operations depending:
>
> if(USERISVALID)
> {
> // header("Content-Type: image/jpeg");
> // include $_SERVER['DOCUMENT_ROOT'].'/images/directory/hats1.jpg';
> header("Content-Type: ".$array[$id][0]);
> include $_SERVER['DOCUMENT_ROOT'].'/gallery/'.$gal.'/'.$array[$id]
> [1];
> exit;}
>
> else
> {
> header("Content-Type: image/png");
> include $_SERVER['DOCUMENT_ROOT']."/template/imageFail.png";
> exit;
>
> }
>
> The imageFail.png file which I made in Photoshop works perfectly, but
> when I try any other image (png's or jpg's) that I got off the web, it
> fails (just prints the url, as if the image was corrupted - which it's
> not). I'm still experimenting, trying to determine exactly what kind
> of images work and don't, but I'm wondering if anyone else has run
> into this problem, or have any solutions?


  Réponse avec citation
Vieux 28/02/2008, 20h15   #4
MichaelD
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Outputting Images

On Feb 27, 4:28 pm, petersprc <peters...@gmail.com> wrote:
> Hi,
>
> Try readfile instead of include.
>
> You can also set error_reporting(E_ALL) to see if you have any
> notices.
>


Yeah, I ended up using file_get_contents() which seems to work
perfectly. Thanks for the !
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,74923 seconds with 12 queries