TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

June 26, 2024, 01:51:55 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,280
  • Total Topics: 21,227
  • Online today: 203
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 219
  • Total: 219

TP prefixing absolute paths in php scripts?

Started by Inge Jones, January 29, 2007, 06:00:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zetan

Hi J.A.Cortina, slightly off topic. I've been reading this thread some of today.
I'm interested in the Anti Hotlinking you were talking about. I've tried editing my .htaccess and I can't seem to get it to work. I'm doing something wrong.

ZTN

jacortina

It's specific to the given site/domain. What lines are you trying to use and what is your website URL?

Zetan

I did edit the paths.. I tried sveral different ways.. and I have a banner I whipped up.

Here is the code if you don't mind taking a look.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://labradio\.co\.uk(/)?.*$     [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://labradio.co.uk      [R,NC,L]
RewriteCond %{HTTP_REFERER} !^http://administrator.labradio.co.uk/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://administrator.labradio.co.uk$      [NC]
RewriteCond %{HTTP_REFERER} !^http://dj.labradio.co.uk/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://dj.labradio.co.uk$      [NC]
RewriteCond %{HTTP_REFERER} !^http://labradio.co.uk/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://labradio.co.uk$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.labradio.co.uk/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.labradio.co.uk$      [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://labradio.co.uk/dontstealourbandwidth.gif [R,NC,L]


I've taken some of it out.
I can't call the banner at all.. it redirects me to the home page.

ZTN

jacortina

The first rule listed (line 3 in the code) will force that redirect and I believe the 'L' in the [R, NC, L] means it's the Last processing mod_rewrite shoudl do.

Note that I don't claim to be a mod_rewrite expert, but I'm fairly sure that if anything with labradio.co.uk is allowed, then only one condition line should be needed. Try something like this (yes, replacing everything you showed:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?labradio\.co\.uk(/)?.*$Ã,  Ã,  Ã,  [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://labradio.co.uk/dontstealourbandwidth.gif [R,NC,L]

Zetan

#34
No worries, I understand you are not an expert.
I'll just think out loud for a bit.
I've played with this last night.. and it's still not quite working.

<Files 403.shtml>
order allow,deny
allow from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?labradio\.co\.uk(/)?.*$      [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://labradio.co.uk/bandwidth.gif [R,NC,L]

I renamed the .gif as  it was a bit long. I've tried to hot link the lab radio's header image in SMF's test board.
It displays the header image briefly and then the image disappears completely and no .gif is displayed.

My cPanel has a Hot Link Protection feature:
HotLink Protection

Hotlink protection is currently: enabled

    HotLink protection prevents other websites from directly linking to files (as specified below) on your website. Other sites will still be able to link to any file type that you don't specify below (ie. html files). An example of hotlinking would be using a <img> tag to display an image from your site from somewhere else on the net. The end result is that the other site is stealing your bandwidth. You should ensure that all sites that you wish to allow direct links from are in the list below. This system attempts add all sites it knows you own to the list, however you may need to add others.


Enable Hotlink Protection
URLs to Allow Access:
http://(.*\.)?labradio\.co\.uk(/)?.*

Extensions to allow (seperate by commas):
Url to Redirect to:
http://labradio.co.uk/bandwidth.gif

Allow direct requests (ie. entering the url to an image in your browser)

If I disable the Hot Link Protection, then the .htaccess has the first code removed.

I'll post the Hot Link here:


I'm guessing it shows until this page has fully loaded, then vanish.
Which does work to a point, in that you won't get an image.


I'm thinking that this thread has gone a bit off topic and should maybe be split

ZTN

digisubs

anyone know how to run phpdictionary (www.phpdictionary.com) on a phpbox? i get a parse error when i copy and paste the script (from the index.php) to the phpbox:

require('config.php');
require('func.php');
IsAdminLogin();
SiteMenu();

include('_header.php');
echo $GLOBALS['content'];
include('_footer.php');

mysql_close();