Which one of these is better :
include("up.php");
content here
include("down.php");
up.php file contains each page up part
down.php file contains each page footer part
or
$sivu = $_GET['sivu'];
$sivu = str_replace("/", "", $sivu); //only this directory allowed
include("".$sivu.".php");
The first solution is easy to read, easy to debug, and perfectly safe, even on Windows.
The second solution allows attackers to execute arbitrary files, at least on Windows by using backslashes(
\) instead of slashes. Also, it’s unnecessarily complex.