Okai ladies and gents, and little scripters (you 1337 *****)
Here's some PHP & Lil Apache rewrite for you
Basically, I got bored and coded this up. It allows people to hotlink for a period of time, say 1 minute, or 50 hours?
Its not the best way to do it and could probably changed > alot <
Heres the main part of it...
I'ma post the folder here, so you can see how it all works alltogether, if ur interested.PHP Code:<?php
mysql_connect( 'localhost', 'dev_hotLink', 'hottie' ) or die( 'Error Mysql DB' );
mysql_select_db( 'dev_hotLinks' );
function createImg( $i )
{
$f = @file_get_contents( $i );
$iS = imagecreatefromstring( $f );
header( 'content-type: image/png' );
imagepng( $iS );
imagedestroy( $iS );
}
function hotLink( $i, $t, $a )
{
if( $i != '' && $t != '' )
{
if( is_numeric( $t ) )
{
$iS = rand() . '-imageHotlink-' . rand();
if( $q = mysql_query( 'INSERT INTO `hotlinks` (`id`, `img`, `session`, `timeout`, `time`) VALUES (NULL, "' . mysql_real_escape_string( $i ) . '", "' . $iS . '", "' . ( $t * 60 ) . '", "' . time() . '");' ) )
{
echo( '<img src="images/' . $iS . '" alt="' . $a . '" />' );
}
}
else
{
echo( '<img src="error.jpg" alt="' . $a . '" />' );
}
}
else
{
echo( '<img src="error.jpg" alt="' . $a . '" />' );
}
}
function findImage( $s )
{
if( $s != '' )
{
if( $q = mysql_query( 'SELECT * FROM `hotlinks` WHERE `session` = "' . mysql_real_escape_string( $s ) . '"' ) )
{
if( mysql_num_rows( $q ) >= 1 )
{
if( $f = mysql_fetch_array( $q ) )
{
if( abs( ( time() - $f[ 'time' ] ) ) <= $f[ 'timeout' ] )
{
createImg( $f[ 'img' ] );
}
else
{
mysql_query( 'DELETE FROM `hotlinks` WHERE `hotlinks`.`id` = "' . $f[ 'id' ] . '" LIMIT 1' );
createImg( 'hotlink.jpg' );
}
}
}
else
{
createImg( 'hotlink.jpg' );
}
}
else
{
createImg( 'error.jpg' );
}
}
else
{
createImg( 'error.jpg' );
}
}
?>
Heres the SQL => http://dev.e-mx.co.uk/dev_hotLinks.sql
Heres the ZIP => http://dev.e-mx.co.uk/hotlink.zip
FLAME FLAME FLAME :eusa_danc
xxxxxxx
Protege





Reply With Quote



Well done.
