|
|
@@ -1,7 +1,26 @@
|
|
|
<?php
|
|
|
-
|
|
|
+/**
|
|
|
+ * Classe `core`
|
|
|
+ *
|
|
|
+ * Cette classe fournit des outils utilitaires pour diverses opérations courantes dans l'application.
|
|
|
+ *
|
|
|
+ * Fonctionnalités principales :
|
|
|
+ * - Gestion des données GET, POST et FILES.
|
|
|
+ * - Manipulation des dates et des formats.
|
|
|
+ * - Gestion des configurations de l'application.
|
|
|
+ * - Génération d'éléments d'interface utilisateur (menus, badges, etc.).
|
|
|
+ * - Outils divers pour le traitement des chaînes, des fichiers et des données.
|
|
|
+ *
|
|
|
+ * @package Core\Class
|
|
|
+ */
|
|
|
class core
|
|
|
{
|
|
|
+ /**
|
|
|
+ * Vérifie si une variable GET est définie.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable GET (optionnel).
|
|
|
+ * @return bool TRUE si la variable est définie, FALSE sinon.
|
|
|
+ */
|
|
|
public static function ifGet(?string $_string = NULL)
|
|
|
{
|
|
|
if($_string == NULL){
|
|
|
@@ -15,6 +34,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une variable POST est définie.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable POST (optionnel).
|
|
|
+ * @return bool TRUE si la variable est définie, FALSE sinon.
|
|
|
+ */
|
|
|
public static function ifPost(?string $_string = NULL)
|
|
|
{
|
|
|
if($_string == NULL){
|
|
|
@@ -28,6 +53,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une variable FILES est définie.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable FILES (optionnel).
|
|
|
+ * @return bool TRUE si la variable est définie, FALSE sinon.
|
|
|
+ */
|
|
|
public static function ifFiles(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string == NULL) {
|
|
|
@@ -41,6 +72,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère une variable GET.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable GET (optionnel).
|
|
|
+ * @return mixed La valeur de la variable GET ou NULL si non définie.
|
|
|
+ */
|
|
|
public static function getGet(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string == NULL) {
|
|
|
@@ -54,6 +91,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère une variable POST.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable POST (optionnel).
|
|
|
+ * @return mixed La valeur de la variable POST ou NULL si non définie.
|
|
|
+ */
|
|
|
public static function getPost(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string == NULL) {
|
|
|
@@ -67,6 +110,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère une variable FILES.
|
|
|
+ *
|
|
|
+ * @param string|null $_string Le nom de la variable FILES (optionnel).
|
|
|
+ * @return mixed La valeur de la variable FILES ou NULL si non définie.
|
|
|
+ */
|
|
|
public static function getFiles(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string == NULL) {
|
|
|
@@ -80,6 +129,14 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une chaîne est présente dans un tableau.
|
|
|
+ *
|
|
|
+ * @param array $_array Le tableau à vérifier.
|
|
|
+ * @param string $_string La chaîne à rechercher.
|
|
|
+ * @param int|null $_exact Indique si la correspondance doit être exacte (1 pour oui, NULL pour non).
|
|
|
+ * @return bool TRUE si la chaîne est trouvée, FALSE sinon.
|
|
|
+ */
|
|
|
public static function isInArrayString(array $_array, string $_string, ?int $_exact = NULL)
|
|
|
{
|
|
|
foreach ($_array as $value) {
|
|
|
@@ -92,6 +149,13 @@ class core
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un attribut "checked" pour une case à cocher.
|
|
|
+ *
|
|
|
+ * @param bool $_val Indique si la case doit être cochée.
|
|
|
+ * @param int $_echo Indique si le résultat doit être affiché (1) ou retourné (0).
|
|
|
+ * @return string|null L'attribut "checked" ou NULL.
|
|
|
+ */
|
|
|
public static function checkboxSelecter(bool $_val, $_echo = 1)
|
|
|
{
|
|
|
$tmp = ($_val == TRUE) ? "checked" : "";
|
|
|
@@ -102,6 +166,11 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère toutes les configurations de l'application.
|
|
|
+ *
|
|
|
+ * @return array|bool Les configurations ou FALSE en cas d'erreur.
|
|
|
+ */
|
|
|
public static function getAllConfig()
|
|
|
{
|
|
|
db::query("SELECT "
|
|
|
@@ -111,6 +180,12 @@ class core
|
|
|
return db::resultset();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère une configuration spécifique de l'application.
|
|
|
+ *
|
|
|
+ * @param string $_name Le nom de la configuration.
|
|
|
+ * @return mixed La valeur de la configuration.
|
|
|
+ */
|
|
|
public static function getConfig(string $_name)
|
|
|
{
|
|
|
db::query("SELECT value FROM " . DB_T_CONFIG . " WHERE name = :name");
|
|
|
@@ -118,6 +193,13 @@ class core
|
|
|
return db::single()["value"];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Met à jour une configuration de l'application.
|
|
|
+ *
|
|
|
+ * @param string $_name Le nom de la configuration.
|
|
|
+ * @param string $_value La nouvelle valeur de la configuration.
|
|
|
+ * @return bool TRUE si la mise à jour a réussi, FALSE sinon.
|
|
|
+ */
|
|
|
public static function updateConfig(string $_name, string $_value)
|
|
|
{
|
|
|
db::query("UPDATE " . DB_T_CONFIG . " SET "
|
|
|
@@ -134,6 +216,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Supprime les accents d'une chaîne de caractères.
|
|
|
+ *
|
|
|
+ * @param string $_data La chaîne à traiter.
|
|
|
+ * @return string La chaîne sans accents.
|
|
|
+ */
|
|
|
public static function cleanAccent(string $_data)
|
|
|
{
|
|
|
$search = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ');
|
|
|
@@ -142,6 +230,13 @@ class core
|
|
|
return strtoupper($return);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit une date MySQL en format français.
|
|
|
+ *
|
|
|
+ * @param string $_datetime La date au format MySQL.
|
|
|
+ * @param bool $_hour Indique si l'heure doit être incluse.
|
|
|
+ * @return string La date au format français.
|
|
|
+ */
|
|
|
public static function convertDate(string $_datetime, bool $_hour = TRUE)
|
|
|
{
|
|
|
$pieces = explode(" ", $_datetime);
|
|
|
@@ -156,6 +251,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Retourne la date actuelle au format français.
|
|
|
+ *
|
|
|
+ * @param string|null $_timestampMysql Le timestamp MySQL (optionnel).
|
|
|
+ * @return string|DateTime La date au format français ou un objet DateTime.
|
|
|
+ */
|
|
|
public static function dateFr(?string $_timestampMysql = NULL)
|
|
|
{
|
|
|
if ($_timestampMysql == NULL) {
|
|
|
@@ -166,6 +267,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit un timestamp en date.
|
|
|
+ *
|
|
|
+ * @param int|null $_timestamp Le timestamp à convertir (optionnel).
|
|
|
+ * @return string|null La date au format MySQL ou NULL si aucun timestamp n'est fourni.
|
|
|
+ */
|
|
|
public static function dateFromTimestamp(?int $_timestamp = NULL)
|
|
|
{
|
|
|
if ($_timestamp == NULL) {
|
|
|
@@ -175,11 +282,24 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Extrait la date sans l'heure d'une chaîne datetime.
|
|
|
+ *
|
|
|
+ * @param string $_datetime La chaîne datetime.
|
|
|
+ * @return string La date sans l'heure.
|
|
|
+ */
|
|
|
public static function dateWhithoutHours(string $_datetime)
|
|
|
{
|
|
|
return explode(" ", $_datetime)[0];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Formate une taille de fichier en unités lisibles.
|
|
|
+ *
|
|
|
+ * @param float $_size La taille en octets.
|
|
|
+ * @param int $_decimalplaces Le nombre de décimales à inclure.
|
|
|
+ * @return string La taille formatée.
|
|
|
+ */
|
|
|
public static function formatFileSize(float $_size, int $_decimalplaces = 0)
|
|
|
{
|
|
|
$sizes = array('O', 'Ko', 'Mo', 'Go', 'To');
|
|
|
@@ -189,6 +309,12 @@ class core
|
|
|
return round($_size, $_decimalplaces) . ' ' . $sizes[$i];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Formate un montant en euros.
|
|
|
+ *
|
|
|
+ * @param float $_amount Le montant à formater.
|
|
|
+ * @return string Le montant formaté en euros.
|
|
|
+ */
|
|
|
public static function formatEuro($_amount) {
|
|
|
$amount = (float)$_amount;
|
|
|
$formattedAmount = number_format($amount, 2, ',', ' ');
|
|
|
@@ -196,6 +322,12 @@ class core
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie si une chaîne ne contient que des caractères alphabétiques.
|
|
|
+ *
|
|
|
+ * @param string $_string La chaîne à vérifier.
|
|
|
+ * @return bool TRUE si la chaîne contient uniquement des lettres, FALSE sinon.
|
|
|
+ */
|
|
|
public static function checkStringOnly(string $_string)
|
|
|
{
|
|
|
if (!ctype_alpha($_string)) {
|
|
|
@@ -205,6 +337,16 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un élément de menu.
|
|
|
+ *
|
|
|
+ * @param string $_id L'identifiant de l'élément de menu.
|
|
|
+ * @param string $_href L'URL de destination.
|
|
|
+ * @param string $_titre Le titre de l'élément de menu.
|
|
|
+ * @param string|null $_style Le style CSS à appliquer (optionnel).
|
|
|
+ * @param string|null $_icon L'icône à afficher (optionnel).
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function elementMenu(string $_id, string $_href, string $_titre, ?string $_style = NULL, ?string $_icon = NULL)
|
|
|
{
|
|
|
if (access::ifAccesss($_id)) {
|
|
|
@@ -215,6 +357,16 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un élément de menu avec un lien.
|
|
|
+ *
|
|
|
+ * @param string $_id L'identifiant de l'élément de menu.
|
|
|
+ * @param string $_href L'URL de destination.
|
|
|
+ * @param string $_titre Le titre de l'élément de menu.
|
|
|
+ * @param string|null $_style Le style CSS à appliquer (optionnel).
|
|
|
+ * @param string $_target La cible du lien (par défaut "_blank").
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function elementMenuLink(string $_id, string $_href, string $_titre, ?string $_style = NULL, string $_target = "_blank")
|
|
|
{
|
|
|
if (access::ifAccesss($_id)) {
|
|
|
@@ -225,6 +377,15 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un en-tête de section.
|
|
|
+ *
|
|
|
+ * @param string $_id L'identifiant de l'en-tête.
|
|
|
+ * @param string $_titre Le titre de l'en-tête.
|
|
|
+ * @param string|null $_style Le style CSS à appliquer (optionnel).
|
|
|
+ * @param string|null $_collapse L'identifiant de la section à réduire/étendre (optionnel).
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function elementMenuH6(string $_id, string $_titre, ?string $_style = NULL, ?string $_collapse = NULL)
|
|
|
{
|
|
|
if (access::ifAccesss($_id)) {
|
|
|
@@ -235,6 +396,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère une fil d'Ariane (breadcrumb).
|
|
|
+ *
|
|
|
+ * @param array $_arbo Les éléments de la fil d'Ariane.
|
|
|
+ * @return string Le code HTML de la fil d'Ariane.
|
|
|
+ */
|
|
|
public static function filAriane(array $_arbo)
|
|
|
{
|
|
|
|
|
|
@@ -295,6 +462,14 @@ class core
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Calcule un pourcentage.
|
|
|
+ *
|
|
|
+ * @param int|null $_nombre Le nombre partiel.
|
|
|
+ * @param int|null $_total Le nombre total.
|
|
|
+ * @param int $_pourcentage Le pourcentage à calculer (par défaut 100).
|
|
|
+ * @return int Le pourcentage calculé.
|
|
|
+ */
|
|
|
public static function caculPourcentage(?int $_nombre, ?int $_total, int $_pourcentage = 100)
|
|
|
{
|
|
|
if ($_nombre == NULL) return 0;
|
|
|
@@ -302,11 +477,22 @@ class core
|
|
|
return round($resultat);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Encode une chaîne en UTF-8.
|
|
|
+ *
|
|
|
+ * @param string $_data La chaîne à encoder.
|
|
|
+ * @return string La chaîne encodée en UTF-8.
|
|
|
+ */
|
|
|
public static function encodeUTF8(string $_data)
|
|
|
{
|
|
|
return (mb_detect_encoding($_data) != "UTF-8") ? mb_convert_encoding($_data, 'UTF-8', mb_list_encodings()) : $_data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie la connexion à Internet.
|
|
|
+ *
|
|
|
+ * @return bool TRUE si connecté, FALSE sinon.
|
|
|
+ */
|
|
|
public static function testConnexionInternet()
|
|
|
{
|
|
|
$hosts = ['1.1.1.1', '1.0.0.1', '8.8.8.8', '8.8.4.4'];
|
|
|
@@ -319,12 +505,22 @@ class core
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Retourne la date et l'heure actuelles au format texte.
|
|
|
+ *
|
|
|
+ * @return string La date et l'heure au format texte.
|
|
|
+ */
|
|
|
public static function printDateTxt()
|
|
|
{
|
|
|
$date = new IntlDateFormatter('fr_FR', IntlDateFormatter::LONG, IntlDateFormatter::NONE);
|
|
|
return $date->format(time()) . " à " . date("H:i:s");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Réinitialise les données dans la base de données.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function resetDatas()
|
|
|
{
|
|
|
db::query("TRUNCATE " . DB_T_TEMP_SALARIES);
|
|
|
@@ -361,16 +557,34 @@ class core
|
|
|
file::cleanAllFiles(SFTP_LOCAL);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Encode une chaîne en base64 pour une utilisation dans une URL.
|
|
|
+ *
|
|
|
+ * @param string $val La chaîne à encoder.
|
|
|
+ * @return string La chaîne encodée en base64.
|
|
|
+ */
|
|
|
public static function base64_url_encode(string $val)
|
|
|
{
|
|
|
return strtr(base64_encode($val), '+/=', '-_,');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Décode une chaîne base64 encodée pour une utilisation dans une URL.
|
|
|
+ *
|
|
|
+ * @param string $val La chaîne à décoder.
|
|
|
+ * @return string La chaîne décodée.
|
|
|
+ */
|
|
|
public static function base64_url_decode(string $val)
|
|
|
{
|
|
|
return base64_decode(strtr($val, '-_,', '+/='));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit un texte en UTF-8 si nécessaire.
|
|
|
+ *
|
|
|
+ * @param string $_texte Le texte à convertir.
|
|
|
+ * @return string Le texte converti en UTF-8.
|
|
|
+ */
|
|
|
public static function convertirEnUtf8(string $_texte)
|
|
|
{
|
|
|
if (!mb_detect_encoding($_texte, 'UTF-8', TRUE)) {
|
|
|
@@ -380,6 +594,13 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Imprime une option sélectionnée dans un formulaire.
|
|
|
+ *
|
|
|
+ * @param string|null $_string La valeur de l'option.
|
|
|
+ * @param mixed $_value La valeur à comparer.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function printFormSelectOption(?string $_string = NULL, $_value)
|
|
|
{
|
|
|
if ($_string != NULL and $_string == $_value) {
|
|
|
@@ -387,6 +608,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère la valeur d'un formulaire.
|
|
|
+ *
|
|
|
+ * @param string|null $_string La valeur à récupérer.
|
|
|
+ * @return string|null La valeur récupérée ou NULL.
|
|
|
+ */
|
|
|
public static function getFormValue(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string != NULL) {
|
|
|
@@ -394,6 +621,12 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Imprime la valeur d'un formulaire.
|
|
|
+ *
|
|
|
+ * @param string|null $_string La valeur à imprimer.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function printFormValue(?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string != NULL) {
|
|
|
@@ -401,6 +634,15 @@ class core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Convertit des octets entre différentes unités.
|
|
|
+ *
|
|
|
+ * @param float $val La valeur à convertir.
|
|
|
+ * @param string $type_val L'unité d'origine.
|
|
|
+ * @param string $type_wanted L'unité cible.
|
|
|
+ * @param bool $_float Indique si le résultat doit être un flottant.
|
|
|
+ * @return string La valeur convertie avec l'unité cible.
|
|
|
+ */
|
|
|
public static function convertBytes(float $val, string $type_val = "o", string $type_wanted = "Mo", bool $_float = FALSE)
|
|
|
{
|
|
|
$tab_val = array("o", "ko", "Mo", "Go", "To", "Po", "Eo");
|
|
|
@@ -418,6 +660,11 @@ class core
|
|
|
return round(($val), 2) . $type_wanted_print;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère la taille de la base de données.
|
|
|
+ *
|
|
|
+ * @return array Les informations sur la taille de la base de données.
|
|
|
+ */
|
|
|
public static function getSizeDataBase(){
|
|
|
db::query("SELECT
|
|
|
table_schema AS nameDB,
|
|
|
@@ -427,6 +674,15 @@ class core
|
|
|
return db::single();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère une barre de progression avec des avertissements.
|
|
|
+ *
|
|
|
+ * @param float $_num La valeur actuelle.
|
|
|
+ * @param float $_max La valeur maximale.
|
|
|
+ * @param string $_label L'étiquette de la barre de progression.
|
|
|
+ * @param string $_icon L'icône à afficher.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public static function progressBarWarning(float $_num, float $_max, string $_label, string $_icon){
|
|
|
$changeUnit = 1073741824;
|
|
|
$valueUnitNum = $_num >= $changeUnit ? "Go" : "Mo";
|
|
|
@@ -449,10 +705,21 @@ class core
|
|
|
</div>';
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un badge d'alerte si nécessaire.
|
|
|
+ *
|
|
|
+ * @param bool $_alerte Indique si l'alerte doit être affichée.
|
|
|
+ * @return string|null Le code HTML du badge ou NULL.
|
|
|
+ */
|
|
|
static public function printBadgeGeneral(bool $_alerte){
|
|
|
return $_alerte == TRUE ? '<span class="position-absolute start-100 translate-middle p-1 bg-danger border border-light rounded-circle"></span>' : NULL;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Vérifie les alertes pour les documents.
|
|
|
+ *
|
|
|
+ * @return array Les informations sur les alertes.
|
|
|
+ */
|
|
|
static public function ifbadge()
|
|
|
{
|
|
|
$return = [];
|
|
|
@@ -466,6 +733,12 @@ class core
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Génère un menu de navigation.
|
|
|
+ *
|
|
|
+ * @param array $_navInfos Les informations de navigation.
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
static public function menu(array $_navInfos){
|
|
|
$badge = self::ifbadge();
|
|
|
echo '<a href="/" style="box-shadow: none; background-color:'. $_navInfos["color"] .';" class="navbar-brand">' . $_navInfos["title"] . '</a>' . debug::getBadges();
|
|
|
@@ -488,6 +761,11 @@ class core
|
|
|
echo '</div>';
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Récupère l'adresse IP de l'utilisateur.
|
|
|
+ *
|
|
|
+ * @return string L'adresse IP de l'utilisateur.
|
|
|
+ */
|
|
|
static public function getUserIP() {
|
|
|
$ip = 'Inconnue';
|
|
|
|
|
|
@@ -510,6 +788,12 @@ class core
|
|
|
return $ip;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Aplatit un tableau multidimensionnel.
|
|
|
+ *
|
|
|
+ * @param array|null $_array Le tableau à aplatir (optionnel).
|
|
|
+ * @return array|null Le tableau aplati ou NULL.
|
|
|
+ */
|
|
|
static public function extractArrayInArray(?array $_array = NULL){
|
|
|
if($_array != NULL){
|
|
|
foreach ($_array as $item) {
|