116 lines
4.7 KiB
PHP
Executable File
116 lines
4.7 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
if (!isset( $_SESSION )) {session_start();}
|
|
|
|
// -----------------------------------------------------
|
|
// Init
|
|
// -----------------------------------------------------
|
|
// -----------------------------------------------------
|
|
// Appel vers SMS Factor avec mon Token
|
|
// -----------------------------------------------------
|
|
// https://secure.smsfactor.com/token.html;
|
|
// $token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI0MzQxMyIsImlhdCI6MTYxOTI5NzM4OX0.WF7mz-IkZ_wXIs7khuibbBypEDKile9nSo3wc7nu-mk ";
|
|
// include ($includePathAdmin. "/psk/psk.smsFactor.php");
|
|
include ($includePathAdmin. "/psk.smsFactor.php");
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['mon token sms factor =' => $token], '');}
|
|
|
|
// -----------------------------------------------------
|
|
// Preparation Curl
|
|
// -----------------------------------------------------
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, "https://api.smsfactor.com/sub-accounts");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $token));
|
|
|
|
// -----------------------------------------------------
|
|
// Execution et Retour
|
|
// -----------------------------------------------------
|
|
$response = curl_exec($ch);
|
|
if ($response )
|
|
{$output= 'Compte SMS '; $continuer=1; }
|
|
else
|
|
{$output='Erreur compte SMS : '.curl_error($ch); }
|
|
|
|
curl_close($ch);
|
|
|
|
// -----------------------------------------------------
|
|
// Debug
|
|
// -----------------------------------------------------
|
|
if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .= monDebug (1,['output' => $output, 'Response =' => $response],'0.5retrieveCompteSmsFactor.php');
|
|
|
|
// -----------------------------------------------------
|
|
// Json en tableau associatif
|
|
// -----------------------------------------------------
|
|
$responseToTab=json_decode($response, true);
|
|
$statut=$responseToTab['status'];
|
|
$message=$responseToTab['message'];
|
|
$details=isset($responseToTab['details']);
|
|
|
|
// -----------------------------------------------------
|
|
// Code garder Parcours tableau associatif
|
|
// -----------------------------------------------------
|
|
if (isset($debug[1]) && $debug[1] == '1') {
|
|
foreach ($responseToTab as $key=> $data1) {
|
|
$debugMsg .= monDebug (1,[$key => $data1],'');
|
|
}
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Parcours tableau associatif
|
|
// compare avec mail adm
|
|
if(!isset($_SESSION['tableLibAdmin'])) {
|
|
include_once($includePath. "/req/15-init.adminMsgList.php");
|
|
}
|
|
|
|
$trouve=0;
|
|
$tabTab=$responseToTab['sub-accounts'];
|
|
for($n=0;$n<count($tabTab);$n++) {
|
|
$adminMail=$tabTab[$n]['email'];
|
|
for($a=0;$a<count($_SESSION['tableLibAdmin']);$a++) {
|
|
if ($adminMail==$_SESSION['tableLibAdmin'][$a]) {
|
|
$email2=$tabTab[$n]['email'];
|
|
$firstname=$tabTab[$n]['firstname'];
|
|
$lastname=$tabTab[$n]['lastname'];
|
|
$credits=$tabTab[$n]['credits'];
|
|
$trouve=1;
|
|
}
|
|
}
|
|
}
|
|
|
|
// flag traduction
|
|
if ($trouve==0 && isset($debug[1]) && $debug[1] == '1') { $debugMsg .= monDebug (1,['Pas de compte SMS trouvé' => '' ],'');
|
|
|
|
include_once("mailer.v04.php");
|
|
$sujet="Pas de compte SMS";
|
|
$message_html = "<!DOCTYPE html><html><head>";
|
|
$message_html = $message_html. "<title>' .$sujet. '</title>";
|
|
$message_html = $message_html. "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
|
|
$message_html = $message_html. "</head><body>";
|
|
$message_html = $message_html. "Cher Administrateur,<br>";
|
|
$message_html = $message_html. "Ce client adminMail = " .$adminMail. " n'a pas de compte SMS<br>";
|
|
$message_html = $message_html. "Pourtant on a essayer de lui en envoyer un<br>";
|
|
$message_html = $message_html. "Cela se passe dans 'extensions/sms/0.5retrieveCompteSmsFactor.php' <br>";
|
|
$message_html = $message_html. "Il faut débugger ce cas <br>";
|
|
$message_html = $message_html. "<br><br>";
|
|
$message_html = $message_html. "Merci, amigo<br>";
|
|
$message_html = $message_html. "";
|
|
$message_html = $message_html. "</body></html>";
|
|
$message_html=stripslashes($message_html);
|
|
$envMail = mailer(1, '','', 0, $_SESSION['smtpServer123'], $sujet, $message_html, 'dev@123ventes.com', '', '', 0, 'Mail ok', 'Mail ko', 0, '', '', 'admin@123ventes.com', '1.2.3. Debug', '', 'FRA');
|
|
}
|
|
|
|
// -----------------------------------------------------
|
|
// Debug
|
|
// -----------------------------------------------------
|
|
if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug (1,[
|
|
'statut' => $statut,
|
|
'message' => $message,
|
|
'adminMail session' => $_SESSION['adminMail'],
|
|
'email 1' => $email,
|
|
'email 2' => $email2,
|
|
'nom' => $lastname,
|
|
'Prénom' => $firstname,
|
|
'credits' => $credits
|
|
],'');
|
|
}
|
|
?>
|