Reply to Re: Prevent loading of php pages

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация