| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 74116 | 2006-11-12 06:21:00 | php - Allow file to be accessed by relative link only no direct access | Morgenmuffel (187) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 498318 | 2006-11-12 06:21:00 | php - Allow file to be accessed by relative link only no direct access I remember seeing a small script that prevented someone direct accessing a php page, but allowing it to be accessed by a relative link, but i cannot for the life of me find it, so anyhelp would be appreciated note this was just a small 2 or 3 line script that sat at the top of the page Cheers |
Morgenmuffel (187) | ||
| 498319 | 2006-11-12 07:11:00 | Hi there. Try: if (eregi("somefile.php", $_SERVER['PHP_SELF'])) { //do something } If you wanted to redirect to a page: if (eregi("somefile.php", $_SERVER['PHP_SELF'])) { header("Location: index.php"); die(); } Or give an error: if (eregi("somefile.php", $_SERVER['PHP_SELF'])) { die('Direct access blocked'); } |
gizmoguy (11231) | ||
| 498320 | 2006-11-14 06:00:00 | Thanks for that **must remember to subscribe to my own threads |
Morgenmuffel (187) | ||
| 1 | |||||