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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
"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 |
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|