/** * Index Action - "http://SERVER/internal" * This is where the internal's POST Messages will point to.- * aFirst step get the parameters in POST * */ public function indexAction() { $params = Application_Model_General::getParamsArray($this->getRequest()->getParams()); // backward compatability if (isset($params['NUMBER'])) { $params['PHONE_NUMBER'] = $params['NUMBER']; unset($params['NUMBER']); } if (isset($params['TO'])) { $params['TO_PROVIDER'] = $params['TO']; unset($params['TO']); } if (isset($params['FROM'])) { $params['FROM_PROVIDER'] = $params['FROM']; unset($params['FROM']); } // error_log(print_R($params, 1)); $this->AddParamsToInternalReq($params); $model = new Application_Model_Internal($params); $obj = new stdClass(); $obj->status = $model->Execute(); $request_params = $model->getParams(); if (isset($request_params)) { $obj->reqId = isset($request_params['REQUEST_ID']) ? $request_params['REQUEST_ID'] : ''; $obj->msgType = isset($request_params['MSG_TYPE']) ? $request_params['MSG_TYPE'] : ''; } $desc = $model->getErrorMsg(); if (!empty($desc)) { $obj->msgDesc = $obj->desc = $desc; } else { $obj->msgDesc = $obj->desc = ''; } $this->view->ack = $obj; // log the request and response $logContentRequest = "Receive from internal " . PHP_EOL . print_R($this->getRequest()->getParams(), 1) . PHP_EOL; Application_Model_General::logRequest($logContentRequest, $obj->reqId); $logContentResponse = "Response to internal " . PHP_EOL . print_R($obj, 1) . PHP_EOL; Application_Model_General::logRequest($logContentResponse, $obj->reqId); }
public function sendAction() { $params = $this->getRequest()->getParams(); $url = 'Internal'; $method = $params['MSG_TYPE']; Application_Model_General::prefixPhoneNumber($params['NUMBER']); $args = array('method' => Application_Model_Internal::getMethodName($method), 'msg_type' => $method, 'provider' => $params['TO'], 'number' => $params['NUMBER'], 'request_time' => time()); if ($method == 'Request' || $method == 'Update') { $args['transfer_time'] = $params['porttime']; } else { if ($method == 'Execute_response') { $args['more']['connect_time'] = time(); } } $success = Application_Model_General::forkProcess($url, $args, true); if ($success) { $params['success'] = 1; $params['message'] = 'Request sent'; } else { $params['success'] = 0; $params['message'] = 'Request failed'; } $this->_redirect(Application_Model_General::getBaseUrl() . '/monitor/request?' . http_build_query($params)); }
/** * send error to internal if happened directly * @param type $errorCode * @return boolean */ protected function SendErrorToInternal($errorCode = false) { if (Application_Model_General::isMsgResponse($this->request->getHeaderField('MSG_TYPE'))) { // don't send error on response return true; } $params = $this->data; // send the error as response to internal $params['MSG_TYPE'] = $this->request->getHeaderField('MSG_TYPE') . '_response'; $params['STATUS'] = $errorCode; $params['APPROVAL_IND'] = 'N'; $params['FROM'] = $params['FROM_PROVIDER']; $params['TO'] = $params['TO_PROVIDER']; $response = new Application_Model_Internal($params); $response->SendErrorToInternal($params); }