Ripristino template originale
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* In this array, please add the functions you may want to add on your project.
|
||||
* Please note that you can use a variable or a costant by adding a space rather than
|
||||
*/
|
||||
|
||||
$NewCostants = [
|
||||
[ "BLOCKNOTES_FOLD", "ROOT_DIR", "blocknotes/" ]
|
||||
|
||||
];
|
||||
|
||||
// ##### PLEASE DO NOT TOUCH THE BELOW COSTANTS ##### //
|
||||
// --- ROOT DIR --- //
|
||||
define("ASSETS_FOLD", ROOT_DIR . "assets/");
|
||||
define("ADMIN_FOLD", ROOT_DIR . "admin/");
|
||||
define("BLOCKNOTES_FOLD", ROOT_DIR . "blocknotes/");
|
||||
define("CONFIG_FOLD", ROOT_DIR . "config/");
|
||||
define("PAGES_FOLD", ROOT_DIR . "pages/");
|
||||
define("PUBLIC_FOLD", ROOT_DIR . "public/");
|
||||
define("TEMPLATES_FOLD", ROOT_DIR . "templates/");
|
||||
define("THEMES_FOLD", ROOT_DIR . "themes/");
|
||||
define("FUNCTIONS_FOLD", ROOT_DIR . "functions/");
|
||||
define("INCLUDES_FOLD", ROOT_DIR . "includes/");
|
||||
|
||||
// - ASSETS
|
||||
define("CSS_FOLD", ASSETS_FOLD . "css/");
|
||||
define("IMG_FOLD", ASSETS_FOLD . "img/");
|
||||
define("JS_FOLD", ASSETS_FOLD . "js/");
|
||||
define("FONTS_FOLD", CSS_FOLD . "fonts/");
|
||||
|
||||
// --------------- //
|
||||
|
||||
|
||||
// --- ROOT URL --- //
|
||||
// - CSS
|
||||
define("CSS_STYLE", ROOT_URL . "/assets/css/style.css");
|
||||
define("CSS_VAR", ROOT_URL . "/assets/css/variables.css");
|
||||
define("CSS_ANIM", ROOT_URL . "/assets/css/animations.css");
|
||||
define("CSS_FONTS", ROOT_URL . "/assets/css/fonts.css");
|
||||
|
||||
// - JS
|
||||
define("JS_MAIN", ROOT_URL . "/assets/js/main.js");
|
||||
// --------------- //
|
||||
|
||||
|
||||
/// CUSTOM COSTANTS DECLARED ///
|
||||
foreach ($NewCostants as $const_array) {
|
||||
$const_name = strtoupper($const_array[0]);
|
||||
|
||||
if (isset($const_array[2]) && !empty($const_array[2])) {
|
||||
$base = $const_array[1];
|
||||
$const_before = defined($base) ? constant($base) : $base;
|
||||
$const_value = $const_array[2];
|
||||
$full_path = $const_before . $const_value;
|
||||
|
||||
if (!is_dir($full_path) && !is_file($full_path)) {
|
||||
debugStatusMes("The folder/file declared into '$const_name' constant is missing or not accessible. Please check it.", "High");
|
||||
die;
|
||||
}
|
||||
|
||||
if (!defined($const_name)) {
|
||||
define($const_name, $full_path);
|
||||
}
|
||||
} else {
|
||||
$const_value = $const_array[1];
|
||||
|
||||
if (!is_dir($const_value) && !is_file($const_value)) {
|
||||
debugStatusMes("The folder/file declared into '$const_name' constant is missing or not accessible. Please check it.", "High");
|
||||
die;
|
||||
}
|
||||
|
||||
if (!defined($const_name)) {
|
||||
define($const_name, $const_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// Exceptions PHP-MSQLI
|
||||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
|
||||
try {
|
||||
// Create Connection
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
// Connections Successfully
|
||||
if(DB_DEBUG == "yes"){
|
||||
echo "Connected successfully";
|
||||
}
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
// Access Deny
|
||||
include(PAGES_FOLD . "db-error.php");
|
||||
debugStatusMes("Database connection failed.", "High");
|
||||
|
||||
|
||||
die();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
function error_env($option) {
|
||||
global $env;
|
||||
|
||||
if (empty($env)) {
|
||||
$result = "<p class='err_env_result'><span>ERROR:</span> Variable '<u>\$env</u>' is empty!</p>";
|
||||
$help = "<p class='err_env_help'>Please insert the correct value in the file 'config/init.php' or leave it to 'generic'</p>";
|
||||
} else {
|
||||
$result = "<p class='err_env_result'><span>ERROR:</span> The environment '<u>{$env}</u>' does not exist!</p>";
|
||||
$help = "<p class='err_env_help'>Please insert the correct value in the file 'config/init.php' or leave it to 'generic'</p>";
|
||||
}
|
||||
|
||||
echo $option === "result" ? $result : $help;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current page safely.
|
||||
*/
|
||||
function get_current_page() {
|
||||
$page = $_GET["page"] ?? "home";
|
||||
|
||||
$page = strtolower(trim($page));
|
||||
$page = preg_replace("/[^a-z0-9\-]/", "", $page);
|
||||
|
||||
if ($page === "") {
|
||||
$page = "home";
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve page file.
|
||||
*/
|
||||
function resolve_page() {
|
||||
$page = get_current_page();
|
||||
$file = PAGES_FOLD . $page . ".php";
|
||||
|
||||
// 👉 rendi disponibile globalmente
|
||||
$GLOBALS["current_page"] = $page;
|
||||
|
||||
if (file_exists($file)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
http_response_code(404);
|
||||
$GLOBALS["current_page"] = "404";
|
||||
return PAGES_FOLD . "404.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* DEBUG FUNCTIONS AND ARRAY
|
||||
*/
|
||||
|
||||
$debug_messages = [
|
||||
'High' => [],
|
||||
'Medium' => [],
|
||||
'Low' => [],
|
||||
'Info' => []
|
||||
];
|
||||
|
||||
// FUNCTION TO GET DEBUG STATUS MESSAGES
|
||||
function debugStatusMes( string $Message, string $intensity) {
|
||||
global $debug, $debug_messages;
|
||||
|
||||
// Controlla se il debug è attivo
|
||||
if ($debug !== "on") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalizza l'intensità per evitare errori di battitura (es. "high" diventa "High")
|
||||
$intensity = ucfirst(strtolower($intensity));
|
||||
|
||||
// Verifica che l'intensità sia valida prima di inserire il messaggio
|
||||
if (array_key_exists($intensity, $debug_messages)) {
|
||||
$debug_messages[$intensity][] = $Message;
|
||||
} else {
|
||||
// Se l'intensità non è corretta, la salva in una categoria generica o Low
|
||||
$debug_messages['Low'][] = "[Intensità errata: $intensity] " . $Message;
|
||||
}
|
||||
}
|
||||
|
||||
// DISPLAY DEBUG ERROR BAR
|
||||
function displayDebug() {
|
||||
global $debug, $debug_messages;
|
||||
|
||||
if ($debug !== "on") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Contenitore temporaneo nascosto per non creare sfarfallii nella pagina
|
||||
echo '<div id="debug-source-content" style="display: none;">';
|
||||
echo '<div style="background: #222; color: #fff; padding: 15px; font-family: monospace; border-bottom: 3px solid #ff4444; border-top: 3px solid #ff4444; margin-bottom: 20px;">';
|
||||
echo '<h3 style="margin-bottom:5px;">⚙️ Debug Status Messages</h3>';
|
||||
|
||||
foreach ($debug_messages as $level => $messages) {
|
||||
if (!empty($messages)) {
|
||||
$color = '#6cef93';
|
||||
if ($level === 'High') $color = '#ff4444';
|
||||
if ($level === 'Medium') $color = '#ffbb33';
|
||||
if ($level === 'Info') $color = '#4444ff';
|
||||
|
||||
echo "<div style='margin-bottom: 10px;'>";
|
||||
echo "<strong style='color: $color;'>[" . $level . "]</strong>";
|
||||
echo "<ul style='margin: 5px 0; padding-left: 20px;'>";
|
||||
foreach ($messages as $msg) {
|
||||
echo "<li>" . htmlspecialchars($msg) . "</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
// Questo script JS prende il contenuto appena generato e lo sposta nel segnaposto in cima
|
||||
?>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const source = document.getElementById('debug-source-content');
|
||||
const target = document.getElementById('debug-target-container');
|
||||
if (source && target) {
|
||||
// Sposta l'HTML dentro il contenitore all'inizio del body
|
||||
target.innerHTML = source.innerHTML;
|
||||
// Rimuove il vecchio elemento nascosto per pulizia
|
||||
source.remove();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include("config/functions_init.php");
|
||||
$env="generic";
|
||||
|
||||
switch($env){
|
||||
/*------ DON'T TOUCH THIS PART ------ */
|
||||
case "generic":
|
||||
define('WEB_ROOT', $_SERVER['DOCUMENT_ROOT']);
|
||||
define('DOMAIN', $_SERVER['HTTP_HOST']);
|
||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
|
||||
define('FULL_DOMAIN', $protocol . $_SERVER['HTTP_HOST']);
|
||||
define("ROOT_URL", "http://" . DOMAIN );
|
||||
define("ROOT_DIR", WEB_ROOT . "/");
|
||||
break;
|
||||
/* ----------------------------------- */
|
||||
default:
|
||||
// Showing error page by default.
|
||||
$error_env_check=true;
|
||||
include("pages/env-error.php");
|
||||
die;
|
||||
|
||||
}
|
||||
require_once(ROOT_DIR . "config/constants.php");
|
||||
require_once(CONFIG_FOLD . "settings.php");
|
||||
require_once(FUNCTIONS_FOLD . "functions.php");
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
// -- GENERAL SETTING --
|
||||
$debug="on";
|
||||
$php_debug="on";
|
||||
|
||||
// --- DB SETTINGS ---
|
||||
$db_needed="no";
|
||||
$db_debug="yes";
|
||||
$db_host="localhost";
|
||||
$db_name="database-name";
|
||||
$db_user="database-user";
|
||||
$db_pass="database-user-password";
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// --- DON'T CHANGE ALL THE CODE BELOW!!! ---
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
// --- GENERAL SECTION CONFIGURATION
|
||||
if ($debug == "on"){ define("DEBUG",true);} else { define("DEBUG", false); }
|
||||
|
||||
if ($php_debug == "on") {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
} else {
|
||||
ini_set('display_errors', 0);
|
||||
error_reporting(0);
|
||||
}
|
||||
|
||||
// --- DB SECTION CONFIGURATION
|
||||
if ($db_needed == "yes"){
|
||||
define("DB_HOST", $db_host);
|
||||
define("DB_USER", $db_user);
|
||||
define("DB_PASS", $db_pass);
|
||||
define("DB_NAME", $db_name);
|
||||
define("DB_DEBUG", $db_debug);
|
||||
require_once(CONFIG_FOLD . "db.php");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user