ryxeo-glpi-git / plugins / anet_epacks / front / plugin_sms_send.php @ 0c00bf18
Historique | Voir | Annoter | Télécharger (2,19 ko)
1 | 0c00bf18 | Eric Seigne | <!-- ouverture de la balise php -->
|
---|---|---|---|
2 | <?php
|
||
3 | /*
|
||
4 | *
|
||
5 | * plate-forme d'expedition automatique de SMS ...
|
||
6 | *
|
||
7 | */
|
||
8 | //ovh stuff ==========================
|
||
9 | $nic=""; |
||
10 | $pass=""; |
||
11 | $sms_compte=""; |
||
12 | $from=""; |
||
13 | //ovh stuff ==========================
|
||
14 | //tout ceci est configure dans le fichier suivant qui n'est pas versionne ... merci mon mot de passe
|
||
15 | include_once ("plugin_sms_config.php"); |
||
16 | |||
17 | if(!defined('GLPI_ROOT')){ |
||
18 | define('GLPI_ROOT', '../../..'); |
||
19 | } |
||
20 | include_once (GLPI_ROOT . "/inc/includes.php"); |
||
21 | |||
22 | global $DB; |
||
23 | |||
24 | //on récupère les packs activés et dont l'entitée finale est connue
|
||
25 | $query = "SELECT mobile from `glpi_users` WHERE name='" . trim($_GET['dest']) . "'"; |
||
26 | $result = $DB->query($query); |
||
27 | if($data=$DB->fetch_array($result)) { |
||
28 | $to = $data[0]; |
||
29 | $message=str_split($_GET['message'],138); |
||
30 | try
|
||
31 | { |
||
32 | $soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.8.wsdl"); |
||
33 | $session = $soap->login("$nic", "$pass","fr", false); |
||
34 | //echo "login successfull\n";
|
||
35 | $result = $soap->telephonySmsSend($session, "$sms_compte", "$from", "$to", $message[0], "", "1", "", ""); |
||
36 | //echo "telephonySmsSend successfull\n";
|
||
37 | $soap->logout($session); |
||
38 | //echo "logout successfull\n";
|
||
39 | |||
40 | |||
41 | //on double d'un mail ...
|
||
42 | |||
43 | $mail_body = " |
||
44 | SMS Envoyé à " . $_GET['dest'] . " - $to |
||
45 | Message: " . $_GET['message'] . " |
||
46 |
|
||
47 | --
|
||
48 | Script d'envoi automatique de SMS
|
||
49 | ";
|
||
50 | |||
51 | include('Mail.php'); |
||
52 | include('Mail/mime.php'); |
||
53 | //$text = $mail_body;
|
||
54 | $html = "<html> |
||
55 | <head>
|
||
56 | <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
|
||
57 | </head>
|
||
58 | <body>
|
||
59 | <pre>" . $mail_body . "</pre> |
||
60 | </body>
|
||
61 | </html>\n";
|
||
62 | $crlf = "\n"; |
||
63 | $hdrs = array( 'From' => 'supportteam@ryxeo.com', |
||
64 | 'Subject' => "[SMS] Nouveau SMS Envoyé a : " . $_GET['dest'] , |
||
65 | 'Content-Type' => 'text/html; charset="UTF-8"' |
||
66 | ); |
||
67 | |||
68 | $mime = new Mail_mime($crlf); |
||
69 | //$mime->setTXTBody($text);
|
||
70 | $mime->setHTMLBody($html); |
||
71 | $body = $mime->get(array('text_charset' => 'utf-8', 'html_charset' => 'utf-8')); |
||
72 | $hdrs = $mime->headers($hdrs); |
||
73 | $mail =& Mail::factory('mail'); |
||
74 | $mail->send('supportteam@ryxeo.com', $hdrs, $body); |
||
75 | |||
76 | |||
77 | } |
||
78 | catch(SoapFault $fault) |
||
79 | { |
||
80 | // affichage des erreurs
|
||
81 | echo $fault; |
||
82 | } |
||
83 | } |
||
84 | else {
|
||
85 | print "erreur"; |
||
86 | } |
||
87 | ?> |