| 
	
 | 
 Posted by Dana Cartwright on 04/27/06 04:09 
>I have a website consisting of php segments. 
> 
> Example 
> page1.html calls in code from seg1.php and seg2.php 
> 
> If the user goes directly to www.mydomain.com/seg1.php they see everything  
> visible to a browser on that page. 
> 
> Can I prevent users from loading individual php segments. The only time  
> that seg1.php should be visible is in its original context on page1.html 
> 
 
The way Joomla and Mambo handle this is as follows: 
 
In page1.php (surely you meant .php, not .html?) you do this right at the  
top: 
 
define( 'MAIN_PAGE_LOADED', TRUE ); 
 
Then, in "seg1" and "seg2" you do this, again right at the top: 
 
defined( 'MAIN_PAGE_LOADED' ) or die ( 'This page is restricted' ); 
 
So, you prevent 'seg1' and 'seg2' from being directly loaded by the user.  
They can only be used as include files in 'page1'. 
 
Seems like a simple and effective solution. 
 
-Dana
 
  
Navigation:
[Reply to this message] 
 |