firts commit

This commit is contained in:
2026-04-27 08:48:03 +01:00
commit 05f24c50a8
18 changed files with 420 additions and 0 deletions

36
config/constants.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
// --- 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");
// --------------- //
?>

20
config/db.php Normal file
View File

@@ -0,0 +1,20 @@
<?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");
die();
}
?>

22
config/functions_init.php Normal file
View File

@@ -0,0 +1,22 @@
<?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>' not exists!</p>";
$help="<p class='err_env_help'>Please insert the correct value in the file 'config/init.php or leave it to 'generic'</p>";
}
if($option == "result"){
echo $result;
}elseif($option == "help"){
echo $help;
}else{
echo "ERROR: Wrong attribute in declared in the function!";
die;
}
}
?>

24
config/init.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
$env="";
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:
include("config/functions_init.php");
include("pages/env-error.php");
die;
}
require_once(ROOT_DIR . "config/constants.php");
require_once(CONFIG_FOLD . "settings.php");
?>

22
config/settings.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
// --- 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 ---
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");
}
?>