Access to remote included file classes and functions
<!-- php.ini -->
allow_url_include = On
<!-- fooFile.php on "http://www.example.com/" -->
<?php
function fooFunc()
{ // this function has SOME SECURITY CODE that remote user can not be seen that...
return ("this as fooFunc() on fooFile.php");
}
?>
<!-- index.php on "my website" -->
<?php
required_once("http://www.example.com/fooFile.php");
echo fooFunc();
?>
Fatal error: Call to undefined func开发者_运维技巧tion fooFunc() in ...
The server on example.com must return PHP as output. In other words, it must return plain text. Disable your PHP engine on example.com or change fooFile.php to :
<?php
echo <<<'EOD'
<?php
function fooFunc()
{ return ("this as fooFunc() on fooFile.php");
}
?>
EOD;
?>
If you require a external php-page, you get the parsed results. Imagine what a security hazard it would be if you could "require" an external page and instantly see the code..
If you want to include it as source, the source should be readable, like making it a .txt
in stead of a .php
You would have to make it plain text. If you don't want people to see the security info then store it somewhere else like an SQL or MySQL database, if your server supports it, then in the code you can just retrieve the data from your database.
精彩评论