Cassius
01-16-2005, 07:19 AM
I'm using the PHP "include" function for including the header and footer on a page. I want to make sure that the right page is included and that the website stays secure. I'm considering a simple solution to make sure that it works.
<?php
$this1 = "my";
$this2 = "in";
$this3 = "clude";
$exten_a7f = ".txt";
$path_gr4 = "../something/";
if ( $path_gr4 . $this1 . #this2 . $this3 . $exten_a7f == "../something/myinclude.txt");
{
include($path_gr4 . $this1 . #this2 . $this3 . $exten_a7f);
}
else {
echo "All your bases";
}
?>
Does this seem like an absurd approach that's still insecure? Do any of you know a better way to do this?
I'm considering using the "preg_match" function with Regular Expressions for validation, but I'm new to using Regular Expressions (I only understand the simple stuff) and I'm not sure about how to approach implementation. Like, should I be checking for special characters that shouldn't be there or only the characters that should be there? This is why I've leaned toward the aforementioned solution, since I don't want to screw things up. That goes both ways since the aforementioned was kind of stupid and already screwed up.
<?php
$this1 = "my";
$this2 = "in";
$this3 = "clude";
$exten_a7f = ".txt";
$path_gr4 = "../something/";
if ( $path_gr4 . $this1 . #this2 . $this3 . $exten_a7f == "../something/myinclude.txt");
{
include($path_gr4 . $this1 . #this2 . $this3 . $exten_a7f);
}
else {
echo "All your bases";
}
?>
Does this seem like an absurd approach that's still insecure? Do any of you know a better way to do this?
I'm considering using the "preg_match" function with Regular Expressions for validation, but I'm new to using Regular Expressions (I only understand the simple stuff) and I'm not sure about how to approach implementation. Like, should I be checking for special characters that shouldn't be there or only the characters that should be there? This is why I've leaned toward the aforementioned solution, since I don't want to screw things up. That goes both ways since the aforementioned was kind of stupid and already screwed up.