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
/*
* 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/");
@@ -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);
}
}
}
?>