You are here: Re: [PHP] Preventing execution without inclusion « PHP « IT news, forums, messages
Re: [PHP] Preventing execution without inclusion

Posted by Jacek Blech on 01/14/05 09:42

Adam Hubscher wrote:

> I am trying to prevent 2 from even occuring, utilizing a piece of code
> that would check if index.php had included it, or not. This code would
> be in the beginning of all the class files, at the top, before any
> other code was to be executed.

use the 2 constants/variables available in PHP scripts to check if the
class file has been included by another php script:

__FILE__ // the name of the file the current codeline is a part of
$_SERVER["SCRIPT_FILENAME"] // the name of the primary php file, that
has included the current file

so it may be enough for you to do something like this in you class files:

<?php

if ( basename(__FILE__) != 'index.php' ) {
// redirection to index.php ...
}

class Join
{}

?>

>
> As of yet, it has eluded me...
>
hth, bye.

 

Navigation:

[Reply to this 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

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