Added new features: adding new constant in a loop

This commit is contained in:
2026-08-10 17:48:24 +01:00
parent 40b41f8930
commit f782c6f531
5 changed files with 60 additions and 0 deletions
+42
View File
@@ -1,4 +1,15 @@
<?php <?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 --- // // --- ROOT DIR --- //
define("ASSETS_FOLD", ROOT_DIR . "assets/"); define("ASSETS_FOLD", ROOT_DIR . "assets/");
define("ADMIN_FOLD", ROOT_DIR . "admin/"); define("ADMIN_FOLD", ROOT_DIR . "admin/");
@@ -32,5 +43,36 @@
// --------------- // // --------------- //
/// 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);
}
}
}
?> ?>
+10
View File
@@ -1,6 +1,7 @@
<?php <?php
// -- GENERAL SETTING -- // -- GENERAL SETTING --
$debug="on"; $debug="on";
$php_debug="on";
// --- DB SETTINGS --- // --- DB SETTINGS ---
$db_needed="no"; $db_needed="no";
@@ -17,6 +18,15 @@ $db_pass="database-user-password";
// --- GENERAL SECTION CONFIGURATION // --- GENERAL SECTION CONFIGURATION
if ($debug == "on"){ define("DEBUG",true);} else { define("DEBUG", false); } 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 // --- DB SECTION CONFIGURATION
if ($db_needed == "yes"){ if ($db_needed == "yes"){
define("DB_HOST", $db_host); define("DB_HOST", $db_host);
+1
View File
@@ -4,6 +4,7 @@
Include in this array all the function files you may want to include. Include in this array all the function files you may want to include.
You don't need to specify the extension .php, the system will automatically add it. You don't need to specify the extension .php, the system will automatically add it.
*/ */
$fun_to_inc = array( $fun_to_inc = array(
//"example", //"example",
"demo-example" "demo-example"
+6
View File
@@ -0,0 +1,6 @@
<main class="main-content">
<section>
<h1>Welcome to the Home Page</h1>
<p>This is the home page.</p>
</section>
</main>
+1
View File
@@ -0,0 +1 @@
public_html