Ignore:
Timestamp:
Nov 10, 2014 11:56:43 PM (11 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php

    r313 r457  
    1010{
    1111       
    12         public function __construct()
    13         {
    14                 parent::__construct();
     12        function __construct() {
     13                parent::__construct ();
     14                $this->nusoap_server = new soap_server ();
     15                $this->nusoap_server->configureWSDL('messageReceiver', 'urn:messageReceiver');
     16                $this->nusoap_server->soap_defencoding = 'UTF-8';
     17                $this->nusoap_server->methodreturnisliteral=TRUE;
     18               
     19                $this->nusoap_server->wsdl->addComplexType(
     20                                'messageReceiver',
     21                                'simpleType',
     22                                'struct',
     23                                '',
     24                                'SOAP-ENC:Array',
     25                                array(
     26                                                'username'=>array('name'=>'username', 'type'=>'xsd:string'),
     27                                                'password'=>array('name'=>'password', 'type'=>'xsd:string'),
     28                                                'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
     29                                                'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
     30                                                'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
     31                                                'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
     32                                                'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
     33                                                'info'=>array('name'=>'info', 'type'=>'xsd:string'),
     34                                                'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
     35                                )
     36                );
     37               
     38                $this->nusoap_server->register ( 'MOReceiver',
     39                                array( 'username' => 'xsd:string',
     40                                                'password' => 'xsd:string',
     41                                                'requestID' => 'xsd:string',
     42                                                'userID' => 'xsd:string',
     43                                                'receiverID' => 'xsd:string',
     44                                                'serviceID' => 'xsd:string',
     45                                                'commandCode' => 'xsd:string',
     46                                                'info' => 'xsd:string',
     47                                                'receiveTime' => 'xsd:string')
     48                                , array ('return' => 'xsd:string'),false,false
     49                                ,'rpc'                         
     50                                );
    1551        }
    1652
    17         public function index()
    18         {
    19                 $this->load->view ( 'main');
     53        function index() {
     54                if($this->uri->segment(3) == "wsdl") {
     55                        $_SERVER['QUERY_STRING'] = "wsdl";
     56                } else {
     57                        $_SERVER['QUERY_STRING'] = "";
     58                }
     59                $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:'';
     60                $this->nusoap_server->service($HTTP_RAW_POST_DATA);
    2061        }
    2162       
    2263        public function mo()
    2364        {
    24                 $aryParams = array();
    25                 $aryParamsName = array( 'username',
    26                                                                 'password',
    27                                                                 'requestID',
    28                                                                 'userID',
    29                                                                 'receiverID',
    30                                                                 'serviceID',
    31                                                                 'commandCode',
    32                                                                 'info',
    33                                                                 'receiveTime');
    34                
    35                 foreach ($aryParams as $key => $value) {
    36                         $aryParams[$value] =  $this->input->post($value,TRUE);
     65                function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info,$receiveTime){
     66                        $msgType = '0'; //text message
     67                        $errCode = '1'; //#1:error; 1:Success;
     68                       
     69                        $CI =& get_instance();                 
     70                        $mo_username = $CI->config->item('mo_username');
     71                        $mo_password = $CI->config->item('mo_password');
     72
     73                        /* if (!isset($parameters['username'])) return '0|0|Username is required!';
     74                        if (!isset($parameters['password'])) return '0|0|Password is required!';
     75                        if ($parameters['username'] != $mo_username) return '0|0|Username is not corrected!'.var_export($parameters, true);
     76                        if ($parameters['password'] != $mo_password) return '0|0|Password is not corrected!';
     77                        if (!isset($parameters['userID'])) return '0|0|UserID is required!';
     78                        if (!isset($parameters['userID'])) return '0|0|UserID is required!';
     79                        if (!isset($parameters['serviceID'])) return '0|0|serviceID is required!';
     80                        if ($parameters['serviceID'] != '8062') return '0|0|serviceID is not corrected!'; */
     81                       
     82                        if (!$username) return '0|0|Username is required!';
     83                        if (!$password) return '0|0|Password is required!';
     84                        if ($username != $mo_username) return '0|0|Username is not corrected!';
     85                        if ($password != $mo_password) return '0|0|Password is not corrected!';
     86                        if (!$requestID) return '0|0|requestID is required!';
     87                        if (!$userID) return '0|0|UserID is required!';
     88                        if (!$serviceID) return '0|0|serviceID is required!';
     89                        if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
     90                                               
     91                        $sentNumber = $userID;                                                                 
     92                        $username = !$receiverID ? $sentNumber : $receiverID;
     93                       
     94                        $CI->load->model('frontend/user_model', 'userModel');
     95                        $password = $CI->userModel->create_random_password();
     96                        $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan SBGOnline. Hay dang nhap vao http://soanbaigiang.smas.vn/ voi ten truy nhap ".$username.", mat khau ".$password." de su dung.";                       
     97                        //$msg = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status);
     98                       
     99                        //return $status.'|'.$msgType.'|'.$msg;
     100
     101                        //for dummy data
     102                        return '1|0|'.$sms;
    37103                }
    38104               
    39                 $this->load->model('Sms_model', 'objSMS');
    40                
    41                 $separator = '|';
    42                 $errCode = 1;
    43                 $messageType = 0;
    44                 $message = $this->objSMS->getSMSByServiceId();;
    45                
    46                 header('Content-type:text/html');
    47                 echo $errCode,$separator,$messageType,$separator,$message;
    48         }
    49        
    50         public function mt()
    51         {
    52                
     105                $this->nusoap_server->service(file_get_contents("php://input"));
    53106        }
    54107}
    55108
    56109/* End of file viettel.php */
    57 /* Location: ./application/modules/service/controllers/viettel.php */
     110/* Location: ./application/modules/service/controllers/viettel.php */ 
Note: See TracChangeset for help on using the changeset viewer.