commit
b2750c151c
9 changed files with 292 additions and 0 deletions
-
9.gitattributes
-
49classes/smsfactor/AccuseReceptionSMSClass.php
-
70classes/smsfactor/sendSMSclass.php
-
46formulaires/configurer_sms.html
-
12lang/paquet-sms_fr.php
-
36lang/sms_fr.php
-
16paquet.xml
-
7prive/squelettes/contenu/configurer_sms.html
-
47sms_fonctions.php
@ -0,0 +1,9 @@ |
|||
* text=auto !eol |
|||
classes/smsfactor/AccuseReceptionSMSClass.php -text |
|||
classes/smsfactor/sendSMSclass.php -text |
|||
formulaires/configurer_sms.html -text |
|||
lang/paquet-sms_fr.php -text |
|||
lang/sms_fr.php -text |
|||
/paquet.xml -text |
|||
prive/squelettes/contenu/configurer_sms.html -text |
|||
/sms_fonctions.php -text |
@ -0,0 +1,49 @@ |
|||
<?php |
|||
|
|||
|
|||
|
|||
class AccuseReceptionSMSClass |
|||
{ |
|||
//input parameters ---------------------
|
|||
var $username; //your username
|
|||
var $password; //your password
|
|||
var $ticket; //your ticket
|
|||
var $response; //wainting response
|
|||
//--------------------------------------
|
|||
|
|||
|
|||
function AccuseReceptionSMS($username, $password, $ticket) |
|||
{ |
|||
$this->username = $username; |
|||
$this->password = $password; |
|||
$this->ticket = $ticket; |
|||
|
|||
// (POST /dr) get recipient, url + dr
|
|||
$host = "https://api.smsfactor.com/dr"; |
|||
|
|||
$this->prepareXMLdata(); |
|||
|
|||
$this->response = $this->do_post_request($host,$this->request_data); |
|||
return $this->response; |
|||
} |
|||
|
|||
function prepareXMLdata() |
|||
{ |
|||
$xmldata = "<deliveryreport><authentification><username>" . $this->username . "</username><password>" . $this->password . "</password></authentification><message><ticket gsmsmsid=\"\">" . $this->ticket . "</ticket></message></deliveryreport>"; |
|||
$this->request_data = 'XML=' . $xmldata; |
|||
} |
|||
|
|||
function do_post_request($url, $postdata, $optional_headers = null) |
|||
{ |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); |
|||
curl_setopt($ch, CURLOPT_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); |
|||
$response = curl_exec($ch); |
|||
curl_close($ch); |
|||
return $response; |
|||
} |
|||
} |
|||
|
|||
?>
|
@ -0,0 +1,70 @@ |
|||
<?php |
|||
|
|||
|
|||
|
|||
class SendSMSclass |
|||
{ |
|||
//input parameters ---------------------
|
|||
var $username; //your username
|
|||
var $password; //your password
|
|||
var $sender; //sender text
|
|||
var $message; //message text
|
|||
var $inputgsmnumbers = array(); //destination gsm numbers
|
|||
//--------------------------------------
|
|||
|
|||
var $host; |
|||
var $XMLgsmnumbers; |
|||
var $xmldata; |
|||
var $request_data; |
|||
var $response; |
|||
|
|||
|
|||
function SendSMS($username, $password, $sender, $message, $inputgsmnumbers) |
|||
{ |
|||
$this->username = $username; |
|||
$this->password = $password; |
|||
$this->sender = $sender; |
|||
$this->message = $message; |
|||
$this->inputgsmnumbers = $inputgsmnumbers; |
|||
|
|||
$this->host = "https://api.smsfactor.com"; |
|||
|
|||
$this->convertGSMnumberstoXML(); |
|||
$this->prepareXMLdata(); |
|||
|
|||
$this->response = $this->do_post_request($this->host,$this->request_data); |
|||
return $this->response; |
|||
} |
|||
|
|||
function convertGSMnumberstoXML() |
|||
{ |
|||
$gsmcount = count($this->inputgsmnumbers); #counts gsm numbers
|
|||
|
|||
for ( $i = 0; $i < $gsmcount; $i++ ) |
|||
{ |
|||
$this->XMLgsmnumbers .= "<gsm>" . $this->inputgsmnumbers[$i] . "</gsm>"; |
|||
} |
|||
} |
|||
|
|||
function prepareXMLdata() |
|||
{ |
|||
$this->xmldata = "<sms><authentification><username>" . $this->username . "</username><password>" . $this->password . "</password></authentification><message><sender>" . $this->sender . "</sender><text>" . $this->message . "</text></message><recipients>" . $this->XMLgsmnumbers . "</recipients></sms>"; |
|||
$this->request_data = 'XML=' . $this->xmldata; |
|||
} |
|||
|
|||
|
|||
function do_post_request($url, $postdata, $optional_headers = null) |
|||
{ |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); |
|||
curl_setopt($ch, CURLOPT_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); |
|||
$response = curl_exec($ch); |
|||
curl_close($ch); |
|||
return $response; |
|||
} |
|||
|
|||
} |
|||
|
|||
?>
|
@ -0,0 +1,46 @@ |
|||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM"> |
|||
|
|||
<h3 class="titrem"><:sms:cfg_titre_parametrages:></h3> |
|||
|
|||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
|||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
|||
|
|||
<form method="post" action="#ENV{action}"> |
|||
#ACTION_FORMULAIRE{#ENV{action}} |
|||
|
|||
<input type="hidden" name="_meta_casier" value="sms" /> |
|||
|
|||
<ul class=""> |
|||
<li class="fieldset"> |
|||
<h3 class="legend"><:sms:choix_prestataire:></h3> |
|||
<ul> |
|||
<li class="editer"> |
|||
<input type="radio" name="prestataire" value="" [(#ENV{prestataire}|=={""}|oui) checked]><:sms:aucun:> |
|||
<input type="radio" name="prestataire" value="smsfactor" [(#ENV{prestataire}|=={smsfactor}|oui) checked]>SMS Factor |
|||
</li> |
|||
</ul> |
|||
</li> |
|||
|
|||
<li class="fieldset"> |
|||
<h3 class="legend">SMS Factor </h3> |
|||
<p class="explication"><:sms:explication_smsfactor:></p> |
|||
<ul> |
|||
<li class="editer"> |
|||
<label for="login_smsfactor"><:sms:login:></label> |
|||
<input type="text" name="login_smsfactor" value="[(#ENV{login_smsfactor})]" placeholder="mon_mail@spip.net"> |
|||
</li> |
|||
<li class="editer"> |
|||
<label for="login_smsfactor"><:sms:mot_de_passe:></label> |
|||
<input type="password" name="mdp_smsfactor" value="[(#ENV{mdp_smsfactor})]"> |
|||
</li> |
|||
<li class="editer"> |
|||
<p class="explication"><:sms:explication_expediteur:></p> |
|||
<label for="expediteur_smsfactor"><:sms:expediteur:></label> |
|||
<input type="text" name="expediteur_smsfactor" value="[(#ENV{expediteur_smsfactor})]"> |
|||
</li> |
|||
</ul> |
|||
</li> |
|||
|
|||
<p class="boutons"> <input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p> |
|||
</form> |
|||
</div> |
@ -0,0 +1,12 @@ |
|||
<?php |
|||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
|
|||
|
|||
if (!defined('_ECRIRE_INC_VERSION')) return; |
|||
|
|||
$GLOBALS[$GLOBALS['idx_lang']] = array( |
|||
|
|||
// S
|
|||
'sms_description' => 'API pour envoyer des sms simplement', |
|||
'sms_nom' => 'SMS SPIP', |
|||
'sms_slogan' => '', |
|||
); |
@ -0,0 +1,36 @@ |
|||
<?php |
|||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
|
|||
|
|||
if (!defined('_ECRIRE_INC_VERSION')) return; |
|||
|
|||
$GLOBALS[$GLOBALS['idx_lang']] = array( |
|||
|
|||
// A
|
|||
'aucun' => 'Aucun', |
|||
// S
|
|||
'sms_titre' => 'SMS SPIP', |
|||
|
|||
// C
|
|||
'cfg_exemple' => 'Exemple', |
|||
'cfg_exemple_explication' => 'Explication de cet exemple', |
|||
'cfg_titre_parametrages' => 'Paramétrages', |
|||
'choix_prestataire' => 'Choix du prestataire', |
|||
|
|||
// E
|
|||
'expediteur' => 'Expéditeur', |
|||
'explication_expediteur' => 'Personnalisation de l’expéditeur avec du texte (11 caractères Max.) |
|||
N° de Téléphone non pris en charge en France.', |
|||
'explication_smsfactor' => 'Identifiant de votre compte en ligne', |
|||
|
|||
// L
|
|||
'login' => 'Login', |
|||
|
|||
// M
|
|||
'mot_de_passe' => 'Mot de passe', |
|||
|
|||
// S
|
|||
'sms_titre' => 'SMS SPIP', |
|||
|
|||
// T
|
|||
'titre_page_configurer_sms' => 'Configuration de l\'API SMS', |
|||
); |
@ -0,0 +1,16 @@ |
|||
<paquet |
|||
prefix="sms" |
|||
categorie="communication" |
|||
version="1.0.3" |
|||
etat="test" |
|||
compatibilite="[3.0.0;3.1.*]" |
|||
logo="" |
|||
documentation="" |
|||
> |
|||
<nom>SMS SPIP</nom> |
|||
|
|||
<auteur>tofulm</auteur> |
|||
|
|||
<licence>GNU/GPL</licence> |
|||
|
|||
</paquet> |
@ -0,0 +1,7 @@ |
|||
[(#AUTORISER{configurer,_sms}|sinon_interdire_acces)] |
|||
|
|||
<h1 class="grostitre"><:sms:titre_page_configurer_sms:></h1> |
|||
|
|||
<div class="ajax"> |
|||
#FORMULAIRE_CONFIGURER_SMS |
|||
</div> |
@ -0,0 +1,47 @@ |
|||
<?php |
|||
/** |
|||
* Fonctions utiles au plugin SMS SPIP |
|||
* |
|||
* @plugin SMS SPIP |
|||
* @copyright 2015 |
|||
* @author tofulm |
|||
* @licence GNU/GPL |
|||
* @package SPIP\Sms\Fonctions |
|||
*/ |
|||
|
|||
if (!defined('_ECRIRE_INC_VERSION')) return; |
|||
|
|||
//Utilisation de SMS factor
|
|||
if ( lire_config('sms/prestataire') == "smsfactor") { |
|||
|
|||
function envoyer_sms($message,$destinataire,$arg=array()){ |
|||
return smsfactor($message,$destinataire,$arg); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Envoie le sms en utilisant l'API du prestataire sms factor |
|||
* |
|||
* @param string $message |
|||
* le texte d'envoie doit etre du texte et non du html |
|||
* @param array $destinataire |
|||
* @param array $arg |
|||
* utilise pour : $arg['sender'] |
|||
* @return boolean |
|||
**/ |
|||
function smsfactor($message,$destinataire,$arg){ |
|||
$username = lire_config('sms/login_smsfactor'); |
|||
$password = lire_config('sms/mdp_smsfactor'); |
|||
$sender = ($arg['sender']) ? $arg['sender'] : lire_config('sms/expediteur_smsfactor'); |
|||
|
|||
require_once('classes/smsfactor/sendSMSclass.php'); |
|||
$SENDSMS = new SendSMSclass(); |
|||
$retour = $SENDSMS->SendSMS($username,$password,$sender,$message,$destinataire); |
|||
|
|||
$reponse = new SimpleXMLElement($retour); |
|||
if ( $reponse->message == "OK" ){ |
|||
return true; |
|||
}else{ |
|||
return false; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue