Forum Moderators: coopster

Message Too Old, No Replies

Looking for a PHP Code that...

         

lindajames

4:39 pm on May 17, 2003 (gmt 0)

10+ Year Member



Hi,

Does anyone know of any Open Source PHP codes that does the following:

if i open index.php?page=home.html the code should open home.html. in other words a template driven php code.

Any suggestions would be very much appreciated.

Cheers
Linda

jatar_k

4:51 pm on May 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



for php templating try taking a look at smarty.php.net

grahamstewart

4:53 pm on May 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php
require_once( $_GET['page'] );
?>

Thats your basics right there.
However, you should really validate the file they are requesting otherwise any script kiddie hacker could try something like index.php?page=/etc/passwd

So you probably want somethng more like..

[pre]
$allowedPages = array ( 'home.html', 'away.html', 'contact_us.html' );

if ( isset($_GET['page']) and array_search($_GET['page'], $allowedPages) )
require( $_GET['page'] );
else
require( 'home.html' );
[/pre]