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