qui non serve mysql ....
eppure non ne comprendo la necessità di quanto segue...
http://www.dot.com/index.php?cat1=mypage
Codice PHP:
// 2-variables Page Include PHP-script
// CONFIGURATION
$dir1 = "./inc"; /* The directory where all the pages for category 1 are */
$dir2 = "./inc2"; /* The directory where all the pages for category 2 are */
$mainpage = "./inc/main.php"; /* Main page that is included if neither cat1 nor cat2 is defined in the URL */
$fileext = ".php"; /* File extension for all pages and tutorials. ".php" by default */
$error404 = "<h2>Error 404</h2>
Could not find the requested page</p>"; /* Error message displayed when a page doesn't exist */
/* Change the word inside the [' and the '] as you like. I.e ['page'] or ['id'] or ['section'] or whatever */
$cat1 = $_GET['cat1']; /* Example: [url]http://www.dot.com/index.php?cat1=mypage[/url] */
$cat2 = $_GET['cat2']; /* Example: [url]http://www.dot.com/index.php?cat2=mypage[/url] */
// END OF CONFIGURATION
// If cat1 is defined in the URL:
if (isset($cat1)) {
$cat1 = stripslashes(strip_tags($cat1));
$forbidden1 = ereg("\.\./", $cat1);
$forbidden2 = ereg("/", $cat1);
$includepath= $dir1 . "/" . $cat1 . $fileext;
if ($forbidden1 || $forbidden2) {
echo "<h2>Error</h2>";
echo "
Could not include page. Only local files may be included</p>";
}
else {
//echo "$includepath";
if (fopen("$includepath", "r")) {
include ("$includepath");
}
else {
if (!(fopen("$includepath", "r"))) {
//echo "$includepath";
echo "$error404";
}
}
}
}
// If cat2 is defined in the URL:
elseif (isset($cat2)) {
$cat2 = stripslashes(strip_tags($cat2));
$forbidden1 = ereg("\.\./", $cat2);
$forbidden2 = ereg("/", $cat2);
$includepath= $dir2 . "/" . $cat2 . $fileext;
if ($forbidden1 || $forbidden2) {
echo "<h2>Error</h2>";
echo "
Could not include page. Only local files may be included</p>";
}
else {
if (fopen("$includepath", "r")) {
include ("$includepath");
}
else {
if (!(fopen("$includepath", "r"))) {
echo "$error404";
}
}
}
}
// If no category is defined in the URL:
else {
include ("$mainpage");
}
?>