1
0
moha/hooks/notifiers/notificationfreemobile.php
daniel Tartavel 0d35b1ff3f - lots of debugging
- beginning to add graphical stats
- beginning to add device by type
- added a dashboard "etage"
- begining to add notification to multiple recipients in freemobile hook
2022-03-28 00:40:34 +02:00

53 lines
1.3 KiB
PHP

<?php
class notificationFreemobile
{
private $url = "https://smsapi.free-mobile.fr/sendmsg?user=";
private $name = "freemobile";
public $active = true;
public $level;
private $dest = array(
"32886706&pass=JTGUY6l5OG73zX", //daniel
);
function __construct()
{
$this->level = ALERT | ERROR;
}
function send($message, $destinataire=0)
{
global $curlErr;
$result = false;
if ($this->active == true)
{
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $this->url . $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)
{
$result = curl_exec($ch);
if ($result === false)
{
$curlErr += 1;
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);
}
} //TODO managing curl errors
// close curl resource to free up system resources
curl_close($ch);
return true;
}
return false;
}
}
$notificationMethods["freemobile"] = new notificationFreemobile();
?>