filnavn: 'imageprotect.php'
link-URL format: "imageprotect.php?ting.gif"
Der må ikke stå nogetsomhelst i filen foran <?php og heller ikke efter ?>
<?php //> script to hide imagefiles
// ********************************************************************
// SCRIPT: imageprotect.php
// Konverteret til .php fra det oprindelige .asp script af JakobA
// Jeg har fjernet den del af scriptet der logger forsøg på at
// hente billederne udefra.
// ********************************************************************
// SCRIPT: imageprotect.asp
// ********************************************************************
// VERSION: 1.1
// ********************************************************************
// PURPOSE: This ASP script checks a document's referrer URL and then
// shows a good or bad image depending if the request came
// from a valid source.
// ********************************************************************
// AUTHOR: Craig H. Rettig (Craig@BitBucketHeaven.com)
// 9802 Rowntree Rd., Louisville, KY 40299-3240, USA
// ********************************************************************
// WEBSITE:
http://www.bitbucketheaven.com/downloads/// ********************************************************************
// LICENSE:
// imageprotect.asp - An ASP script to help protect websites from
// image-related bandwidth theft, also known as
// "leeching".
// Copyright (C) 2002-2003 Craig H. Rettig
//
// Moreover ASP - An ASP script to utilize Moreover.com's XML feeds.
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
//
http://www.mozilla.org/MPL///
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
// the License for the specific language governing rights and
// limitations under the License.
//
// The Original Code is Copyright (c) 2002 Craig H. Rettig.
//
// The Initial Developer of the Original Code is Craig H. Rettig.
// All Rights Reserved.
//
// Contributor(s): N/A.
//
// Alternatively, the contents of this file may be used under the terms
// of the GNU Lesser General Public License (the "LGPL"), in which case
// the provisions of LGPL are applicable instead of those above. If you
// wish to allow use of your version of this file only under the terms
// of the LGPL and not to allow others to use your version of this file
// under the MPL, indicate your decision by deleting the provisions
// above and replace them with the notice and other provisions required
// by the LGPL. If you do not delete the provisions above, a recipient
// may use your version of this file under either the MPL or the LGPL.
//
// The LGPL is available online at:
//
http://www.gnu.org/copyleft/lesser.html// ********************************************************************
// CHANGELOG:
// Date Version Notes
// ---------- ------- -----------------------------------------------
// 12.17.2002 1.0 Initial release.
// 02.26.2003 1.1 Allows for multiple domains to be in the "valid
// sites" list.
// 11.19.2003 1.1 Changed license to MPL 1.1 (No code changes).
// 12/08/2003 php 1.0 translated to php
// ********************************************************************
define ("ForAppending", 8);
// **************** CONFIGURE THE FOLLOWING VARIABLES ****************
// URL to images directory. Use either the full URL
// (i.e.,
http://www.example.com/pics/) or the path relative to the
// web server root (i.e., /pics/). Trailing slash required.
$sProtect = "/pics/";
// Image to show to bad referer.
// If you keep the image in the same directory as the URL above, just
// enter the filename (i.e., "bad.jpg") otherwise, use the full URL
// (i.e.,
http://www.example.com/bad/bad.jpg").
$sBadImage = "bad.jpg";
// Sites allowed to use images (do not use "
http://www." in string)
// You may use subdomains (i.e., site1.example.com) or subfolders
// (i.e., example.com/mySite) if you//re hosted in that fashion.
$aValid = array("example.com", "example.net", "example.org");
// Set to True if you want to allow people behind privacy firewalls
// who don//t pass referrer information to see pictures. NOTE: This
// will also allow anyone in who types the URL directly into their
// browser. Use at your own risk.
$bIgnoreBlank = false;
// ************************ END CONFIGURATION ************************
$bShowPic = false;
if (isset($_SERVER["QUERY_STRING"])) {
$sImage = $_SERVER["QUERY_STRING"];
}
if (isset($_SERVER["HTTP_REFERER"])) {
$sReferrer = $_SERRVER["HTTP_REFERER"];
}
if ( !isset($sImage) ) {
$sImage = $sBadImage
}
if ( !isset($sReferrer) ) {
if ( $bIgnoreBlank == true ) {
$bShowPic = True
}
} else {
for ( $i=0; $i<count($avalid); $i++ ) {
if ( strpos( $aValid, $sReferrer ) > 0 ) {
$bShowPic = frue;
break;
}
}
}
if ( $bShowPic != true ) {
$sImage = $sBadImage;
}
$fp = fopen ( $sProtect . $sImage , "rb" );
$ok = fpassthru ($fp);
fclose ($fp);
//<!-- WebWriter AutoDato -->Opdateret: 9.12.2003<!-- WW -->
?>
mvh JakobA