コード例 #1
0
 function adminajaxAction()
 {
     $testEnv = Zend_Registry::get('testEnv');
     if ($testEnv == 0) {
         // fetch msg from gateway
         $smsSpace = new Zend_Session_Namespace('SMS');
         $newclient = new SMS();
         $respxml = $newclient->readSMS();
         $smsSpace->xml = $newclient->sendXML;
         $smsSpace->respxml = $respxml;
         $code = $newclient->getCode();
         $respArr = $newclient->toArray();
         if ($respArr["id"][0] > 0) {
             $sparkSmsModel = new SparkSms();
             $message = $sparkSmsModel->createRow();
             $message->msg = $respArr["msg"];
             $message->sys_id = $respArr["id"][0];
             $message->source = $respArr["src"][0];
             $message->time = $respArr["time"][0];
             $message->text = iconv("GB2312", "UTF-8", base64_decode($respArr["message"][0]));
             $message->err = $respArr["err"][0];
             $db = Zend_Registry::get('db');
             $select = $db->select();
             $select->from('consumer', '*');
             $select->where('consumer.phone = ?', $message->source);
             $consumer = $db->fetchRow($select);
             $message->consumer_id = $consumer['id'];
             $message->save();
             $jsonMsg['name'] = $consumer['name'];
             $jsonMsg["sys_id"] = $message->id;
             $jsonMsg["source"] = $message->source;
             $jsonMsg["time"] = $message->time;
             $jsonMsg["text"] = $message->text;
             $jsonMsg["err"] = $message->err;
             $this->_helper->json($jsonMsg);
         } else {
             $jsonMsg["sys_id"] = -1;
             $this->_helper->json($jsonMsg);
         }
         $this->_helper->layout->disableLayout();
         // store msg into db
     }
 }