Ticket #3: nonoh.php

File nonoh.php, 3.0 KB (added by axel, 4 years ago)

Next Version from nonoh

Line 
1<?php
2/**
3 * $Id:$
4 *
5* @author Axel Sauerhöfer <axel@willcodejoomlaforfood.de>
6* @copyright Copyright &copy; 2007, Axel Sauerhöfer
7* @version 0.8
8* @package MySMS
9*
10* All rights reserved.  MySMS Component for Joomla!
11*
12* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
13* MySMS! is free software. This version may have been modified pursuant
14* to the GNU General Public License, and as distributed it includes or
15* is derivative of works licensed under the GNU General Public License or
16* other free or open source software licenses.
17*
18* This program is distributed in the hope that it will be useful,
19* but WITHOUT ANY WARRANTY; without even the implied warranty of
20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21*
22**/
23
24defined( '_VALID_MOS' ) or die( 'Restricted access' );
25
26/**
27 * require our base class
28 */
29require_once('provider.php');
30
31
32/**
33*  Smsbox is a sms gateway connection implementation (https://www.smsbox.fr)
34*
35* @package MySMS
36* @subpackage Provider
37**/
38
39class NONOH extends Provider
40{
41
42   /**
43   *  Constructor, setting up name, file and parameters
44   */
45      function NONOH()
46      {
47        Provider::Provider();   //call base class constructor
48        $this->_name = 'NONOH';
49        $this->_file = 'nonoh.php'; //maybe use __FILE__ in next version
50
51        $this->_params['username']      =  'test';            //default params
52        $this->_params['password']      =  'test';            //default params
53      }
54
55
56   /**
57   *  The sendSMS is for sending a sms, this function must be reimplemented in all dirved classes
58   *  @param string $text
59   *  @param string $from
60   *  @param string $to
61   */
62      function sendSms($text, &$from, &$to, &$errMsg)
63      {
64           //decode message text
65        $text = html_entity_decode( $text );
66
67        $data = array(  'username'      => $this->_params['username'],
68                                'password'      => $this->_params['password'],
69                                'text'          => $text,
70                                'to'            => $to,
71                                'from'          => $from );
72
73                $data = sprintf( 'username=%s&password=%s&text=%s&to=%s&from=%s', $this->_params['username'], $this->_params['password'], $text, $to, $from );
74        $u = 'https://myaccount.nonoh.net/clx/sendsms.php?' . $data;
75        $ret = file_get_contents($u);
76
77            //check if simplexml extension is available, we are php5
78
79          if( class_exists ( 'SimpleXMLElement' ) ){
80
81                try{
82                $xml = new SimpleXMLElement( $ret );
83                }catch(Exception $e ){
84                                //Something went wrong with the xml
85                                $errMsg = $e->getMessage();
86                return false;
87                }
88
89            if( $xml->result == 1 ){
90                     return true;
91            }
92
93            $errMsg = $xml->description;
94            return false;
95            }else{
96
97                    if( eregi('<result>1</result>', $ret ) ){
98                            return true;
99                     }
100             }
101
102             return false;
103
104      }//end send sms
105} //end class aspsms
106?>