1
0
moha/hooks/notifiers/notificationfreemobile.php

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
class notificationFreemobile
{
private $url = "https://smsapi.free-mobile.fr/sendmsg?user=";
private $name = "freemobile";
2022-01-02 18:14:13 +01:00
public $active = true;
public $level;
private $dest = array(
2022-04-23 02:00:52 +02:00
"daniel" => "32886706&pass=JTGUY6l5OG73zX",
);
function __construct()
{
2022-01-23 09:46:06 +01:00
$this->level = ALERT | ERROR;
}
2022-04-23 02:00:52 +02:00
function send($message, $destinataire=NOTIF_DEFAULT_DEST)
{
global $curlErr;
$result = false;
2022-05-29 01:55:22 +02:00
if ($this->active === true)
{
$ch = curl_init();
// set url
2022-04-23 02:00:52 +02:00
curl_setopt($ch, CURLOPT_URL, $this->url . $this->dest[$destinataire] . "&msg=" . urlencode(trim($message)));
echo $this->url . urlencode(trim($message)) . EOL;
//return the transfer as a string
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $result contains the output string
if ($curlErr <= 10)
2022-01-02 18:14:13 +01:00
{
$result = curl_exec($ch);
if ($result === false)
{
$curlErr += 1;
2022-01-28 23:05:58 +01:00
logger(ERROR, sprintf( _("Curl return error %d: %s when sending notification"), curl_errno($ch), curl_error($ch)), false, __FILE__ . ":" . __LINE__);
}else
{
logger(DEBUG, sprintf(_("Curl return: %s when sending notification"), $result), false);
}
2022-01-28 23:05:58 +01:00
} //TODO managing curl errors
// close curl resource to free up system resources
curl_close($ch);
return true;
}
return false;
}
}
2022-01-02 18:14:13 +01:00
$notificationMethods["freemobile"] = new notificationFreemobile();
?>