restrict access to a script

This is a discussion on restrict access to a script within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello All , I am trying to find a way to restrict access to a php script based on the url ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-13-2004
Denis
 
Posts: n/a
Default restrict access to a script

Hello All ,
I am trying to find a way to restrict access to a php script based on
the url it is being called from ,is this possable?

TIA

Reply With Quote
  #2 (permalink)  
Old 06-13-2004
Ron
 
Posts: n/a
Default Re: restrict access to a script

"Denis" <dzapped@hotmail.com> wrote in message
news:PzMyc.1037$Pt.55@newssvr19.news.prodigy.com.. .
> Hello All ,
> I am trying to find a way to restrict access to a php script based on
> the url it is being called from ,is this possable?


Denis,

Possible and fairly straightforward.

First, get the server name $_SERVER['SERVERNAME']
test it to determine if it is one to be protected,
then you have a choice.
you can use PHP_Authentication to send a challenge screen,
or you can send a login screen then you need to validate against a database
or a text file or a constant within the script itself.

the PHP manual covers the authentication test but beware that the
documentation was written with register_globals on so you need to handle
the variables as subscripts to the appropriate superglobals array if
register globals is off

HTH


Ron


Reply With Quote
  #3 (permalink)  
Old 06-13-2004
eclipsboi
 
Posts: n/a
Default Re: restrict access to a script

Hm, you could maybe try something like:

<?
$allowed_servers = array(
'server1',
'server2',
'server3',
'server4');

if (!in_array($_SERVER['SERVER_NAME'], $allowed_server)) {
die("Server not allowed.");
}
... // Your code
?>

On Sat, 12 Jun 2004 23:44:47 GMT, Denis <dzapped@hotmail.com> wrote:

>Hello All ,
>I am trying to find a way to restrict access to a php script based on
>the url it is being called from ,is this possable?
>
>TIA


Reply With Quote
Reply


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

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



All times are GMT +1. The time now is 06:16 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0