|
|
|
This attached file is a script that allows you to perform hotlink prevention in pure php, for those that cannot do .htaccess or other methods. It includes full documentation on getting it up and running. More scripts available at http://www.suryvial.com.
| <?php
/*
Copyright (C) 2003 Enders Web Development
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the
Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author Email: tomender@ptd.net
Author Post:
J. Thomas Enders
PO Box 663
Gilbert, PA 18331, USA
*/
error_reporting(E_ALL);
//where, in relation to this script, are the files stored
define(FILE_DIR,'.');
define(MY_URL,'suryvial.com');
//set up the array of types the system recognizes
$file_types = array(
'jpg' => array('image/jpeg','hotlinker.jpg'),
'gif' => array('image/gif','hotlinker.gif'),
'png' => array('image/png','hotlinker.png')
);
//make sure the script was called with the correct parameters
if(!isset($_GET['File']) || !isset($_GET['Type'])) {
die('Required Parameters Not Specified');
} elseif(!file_exists($_GET['File'])) {
die('Invalid File Specified');
} elseif(!isset($file_types[$_GET['Type']])) {
die('Invalid Type Specified');
} //end if
//check if the link originated from our site
if(!ereg(MY_URL,$_SERVER['HTTP_REFERER'])) {
//reset the file to be the one we point hotlinkers to
$_GET['File'] = $file_types[$_GET['Type']][1];
} //end if
//send out the headers for this file
header('Last-Modified: ' . date('D, d M Y G:i:s T',filemtime($_GET['File'])));
header('Accept-Ranges: bytes');
header('Content-Length: ' . filesize($_GET['File']));
header('Connection: close');
header('Content-Type: ' . $file_types[$_GET['Type']][0]);
//send the file to the browser
$file = fopen($file_dir . '/' . $_GET['File'],'r');
while(!feof($file)) {
print(fread($file,4096));
flush();
} //end while
fclose($file);
?> | | |
|
| File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection. Categories : Complete Programs, Content Management, Filesystem, PHP | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs | | | QTO File Manager Categories : Filesystem, filePro, Complete Programs, PHP, Content Management | | | Easy slideshow with php. Just place this one file into a subdirectory where jpg files reside. An instant slideshow is yours. MS explorer only. Categories : PHP, Filesystem, Graphics | | | Simple image counter Categories : PHP, Graphics, Filesystem, Beginner Guides | | | Image Browser Categories : Filesystem, GD image library, Content Management, PHP | | | This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given. Categories : PHP, Arrays, Graphics, Filesystem | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP, GD image library, Graphics | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | A flat file counter Categories : PHP, Cookies, Filesystem, Beginner Guides | | | background music script for random notes in a frame Categories : PHP, Content Management, HTML and PHP | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | |
|
|
|