[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 | {
|
---|
| 11 |
|
---|
[457] | 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'),
|
---|
[460] | 33 | 'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
|
---|
[457] | 34 | 'info'=>array('name'=>'info', 'type'=>'xsd:string'),
|
---|
| 35 | 'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
|
---|
| 36 | )
|
---|
| 37 | );
|
---|
| 38 |
|
---|
| 39 | $this->nusoap_server->register ( 'MOReceiver',
|
---|
| 40 | array( 'username' => 'xsd:string',
|
---|
| 41 | 'password' => 'xsd:string',
|
---|
| 42 | 'requestID' => 'xsd:string',
|
---|
| 43 | 'userID' => 'xsd:string',
|
---|
| 44 | 'receiverID' => 'xsd:string',
|
---|
| 45 | 'serviceID' => 'xsd:string',
|
---|
| 46 | 'commandCode' => 'xsd:string',
|
---|
[460] | 47 | 'contentType' => 'xsd:string',
|
---|
[457] | 48 | 'info' => 'xsd:string',
|
---|
| 49 | 'receiveTime' => 'xsd:string')
|
---|
| 50 | , array ('return' => 'xsd:string'),false,false
|
---|
| 51 | ,'rpc'
|
---|
| 52 | );
|
---|
[294] | 53 | }
|
---|
| 54 |
|
---|
[457] | 55 | function index() {
|
---|
| 56 | if($this->uri->segment(3) == "wsdl") {
|
---|
| 57 | $_SERVER['QUERY_STRING'] = "wsdl";
|
---|
| 58 | } else {
|
---|
| 59 | $_SERVER['QUERY_STRING'] = "";
|
---|
| 60 | }
|
---|
[460] | 61 |
|
---|
| 62 | function MOReceiver () {
|
---|
| 63 | return 'Service not available!';
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[457] | 66 | $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:'';
|
---|
| 67 | $this->nusoap_server->service($HTTP_RAW_POST_DATA);
|
---|
[294] | 68 | }
|
---|
| 69 |
|
---|
| 70 | public function mo()
|
---|
| 71 | {
|
---|
[460] | 72 | function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime){
|
---|
[457] | 73 | $msgType = '0'; //text message
|
---|
| 74 | $errCode = '1'; //#1:error; 1:Success;
|
---|
| 75 |
|
---|
| 76 | $CI =& get_instance();
|
---|
| 77 | $mo_username = $CI->config->item('mo_username');
|
---|
| 78 | $mo_password = $CI->config->item('mo_password');
|
---|
| 79 |
|
---|
| 80 | if (!$username) return '0|0|Username is required!';
|
---|
| 81 | if (!$password) return '0|0|Password is required!';
|
---|
| 82 | if ($username != $mo_username) return '0|0|Username is not corrected!';
|
---|
| 83 | if ($password != $mo_password) return '0|0|Password is not corrected!';
|
---|
| 84 | if (!$requestID) return '0|0|requestID is required!';
|
---|
| 85 | if (!$userID) return '0|0|UserID is required!';
|
---|
| 86 | if (!$serviceID) return '0|0|serviceID is required!';
|
---|
| 87 | if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
|
---|
[460] | 88 |
|
---|
| 89 | $status = 0;
|
---|
[457] | 90 | $sentNumber = $userID;
|
---|
| 91 | $username = !$receiverID ? $sentNumber : $receiverID;
|
---|
| 92 |
|
---|
| 93 | $CI->load->model('frontend/user_model', 'userModel');
|
---|
[460] | 94 | $password = $CI->userModel->create_random_password();
|
---|
[457] | 95 |
|
---|
[460] | 96 | $result = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status);
|
---|
| 97 | $aryAgrs = func_get_args ();
|
---|
| 98 | $fh = fopen('register.log', 'a+');
|
---|
| 99 | fwrite ($fh, var_export($aryAgrs, true). "\n");
|
---|
| 100 | fclose($fh);
|
---|
| 101 |
|
---|
| 102 | $aryResult = explode ('|', $result);
|
---|
| 103 |
|
---|
| 104 | return $aryResult[0].'|'.$msgType.'|'.$aryResult[1];
|
---|
[313] | 105 | }
|
---|
| 106 |
|
---|
[457] | 107 | $this->nusoap_server->service(file_get_contents("php://input"));
|
---|
[294] | 108 | }
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /* End of file viettel.php */
|
---|
[457] | 112 | /* Location: ./application/modules/service/controllers/viettel.php */ |
---|