282 lines
6.2 KiB
PHP
282 lines
6.2 KiB
PHP
<?php
|
|
require_once 'Functions.php';
|
|
|
|
class Cronenvoisms
|
|
{
|
|
public function __construct() {
|
|
}
|
|
|
|
public function charger_les_sms($nbSms)
|
|
{
|
|
require_once 'Envoismscron.php';
|
|
|
|
$this->smscron = new Envoismscron();
|
|
|
|
$this->lesSms = $this->smscron->get_les_smsaenvoyer($nbSms);
|
|
}
|
|
|
|
public function chargersociete()
|
|
{
|
|
require_once 'Societeuser.php';
|
|
|
|
$this->societe = new Societeuser();
|
|
$societe = $this->societe->getparametressociete();
|
|
|
|
$this->fournisseurSms = $societe['fournisseurSms'];
|
|
$this->devise = $societe['devise'];
|
|
$this->nbSmsParCron = $societe['nbSmsParCron'];
|
|
$this->nomProduitSante = $societe['nomProduitSante'];
|
|
$this->titreSms = $societe['titreSms'];
|
|
|
|
$this->loginSms = $societe['loginSms'];
|
|
$this->motPassSms = $societe['motPassSms'];
|
|
}
|
|
|
|
public function marquersms($idSms, $etat)
|
|
{
|
|
require_once 'Envoismscron.php';
|
|
|
|
$this->smscron = new Envoismscron();
|
|
$smsaenvoyer = $this->smscron->marquersms($idSms, $etat);
|
|
}
|
|
|
|
public function envoyer_les_sms()
|
|
{
|
|
$lesSms = $this->lesSms;
|
|
|
|
foreach ($lesSms as $un_sms)
|
|
{
|
|
$this->idSms = $un_sms['idSms'];
|
|
$this->destinataires = $un_sms['destinataires'];
|
|
$this->message = $un_sms['message'];
|
|
|
|
/*
|
|
echo $this->idSms;
|
|
echo "<br>";
|
|
|
|
echo $this->destinataires;
|
|
echo "<br>";
|
|
|
|
echo $this->message;
|
|
echo "<br>";
|
|
*/
|
|
|
|
$this->envoyer_un_des_sms();
|
|
|
|
sleep(1);
|
|
}
|
|
}
|
|
|
|
public function envoyer_un_des_sms()
|
|
{
|
|
/*
|
|
echo "envoyer_un_des_sms";
|
|
exit();
|
|
*/
|
|
|
|
$destinataires = $this->destinataires;
|
|
$message = $this->message;
|
|
$fournisseurSms = $this->fournisseurSms;
|
|
$nomProduitSante = $this->nomProduitSante;
|
|
$titreSms = $this->titreSms;
|
|
$fournisseurSms = $this->fournisseurSms;
|
|
|
|
|
|
$dest = explode(',', $destinataires);
|
|
foreach ($dest as $tel)
|
|
{
|
|
if($fournisseurSms=="esicia")
|
|
{
|
|
$this->envoyersmsesicia($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="blive")
|
|
{
|
|
$this->envoyersmsbliive($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="hooza")
|
|
{
|
|
$this->envoyersmshooza($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="skysms")
|
|
{
|
|
$this->envoyersmsskysms($tel, $message, $titreSms);
|
|
}
|
|
|
|
sleep(1);
|
|
}
|
|
}
|
|
|
|
public function envoyersmsbliive($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
// problème avec le https
|
|
// $url = "http://app.blive.bi/bridge-ws/ws/send";
|
|
$url = "https://app.blive.bi/bridge-ws/ws/send";
|
|
|
|
$get = array
|
|
(
|
|
// 'id' =>'snd-4b3abf81d-21707',
|
|
'id' =>$loginSms,
|
|
'from' =>$titreSms_c,
|
|
'to' =>$destinataires_c,
|
|
'text' =>$message_c
|
|
);
|
|
|
|
// var_dump($get);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
// curl_setopt($ch, CURLOPT_USERPWD, "BICOR-VIE:60cd7371a27c410484a1b485d273bef9");
|
|
curl_setopt($ch, CURLOPT_USERPWD, $motPassSms);
|
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
|
curl_setopt($ch, CURLOPT_POST, TRUE);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $get);
|
|
|
|
$result = curl_exec($ch);
|
|
|
|
if (curl_errno($ch))
|
|
{
|
|
echo 'Error:' . curl_error($ch);
|
|
}
|
|
|
|
// $info = curl_getinfo($ch);
|
|
curl_close($ch);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
// A SUPPRIMER => juste pou tester
|
|
var_dump($result);
|
|
}
|
|
|
|
public function envoyersmsesicia($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
// problème avec le https
|
|
$url = "http://gateway.esicia.com/sendsms/?";
|
|
|
|
$postFields = array
|
|
(
|
|
'ohereza' =>$titreSms_c,
|
|
'kuri' =>$destinataires_c,
|
|
'ubutumwa' =>$message_c,
|
|
|
|
// 'client' =>'radiant',
|
|
// 'password' =>'umugozi',
|
|
|
|
'client' =>$loginSms,
|
|
'password' =>$motPassSms,
|
|
'msgid' =>'kanesin'
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
$result = file_get_contents($url);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
// A SUPPRIMER
|
|
// var_dump($result);
|
|
}
|
|
|
|
public function envoyersmshooza($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
// $message_c .= " => ".$loginSms;
|
|
|
|
$url = "http://rslr.connectbind.com/bulksms/bulksms";
|
|
|
|
$get = array
|
|
(
|
|
// 'username' =>'HoAj-radiant',
|
|
// 'password' =>'radiant',
|
|
|
|
'username' =>$loginSms,
|
|
'password' =>$motPassSms,
|
|
'type' =>'0',
|
|
'dlr' =>'1',
|
|
'destination' =>$destinataires_c,
|
|
'source' =>$titreSms_c,
|
|
'message' =>$message_c
|
|
);
|
|
|
|
$defaults = array(
|
|
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
|
|
// CURLOPT_URL => $url,
|
|
CURLOPT_HEADER => 0,
|
|
CURLOPT_RETURNTRANSFER => TRUE,
|
|
CURLOPT_TIMEOUT => 10
|
|
);
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt_array($ch, ($defaults));
|
|
if( ! $result = curl_exec($ch))
|
|
{
|
|
trigger_error(curl_error($ch));
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
// A SUPPRIMER
|
|
// var_dump($result);
|
|
}
|
|
|
|
public function envoyersmsskysms($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
// $message_c .= " => SKYSMS";
|
|
|
|
$url = "http://137.74.43.214:9000/api/public/sendsms/v2/output=text?";
|
|
|
|
$postFields = array
|
|
(
|
|
'user' => $loginSms,
|
|
'password' => $motPassSms,
|
|
'sender' => $titreSms_c,
|
|
'phone' => $destinataires_c,
|
|
'message' => $message_c
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
$result = file_get_contents($url);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
// A SUPPRIMER
|
|
// var_dump($result);
|
|
}
|
|
|
|
|
|
} // FIN CLASSE
|
|
|
|
// envoi des SMS
|
|
|
|
$envoismsdivers = new Cronenvoisms();
|
|
|
|
$envoismsdivers->chargersociete();
|
|
|
|
$nbSms = $envoismsdivers->nbSmsParCron;
|
|
|
|
$envoismsdivers->charger_les_sms($nbSms);
|
|
|
|
// echo "charger_les_sms";
|
|
// exit();
|
|
|
|
$envoismsdivers->envoyer_les_sms();
|