599 lines
13 KiB
PHP
Executable File
599 lines
13 KiB
PHP
Executable File
<?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->compteSms = $societe['compteSms'];
|
|
|
|
$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'];
|
|
|
|
$this->envoyer_un_des_sms();
|
|
|
|
// sleep(1);
|
|
usleep(2000); // Stoppe pour 2 millisecondes
|
|
}
|
|
}
|
|
|
|
public function envoyer_un_des_sms()
|
|
{
|
|
$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);
|
|
}
|
|
elseif($fournisseurSms=="satelcom")
|
|
{
|
|
$this->envoyersmssatelcom($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="noah")
|
|
{
|
|
$this->envoyersmsnoah($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="nerhysms")
|
|
{
|
|
$this->envoyersmsnerhysms($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="emisms")
|
|
{
|
|
$this->envoyersmsemisms($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="erling")
|
|
{
|
|
$this->envoyersmserling($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="ovh")
|
|
{
|
|
$this->envoyersmsovh($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="afriksms")
|
|
{
|
|
$this->envoyersmsafriksms($tel, $message, $titreSms);
|
|
}
|
|
elseif($fournisseurSms=="ekotech")
|
|
{
|
|
$this->envoyersmsekotech($tel, $message, $titreSms);
|
|
}
|
|
|
|
// sleep(1);
|
|
usleep(2000); // Stoppe pour 2 millisecondes
|
|
}
|
|
}
|
|
|
|
public function envoyersmsbliive($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "https://app.blive.bi/bridge-ws/ws/send";
|
|
|
|
$get = array
|
|
(
|
|
'id' =>$loginSms,
|
|
'from' =>$titreSms_c,
|
|
'to' =>$destinataires_c,
|
|
'text' =>$message_c
|
|
);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
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);
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
|
|
public function envoyersmsesicia($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "http://gateway.esicia.com/sendsms/?";
|
|
|
|
$postFields = array
|
|
(
|
|
'ohereza' =>$titreSms_c,
|
|
'kuri' =>$destinataires_c,
|
|
'ubutumwa' =>$message_c,
|
|
'client' =>$loginSms,
|
|
'password' =>$motPassSms,
|
|
'msgid' =>'kanesin'
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
$result = file_get_contents($url);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
|
|
public function envoyersmshooza($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "http://rslr.connectbind.com/bulksms/bulksms";
|
|
|
|
$get = array
|
|
(
|
|
'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_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");
|
|
}
|
|
|
|
public function envoyersmsskysms($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$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");
|
|
}
|
|
|
|
public function envoyersmssatelcom($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "http://satelsms.satelcom.cd:8080/bulksms/bulksms?";
|
|
|
|
$postFields = array
|
|
(
|
|
'username' => $loginSms,
|
|
'password' => $motPassSms,
|
|
'type' => '0',
|
|
'dlr' => '1',
|
|
'destination' => $destinataires_c,
|
|
'source' => $titreSms_c,
|
|
'message' => $message_c
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
$result = file_get_contents($url);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
|
|
public function envoyersmsnoah($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
|
|
$apiId = 'R1CU5E98NHGNZP7ER8GKSVJ11AEVL1';
|
|
$suid = '5164CR45MTKYZ9';
|
|
|
|
$curl = curl_init();
|
|
$post = array(
|
|
"apiId" => $apiId,
|
|
"suid" => $suid,
|
|
"message" => $message_c,
|
|
"numbers" => [$destinataires_c],
|
|
"country" => "ci"
|
|
);
|
|
$postjson = json_encode($post);
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://texto.noahmobile.com/api/v1/send',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS =>$postjson,
|
|
CURLOPT_HTTPHEADER => array(
|
|
'NOMO-API-KEY: 8C537744BA5B5BB5BFFBA064E853FB16A7A6F002B775C',
|
|
'Content-Type: application/json'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
/*
|
|
$user = "rkramo@vitalis-ci.com";
|
|
$secret = "8dsuUuFvCGs9oi49kq9dTwPsw+ANiMWO9xJK@jin";
|
|
$msg = rawurlencode($message_c);
|
|
$receiver = urlencode($destinataires_c);
|
|
|
|
//$msg = $message_c;
|
|
//$receiver = $destinataires_c;
|
|
|
|
$sender = $titreSms_c;
|
|
$cltmsgid = "1";
|
|
|
|
$url = "http://sms.noahmobile.com/send_message/user/".$user."/secret/".$secret;
|
|
$url .= "/msg/".$msg."/receiver/".$receiver."/sender/".$sender."/cltmsgid/".$cltmsgid;
|
|
|
|
|
|
$curl = curl_init($url);
|
|
curl_setopt_array($curl, [
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_TIMEOUT => 30
|
|
]);
|
|
|
|
$data= curl_exec($curl);
|
|
|
|
|
|
if($response===false){
|
|
var_dump(curl_error($curl));
|
|
}else{
|
|
if(curl_getinfo($curl, CURLINFO_HTTP_CODE) === 200){
|
|
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
$data = json_decode($data,true);
|
|
|
|
echo '<pre>';
|
|
var_dump($data);
|
|
echo '</pre>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curl_close($curl);
|
|
*/
|
|
}
|
|
|
|
|
|
public function envoyersmsnerhysms($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
|
|
$post = array(
|
|
"from" => $titreSms_c,
|
|
"content"=> $message_c,
|
|
"to" => [$destinataires_c]
|
|
);
|
|
|
|
$postjson = json_encode($post);
|
|
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://app.nerhysms.com/api/send/multiple',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
CURLOPT_POSTFIELDS =>$postjson,
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Authorization: Bearer 97e9dab8fa04aad831b1f41b80',
|
|
'Content-Type: application/json'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
|
|
|
|
}
|
|
|
|
|
|
public function envoyersmsemisms($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "https://app.emisms.com/sms/api?";
|
|
|
|
$postFields = array
|
|
(
|
|
'action' => $loginSms,
|
|
'api_key' => $motPassSms,
|
|
'to' => $destinataires_c,
|
|
'from' => $titreSms_c,
|
|
'sms' => $message_c
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
$result = file_get_contents($url);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
|
|
public function envoyersmserling($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
|
|
$url = "http://erling.vavasms.com/api/v1/text/single";
|
|
|
|
$get = array
|
|
(
|
|
'api_key' =>$motPassSms,
|
|
'sender_id' =>$titreSms_c,
|
|
'phone' =>$destinataires_c,
|
|
'message' =>$message_c
|
|
);
|
|
|
|
$defaults = array(
|
|
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
|
|
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");
|
|
}
|
|
|
|
public function envoyersmsovh($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
$titreSms = $this->titreSms;
|
|
$compteSms = $this->compteSms;
|
|
|
|
$url = "https://www.ovh.com/cgi-bin/sms/http2sms.cgi?";
|
|
|
|
$get = array
|
|
(
|
|
'account' => $compteSms,
|
|
'login' => $loginSms,
|
|
'password' => $motPassSms,
|
|
// 'from' => 'INTERSANTE',
|
|
'from' => $titreSms,
|
|
'to' => $destinataires_c,
|
|
'message' => $message_c
|
|
);
|
|
|
|
$defaults = array(
|
|
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
|
|
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");
|
|
}
|
|
|
|
public function envoyersmsafriksms($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
|
|
$curl = curl_init();
|
|
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
$titreSms = $this->titreSms;
|
|
$compteSms = $this->compteSms;
|
|
|
|
$url = "https://api.afriksms.com/api/web/web_v1/outbounds/send?";
|
|
|
|
$postFields = array
|
|
(
|
|
'ClientId' => $loginSms,
|
|
'ApiKey' => $motPassSms,
|
|
'SenderId' => $titreSms,
|
|
'Message' => $message_c,
|
|
'MobileNumbers' => $destinataires_c
|
|
);
|
|
|
|
$post = http_build_query($postFields);
|
|
|
|
$url .= $post;
|
|
|
|
curl_setopt_array
|
|
(
|
|
$curl,
|
|
array
|
|
(
|
|
CURLOPT_URL => $url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
)
|
|
);
|
|
|
|
$response = curl_exec($curl);
|
|
// var_dump($response);
|
|
|
|
curl_close($curl);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
|
|
public function envoyersmsekotech($destinataires_c, $message_c, $titreSms_c)
|
|
{
|
|
|
|
$curl = curl_init();
|
|
|
|
$loginSms = $this->loginSms;
|
|
$motPassSms = $this->motPassSms;
|
|
$titreSms = $this->titreSms;
|
|
|
|
$url = "https://api-public.ekotech.cm/messages";
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => $url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => "",
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 30,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => "POST",
|
|
CURLOPT_POSTFIELDS => "username=$loginSms&password=$motPassSms&msisdn=$destinataires_c&msg=$message_c&sender=$titreSms"
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
// var_dump($response);
|
|
|
|
curl_close($curl);
|
|
|
|
$this->marquersms($this->idSms, "1");
|
|
}
|
|
}
|
|
// FIN CLASSE
|
|
|
|
// envoi des SMS
|
|
$envoismsdivers = new Cronenvoisms();
|
|
|
|
$envoismsdivers->chargersociete();
|
|
|
|
$nbSms = $envoismsdivers->nbSmsParCron;
|
|
|
|
$envoismsdivers->charger_les_sms($nbSms);
|
|
|
|
$envoismsdivers->envoyer_les_sms();
|