[758] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | if (! defined ( 'BASEPATH' ))
|
---|
| 4 | exit ( 'No direct script access allowed' );
|
---|
[294] | 5 | /**
|
---|
| 6 | * Viettel Class
|
---|
[758] | 7 | *
|
---|
[294] | 8 | * @author dzungnv02
|
---|
[758] | 9 | *
|
---|
[294] | 10 | */
|
---|
[758] | 11 | class Viettel extends MX_Controller {
|
---|
[483] | 12 | private $_server = null;
|
---|
| 13 |
|
---|
[457] | 14 | function __construct() {
|
---|
| 15 | parent::__construct ();
|
---|
[758] | 16 | ini_set ( "soap.wsdl_cache_enabled", "1" );
|
---|
| 17 | $this->_server = new SoapServer ( NULL, array (
|
---|
| 18 | 'soap_version' => SOAP_1_2,
|
---|
| 19 | 'encoding' => 'UTF-8',
|
---|
| 20 | 'uri' => 'http://tempuri.org/'
|
---|
| 21 | ) );
|
---|
[294] | 22 | }
|
---|
[758] | 23 |
|
---|
| 24 | function __destruct() {
|
---|
| 25 | ini_set ( "soap.wsdl_cache_enabled", "0" );
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public function index() {
|
---|
| 29 | if ($this->uri->segment ( 4 ) == "wsdl") {
|
---|
| 30 | header ( 'Content-Type: text/xml; charset: utf-8' );
|
---|
| 31 | $this->load->view ( 'mowsdl' );
|
---|
[457] | 32 | } else {
|
---|
[758] | 33 | header ( 'Content-Type: text/html; charset: utf-8' );
|
---|
| 34 | echo 'See service <a href="' . base_url () . 'violetservice/soanbai/mo/wsdl">WSDL page</a>';
|
---|
| 35 | }
|
---|
[294] | 36 | }
|
---|
| 37 |
|
---|
[758] | 38 | public function mo() {
|
---|
| 39 | function messageReceiver() {
|
---|
| 40 | $aryArgs = func_get_args ();
|
---|
| 41 | $aryExport = array (
|
---|
| 42 | 'Username' => $aryArgs [0],
|
---|
| 43 | 'Password' => $aryArgs [1],
|
---|
| 44 | 'RequestID' => $aryArgs [2],
|
---|
| 45 | 'UserID' => $aryArgs [3],
|
---|
| 46 | 'ReceiverID' => $aryArgs [4],
|
---|
| 47 | 'ServiceID' => $aryArgs [5],
|
---|
| 48 | 'CommandCode' => $aryArgs [6],
|
---|
| 49 | 'Info' => $aryArgs [7],
|
---|
| 50 | 'ReceiveTime' => $aryArgs [8]
|
---|
| 51 | );
|
---|
[483] | 52 |
|
---|
[758] | 53 | error_log ( date ( 'Y-m-d H:i:s' ) . ' -- VARIABLES: ' . var_export ( $aryExport, TRUE ) . "\n", 3, '/srv/www/sbg/log/sms.log' );
|
---|
| 54 | list ( $username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info, $receiveTime ) = $aryArgs;
|
---|
[457] | 55 |
|
---|
[758] | 56 | $msgType = '0'; // text message
|
---|
| 57 | $errCode = '1'; // #1:error; 1:Success;
|
---|
[716] | 58 |
|
---|
[758] | 59 | $CI = & get_instance ();
|
---|
| 60 | $mo_username = $CI->config->item ( 'mo_username' );
|
---|
| 61 | $mo_password = $CI->config->item ( 'mo_password' );
|
---|
| 62 |
|
---|
| 63 | if (! $username)
|
---|
| 64 | return '0|0|Username is required!';
|
---|
| 65 | if (! $password)
|
---|
| 66 | return '0|0|Password is required!';
|
---|
| 67 | if ($username != $mo_username)
|
---|
| 68 | return '0|0|Username is not corrected!';
|
---|
| 69 | if ($password != $mo_password)
|
---|
| 70 | return '0|0|Password is not corrected!';
|
---|
| 71 | if (! $requestID)
|
---|
| 72 | return '0|0|requestID is required!';
|
---|
| 73 | if (! $userID)
|
---|
| 74 | return '0|0|UserID is required!';
|
---|
| 75 | if (! $serviceID)
|
---|
| 76 | return '0|0|serviceID is required!';
|
---|
| 77 | if ($serviceID != '8062')
|
---|
| 78 | return '0|0|serviceID is not corrected!';
|
---|
| 79 |
|
---|
| 80 | $CI->load->model ( 'Services_model' );
|
---|
| 81 | $CI->load->model ( 'frontend/User_model', 'objUserModel' );
|
---|
| 82 |
|
---|
[768] | 83 | $mtBody = '';
|
---|
| 84 | $result = $CI->Services_model->processMORequest ( $userID, $info , $mtBody);
|
---|
| 85 | $responseTime = date ( 'Y-m-d H:i:s' );
|
---|
| 86 | error_log ( $responseTime . ' -- INFO VAR: ' . var_export ( $info, TRUE ) . "\n\n", 3, '/srv/www/sbg/log/sms.log' );
|
---|
[758] | 87 | $aryResult = explode ( '|', $result );
|
---|
[768] | 88 |
|
---|
| 89 | $CI->objUserModel->insertSmslog ( $receiverID, $serviceID, $commandCode, $info, $receiveTime , $mtBody, $responseTime);
|
---|
| 90 |
|
---|
[758] | 91 | return $aryResult [0] . '|' . $msgType . '|' . $aryResult [1];
|
---|
[313] | 92 | }
|
---|
| 93 |
|
---|
[758] | 94 | $this->_server->addFunction ( 'messageReceiver' );
|
---|
[499] | 95 |
|
---|
[483] | 96 | try {
|
---|
[758] | 97 | ob_start ();
|
---|
[483] | 98 | $soapOutput = '';
|
---|
[758] | 99 | $this->_server->handle ();
|
---|
| 100 |
|
---|
| 101 | if (ob_get_length () > 0) {
|
---|
| 102 | $soapOutput = ob_get_clean ();
|
---|
[483] | 103 | }
|
---|
[758] | 104 |
|
---|
[483] | 105 | if ($soapOutput != '') {
|
---|
| 106 | $pattern = '/<[^>]*[^\/]>/i';
|
---|
[758] | 107 | $aryOutput = preg_split ( $pattern, $soapOutput, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
|
---|
| 108 | $aryData = array ();
|
---|
| 109 | $aryData ['message'] = $aryOutput [1];
|
---|
| 110 | $xml = $this->load->view ( 'mo', $aryData, TRUE );
|
---|
| 111 | header ( 'Content-Type: text/xml; charset: utf-8' );
|
---|
[483] | 112 | echo $xml;
|
---|
[758] | 113 | } else {
|
---|
| 114 | header ( 'Content-Type: text/html; charset: utf-8' );
|
---|
| 115 | echo 'See service <a href="' . base_url () . 'violetservice/soanbai/mo/wsdl">WSDL page</a>';
|
---|
[483] | 116 | }
|
---|
[758] | 117 | } catch ( Exception $e ) {
|
---|
| 118 | $this->_server->fault ( 'Sender', $e->getMessage () );
|
---|
[483] | 119 | }
|
---|
[294] | 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | /* End of file viettel.php */
|
---|
[457] | 124 | /* Location: ./application/modules/service/controllers/viettel.php */ |
---|