Re: munge / obfuscate ?
| From: | Robert Cummings | Date: | Fri, 28 Mar 2008 01:27:39 +0000 |
| Subject: | Re: munge / obfuscate ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272192@lists.php.net to get a copy of this message | ||
On Thu, 2008-03-27 at 21:10 -0400, Joey wrote:
> Hi All,
>
>
>
> I have written an app to allow a person to go online and see a picture we
> take of them. When we link to the picture I don't want it to be obvious
> that the URL is
>
> Domain.Com/Pix/123.jpg because the next person we take a picture of may be
> 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious.
<?php
$sekret = 'the brown cow stomped on the wittle bug';
$id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0;
$key = isset( $_GET['key'] ) ? (string)$_GET['key'] : '';
if( $key == sha1( $key.':'.$sekret ) )
{
header( 'Content-Type: image/jpg' );
readfile( "/images/not/in/web/path/$id.jpg" )
exit();
}
//
// Failure... tell them to bugger off :)
//
header( 'Content-Type: image/jpg' );
readfile( '/images/wherever/you/please/buggerOff.jpg' );
exit();
?>
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP