Current location: Hot Scripts Forums » Programming Languages » PHP » Only allowing original referrer to access a page


Only allowing original referrer to access a page

Reply
  #1 (permalink)  
Old 11-16-03, 12:40 AM
fixafone123 fixafone123 is offline
New Member
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Only allowing original referrer to access a page

I have a .php page that I only want to be accessed via a call from another page on my site. I dont want someone to be able to type the URL of the page into their browser and get to it. I thought I could ban all other IPs except the local ip (127.0.0.1) from accessing the page, but I cant get it to work and am not sure if this is the most efficient way to do it. Any help would be appreciated.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-16-03, 02:53 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post

Try this...
Attached Files
File Type: txt deny access.txt (4.2 KB, 814 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-28-04, 05:37 AM
mixDev's Avatar
mixDev mixDev is offline
Newbie Coder
 
Join Date: May 2004
Location: Bangalore
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation

HI all,


Authentication systems based on HTTP_REFERER checking are not really secure as it can be Spoofed easily using custom HTTP headers. A simple googling for HTTP_REFERER gives the first link titled "How to spoof HTTP_REFERER".

So I changed something there in the above script file Change "Your Ip here" to the IP address whom u want to allow access.
PHP Code:

<?php 

$USERIP 
getenv("REMOTE_ADDR");
 
if (!
strchr($USERIP"Your IP Here")) { 
echo 
"<script>alert('Sorry, you are not allowed access');window.location='localhost/community/sorry.php';</script>"
 exit(); 

 
?>
BUT,
If you really need a secure system, u can use Apache .htaccess password protection techniques. You can see one tutorial here.
If you are not using apache at all, try php session varibles to authenticate users.


(is that so general?. this is my first post. So plz dont flame me. )
__________________
-=| mixDev |=-

SenseLabs Webmaster Tools | SubmitForce URL Submitter<br>

Last edited by mixDev; 05-28-04 at 06:00 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-28-04, 05:42 AM
mixDev's Avatar
mixDev mixDev is offline
Newbie Coder
 
Join Date: May 2004
Location: Bangalore
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

HI again,

Here is a related theread u may be interested in.
http://www.programmingtalk.com/showthread.php?t=5864
__________________
-=| mixDev |=-

SenseLabs Webmaster Tools | SubmitForce URL Submitter<br>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
echo foriegn html in static page fergusom Everything Java 4 11-10-03 03:35 AM
Block Access to a page Ikoh ASP 1 07-21-03 10:51 AM


All times are GMT -5. The time now is 09:26 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.