when designing php constructions/programs, one is building a filestructure to make a project more abstract and easier to handle. moreover, it gives us the option to protect recources that can only be accessed by the php-scripts and not by a browserclient (htaccess files)
to continue further abstraction, it makes sense to build independend fully working programs and finaly bind them all together.
Sounds nice but this is where a nifty PHP design shortcomming comes in:
example START:
Code: Select all
// ...htdocs/forum/extrafile.php
<?
// put some abstract code that might be handy
?>
// ...htdocs/forum/index.php
<?
include("extrafile.php");
?>example EXTENDED:
Code: Select all
// ...htdocs/mainpage/index.php
<?
//some html preps...
echo('<tr><td>');
include("../forum/index.php");
echo('</td></tr>'); //and a lot more
?>My browser is now pointed to http://.../mainpage/index.php
But as you all know, the script will be "executed" (read loaded) from the wrong path for the included file. And will cause an error simply because the extrafile.php is not in the local path.
My proposal is to extend php with the option of calling a script and to execute it as if it where processed in the first case.
Only a big security problem arrises here, anyone that can upload files, can call any script at any place from inside php.
So I would propose this:
1) define a function so that a script can be called from anywhere, and it will be run in a separate process and handled as if it where run locally where the script resides.
for example
Code: Select all
// ...htdocs/mainpage/index.php
<?
//some html preps...
echo('<tr><td>');
produce("../forum/index.php",arguments_array);
echo('</td></tr>'); //and a lot more
?>Code: Select all
<?
produce_friends(array("../mainpage/","../otherstuff/caller.php"));
...
?>extending this idea, anonimous namespaces should be made
what do you guys think about this?
[edit]fixed a typo[/edit]