fxGetResults($sql); if (empty($rows)) { $sql = " INSERT INTO dashboard_log (log_ip, log_page, log_first_access, log_last_access, log_allowed) VALUES ('$ip','$page','$now','$now',0) "; $objDatabase->fxQuery($sql); return false; } $sql = " UPDATE dashboard_log SET log_last_access = '$now' WHERE log_ip = '$ip' AND log_page = '$page' "; $objDatabase->fxQuery($sql); // ✅ prendre la 1re ligne peu importe l'index (0, 1, 27...) $first = reset($rows); return (isset($first['log_allowed']) && intval($first['log_allowed']) === 1); } function getPrixEpreuvesProchainsJours($nbJours = 4) { global $objDatabase; $nbJours = intval($nbJours); $sql = " SELECT pe.eve_id, pa.ep_date_limite, pe.eve_nom_fr, e.epr_type_fr, pa.ep_montant, e.epr_id, ( SELECT pa2.ep_montant FROM inscriptions_epreuves_prix pa2 WHERE pa2.epr_id = pa.epr_id AND pa2.ep_date_limite < pa.ep_date_limite ORDER BY pa2.ep_date_limite DESC LIMIT 1 ) AS ep_montant_avant FROM inscriptions_epreuves_prix pa JOIN inscriptions_panier_evenements pe ON pa.eve_id = pe.eve_id JOIN inscriptions_panier_epreuves e ON e.epr_id = pa.epr_id WHERE pa.ep_date_limite BETWEEN CURRENT_DATE AND DATE_ADD(CURRENT_DATE, INTERVAL $nbJours DAY) GROUP BY pe.eve_id ORDER BY pa.ep_date_limite, pa.eve_id, pa.epr_id "; $rows = $objDatabase->fxGetResults($sql); return $rows; } function getTopEventsMultiDays($nbJours = 2) { global $objDatabase; $nbJours = intval($nbJours); $dateFin = new DateTime(); $dateDebut = (new DateTime())->modify("-$nbJours days"); $result = []; $periode = new DatePeriod( $dateDebut, new DateInterval('P1D'), (clone $dateFin)->modify('+1 day') ); $previousDayData = []; foreach ($periode as $date) { $jour = $date->format('Y-m-d'); $sql = " SELECT pa.eve_id, pe.eve_nom_fr, SUM(pa.ach_total) as total, COUNT(*) as nbtransact FROM inscriptions_panier_acheteurs pa LEFT JOIN inscriptions_panier_evenements pe ON pa.eve_id = pe.eve_id WHERE pa.ach_total > 0 AND pa.sta_id = 3 AND DATE(pa.ach_maj) = '$jour' GROUP BY pa.eve_id ORDER BY total DESC LIMIT 10 "; $rows = $objDatabase->fxGetResults($sql); $dayData = []; foreach ($rows as $row) { $eveId = $row['eve_id']; $total = floatval($row['total']); $variation = null; if (isset($previousDayData[$eveId]) && $previousDayData[$eveId] > 0) { $variation = round((($total - $previousDayData[$eveId]) / $previousDayData[$eveId]) * 100); } $dayData[$eveId] = $total; $result[$jour][] = [ 'eve_id' => $eveId, 'eve_nom_fr' => $row['eve_nom_fr'], 'total' => $total, 'transactions' => intval($row['nbtransact']), 'variation' => $variation ]; } $previousDayData = $dayData; } $result = array_reverse($result, true); return $result; } function fxGetDashboard() { // trouver labonnement global $objDatabase; $arrdb = null; $sqldb = " SELECT * FROM dashboard WHERE db_actif = 1 order by trie "; $arrdb = $objDatabase->fxGetResults($sqldb); return $arrdb; } function fxbackup($param) { try { $pdo = new PDO('mysql:host=localhost;dbname=progiweb_prod;charset=utf8', 'progiweb_bd', '8dYhZ9Hcz{ZC'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) { echo('Erreur de connexion : ' . $e->getMessage()); } // Exemple : tu peux remplacer ceci par $_GET['param'] si tu veux $mot_cle = $param; // Requête avec LIKE sécurisé $sql = " SELECT * FROM backup_logs WHERE actif = 1 AND `mots` LIKE :mot "; // Affiche la requête (à des fins de debug, optionnel) $stmt = $pdo->prepare($sql); // Exécuter la requête avec le mot-clé entouré de % $stmt->execute(['mot' => '%' . $mot_cle . '%']); // Récupération $results = $stmt->fetchAll(PDO::FETCH_ASSOC); if (!empty($results)) { foreach ($results as $row) { $style = ($row['status'] === 'fail') ? 'color:red;' : ''; echo "

" . htmlspecialchars($row['database_name']) . "
" . htmlspecialchars($row['backup_date']) . " " . htmlspecialchars($row['status']) . "

"; } } } function fxGetTicket($status) { // --- Configuration Jira --- $jiraDomain = 'https://progiwebinc.atlassian.net'; $admin_email = 'stephan@progiweb.ca'; // ms1inscription v4 $api_token = 'ATATT3xFfGF0Er4BgSMTqYjcLEWCZAIQKy9Ja21yEQe5rQXVJD775Wrzi6aBJrZnm0SFgsoxAVyRMJk3LyzXiki2Ilzy09vAtmmkh37Z3rwBjVhT2HilCO8sruV0PeYlDNXlWAEtPxqyg0D3vBimSRieTGV3Fi-G9pj9_djyL6Pg3gFYuGEEapI=D0D802D6'; // --- Construire dynamiquement la JQL --- $status = trim($status); if ($status !== '') { $status = addslashes($status); $jql = sprintf('project = "SM" AND status = "%s"', $status); } else { $jql = 'project = "SM"'; } // --- Endpoint Jira --- $url = $jiraDomain . '/rest/api/3/search/jql'; // --- Requête JSON --- $payload = [ 'jql' => $jql, 'maxResults' => 100, 'fields' => ['id'] // champ minimal requis ]; // --- cURL --- $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Basic ' . base64_encode("$admin_email:$api_token"), 'Content-Type: application/json', 'Accept: application/json' ], CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_TIMEOUT => 15 ]); $response = curl_exec($ch); $curl_error = curl_error($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // --- Sortie simple, comme avant --- if ($curl_error) { echo "0\n"; return; } if ($http_code === 200) { $data = json_decode($response, true); if (isset($data['issues'])) { echo count($data['issues']) . "\n"; return; } } // Si erreur ou rien trouvé echo "0\n"; } function fxGetTicketold($param){ // Configuration Jira $jiraDomain = 'https://progiwebinc.atlassian.net'; // Domaine Jira $admin_email = 'stephan@progiweb.ca'; // Email de l'administrateur $api_token = 'ATATT3xFfGF0DuhOhRUxFlj2hFpLuzYGapJIrhMETB35NnLFi1TyxDszp3tTa8MaadTpT72GfDk9FOpDm07m6HbdXoQ9plDeRvB6OwRnD19VrIqA8M3HmDGgf_MWR7Pwk5731ahbgb4UBdRgj-ICBqt9A0SjJPnnoTfu4ECVh51HjM0RsekOmeM=908B030C'; // Jeton d'API sécurisé // Construire la requête JQL pour les tickets ouverts $jqlQuery = $param.' AND project = "SM"'; // Modifiez le projet si nécessaire // Initialisation de cURL $ch = curl_init(); // Construire l'URL de l'API de recherche $url = $jiraDomain . '/rest/api/3/search?jql=' . urlencode($jqlQuery) . '&maxResults=0'; // Configurer les options cURL curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Basic ' . base64_encode("$admin_email:$api_token"), 'Content-Type: application/json', ], ]); // Exécuter la requête et obtenir la réponse $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Vérifier la réponse if ($http_code === 200) { $data = json_decode($response, true); $openTicketsCount = $data['total']; // Le nombre total de tickets ouverts echo "$openTicketsCount\n"; } else { echo "Erreur : Code HTTP $http_code\n"; echo "Réponse : $response\n"; } } function fxGetSlack() { // Token d'accès Slack (OAuth) $slackToken = 'xoxe.xoxp-1-Mi0yLTUyMDkwNTY3Nzc3Ni01MjEwMzgwMDc0MjUtODA1NDI4OTYxODE1MC04MDU0Mjk5OTc4NDcwLWFiM2ExM2U5NzRlNmZkZGE3MmFkMWUyODg3ZTc3ODEzZjExMDVhZTE2ZGMwZjE2MWUxNzEzZmQ2MjY1YzA4NDM'; // Remplacez par votre token OAuth // ID du canal Slack à récupérer (par exemple, 'C01234567') $channelId = 'CFWKAFZFS'; // URL de l'API Slack $url = "https://slack.com/api/conversations.history?channel=$channelId"; // Initialisation cURL $ch = curl_init($url); // Configuration cURL curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Bearer $slackToken", "Content-Type: application/json" ]); // Exécuter la requête $response = curl_exec($ch); curl_close($ch); // Décoder la réponse JSON $data = json_decode($response, true); // Vérifier si la requête a réussi if (isset($data['ok']) && $data['ok'] === true) { echo "

Messages du Canal

"; foreach ($data['messages'] as $message) { echo "

Message: " . htmlspecialchars($message['text']) . "

"; } } else { echo "

Erreur : " . htmlspecialchars($data['error'] ?? 'Inconnue') . "

"; } } function fxGetUptime(){ // Votre clé API UptimeRobot $apiKey = 'u428511-bc7dc8e62a02e78603ec46b2'; // L'URL de l'API UptimeRobot $url = 'https://api.uptimerobot.com/v2/getMonitors'; // Initialisation de cURL $curl = curl_init(); // Configuration de la requête cURL curl_setopt_array($curl, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query([ 'api_key' => $apiKey, 'format' => 'json' ]), CURLOPT_HTTPHEADER => [ 'Content-Type: application/x-www-form-urlencoded' ] ]); // Exécution de la requête et récupération de la réponse $response = curl_exec($curl); // Gestion des erreurs if (curl_errno($curl)) { echo 'Erreur cURL : ' . curl_error($curl); exit; } // Fermeture de cURL curl_close($curl); // Décodage de la réponse JSON $data = json_decode($response, true); // Vérification et affichage des résultats if (isset($data['stat']) && $data['stat'] === 'ok') { // echo "Liste des serveurs surveillés :\n"; foreach ($data['monitors'] as $monitor) { if (substr($monitor['friendly_name'] , 0, 2)=="zz"){}else{ echo "" . $monitor['friendly_name'] . ""; if($monitor['status'] == 2){ echo "En ligne
"; }else{ echo "Hors ligne
"; } // echo " Uptime : " . $monitor['alltimeuptimeratio'] . "%\n"; // echo "---------------------------\n"; } } } else { echo "Erreur : " . ($data['error']['message'] ?? 'Inconnue') . "\n"; } } function fxGetAgenda(){ // Clé API Google $apiKey = "AIzaSyDTNqa5abH5-OBG_AsrBfkNulV4E13bCv4"; // ID du calendrier (remplacez par un ID valide) $calendarId = "c_3efceaf4b459c62dac1a19f8f6f2f95c656d03158d9b2c135cef641cc7c48e67@group.calendar.google.com"; // URL de l'API Google Calendar $apiUrl = "https://www.googleapis.com/calendar/v3/calendars/{$calendarId}/events?key={$apiKey}"; // Déterminer la période : aujourd'hui à 30 jours $timeMin = date('Y-m-d\T00:00:00\Z'); // Aujourd'hui à minuit UTC $timeMax = date('Y-m-d\T23:59:59\Z', strtotime('+30 days')); // Dans 30 jours à 23h59 UTC // Paramètres pour la requête $params = [ 'maxResults' => 10, 'orderBy' => 'startTime', 'singleEvents' => 'true', 'timeMin' => $timeMin, 'timeMax' => $timeMax, ]; $apiUrl .= '&' . http_build_query($params); // Initialiser cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Exécuter la requête $response = curl_exec($ch); curl_close($ch); // Décoder la réponse JSON $data = json_decode($response, true); if (!empty($data['items'])) { foreach ($data['items'] as $event) { $summary = $event['summary'] ?? '(Sans titre)'; $start = $event['start']['dateTime'] ?? $event['start']['date'] ?? '(Pas de date)'; echo "

{$summary}
"; echo "Début : {$start}

"; } } else { echo "Aucun événement trouvé."; } } function getAccessToken($credentialsPath) { // Lire les informations d'identification JSON $credentials = json_decode(file_get_contents($credentialsPath), true); // Préparer les données pour la requête $postData = [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion' => createJwt($credentials) ]; // Faire une requête cURL pour obtenir le jeton $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://oauth2.googleapis.com/token'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded', ]); $response = curl_exec($ch); curl_close($ch); $response = json_decode($response, true); if (isset($response['access_token'])) { return $response['access_token']; } else { die('Erreur lors de la récupération du jeton d\'accès.'); } } function createJwt($credentials) { $header = [ 'alg' => 'RS256', 'typ' => 'JWT', ]; $claims = [ 'iss' => $credentials['client_email'], 'scope' => 'https://www.googleapis.com/auth/analytics.readonly', 'aud' => 'https://oauth2.googleapis.com/token', 'exp' => time() + 3600, 'iat' => time(), ]; $base64UrlHeader = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(json_encode($header))); $base64UrlPayload = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(json_encode($claims))); $signature = ''; openssl_sign($base64UrlHeader . "." . $base64UrlPayload, $signature, $credentials['private_key'], 'SHA256'); $base64UrlSignature = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($signature)); return $base64UrlHeader . "." . $base64UrlPayload . "." . $base64UrlSignature; } function getAnalyticsData($accessToken, $propertyId) { $url = "https://analyticsdata.googleapis.com/v1beta/properties/$propertyId:runReport"; $postData = json_encode([ 'dateRanges' => [ ['startDate' => '7daysAgo', 'endDate' => 'today'], ], 'dimensions' => [ ['name' => 'date'], ], 'metrics' => [ ['name' => 'activeUsers'], ], ]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $accessToken, 'Content-Type: application/json', ]); $response = curl_exec($ch); curl_close($ch); return json_decode($response, true); } function analy7jours($propertyId) { $credentialsPath = '../superadm/analytique-446019-0f3ca3c0452f.json'; $accessToken = getAccessToken($credentialsPath); $data = getAnalyticsData($accessToken, $propertyId); return $data; }