Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
Steptoe
Involved
Involved



Joined: Oct 09, 2004
Posts: 293

PostPosted: Sun Jun 08, 2008 3:50 pm Reply with quote

Hey guys, see u are all still kicking around, keeping well I hope.
I have been playing with
1/ .htaccess and
2/ .htaccess/showpic.php
They both work but cant figure out how to make them work as I would like.

the simple .htaccess method described in older posts and below just replaces the hotlinked file with a gif

What I would like to do is have that hotlink pic
Image
(or preferible site link banner )
Image
With a hyper link to kakariki.net home page
And words below like "hotlink bandwidth theft is not permiited, if you wish to visit us clk the banner above" A alt tag with site description
Sort of the same as the code in the link to us block raven has on the home page

The codes I have been playing with are
1/
Code:
RewriteEngine on

 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?kakariki.net/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?kakariki.sytes.net/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?babelfish.altavista.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?translate.google.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?yahoo.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?yahoo.net/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?msn.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?msn.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?windowslivetranslator.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ /hotlink.jpg [R,L]


2/ in .htaccess
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} .*jpg$.*gif$.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !kakariki\.net [NC]
RewriteCond %{HTTP_REFERER} !kakariki\.sytes\.net [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
#RewriteRule (.*) /showpic.php?pic=$1


And a new file showpic.php
Code:
<?php

  header("Content-type: text/html");
  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  header("Cache-Control: no-store, no-cache,
          must-revalidate");
  header("Cache-Control: post-check=0, pre-check=0",
          false);
  header("Pragma: no-cache");
  $pic = strip_tags( $_GET['pic'] );

  if ( ! $pic ) {
    die("No picture specified.");
  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php echo($pic); ?></title>
<meta
  http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1"
>
</head>
<body>
<p>
  <img src="/<?php echo($pic); ?>" alt="Image">
</p>
<p>
  Image from
  <a href="http://www.kakariki.net">
  www.kakariki.net</a>.
</p>
</body>
</html>


I have googled for a few days to find something, but the above seems to be they only choices...
I think dong a link banner concept would be a cool idea. Idea

Once again many thanks for the help in the past.
Cheers
Steps

PS was looking for a Simple access log veiwer prog and found this...
Over the last few weeks the guy has upgraded several times with cool added functions..so its work in progress. I have only used thru LAN
Only registered users can see links on this board! Get registered or login!

_________________
My Spelling is NOT incorrect, it's Creative 
View user's profile Send private message
Steptoe







PostPosted: Mon Jun 09, 2008 3:16 am Reply with quote

Had another go with 2/
Changed showpic.php to
Code:
<?php

  header("Content-type: text/html");
  header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  header("Cache-Control: no-store, no-cache,
          must-revalidate");
  header("Cache-Control: post-check=0, pre-check=0",
          false);
  header("Pragma: no-cache");
//  $pic = strip_tags( $_GET['pic'] );

//  if ( ! $pic ) {
//    die("No picture specified.");
//  }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title><?php echo($pic); ?></title>
<meta
  http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1"
>
</head>
<body>
<p>

 <a href="http://www.kakariki.net"><strong><big></big></strong><b>Due to Hotlinking Abuse the Practice is Blocked</b><br>
<img  src=/kikelogosm.gif alt="Kakariki, Care, Breeding, Diet, Health, Aviaries and Conservation" width=315 height=61><br>
  <strong><big></big></strong><b>You May Like to click Our Banner to Visit Us</b></a><br>
  Admin: Kakariki.net
</p>             

</body>
</html>

If I go to http://www.kakariki.net/showpic.php
I get what I want to present instead of the hotlinked file

But doesnt work where the hot link is??
I suspect it is the last line in the ,htaccess
Code:
RewriteEngine On

 RewriteCond %{REQUEST_FILENAME} .*jpg$.*gif$.*png$ [NC]
 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !kakariki\.net [NC]
 RewriteCond %{HTTP_REFERER} !kakariki\.sytes\.net [NC]
 RewriteCond %{HTTP_REFERER} !google\. [NC]
 RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
 RewriteRule (.*) /showpic.php?pic=$1


O as usual Im trying to do something with something I have no idea ...
Again Rolling Eyes

Help please?
 
Steptoe







PostPosted: Mon Jun 09, 2008 8:03 pm Reply with quote

Bump?
Is it actually possible to do what I would like?
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Jun 10, 2008 5:09 am Reply with quote

Steptoe, bump? Shocked

I think you are on the right track. Unfortunately, I am not sure about the second line within your .htaccess. That may very well be correct as far as I know, but my first glance at it made me unsure of it. Maybe try this:

RewriteCond %{REQUEST_FILENAME} ^.*\.(jpg|gif|png)$ [NC]

In addition, depending upon where these image path names are coming from, you may want to consider doing some input cleansing on the $pic variable as you could be opening yourself up for all sorts of exploitation.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©