Update index.php

This commit is contained in:
deepend 2024-01-10 20:16:27 +00:00
parent 52dff05673
commit ef51522e07
1 changed files with 21 additions and 21 deletions

View File

@ -1,22 +1,22 @@
<?php
// Define the default page
$defaultPage = 'domain_search';
// Get the requested page from the query parameter
$page = isset($_GET['page']) ? $_GET['page'] : $defaultPage;
// Sanitize the page parameter to prevent directory traversal
$page = preg_replace('/[^-a-zA-Z0-9_]/', '', $page);
// Path to the includes directory
$includesPath = './includes/';
// Check if the file exists
if (file_exists($includesPath . $page . '.php')) {
require_once $includesPath . $page . '.php';
} else {
// If the file doesn't exist, you can include a default page or show an error
echo "Page not found.";
// Or include a 404 page
// require_once $includesPath . '404.php';
<?php
// Define the default page
$defaultPage = 'main';
// Get the requested page from the query parameter
$page = isset($_GET['page']) ? $_GET['page'] : $defaultPage;
// Sanitize the page parameter to prevent directory traversal
$page = preg_replace('/[^-a-zA-Z0-9_]/', '', $page);
// Path to the includes directory
$includesPath = './includes/';
// Check if the file exists
if (file_exists($includesPath . $page . '.php')) {
require_once $includesPath . $page . '.php';
} else {
// If the file doesn't exist, you can include a default page or show an error
echo "Page not found.";
// Or include a 404 page
// require_once $includesPath . '404.php';
}