Files
ms1inscription-v5/superadm/php/inc_functions.php

1492 lines
49 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..') . '/');
require_once('inc_settings.php');
require_once('inc_mysql.php');
require_once('inc_dates.php');
require_once('inc_files.php');
require_once('inc_manager.php');
error_reporting(E_ALL);
ini_set("display_errors", 0);
global $arrConDatabasePreProd,$arrConDatabasecrm;
$db = $objDatabase = new clsMysql($GLOBALS['arrConDatabaseMain']);
$db_prod = $objDatabaseProd = new clsMysql($GLOBALS['arrConDatabaseProd']);
$objDatabasePreProd= new clsMysql($arrConDatabasePreProd);
$objDatabasecrm=new clsMysql($arrConDatabasecrm);
// fonction qui détermine le url de retour (JSP)
// créé : 2012-07-02
function fxGetReferer()
{
$url_retour = $GLOBALS['vDomaine'] . '/superadm/index.php';
$dom = parse_url($GLOBALS['vDomaine']);
if ($_SERVER['HTTP_REFERER'] != '') {
$ref = parse_url($_SERVER['HTTP_REFERER']);
if (strpos($ref['host'], $dom['host']) !== false)
$url_retour = $_SERVER['HTTP_REFERER'];
}
return $url_retour;
}
// fonction qui ajoute ou modifie les choix checkbox associé à une autre table
// param: type (add ou mod), nom de la table, champ lié, valeur du champ lié, champ 2, valeurs du champ 2, anciennes valeurs du champ 2
function fxSetCheckboxes($type, $table, $link, $link_value, $field, $values, $values_old) {
switch ($type) {
case 'add':
if (isset($values)) {
foreach ($values as $id) {
$sqlInsert = "INSERT INTO " . $table . "(" . $link . ", " . $field . ") VALUES(" . intval($link_value) . ", " . intval($id) . ")";
$qryInsert = $GLOBALS['db_blog']->fxQuery($sqlInsert);
}
}
break;
case 'mod':
if (isset($values)) {
$values_old1 = explode(',', $values_old);
foreach ($values as $id) {
// si c'est un nouvel item
if (!in_array($id, $values_old1)) {
$sqlInsert = "INSERT INTO " . $table . "(" . $link . ", " . $field . ") VALUES(" . intval($link_value) . ", " . intval($id) . ")";
$qryInsert = $GLOBALS['db_blog']->fxQuery($sqlInsert);
}
}
// vérifier si on doit en supprimer
if ($values_old != '') {
foreach ($values_old1 as $id) {
// si il existait avant, et plus maintenant
if (!in_array($id, $values)) {
$sqlDelete = "DELETE FROM " . $table . " WHERE " . $link . " = " . intval($link_value) . " AND " . $field . " = " . intval($id);
$qryDelete = mysql_query($sqlDelete);
}
}
}
}
elseif ($values_old != '') {
$sqlDelete = "DELETE FROM " . $table . " WHERE " . $link . " = " . intval($link_value);
$qryDelete = mysql_query($sqlDelete);
}
}
}
// fonction qui va cherdcher les étiquettes dans la bdd
// param : page, table, langue
/* function fxGetLabels($strPage, $strTable, $strLangue)
{
$sqlLabel1 = "SELECT info_clef,info_texte,pk_info,'client' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
$tabLabel1 = $GLOBALS['db']->fxFetchArray(3, $sql_info);
$sqlLabel2 = "SELECT info_clef,info_texte,'centrale' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
$tabLabel2 = $GLOBALS['db']->fxFetchArray(3, $sql_info);
$info = array_merge($info1, $info2);
} */
// MOT DE PASSE PERDU
function fxCourrielPerdu() {
$sqlPerdu = "SELECT * FROM usagers WHERE usa_courriel = '" . $GLOBALS['db']->fxEscape($_POST['courriel']) . "' AND usa_actif = 1";
$recPerdu = $GLOBALS['db']->fxGetRow($sqlPerdu);
if ($recPerdu != null)
$perdu = -1;
else {
require_once('mailer/class.phpmailer.php');
//include("mailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = "Bonjour " . $recPerdu['usa_prenom'] . ",\n\nsuite à votre demande, voici vos informations de connexion à l'administration de " . $GLOBALS['vClient'] . ":\n\nNom d'usager: " . $recPerdu['usa_login'] . "\nMot de passe: " . $recPerdu['usa_password'] . "\n\nVeuillez conserver ces informations.\nMerci\n\n\nMessage envoyé automatiquement le: " . fxShowDate(fxGetDate(), 'fr') . " @ " . fxGetTime();
$mail->SetFrom($GLOBALS['vEmail'], $GLOBALS['vClient']);
$mail->AddReplyTo($GLOBALS['vEmail'], $GLOBALS['vClient']);
$mail->Subject = $GLOBALS['vClient'] . " | Vos informations de connexion";
if (filter_var(fxUnescape($_POST['courriel']), FILTER_VALIDATE_EMAIL)) {
$mail->Body = $body;
$mail->AddAddress(fxUnescape($_POST['courriel']), fxUnescape($recPerdu['usa_prenom']) . ' ' . fxUnescape($recPerdu['usa_nom']));
if(!$mail->Send())
$error = 1;
else
$error = 0;
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
if ($error == 0)
return 1;
else
return 0;
}
}
// fonction pour formatter une valeur sous la forme $ 9,999.99
function fxShowMoney($value, $lang) {
if ($lang == 'fr') {
$value = number_format($value, 2, ',', ' ') . ' $';
}
else {
$value = '$ ' . number_format($value, 2, '.', ',');
}
return $value;
}
// fonction pour creer un log
// param : message
// créé: 2014-06-2
function fxcreer_log($strDescription, $intType = 10, $int_Email = 0, $int_eve_id = 0, $int_epr_id = 0, $int_pra_id = 0, $str_no_panier = '', $int_com_id = 0, $str_com_courriel = '') {
//function fxcreer_log($strDescription, $intType = 10, $int_Email = 0, $int_eve_id = 0, $int_epr_id = 0, $int_pra_id = 0, $str_no_panier = '', $int_com_id = 0) {
if (isset($_SESSION['com_id']))
$int_com_id = $_SESSION['com_id'];
if (isset($_SESSION['no_panier']))
$str_no_panier = $_SESSION['no_panier'];
$sqlInsert = "INSERT INTO inscriptions_log SET log_description = '" . $strDescription . "', log_email = " . $int_Email . ", log_type = " . $intType . ", eve_id = " . $int_eve_id . ", epr_id = " . $int_epr_id . ", pra_id = " . $int_pra_id . ", no_panier = '" . $str_no_panier . "', log_time = NOW(), com_id = " . $int_com_id . ", log_prg = '" . $GLOBALS['vPage'] . "', log_com_courriel = '" . $str_com_courriel . "'";
$qryInsert = $GLOBALS['db']->fxQuery($sqlInsert);
return(true);
}
// fonction envoi un courriel (JSP)
// param : sujet, corps du message, courriel destinataire, nom destinataire, courriel expéditeur, nom expéditeur, smtp (oui/non), html (oui/non)
// retourne : vrai ou faux
function fxSendMail($subject, $body, $to_mail, $to_name, $from_mail, $from_name, $smtp, $html) {
require_once('../mailer/class.phpmailer.php');
$mail = new PHPMailer();
if ($smtp == 1) {
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->Host = "pop.progiweb.ca";
$mail->Port = 25;
$mail->Username = "send@progiweb.ca";
$mail->Password = "progiwebsend";
}
$mail->CharSet = "UTF-8";
$mail->SetFrom($GLOBALS['vEmail'], fxRemoveHtml($GLOBALS['vClient']));
$mail->AddReplyTo($from_mail, $from_name);
$mail->Subject = fxRemoveHtml($GLOBALS['vClient']) . " | " . $subject;
if (filter_var($to_mail, FILTER_VALIDATE_EMAIL)) {
if ($html == 1)
$mail->MsgHTML($body);
else
$mail->Body = $body;
$mail->AddAddress($to_mail, $to_name);
if (!$mail->Send())
$error = 1;
else
$error = 0;
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
if ($error == 0)
return true;
else
return false;
}
// fonction qui enlève les tags html (JSP)
// param : string
// créé : 2012-08-02
function fxRemoveHtml($string) {
$string = html_entity_decode($string);
$string = str_replace("&rsquo;", "'", $string);
$string = preg_replace('/\s\s+/', ' ', $string);
$string = strip_tags($string);
return $string;
}
// fonction pour formatter une valeur sous la forme $ 9,999.99
// param : valeur, langue, format (afficher $ CAD)
// créé : 2013-03-28
function fxShowPrix($strValue, $strLangue, $intFormat) {
if ($strLangue == 'fr') {
$strValue = number_format($strValue, 2, ',', ' ');
if ($intFormat == 1)
$strValue .= ' $';
}
else {
$strValue = number_format($strValue, 2, '.', ',');
if ($intFormat == 1)
$strValue = '$ ' . $strValue;
}
return $strValue;
}
// trouve la valeur d'une variable de la bdd
function fxGetVariable($strVarNom) {
global $db;
$sqlVariable = "SELECT var_valeur FROM variables WHERE var_nom = '" . $db->fxEscape($strVarNom) . "'";
$strVarValeur = $db->fxGetVar($sqlVariable);
return $strVarValeur;
}
/** @see php/inc_fonctions.php fxPromoteurLegacySiteEnabled */
function fxPromoteurLegacySiteEnabled()
{
static $blnEnabled = null;
if ($blnEnabled !== null) {
return $blnEnabled;
}
global $db;
if (!isset($db)) {
$blnEnabled = true;
return $blnEnabled;
}
$strVal = fxGetVariable('promoteur_legacy_actif');
$blnEnabled = ($strVal === null || $strVal === '' || intval($strVal) === 1);
return $blnEnabled;
}
function print_mem() {
/* Currently used memory */
$mem_usage = memory_get_usage();
/* Peak memory usage */
$mem_peak = memory_get_peak_usage();
echo 'The script is now using: <strong>' . round($mem_usage / 1024) . 'KB</strong> of memory.<br>';
echo 'Peak usage: <strong>' . round($mem_peak / 1024) . 'KB</strong> of memory.<br><br>';
}
/**
* Description : retourner le texte correspondan a la clef si il a été mis en mémoire
* Parametres : clef
* mem_echo =1 fait un echo sinon la valeur est retourné
* $mem_trduction lest admin on un bouton pour correction
* $mem_global=0 si 1 vas créér la variable avec global pas le nom de la page
* Créateur : stephan
* Date : 13-03-17
*/
function afficheTexte($clef, $mem_echo = 1, $mem_trduction = 1, $mem_global = 0) {
global $vtexte_page, $vPage;
$mem_id = "";
if (isset($vtexte_page[$clef]['info_texte']))
$mem_texte = $vtexte_page[$clef]['info_texte'];
else {
$mem_texte = '*' . $clef . '*';
if ($mem_global == 0)
$mem_page = $vPage;
else
$mem_page = "global";
// creation dans la bd info
$info1 = array("info_clef" => $clef, "info_langue" => "fr", "info_texte" => $clef, "info_prg" => $mem_page, "info_actif" => 1);
fxSetInfo('add', $info1, '', $mem_id);
$info1 = array("info_clef" => $clef, "info_langue" => "en", "info_texte" => $clef, "info_prg" => $mem_page, "info_actif" => 1);
fxSetInfo('add', $info1, '', $mem_id);
}
if ($mem_echo == 1)
echo $mem_texte;
return $mem_texte;
}
/**
* Description : lire le text dans la bd info
* Parametres : 1 - page
* 2 - langue A,F
* optionelle 3- 1 va chercher bd client en premier et centrale en deuxiemme (default)
* 2 jutse bd client
* 3 juste bd centrale
* Créateur : stephan
* Date : 13-03-15
*/
function obtenirTextepage() {
global $objDatabase;
$numargs = func_num_args();
$arg_list = func_get_args();
$page = $arg_list[0];
$Langue = $arg_list[1];
$centrale = $mem_corr = "";
$info = null;
if (array_key_exists(2, $arg_list)) {
$centrale = $arg_list[2];
}
switch ($centrale) {
case 3:
$sql_info = "SELECT info_clef,info_texte,pk_info,info_prg,'centrale' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
$info = $GLOBALS['dbcentrale']->fxFetchArray(3, $sql_info);
break;
case 2:
$sql_info = "SELECT info_clef,info_texte,pk_info,info_prg,'client' as bd FROM info where (info_prg='" . $page . "' or info_prg='global') and info_langue='" . $Langue . "'";
$info = $objDatabase->fxFetchArray(3, $sql_info);
break;
case 1:
$sql_info = "SELECT info_clef,info_texte,pk_info,'client' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
$info2 = $objDatabase->fxFetchArray(3, $sql_info);
$sql_info = "SELECT info_clef,info_texte,'centrale' as bd FROM info where info_prg='" . $page . "' and info_langue='" . $Langue . "'";
$info1 = $objDatabase->fxFetchArray(3, $sql_info);
$info = array_merge($info1, $info2);
break;
}
return $info;
}
/**
* Description : affiche le bouton modi texte et hide les textclef
* Parametres :
* Créateur : stephan
* Date : 13-03-22
*/
function modif_texte_bt() {
global $vadmin_texte;
if ($vadmin_texte == true)
echo "<button onclick=" . chr(34) . "toggle_hideme('modif_texte','text');" . chr(34) . ">changer texte</button>";
}
/**
* Description : Fonction pour ajouter le value dans une formes
* Parametres : $mem_champ nom du champs ,$mem_defaut,$mem_type add ou mod ,$mem_infos tableau des info
* Créateur : stephan
* Date : 13-04-20
*/
function fxFormFieldInfo($mem_champ, $mem_type, $mem_infos, $mem_defaut = "", $mem_array = 0) {
if ($mem_array == 0)
$mem_value = 'id="' . $mem_champ . '" name="' . $mem_champ . '"';
else
$mem_value = 'id="info['.$mem_array.'][' . $mem_champ . ']" name="info['.$mem_array.'][' . $mem_champ . ']"';
switch ($mem_type) {
// AJOUT
case 'add':
if (trim($mem_defaut != ''))
$mem_value = $mem_value . ' value="' . $mem_defaut . '"';
break;
case 'mod':
case 'checkout':
$mem_value = $mem_value . ' value="' . $mem_infos[$mem_champ] . '"';
break;
}
return $mem_value;
}
function fxFormFieldCheck($mem_champ, $mem_type, $mem_infos, $mem_valide, $mem_defaut = "",$mem_action="") {
$mem_value = '';
switch ($mem_type) {
// AJOUT
case 'add':
if (trim($mem_defaut != ''))
$mem_value = 'checked="checked"';
break;
case 'mod':
case 'checkout':
if($mem_action=="mod")
{
if ($mem_infos[$mem_champ] == $mem_valide)
$mem_value = 'checked';
else
$mem_value = 'disabled';
}else{
if ($mem_infos[$mem_champ] == $mem_valide)
$mem_value = 'checked="checked"';
}
break;
}
return $mem_value;
}
function fxFormFieldChecklist($mem_champ, $mem_type, $mem_infos, $mem_valide, $mem_defaut) {
$mem_value = '';
switch ($mem_type) {
// AJOUT
case 'add':
case 'addaffilie':
if ($mem_defaut == $mem_valide)
$mem_value = 'selected="selected"';
break;
case 'mod':
case 'checkout':
if ($mem_infos[$mem_champ] == $mem_valide)
$mem_value = 'selected="selected"';
break;
}
return $mem_value;
}
function fxSetInfo($strAction, $tabData, $strLangue, $id = 0) {
global $objDatabase;
$_SESSION['msg'] = "";
switch ($strAction) {
// AJOUT
case 'add':
// former le INSERT
$tabFieldsValues = fxListFieldsValues($tabData, 'pk_info', 'info', $GLOBALS['arrConDatabaseMain']['db']);
// vérifie si le info existe
$sqlValide = "SELECT COUNT(info_clef) from info where info_clef='" . $tabData['info_clef'] . "' and info_prg='" . $tabData['info_prg'] . "' and info_langue='".$tabData['info_langue']."'";
$nbValide = $objDatabase->fxGetVar($sqlValide);
if ($nbValide > 0) {
break;
}
// insérer les infos du participants
$sqlInsert = "INSERT INTO info " . $tabFieldsValues['set'] . ',info_creation=now()';
$qryInsert = $objDatabase->fxQuery($sqlInsert);
// récupérer le id ajouté
$intCompte = $objDatabase->fxGetLastId();
// $_SESSION['com_id'] = $intCompte;
break;
// MODIFICATION
case 'mod':
$tabFieldsValues = fxListFieldsValues($tabData, 'pk_info', 'info', $GLOBALS['arrConDatabaseMain']['db']);
// verification des champs obligatoire
// update les infos
$sqlUpdate = "UPDATE info " . $tabFieldsValues['set'] . ",info_maj=now() where ". $tabFieldsValues['key'];
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
// définir le message à affiche
break;
// SUPPRESSION
case 'del':
/* PLUS TARD
$sqlDelete = "DELETE FROM ".$bd." WHERE ".$memid." = " . intval($id);
$qryDelete = $objDatabase->fxQuery($sqlDelete); */
}
}
function afficheTexteReplace($mem_tab_replace, $mem_texte) {
foreach ($mem_tab_replace as $key => $value)
$mem_texte=str_replace($key, $value, $mem_texte);
return $mem_texte;
}
// fonction qui retourne les infos des champs de la table (SL / JSP)
// param : nom de la table, nom de la base de données
// créé : 2013-04-10
function fxGetFileds($strTable, $strBdd) {
global $objDatabase;
$sqlFields = "SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $objDatabase->fxEscape($strTable) . "' AND TABLE_SCHEMA = '" . $objDatabase->fxEscape($strBdd) . "'";
$recFields = $objDatabase->fxGetResultsKey($sqlFields);
return $recFields;
}
function conf_getFiltreData($usa_id,$page,$var,$vardefault,$update=0,$typenum=1)
{
// list la bb client
$sqlsortie = "SELECT * FROM usa_filtre WHERE fil_usa_id = '" . $usa_id . "' AND fil_page = '" . $page . "' AND fil_var = '" . $var . "' ";
$sortie = $GLOBALS['db']->fxGetRow($sqlsortie);
if ($sortie==null){
$sqlInsert = "INSERT INTO usa_filtre SET fil_usa_id = '" . $usa_id . "', fil_page = '" . $page . "', fil_var = '" . $var . "', fil_value = '" . $vardefault."'" ;
$qryInsert = $GLOBALS['db']->fxQuery($sqlInsert);
$mem_return=$vardefault;
}else{
if ($update==1){
$sqlInsert = "update usa_filtre SET fil_value = '" . $vardefault."' WHERE fil_usa_id = '" . $usa_id . "' AND fil_page = '" . $page . "' AND fil_var = '" . $var . "' ";
$qryInsert = $GLOBALS['db']->fxQuery($sqlInsert);
$mem_return=$vardefault;
}else{
$mem_return=$sortie['fil_value'];
}
}
if ($typenum==0)
$mem_return='"'.$mem_return.'"';
return $mem_return;
}
// fonction qui compose le SQL pour les INSERT et UPDATE
// param : tableau des données, nom de la clé (PK), nom de la table, nom de la base de données
// créé : 2013-04-10
function fxListFieldsValues($tabData, $strKey, $strTable, $strBdd) {
global $objDatabase;
$tabFields = fxGetFileds($strTable, $strBdd);
$mem_set = "SET ";
$xvide = 0;
$listvide = "";
$mem_id = "";
foreach (array_keys($tabData) as $strField) {
$listvide[$xvide] = $strField;
$xvide += 1;
if (strstr($strField, 'btn') === false) {
if ($strField == $strKey)
$mem_id = $strField . " = " . intval($tabData[$strField]);
else {
if (isset($tabFields[$strField]['DATA_TYPE'])) {
switch ($tabFields[$strField]['DATA_TYPE']) {
case 'char':
case 'varchar':
case 'text':
case 'date':
$mem_set = $mem_set . $strField . " = '" . $objDatabase->fxEscape($tabData[$strField]) . "', ";
break;
case 'tinyint':
case 'int':
case 'smallint':
case 'mediumint':
case 'bigint':
$mem_set = $mem_set . $strField . " = " . intval($tabData[$strField]) . ", ";
break;
case 'double':
case 'float':
$mem_set = $mem_set . $strField . " = " . floatval($tabData[$strField]) . ", ";
break;
}
}
}
}
}
// enlever la virgule de trop et mettre dans le tableau à l'index 'set'
$memreturn['set'] = substr($mem_set, 0, -2);
// mettre dans le tableau à l'index 'key'
$memreturn['key'] = $mem_id;
// mettre dans le tableau les champs pas vide 'vide'
$memreturn['pasvide'] = $listvide;
return $memreturn;
}
function fx_copy_tout($sourceDir,$destinationDir){
// Crée le dossier de destination s'il n'existe pas
// echo($sourceDir);
if (!is_dir($destinationDir)) {
mkdir($destinationDir, 0755, true);
}
// Utilisez glob() pour récupérer tous les fichiers correspondant à *.*
$files = glob($sourceDir . '*.*');
foreach ($files as $file) {
$fileName = basename($file); // Récupère uniquement le nom du fichier
$destination = $destinationDir . $fileName;
if (copy($file, $destination)) {
} else {
$error = error_get_last();
error_log("Détails de l'erreur : " . $error['message']);
error_log( "Échec de la copie pour le fichier $fileName.");
}
}
}
function fxDuplicateRow($table, $id, $primaryKey, $updates = []) {
// Étape 1 : Récupérer l'enregistrement original
$sqlSelect = "SELECT * FROM $table WHERE $primaryKey = $id";
$originalRow = $GLOBALS['db']->fxGetRow($sqlSelect);
if (!$originalRow) {
return false; // Enregistrement non trouvé
}
// Étape 2 : Construire une requête d'insertion
unset($originalRow[$primaryKey]); // Retirer la clé primaire (auto-incrémentée)
foreach ($updates as $column => $value) {
$originalRow[$column] = $value; // Appliquer les mises à jour
}
// Générer les colonnes et les valeurs pour l'INSERT
$columns = array_keys($originalRow);
$values = array_map([$GLOBALS['db'], 'fxEscape'], array_values($originalRow));
$sqlInsert = "
INSERT INTO $table (" . implode(', ', $columns) . ")
VALUES ('" . implode("', '", $values) . "')
";
// Étape 3 : Exécuter la requête d'insertion
$GLOBALS['db']->fxQuery($sqlInsert);
// Retourner l'ID de la nouvelle ligne
return $GLOBALS['db']->fxGetLastId();
}
function print_rsl($arr){
?>
<pre>
<?php
print_r($arr);
?>
</pre>
<?php
}
// php version 8
function fxcountpatch($table){
$sortie= (is_array($table) ? count($table) : 0);
return $sortie;
}
function echosl($string)
{
echo($string);
echo("<br>");
}
function fxcopieevenementv1($eve_id_source)
{
$db = $GLOBALS['db'];
// 1. Lire l'événement source
$sql = "SELECT * FROM inscriptions_evenements WHERE eve_id = $eve_id_source";
$row = $db->fxGetRow($sql);
if (!$row) {
// echo "❌ Événement source introuvable.<br>";
return false;
}
// 2. Modifier les champs
unset($row['eve_id']);
$row['eve_nom_fr'] = trim($row['eve_nom_fr']) . ' _copie';
$row['eve_nom_en'] = trim($row['eve_nom_en']) . ' _copie';
$row['eve_label_url'] = trim($row['eve_label_url']) . '_copie';
$row['eve_actif'] = 0;
$row['prod_update_date'] = date('Y-m-d H:i:s');
// 3. INSERT dans inscriptions_evenements
$columns = array_keys($row);
$values = array_map([$db, 'fxEscape'], array_values($row));
$sqlInsert = "INSERT INTO inscriptions_evenements (" . implode(", ", $columns) . ")
VALUES ('" . implode("', '", $values) . "')";
// echo "<pre><strong>🟦 INSERT événement :</strong>\n$sqlInsert</pre>";
$db->fxQuery($sqlInsert);
$new_eve_id = $db->fxGetLastId();
// echo "<strong>✅ Nouvel événement copié avec eve_id : $new_eve_id</strong><br>";
// 4. Tables liées à copier
$tables = [
['inscriptions_epreuves', 'epr_id'],
['inscriptions_infos_participants', 'inf_id'],
['inscriptions_questions', 'que_id'],
['inscriptions_produits_new', 'pro_id'],
];
// 5. Boucle pour copier chaque table
foreach ($tables as [$table, $pk]) {
$sql = "SELECT * FROM $table WHERE eve_id = $eve_id_source";
$result = $db->fxQuery($sql);
$copied = 0;
while ($row = mysqli_fetch_assoc($result)) {
unset($row[$pk]); // supprimer l'ID auto
$row['eve_id'] = $new_eve_id;
$columns = array_keys($row);
$values = array_map([$db, 'fxEscape'], array_values($row));
$sqlInsert = "INSERT INTO $table (" . implode(", ", $columns) . ")
VALUES ('" . implode("','", $values) . "')";
$db->fxQuery($sqlInsert);
$copied++;
}
// echo "✔ $copied lignes copiées dans <strong>$table</strong><br>";
}
return $new_eve_id ;
//echo "<strong style='color:green;'>🎉 Duplication complète avec succès.</strong>";
}
function fxcopieevenement($eve_id_source)
{
$db = $GLOBALS['db'];
// 1. Lire l'événement source
$sql = "SELECT * FROM inscriptions_evenements WHERE eve_id = $eve_id_source";
$row = $db->fxGetRow($sql);
if (!$row) return false;
// 2. Préparer les données de l'événement
unset($row['eve_id']);
$row['eve_nom_fr'] = trim($row['eve_nom_fr']) . ' _copie';
$row['eve_nom_en'] = trim($row['eve_nom_en']) . ' _copie';
$row['eve_label_url'] = trim($row['eve_label_url']) . '_copie';
$row['eve_actif'] = 0;
$row['prod_update_date'] = date('Y-m-d H:i:s');
// 3. INSERT dans inscriptions_evenements
$columns = array_keys($row);
$values = array_map([$db, 'fxEscape'], array_values($row));
$sqlInsert = "INSERT INTO inscriptions_evenements (" . implode(", ", $columns) . ")
VALUES ('" . implode("', '", $values) . "')";
$db->fxQuery($sqlInsert);
$new_eve_id = $db->fxGetLastId();
// 4. Copier les tables liées
// ['inscriptions_rabais', 'rab_id', null],
$tables = [
['inscriptions_epreuves', 'epr_id', 'epr_id_old'],
['inscriptions_infos_participants', 'inf_id', null],
['inscriptions_questions', 'que_id', null],
['inscriptions_produits_new', 'pro_id', 'pro_id_old'],
];
foreach ($tables as [$table, $pk, $old_id_field]) {
$sql = "SELECT * FROM $table WHERE eve_id = $eve_id_source";
$result = $db->fxQuery($sql);
while ($row = mysqli_fetch_assoc($result)) {
$old_id = $row[$pk];
unset($row[$pk]);
if ($old_id_field) {
$row[$old_id_field] = $old_id;
}
$row['eve_id'] = $new_eve_id;
$columns = array_keys($row);
$values = array_map([$db, 'fxEscape'], array_values($row));
$sqlInsert = "INSERT INTO $table (" . implode(", ", $columns) . ")
VALUES ('" . implode("','", $values) . "')";
$db->fxQuery($sqlInsert);
}
}
// 5. Mise à jour des champs questions_epreuves_incluses
$sql = "SELECT * FROM inscriptions_questions WHERE eve_id = $new_eve_id";
$result = $db->fxQuery($sql);
while ($row = mysqli_fetch_assoc($result)) {
$que_id = $row['que_id'];
$liste_epreuves = $row['que_epreuves_incluses'];
if (empty($liste_epreuves)) continue;
$ids = explode(',', $liste_epreuves);
$nouvelle_liste = [];
foreach ($ids as $id) {
$id = trim($id);
if ($id === '' || $id === '0') {
$nouvelle_liste[] = $id;
continue;
}
$sqlFind = "SELECT epr_id FROM inscriptions_epreuves
WHERE eve_id = $new_eve_id AND epr_id_old = " . intval($id);
$resFind = $db->fxQuery($sqlFind);
if (mysqli_num_rows($resFind) === 1) {
$rowEpr = mysqli_fetch_assoc($resFind);
$nouvelle_liste[] = $rowEpr['epr_id'];
} else {
$nouvelle_liste[] = $id;
}
}
$nouvelle_valeur = implode(',', $nouvelle_liste);
if ($nouvelle_valeur !== $liste_epreuves) {
$escaped_val = $db->fxEscape($nouvelle_valeur);
$update_sql = "UPDATE inscriptions_questions
SET que_epreuves_incluses = '$escaped_val'
WHERE que_id = $que_id";
$db->fxQuery($update_sql);
}
}
// 5. Mise à jour des champs que_choix_produit
$sql = "SELECT * FROM inscriptions_questions WHERE eve_id = $new_eve_id";
$result = $db->fxQuery($sql);
while ($row = mysqli_fetch_assoc($result)) {
$que_id = $row['que_id'];
$liste_epreuves = $row['que_choix_produit'];
if (empty($liste_epreuves)) continue;
$ids = explode(',', $liste_epreuves);
$nouvelle_liste = [];
foreach ($ids as $id) {
$id = trim($id);
if ($id === '' || $id === '0') {
$nouvelle_liste[] = $id;
continue;
}
$sqlFind = "SELECT * FROM inscriptions_produits_new
WHERE eve_id = $new_eve_id AND pro_id_old = " . intval($id);
$resFind = $db->fxQuery($sqlFind);
if (mysqli_num_rows($resFind) === 1) {
$rowEpr = mysqli_fetch_assoc($resFind);
$nouvelle_liste[] = $rowEpr['pro_id'];
} else {
$nouvelle_liste[] = $id;
}
}
$nouvelle_valeur = implode(',', $nouvelle_liste);
if ($nouvelle_valeur !== $liste_epreuves) {
$escaped_val = $db->fxEscape($nouvelle_valeur);
$update_sql = "UPDATE inscriptions_questions
SET que_choix_produit = '$escaped_val'
WHERE que_id = $que_id";
$db->fxQuery($update_sql);
}
}
return $new_eve_id;
}
function fxgetpromoteurs($eve_id_source)
{
$db = $GLOBALS['db'];
// 1. Lire l'événement source
$sql = "SELECT * FROM inscriptions_comptes WHERE FIND_IN_SET('" . $eve_id_source . "', REPLACE(com_eve_promoteur, ' ', '')) > 0;";
$comptes = $db->fxGetResults($sql);
//MSIN-4283
$sql = "
SELECT DISTINCT TRIM(
SUBSTRING_INDEX(
SUBSTRING_INDEX(com_groupe, ',', n.n),
',', -1
)
) AS groupe
FROM inscriptions_comptes
JOIN (
SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
SELECT 4 UNION ALL SELECT 5
) n
ON n.n <= 1 + LENGTH(com_groupe) - LENGTH(REPLACE(com_groupe, ',', ''))
WHERE com_groupe <> ''
ORDER BY groupe
";
$groupes = $db->fxGetResults($sql);
?>
<!-- Bouton pour ouvrir/fermer -->
<p>
<button class="btn btn-secondary" type="button" data-toggle="collapse" data-target="#tableComptes" aria-expanded="false" aria-controls="tableComptes">
Afficher / Masquer la liste des comptes
</button>
</p>
<!-- Tableau en mode collapse -->
<div class="collapse" id="tableComptes">
<div id="pick-promoteur" class="position-relative" style="max-width:420px;">
Ajouter un promoteurs <input type="text" class="form-control" id="pp-email" placeholder="Tapez un e-mail…" autocomplete="off">
<div id="pp-results" class="list-group mt-1 d-none"
style="position:absolute; left:0; right:0; z-index:1000; max-height:220px; overflow:auto;"></div>
<?php
//MSIN-4283
foreach ($groupes as $g) {
echo '<a href="index.php?action=addpromoteurToGroupe'
. '&id=' . urlencode($_GET['id'])
. '&groupe=' . urlencode($g['groupe'])
. '&t=' . urlencode($_GET['t'])
. '" class="btn btn-primary">'
. htmlspecialchars($g['groupe'])
. '</a> ';
}
?>
</div>
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="text-align: center; width: 20px;">#</th>
<th style="text-align: left;">Prénom</th>
<th style="text-align: left;">Nom</th>
<th style="text-align: left;">Courriel</th>
<th style="text-align: left;">Téléphone</th>
<th style="text-align: center; width: 50px;">Effacer</th>
</tr>
</thead>
<tbody>
<?php foreach ($comptes as $index => $c): ?>
<tr>
<td style="text-align: center;"><?= $index ?></td>
<td><?= htmlspecialchars($c['com_prenom']) ?></td>
<td><?= htmlspecialchars($c['com_nom']) ?></td>
<td><?= htmlspecialchars($c['com_courriel']) ?></td>
<td><?= htmlspecialchars($c['com_telephone1']) ?></td>
<td style="text-align: center;">
<a href="index.php?t=<?= urlencode($_GET['t']) ?>&a=mod&id=<?= intval($_GET['id']) ?>&eve_id=<?= intval($_GET['eve_id']) ?>&action=deletepromoteur&promoteur_id=<?=$c['com_id'] ?>"
class="btn btn-sm btn-danger rounded-0"
onclick="return confirm('Voulez-vous vraiment effacer cet élément ?');">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th style="text-align: center;" colspan="7">
<?= count($comptes) ?> / <?= count($comptes) ?> items
</th>
</tr>
</tfoot>
</table>
</div>
<?php
}
function fxgetevenementpromoteurs($com_eve_promoteur_source,$com_id_source)
{
$db = $GLOBALS['db'];
$com_eve_promoteur_source = trim((string)$com_eve_promoteur_source);
$comptes = array();
if ($com_eve_promoteur_source !== '') {
$sql = "SELECT eve_id,eve_nom_fr,eve_date_fin FROM inscriptions_evenements WHERE eve_id IN (".$com_eve_promoteur_source.") order by eve_date_fin DESC;";
$comptes = $db->fxGetResults($sql);
if ($comptes === null) {
$comptes = array();
}
}
?>
<!-- Tableau en mode collapse -->
<div >
<div id="pick-evenement">
<input id="pp-evenement" type="text" class="form-control" placeholder="Rechercher un événement…">
<!-- MSIN-4457 — En flux pour eviter le clip ; hauteur utile. -->
<div id="pp-results-eve" class="list-group d-none mt-1"
style="max-height:min(60vh, 480px);overflow:auto;border:1px solid #ced4da;"></div>
</div>
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="text-align: center; width: 20px;">#</th>
<th style="text-align: left;">eve_id</th>
<th style="text-align: left;">Nom</th>
<th style="text-align: left;">Date fin</th>
<th style="text-align: center; width: 50px;">Effacer</th>
</tr>
</thead>
<tbody>
<?php foreach ($comptes as $index => $c): ?>
<tr>
<td style="text-align: center;"><?= $index ?></td>
<td><?= htmlspecialchars($c['eve_id']) ?></td>
<td><?= htmlspecialchars($c['eve_nom_fr']) ?></td>
<td><?= htmlspecialchars($c['eve_date_fin']) ?></td>
<td style="text-align: center;">
<a href="index.php?t=<?= urlencode($_GET['t']) ?>&a=mod&id=<?= intval($_GET['id']) ?>&eve_id=<?= $c['eve_id']; ?>&action=deletepromoteurcompte&promoteur_id=<?=$com_id_source?>"
class="btn btn-sm btn-danger rounded-0"
onclick="return confirm('Voulez-vous vraiment effacer cet élément ?');">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th style="text-align: center;" colspan="7">
<?= count($comptes) ?> / <?= count($comptes) ?> items
</th>
</tr>
</tfoot>
</table>
</div>
<?php
}
function fxDeleteEvenementFromPromoteur($eve_id, $promoteur_id)
{
$db = $GLOBALS['db'];
$eve_id = (int)$eve_id;
$promoteur_id = (int)$promoteur_id;
// 1) Lire la liste actuelle
$sql = "SELECT com_eve_promoteur
FROM inscriptions_comptes
WHERE com_id = $promoteur_id
LIMIT 1";
$res = $db->fxQuery($sql);
if (!$res || mysqli_num_rows($res) === 0) return false;
$row = mysqli_fetch_assoc($res);
$liste = (string)$row['com_eve_promoteur'];
// Rien à faire si déjà vide
if ($liste === '') return true;
// 2) Exploser sur la virgule (pas d'espaces dans tes données)
$ids = explode(',', $liste);
// 3) Retirer uniquement $eve_id (comparaison numérique stricte)
$changed = false;
$filtered = [];
foreach ($ids as $id) {
// On garde les éléments non vides et différents de $eve_id
if ($id === '') continue;
if ((int)$id === $eve_id) { $changed = true; continue; }
$filtered[] = $id; // on conserve tel quel (pas d'espaces à gérer)
}
// Si rien na changé, on sort
if (!$changed) return true;
// 4) Reconstituer proprement
$nouvelleListe = implode(',', $filtered); // donnera "" si plus rien
// 5) Sauvegarder (et néchapper que si non vide)
$escaped = $db->fxEscape($nouvelleListe);
$sqlUpdate = "UPDATE inscriptions_comptes
SET com_eve_promoteur = '$escaped'
WHERE com_id = $promoteur_id";
$db->fxQuery($sqlUpdate);
return true;
}
//MSIN-4283
function fxAddEvenementToGroupe($eve_id, $nomGroupe)
{
$db = $GLOBALS['db'];
$eve_id = (int)$eve_id;
$nomGroupe = trim($nomGroupe);
if ($eve_id <= 0 || $nomGroupe === '') return false;
// 1) Lire tous les comptes du groupe
$sql = "
SELECT com_id, com_eve_promoteur
FROM inscriptions_comptes
WHERE FIND_IN_SET(
'" . $db->fxEscape($nomGroupe) . "',
REPLACE(com_groupe, ' ', '')
) > 0
";
$res = $db->fxQuery($sql);
if (!$res || mysqli_num_rows($res) === 0) return false;
// 2) Boucle sur chaque promoteur du groupe
while ($row = mysqli_fetch_assoc($res)) {
$liste = (string)$row['com_eve_promoteur'];
if ($liste === '' || $liste === null) {
$nouvelleListe = (string)$eve_id;
} else {
$ids = explode(',', $liste);
$deja = false;
foreach ($ids as $id) {
if ((int)$id === $eve_id) {
$deja = true;
break;
}
}
if ($deja) continue;
$nouvelleListe = $liste . ',' . $eve_id;
}
// 3) Update
$escaped = $db->fxEscape($nouvelleListe);
$sqlUpdate = "
UPDATE inscriptions_comptes
SET com_eve_promoteur = '$escaped'
WHERE com_id = " . (int)$row['com_id'] . "
";
$db->fxQuery($sqlUpdate);
}
return true;
}
function fxAddEvenementToPromoteur($eve_id, $promoteur_id)
{
$db = $GLOBALS['db'];
$eve_id = (int)$eve_id;
$promoteur_id = (int)$promoteur_id;
if ($eve_id <= 0 || $promoteur_id <= 0) return false;
// 1) Lire la liste actuelle
$sql = "SELECT com_eve_promoteur
FROM inscriptions_comptes
WHERE com_id = $promoteur_id
LIMIT 1";
$res = $db->fxQuery($sql);
if (!$res || mysqli_num_rows($res) === 0) return false;
$row = mysqli_fetch_assoc($res);
$liste = (string)$row['com_eve_promoteur'];
// 2) Construire la nouvelle liste (sans espaces, sans doublon)
if ($liste === '' || $liste === null) {
$nouvelleListe = (string)$eve_id;
} else {
// Vérifie le doublon
$ids = explode(',', $liste);
foreach ($ids as $id) {
if ((int)$id === $eve_id) {
// déjà présent, rien à faire
return true;
}
}
// Ajoute à la fin, avec virgule, sans espace
$nouvelleListe = $liste . ',' . $eve_id;
}
// 3) Sauvegarder
$escaped = $db->fxEscape($nouvelleListe);
$sqlUpdate = "UPDATE inscriptions_comptes
SET com_eve_promoteur = '$escaped'
WHERE com_id = $promoteur_id";
$db->fxQuery($sqlUpdate);
return true;
}
/** Durée d'inactivité superadm (MSIN-CON-259) — alignée site public, 3 h. */
function fxSuperadmSessionInactiveSeconds() {
return 10800;
}
/**
* Valide la session superadm via $_SESSION['logged'] uniquement (pas date_maj du compte public).
*
* @return int usa_id ou 0 si session absente / expirée
*/
function fxSuperadmSessionValidate($blnRefresh = true) {
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
if (empty($_SESSION['usa_id']) || empty($_SESSION['usa_info'])) {
return 0;
}
$inactive = fxSuperadmSessionInactiveSeconds();
$intLastActivity = intval($_SESSION['logged'] ?? 0);
if ($intLastActivity <= 0) {
$_SESSION['logged'] = time();
return intval($_SESSION['usa_id']);
}
if ((time() - $intLastActivity) > $inactive) {
return 0;
}
if ($blnRefresh) {
$_SESSION['logged'] = time();
}
return intval($_SESSION['usa_id']);
}
/** Secondes restantes avant expiration (0 = expirée). */
function fxSuperadmSessionExpiresIn() {
if (empty($_SESSION['usa_id'])) {
return 0;
}
$intLastActivity = intval($_SESSION['logged'] ?? 0);
if ($intLastActivity <= 0) {
return fxSuperadmSessionInactiveSeconds();
}
return max(0, fxSuperadmSessionInactiveSeconds() - (time() - $intLastActivity));
}
/**
* Auth AJAX superadm — même règles que inc_start_time.php (MSIN-CON-259, 3 h),
* mais réponse JSON au lieu d'une redirection (logout.php casse les appels $.post).
*/
function fxSuperadmAjaxAuthOrJsonExit() {
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
header('Content-Type: application/json; charset=utf-8');
$intUsaId = fxSuperadmSessionValidate(true);
if ($intUsaId <= 0) {
echo json_encode(array(
'state' => 'error',
'message' => 'Session expirée ou accès refusé.',
'code' => 'session',
));
exit;
}
return $intUsaId;
}
/** Ping session superadm — garde la session vivante tant que l'onglet est ouvert. */
function fxSuperadmSessionPingJson() {
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
header('Content-Type: application/json; charset=utf-8');
$intUsaId = fxSuperadmSessionValidate(true);
if ($intUsaId <= 0) {
echo json_encode(array(
'ok' => false,
'message' => 'Session expirée — reconnectez-vous au superadmin.',
'code' => 'session',
));
exit;
}
$intExpiresIn = fxSuperadmSessionExpiresIn();
echo json_encode(array(
'ok' => true,
'expires_in' => $intExpiresIn,
'warn' => ($intExpiresIn > 0 && $intExpiresIn <= 300),
));
exit;
}
/**
* Super admin connecté — canal superadm/login.php uniquement (usa_id en session).
* Ne jamais déduire du login public : com_info / com_superadm ne comptent pas ici.
*/
function fxSuperadmIsLoggedIn() {
return !empty($_SESSION['usa_id']);
}
/**
* MSIN-4401 — Créer / modifier / supprimer les définitions de kits (pas l'assignation).
* Liste : $arrEveAccesKitEditors dans php/inc_settings.php.
*/
if (!function_exists('fxAdminCanEditEveAccesKits')) {
function fxAdminCanEditEveAccesKits() {
global $arrEveAccesKitEditors;
if (!fxSuperadmIsLoggedIn() || empty($_SESSION['usa_info']) || !is_array($_SESSION['usa_info'])) {
return false;
}
$arrAllow = (isset($arrEveAccesKitEditors) && is_array($arrEveAccesKitEditors))
? $arrEveAccesKitEditors
: array();
$arrNorm = array();
foreach ($arrAllow as $strItem) {
$strItem = strtolower(trim((string)$strItem));
if ($strItem !== '') {
$arrNorm[$strItem] = true;
}
}
if (count($arrNorm) === 0) {
return false;
}
$arrCandidates = array(
strtolower(trim((string)($_SESSION['usa_info']['com_courriel'] ?? ''))),
strtolower(trim((string)($_SESSION['usa_info']['com_login'] ?? ''))),
);
foreach ($arrCandidates as $strCand) {
if ($strCand !== '' && isset($arrNorm[$strCand])) {
return true;
}
}
return false;
}
}
/**
* Session superadm absente → login (pas « Accès refusé »).
* Rapports legacy : session compte public (com_info) suffit pour la vérif droits ensuite.
*/
function fxSuperadmRedirectToLoginIfNeeded($blnAllowCompteLegacy = false) {
if (fxSuperadmIsLoggedIn()) {
return;
}
if ($blnAllowCompteLegacy && !empty($_SESSION['com_info']['com_id'])) {
return;
}
$_SESSION['superadm_redirect_after_login'] = $_SERVER['REQUEST_URI'];
global $vDomaine;
$strLogin = 'login.php';
if (!empty($vDomaine)) {
$strLogin = rtrim((string)$vDomaine, '/') . '/superadm/login.php';
}
header('Location: ' . $strLogin);
exit;
}
/** URL cible après login superadm (évite redirection ouverte). */
function fxSuperadmConsumeRedirectAfterLogin($strDefault = 'index.php') {
if (empty($_SESSION['superadm_redirect_after_login'])) {
return $strDefault;
}
$strUrl = (string)$_SESSION['superadm_redirect_after_login'];
unset($_SESSION['superadm_redirect_after_login']);
if (strpos($strUrl, '/superadm/') === false) {
return $strDefault;
}
if (strpos($strUrl, '://') !== false) {
$strHost = parse_url($strUrl, PHP_URL_HOST);
if ($strHost !== ($_SERVER['HTTP_HOST'] ?? '')) {
return $strDefault;
}
}
return $strUrl;
}
/**
* Accès rapports superadm — super admin = tout ; sinon promoteur legacy (com_eve_promoteur / com_rapports).
*/
function fxSuperadmReportsAllowed($intEvenement = 0) {
if (fxSuperadmIsLoggedIn()) {
return true;
}
if (intval($intEvenement) <= 0 || empty($_SESSION['com_info']['com_id'])) {
return false;
}
global $db;
$recPromoteur = $db->fxGetRow(
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = '
. intval($_SESSION['com_info']['com_id'])
);
if ($recPromoteur == null || trim((string)$recPromoteur['com_eve_promoteur']) === '') {
return false;
}
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
return in_array((string)intval($intEvenement), $tabEve, true);
}
/** Rapports Excel/liste ADM (index.php?a=report&t=…) — super admin ou com_rapports / men_ref promoteur. */
function fxSuperadmReportMenuAllowed($intMenuId) {
if (fxSuperadmIsLoggedIn()) {
return true;
}
if (intval($intMenuId) <= 0 || empty($_SESSION['com_info']['com_id'])) {
return false;
}
global $objDatabase;
$recRapport = $objDatabase->fxGetRow(
'SELECT men_ref FROM adm_menus WHERE men_id = ' . intval($intMenuId)
);
$recPromoteur = $objDatabase->fxGetRow(
'SELECT com_eve_promoteur, com_rapports FROM inscriptions_comptes WHERE com_id = '
. intval($_SESSION['com_info']['com_id'])
);
if ($recPromoteur == null || $recRapport == null) {
return false;
}
$tabEve = array_map('trim', explode(',', (string)$recPromoteur['com_eve_promoteur']));
$tabRapports = array_map('trim', explode(',', (string)$recPromoteur['com_rapports']));
if (trim((string)$recRapport['men_ref']) !== '0'
&& trim((string)$recRapport['men_ref']) !== ''
&& in_array(trim((string)$recRapport['men_ref']), $tabEve, true)) {
return true;
}
return in_array((string)intval($intMenuId), $tabRapports, true);
}
/** Sync tables statiques — superadm, préprod dev seulement (aligné sur sync_static_db.php). */
function fxSuperadmStaticSyncAllowed() {
if (empty($_SESSION['usa_id'])) {
return false;
}
$strHost = strtolower((string)($_SERVER['HTTP_HOST'] ?? ''));
return strpos($strHost, 'ms1inscriptiondev') !== false
&& strpos($strHost, 'preprod.') !== false;
}