source: pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php @ 470

Last change on this file since 470 was 470, checked in by dungnv, 11 years ago
File size: 3.6 KB
Line 
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Viettel Class
4 *
5 * @author dzungnv02
6 *
7 */
8
9class Viettel extends MX_Controller
10{
11        function __construct() {
12                parent::__construct ();
13               
14                $this->nusoap_server = new soap_server ();
15                $this->nusoap_server->configureWSDL('messageReceiverWSDL','urn:messageReceiverWSDL');
16
17                $this->nusoap_server->soap_defencoding = 'UTF-8';               
18                $this->nusoap_server->methodreturnisliteral=TRUE;
19               
20                $this->nusoap_server->wsdl->addComplexType(
21                                'messageReceiver',
22                                'simpleType',
23                                'struct',
24                                '',
25                                'SOAP-ENC:Array',
26                                array(
27                                                'username'=>array('name'=>'username', 'type'=>'xsd:string'),
28                                                'password'=>array('name'=>'password', 'type'=>'xsd:string'),
29                                                'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
30                                                'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
31                                                'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
32                                                'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
33                                                'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
34                                                'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
35                                                'info'=>array('name'=>'info', 'type'=>'xsd:string'),
36                                                'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
37                                )
38                );
39               
40                $this->nusoap_server->register ( 'MOReceiver',
41                                array( 'username' => 'xsd:string',
42                                                'password' => 'xsd:string',
43                                                'requestID' => 'xsd:string',
44                                                'userID' => 'xsd:string',
45                                                'receiverID' => 'xsd:string',
46                                                'serviceID' => 'xsd:string',
47                                                'commandCode' => 'xsd:string',
48                                                'contentType' => 'xsd:string',
49                                                'info' => 'xsd:string',
50                                                'receiveTime' => 'xsd:string')
51                                , array ('return' => 'xsd:string'),
52                                'urn:messageReceiverWSDL',"urn:messageReceiverWSDL#MOReceiver","rpc","encoded");
53        }
54
55        public function index ()
56        {
57                if($this->uri->segment(4) == "wsdl") {
58                        $_SERVER['QUERY_STRING'] = "wsdl";
59                } else {
60                        $_SERVER['QUERY_STRING'] = "";
61                }
62                $this->nusoap_server->service(file_get_contents("php://input"));
63        }
64       
65        public function mo()
66        {       
67                function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime){
68                        $msgType = '0'; //text message
69                        $errCode = '1'; //#1:error; 1:Success;
70                       
71                        $CI =& get_instance();                 
72                        $mo_username = $CI->config->item('mo_username');
73                        $mo_password = $CI->config->item('mo_password');
74
75                        if (!$username) return '0|0|Username is required!';
76                        if (!$password) return '0|0|Password is required!';
77                        if ($username != $mo_username) return '0|0|Username is not corrected!';
78                        if ($password != $mo_password) return '0|0|Password is not corrected!';
79                        if (!$requestID) return '0|0|requestID is required!';
80                        if (!$userID) return '0|0|UserID is required!';
81                        if (!$serviceID) return '0|0|serviceID is required!';
82                        if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
83                       
84                        $status = 0;
85                        $sentNumber = $userID;                                                                 
86                        $username = !$receiverID ? $sentNumber : $receiverID;
87                       
88                        $CI->load->model('frontend/user_model', 'userModel');
89                        $password = $CI->userModel->create_random_password();           
90                       
91                        $result = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status);
92                                       
93                        $aryResult = explode ('|', $result);
94                       
95                        return $aryResult[0].'|'.$msgType.'|'.$aryResult[1];
96                }
97               
98                $this->nusoap_server->service(file_get_contents("php://input"));
99        }
100}
101
102/* End of file viettel.php */
103/* Location: ./application/modules/service/controllers/viettel.php */
Note: See TracBrowser for help on using the repository browser.