Why do most of the Joomla! PHP files start with defined(' JEXEC')?

From Joomla! Documentation

Revision as of 18:10, 2 September 2008 by Dextercowley (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Most PHP files within Joomla! 1.5 begin with the following statement:

    defined('_JEXEC') or die('Restricted access');

This statement checks to see if the file is being called from within a Joomla! session. This protects your site by making it more difficult for a cracker/hacker to damage your site.

However, this line should NOT be included in your main index.php file, since this is the program that starts the Joomla! session.