Exemple #1
0
 protected function response($response_type, $params = array(), $body = NULL, $redirect = '')
 {
     $code = ResponseType::getCode($response_type);
     $msg = Core::sprintf($response_type, $params);
     /*
     $ifconfig_out=Core::cmdRun('/sbin/ifconfig', $cmd_error);
     if($ifconfig_out){
         preg_match('/10\.1\.242\.(\d+)/', $ifconfig_out, $ifconfig);
         Core::header('X-MOMO-SID: '.$ifconfig[1]);
     }
     */
     if ($redirect) {
         $result['code'] = $code;
         $result['msg'] = $msg;
         $result['data'] = $body;
         $href = $redirect . (strpos($redirect, '?') !== FALSE ? '&' : '?') . 'apiResult=' . urlencode(json_encode($result));
         Core::header('Location:' . $href);
     } else {
         Core::outTrace();
         $this->send_response($code, $body, $msg, FALSE);
     }
     Core::quit();
 }
Exemple #2
0
 protected function response($response_type, $params = array(), $body = NULL, $redirect = '')
 {
     $code = ResponseType::getCode($response_type);
     $msg = Core::sprintf($response_type, $params);
     if ($redirect) {
         $result['code'] = $code;
         $result['msg'] = $msg;
         $result['data'] = $body;
         $href = $redirect . (strpos($redirect, '?') !== FALSE ? '&' : '?') . 'apiResult=' . urlencode(json_encode($result));
         Core::header('Location:' . $href);
     } else {
         Core::outTrace();
         $this->send_response($code, $body, $msg, FALSE);
     }
     Core::quit();
 }