mirror of https://github.com/TildeNIC/site.git
Update index.php
This commit is contained in:
parent
52dff05673
commit
ef51522e07
42
index.php
42
index.php
|
@ -1,22 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
// Define the default page
|
// Define the default page
|
||||||
$defaultPage = 'domain_search';
|
$defaultPage = 'main';
|
||||||
|
|
||||||
// Get the requested page from the query parameter
|
// Get the requested page from the query parameter
|
||||||
$page = isset($_GET['page']) ? $_GET['page'] : $defaultPage;
|
$page = isset($_GET['page']) ? $_GET['page'] : $defaultPage;
|
||||||
|
|
||||||
// Sanitize the page parameter to prevent directory traversal
|
// Sanitize the page parameter to prevent directory traversal
|
||||||
$page = preg_replace('/[^-a-zA-Z0-9_]/', '', $page);
|
$page = preg_replace('/[^-a-zA-Z0-9_]/', '', $page);
|
||||||
|
|
||||||
// Path to the includes directory
|
// Path to the includes directory
|
||||||
$includesPath = './includes/';
|
$includesPath = './includes/';
|
||||||
|
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
if (file_exists($includesPath . $page . '.php')) {
|
if (file_exists($includesPath . $page . '.php')) {
|
||||||
require_once $includesPath . $page . '.php';
|
require_once $includesPath . $page . '.php';
|
||||||
} else {
|
} else {
|
||||||
// If the file doesn't exist, you can include a default page or show an error
|
// If the file doesn't exist, you can include a default page or show an error
|
||||||
echo "Page not found.";
|
echo "Page not found.";
|
||||||
// Or include a 404 page
|
// Or include a 404 page
|
||||||
// require_once $includesPath . '404.php';
|
// require_once $includesPath . '404.php';
|
||||||
}
|
}
|
Loading…
Reference in New Issue