public function init() { parent::init(); $ns = new Zend_Session_Namespace('user'); $general = new Application_Model_General(); $statUser = $general->veriStatUser($ns->data); if (!empty($ns->data)) { $this->view->firstname = $ns->data['firstname_user']; $this->view->lastname = $ns->data['lastname_user']; $this->view->lvl = $ns->data['id_rank']; } if ($statUser == 1 or $statUser == 2) { $this->view->isadmin = $statUser; } else { if ($statUser == 3) { Zend_Session::namespaceUnset("user"); Zend_Session::destroy(true); $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'acces'), null, true)); } } $this->category = new Application_Model_Category(); if ($this->_getParam('message') != null) { $this->view->message = "Modification sauvegarder"; } }
/** * Test Controller Class * Index Action - "http://SERVER/Test" * This useful for testing the NGP * * @package ApplicationController * @subpackage CronController */ public function indexAction() { $reply = Application_Model_General::getSettings('test-response', 'true'); $params = $this->getRequest()->getParams(); // error_log(print_R($params, 1)); switch (strtolower($reply)) { case 'rand': case 'random': $ack = $this->randResponse(); break; case 'true': $ack = 'true'; break; case 'ack00': default: $ack = 'Ack00'; break; } $arr = array('reqId' => $params['reqId'], 'status' => $ack, 'desc' => 'run on ' . $reply); switch ($params['method']) { case "execute_transfer": $arr['more']['connect_time'] = time(); break; case "inquire_number": case "inquire_number_response": $arr['more']['current_operator'] = 'PR'; break; } $response = json_encode($arr); $this->view->response = $response; }
/** * method to create xml from the request * * @return SimpleXml xml object */ public function createXml() { $xml = parent::createXml(); $msgType = $this->getHeaderField('MSG_TYPE'); $xml->{$msgType}->portingDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('PORT_TIME')); return $xml; }
public function PostValidate() { $this->setAck($this->validateParams($this->getHeaders())); //first step is GEN if (!$this->checkDirection()) { return "Gen04"; } //HOW TO CHECK Gen05 // if (!$this->ValidateDB()) { // return "Gen07"; // } if (($timer_ack = Np_Timers::validate($this)) !== TRUE) { return $timer_ack; } $tbl = new Application_Model_DbTable_Requests(Np_Db::master()); $updateArray = array('last_transaction' => $this->getHeaderField("MSG_TYPE")); // if we received success return_response and we are not the initiator we need to publish it after (so leave it with status on) if ($this->getHeaderField("TO") == Application_Model_General::getSettings('InternalProvider')) { $updateArray['status'] = 0; } else { $updateArray['status'] = 1; } $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID")); if (!$tbl->update($updateArray, $whereArray)) { return false; } return true; }
public function init() { // Set the method for the display form to POST $this->setMethod('POST'); $this->setAction(Application_Model_General::getBaseUrl() . "/monitor/send/"); $this->setAttrib('class', 'request-form'); $msgTypeOptions = array('label' => 'Message', 'required' => true, 'multioptions' => array('Check' => 'Check', 'Request' => 'Request', 'Update' => 'Update', 'Cancel' => 'Cancel', 'Inquire_number' => 'Inquire_number', 'Return' => 'Return')); $this->addElement('select', 'MSG_TYPE', $msgTypeOptions); $numberOptions = array('label' => 'Phone number', 'required' => true, 'validators' => array('Int', array('StringLength', FALSE, array(10, 10))), 'value' => ''); $this->addElement('text', 'NUMBER', $numberOptions); $d = new Zend_Date(null, null, Application_Model_General::getLocale(null, false)); $dateOptions = array('label' => 'Port Time', 'id' => 'datetimepicker', 'required' => true, 'value' => $d->toString('YYYY-MM-dd HH:mm:ss', Application_Model_General::getLocale(null, false))); $this->addElement('text', 'porttime', $dateOptions); $providers = Application_Model_General::getProviderArray(); $currentProvider = Application_Model_General::getSettings('InternalProvider'); if (($key = array_search($currentProvider, $providers)) !== FALSE) { unset($providers[$key]); } $toOptions = array('label' => 'To', 'multioptions' => array_combine($providers, $providers)); $this->addElement('select', 'TO', $toOptions); $dateTimeLabelOptions = array('label' => 'Date and Time', 'required' => true, 'value' => date('y/m/d:h/i/s'), 'disabled' => 'true'); $this->addElement('text', 'Date and Time', $dateTimeLabelOptions); $submitOptions = array('ignore' => true, 'label' => 'Send'); $this->addElement('submit', 'submit', $submitOptions); }
public function init() { $this->setMethod('GET'); $this->setAction(''); $this->addElement('text', 'request_id', array('label' => 'Request Id')); $this->addElement('text', 'phone', array('label' => 'Phone', 'required' => true, 'validators' => array('Alnum', array('regex', false, '/^[a-z]/i'), 'int'), 'filters' => array('StringTrim'))); $msgTypeOptions = array('label' => 'Stage', 'required' => true, 'multioptions' => array('All' => 'All', 'Check' => 'Check', 'Request' => 'Request', 'Execute' => 'Execute', 'Publish' => 'Publish')); $this->addElement('select', 'stage', $msgTypeOptions); $this->addElement('text', 'date', array('label' => 'Date (YYYY-MM-DD)', 'required' => true)); $this->addElement('text', 'time', array('label' => 'Time (HH:MM:SS)', 'required' => true, 'invalidMessage' => 'Invalid date specified.', 'filters' => array('StringTrim'))); $providers = Application_Model_General::getProviderArray(); $currentProvider = Application_Model_General::getSettings('InternalProvider'); if (($key = array_search($currentProvider, $providers)) !== FALSE) { unset($providers[$key]); } array_unshift($providers, 'None', $currentProvider); $toOptions = array('label' => 'From provider', 'multioptions' => array_combine($providers, $providers)); $this->addElement('select', 'from', $toOptions); $toOptions['label'] = 'To provider'; $this->addElement('select', 'to', $toOptions); $statusOptions = array('label' => 'Status', 'multioptions' => array(-1 => "All", 1 => "Active", 0 => "Inactive")); $this->addElement('select', 'status', $statusOptions); // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Search', 'class' => 'request-search-button')); }
/** * Function indexAction check session if thereis value in session redirect on list action of user controller else redirect on index of login action.. */ public function indexAction() { $data = Application_Model_General::get_Auth_Storage_Session(); if (is_object($data)) { $this->_redirect('/user/list'); } else { $this->_redirect('/login/index'); } }
public function init() { parent::init(); zend_session::start(); $ns = new Zend_Session_Namespace('user'); $use = new Application_Model_User(); $general = new Application_Model_General(); $statUser = $general->veriStatUser($ns->data); if (!empty($ns->data)) { $this->view->firstname = $ns->data['firstname_user']; $this->view->lastname = $ns->data['lastname_user']; $this->view->lvl = $ns->data['id_rank']; } if ($statUser == 1 or $statUser == 2) { $this->view->isadmin = $statUser; } else { if ($statUser == 3) { Zend_Session::namespaceUnset("user"); Zend_Session::destroy(true); $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'acces'), null, true)); } } if ($this->_getParam('message') != null) { switch ($this->_getParam('message')) { case 'deconnection': $this->view->message = "Vous êtes déconnecté"; break; case 'done': $this->view->message = "Un article à été ajouté"; break; case 'connecter': $this->view->message = "Vous êtes connecté"; break; case 'enregistrer': $this->view->message = "Vous êtes inscrit"; break; case 'erreur': $this->view->message = "Une erreur c'est produite lors de votre inscription.<br/>Veuillez contactez un administrateur"; break; } } }
protected function printTableRow($field, $value, $table, $link = false) { $baseUrl = Application_Model_General::getBaseUrl(); if ($field == 'id' && $link && $table == 'Requests') { echo '<td style="border:solid 1px;"><a href="' . $baseUrl . '/monitor/edit?table=Requests&id=' . (int) $value . '">' . $value . '</td>'; } else { if ($value !== NULL) { echo '<td style="border:solid 1px;">' . $value . '</td>'; } else { echo '<td style="border:solid 1px;"> </td>'; } } }
public function init() { $this->setMethod('POST'); $this->setAction(Application_Model_General::getBaseUrl() . "/monitor/execute/"); $this->setAttrib('class', 'execute-form'); $this->addElement('hidden', 'id'); $this->addElement('hidden', 'request_id'); $this->addElement('hidden', 'from_provider'); $this->addElement('hidden', 'to_provider'); $this->addElement('hidden', 'phone_number'); $executeOptions = array('label' => 'Send Execute'); $this->addElement('submit', 'submit', $executeOptions); }
protected function addApprovalXml(&$xml, $msgType) { $route = Application_Model_General::getDateTimeInSqlFormat(Application_Model_General::getRouteTimeByReqId($this->getHeaderField("REQUEST_ID"))); if ($this->getBodyField("APPROVAL_IND") == "Y") { $xml->{$msgType}->positiveApproval; $xml->{$msgType}->positiveApproval->approvalInd = "Y"; $xml->{$msgType}->positiveApproval->routeDateTime = $route; } else { $xml->{$msgType}->negativeApproval; $xml->{$msgType}->negativeApproval->approvalInd = "N"; $rejectReasonCode = $this->getBodyField('REJECT_REASON_CODE'); $xml->{$msgType}->negativeApproval->rejectReasonCode = $rejectReasonCode !== NULL ? $rejectReasonCode : ''; } }
/** * internal Action - "http://SERVER/Provider/internal" * * Gets params from GET and puts them in a new Request Model Object . * then calls executeRequest() to send the message to internal. * * @package ApplicationController * @subpackage ProviderController */ public function internalAction() { $params = Application_Model_General::getParamsArray($this->getRequest()->getParams()); if (isset($params['SLEEP'])) { sleep((int) $params['SLEEP']); } if (isset($params['NUMBER'])) { $params['PHONE_NUMBER'] = $params['NUMBER']; } // error_log(print_R($params, 1)); $reqModel = new Application_Model_Request($params); $manual = isset($params['MANUAL']) && $params['MANUAL']; $reqModel->ExecuteRequest($manual); }
public function contactAction() { $general = new Application_Model_General(); $data_webite = $general->getGeneral(); $data = $data_webite[0]; $this->view->website_address = $data['website_address']; $this->view->website_phone = $data['website_phone']; $this->view->website_email = $data['website_email']; $this->view->website_ville = $data['website_ville']; $this->view->website_code_postal = $data['website_code_postal']; $this->view->website_pays = $data['website_pays']; if ($this->_request->isPost()) { $contact = new Application_Model_Contact(); $nom = $_POST['nom']; $prenom = $_POST['prenom']; $object = $_POST['object']; $mailUser = $_POST['mail']; $message = $_POST['message']; $contact->sendMail($nom, $prenom, $object, $mailUser, $message); mail($mailUser, $object, $message); $this->view->mail = "Votre message à bien été envoyé."; } }
/** * sendMessage method defined by NP wsdl * called by external providers to send transaction messages to internal * the call to internal will be forward by forking * * @param Array $params * @return array "NP_ACK" or string */ public function sendMessage($params) { Application_Model_General::virtualSleep(); $reqModel = new Application_Model_Request($params); //prepares data for sending internal the message $ack = $reqModel->Execute(); // log all received calls if request log enabled if (Application_Model_General::getSettings('EnableRequestLog')) { Application_Model_General::logRequestResponse($params, $ack, $reqModel->getRequest()->getHeaderField('REQUEST_ID'), '[Input] '); } if ($ack === FALSE || strpos(strtolower($ack), "ack") === FALSE) { $ack = "Ack00"; } return array('NP_ACK' => array('ACK_CODE' => $ack, 'ACK_DATE' => Application_Model_General::getDateTimeIso())); }
public function phoneproviderAction() { $phone_number = $this->getPhoneNumber(); if (!empty($phone_number)) { $status = 1; $transfer_statuses = array('Execute_response', 'Publish_response', 'Return_response'); $where = array('last_transaction IN (?)' => $transfer_statuses); $result = Application_Model_General::getRequests($phone_number, 'phone_number', array('to_provider'), $where, 'id DESC', 1); // if phone number not found return the default provider (by its number) if (empty($result)) { $result = Application_Model_General::getDefaultProvider($phone_number); } } else { $status = 0; $result = array(); } $output = array('status' => $status, 'results' => $result); // print "<pre>"; // print_R($output);die; $this->view->response = $this->encodeResponse($output); }
/** * Cron Controller Class * Index Action - "http://SERVER/Cron" * calls the modle to select the requests to Transfer and * opens process for each one of the requests * * @package ApplicationController * @subpackage CronController */ public function indexAction() { $disabled_output = $this->getRequest()->getParam('no-output'); $forceAll = $this->getRequest()->getParam('force-all'); if (!isset($disabled_output) || !$disabled_output) { $this->view->output_enabled = true; } else { $this->view->output_enabled = false; } // we make 3 process at different iteraion // we order the check publish before publish for scenario of force all (all on one time) // we don't use else in case we force all $this->view->transfer = array(); $this->view->publish_check = array(); $this->view->publish = array(); $minute = date('i'); if ($minute % 2 === 0 || $forceAll) { //first execute $this->view->transfer = Application_Model_Cron::makeChangeProvider(); } $publish_verification_iteration = Application_Model_General::getSettings('publish-verification-iteration', 20); $hour = date('G'); // 24-hour format of an hour without leading zeros $dayofweek = date('w'); // Numeric representation of the day of the week, 0 (for Sunday) through 6 (for Saturday) $working_days = (bool) ($dayofweek >= 0 && $dayofweek <= 4 && $hour >= 8 && $hour < 23); $friday = (bool) ($dayofweek == 5 && $hour >= 8 && $hour < 15); if ($minute % $publish_verification_iteration == 0 && ($working_days || $friday) || $forceAll) { // verify all requests return publish $this->view->publish_check = Application_Model_Cron::checkPublishResponseFromProviders(); } if ($minute % 2 === 1 || $forceAll) { // publish $this->view->publish = Application_Model_Cron::publishChangeProvider(); } }
/** * Function forgotpasswordAction which send mail for forgotted password on given user's email address. */ public function forgotpasswordAction() { $this->view->ssMessage = implode($this->_helper->flashMessenger->getMessages(), '.'); $oForgotPasswordForm = new Application_Form_ForgotPassword(); $this->view->forgotPasswordForm = $oForgotPasswordForm; if ($this->getRequest()->isPost()) { $asUserFormDetail = $this->getRequest()->getPost(); if ($oForgotPasswordForm->isValid($asUserFormDetail)) { $saFormDetails = $oForgotPasswordForm->getValues(); $saUserDetail = Doctrine::getTable('Model_Users')->checkEmailExist($saFormDetails['email']); if ($saUserDetail) { $updatePassword = strtoupper(substr(sha1(uniqid(rand(), true)), 0, 6)); Doctrine_Query::create()->update("Model_Users u")->set("u.password", "md5(?)", array($updatePassword))->where("u.email = ?", array($this->_getParam('email')))->execute(); $ssMailBody = $this->view->getHelper('partial')->partial('login/forgotPassword.phtml', array('firstname' => $saUserDetail[0]['first_name'], 'password' => $updatePassword)); $mailSubject = "Stream - forgot password notification"; Application_Model_General::zendRestMail($oForgotPasswordForm->getValue('email'), '*****@*****.**', $mailSubject, $ssMailBody); $this->_helper->flashMessenger->addMessage('Your password is send successfully on your email address'); $this->_redirect('/login/forgotpassword'); } else { $this->view->ssMessage = 'Email is not matched!!! Please try again'; } } } }
/** * sets ack code in body field using validate params * post validation checks for general soap field errors * * @return mixed String or BOOL */ public function PostValidate() { $this->setAck($this->validateParams($this->getHeaders())); //first step is GEN if (!$this->checkDirection()) { return "Gen04"; } if (!$this->ValidateDB()) { return "Gen07"; } if (($timer_ack = Np_Timers::validate($this)) !== TRUE) { $timers_array = array('T2DR1', 'T2DR2', 'T3DR1', 'T3RK1', 'T3DR1U', 'T3RK1', 'T3RK2', 'T3DR1D', 'T3RK3', 'T3KR', 'T4DR0', 'T4DR1', 'T4DR11', 'T4DR2', 'T4DR3', 'T4RR1', 'T4RR11', 'T4OR1', 'T4OR11', 'T4RO1', 'TNP', 'TNP1', 'TNP2', 'TNP3', 'TNP4', 'TNPS', 'TNPB', 'T5BA2', 'T5BA3', 'T5AO1', 'T5OR1', 'T5001', 'T5002', 'T5003', 'TACK1', 'TACK2', 'TRES2', 'T5BA2', 'T5BA22', 'PNP1', 'PNP2', 'PNP3', 'PNP4', 'RACK3', 'N2DR4', 'PNP10', 'PNP4', 'RACK3'); if (in_array($timer_ack, $timers_array)) { Application_Model_General::writeToTimersActivity($this->getHeaders(), $timer_ack); } return $timer_ack; } return true; }
/** * Adds Hardcoded Values to Missing Fields for SOAP Request * * @param array $params * */ private function AddParamsToInternalReq(&$params) { // $params['FORK'] = 1; $params['FROM_PROVIDER'] = Application_Model_General::getSettings('InternalProvider'); //requests from internal - Transfer to internal if (isset($params['MSG_TYPE'])) { $params['PROCESS_TYPE'] = Application_Model_General::getProcessType($params['MSG_TYPE']); } if (isset($params['msg_type'])) { $params['PROCESS_TYPE'] = Application_Model_General::getProcessType($params['msg_type']); } $params['VERSION_NO'] = Application_Model_General::getSettings("VersionNo"); $params['RETRY_NO'] = 1; $params['RETRY_DATE'] = Application_Model_General::getDateTimeIso(); $params['NETWORK_TYPE'] = Application_Model_General::getSettings("NetworkType"); if (isset($params['more'])) { foreach ($params['more'] as $key => $value) { $params[strtoupper($key)] = $value; } } // backward compatibility if (!isset($params['NUMBER_TYPE'])) { $params['NUMBER_TYPE'] = Application_Model_General::getSettings("NumberType"); } if (isset($params['number_type'])) { $params['NUMBER_TYPE'] = $params['number_type']; } }
/** * method triggered after internal response to NPG * * @param object $internalResponseObject */ public function postInternalRequest($internalResponseObject) { if ($this->getHeaderField("TO") == Application_Model_General::getSettings('InternalProvider')) { if (isset($internalResponseObject->connect_time)) { $connect_time = $internalResponseObject->connect_time; } else { $connect_time = time(); } $updateArray = array('connect_time' => Application_Model_General::getDateTimeInSqlFormat($connect_time)); $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID")); $tbl = new Application_Model_DbTable_Requests(Np_Db::master()); return $tbl->update($updateArray, $whereArray); } return true; }
public function createXml() { $xml = parent::createXml(); $msgType = $this->getHeaderField('MSG_TYPE'); $networkType = Application_Model_General::getSettings("NetworkType"); $xml->{$msgType}->donor = $this->getBodyField('DONOR'); $xml->{$msgType}->connectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('CONNECT_TIME')); $xml->{$msgType}->publishType = $this->getBodyField('PUBLISH_TYPE'); $xml->{$msgType}->disconnectDateTime = Application_Model_General::getDateTimeIso($this->getBodyField('DISCONNECT_TIME')); if ($networkType === "M") { $xml->{$msgType}->mobile; $xml->{$msgType}->mobile->numberType = "I"; $xml->{$msgType}->mobile->number = $this->getBodyField("NUMBER"); } else { $xml->{$msgType}->fixed->fixedNumberSingle; } return $xml; }
/** * sends automatic response to transaction messages sent to internal. * * @param bool $status * * @todo refactoring to bridge classes */ public function CreateMethodResponse($status) { //update DB ack! //SEND RESPONSE TO PROVIDER $response = array('REQUEST_ID' => $this->params['REQUEST_ID'], 'PROCESS_TYPE' => $this->params['PROCESS_TYPE'], 'MSG_TYPE' => $this->params['MSG_TYPE'] . "_response", 'REQUEST_TRX_NO' => $this->params['TRX_NO'], 'FROM' => $this->params['TO'], 'TO' => $this->params['FROM'], 'REQUEST_RETRY_DATE' => $this->params['RETRY_DATE'], 'RETRY_DATE' => Application_Model_General::getDateTimeIso(), 'RETRY_NO' => isset($this->params['RETRY_NO']) ? $this->params['RETRY_NO'] : 1, 'VERSION_NO' => Application_Model_General::getSettings("VersionNo"), 'NETWORK_TYPE' => Application_Model_General::getSettings('NetworkType'), 'NUMBER_TYPE' => isset($this->params['NUMBER_TYPE']) ? $this->params['NUMBER_TYPE'] : Application_Model_General::getSettings("NumberType")); $phone_number = array("PHONE_NUMBER" => $this->params['PHONE_NUMBER']); Application_Model_General::writeToLog(array_merge($response, $phone_number)); //check $status if (($status->status == "Ack00" || $status->status == "true") && !isset($status->resultCode) || $status->status == NULL && $status->resultCode == "Ack00") { $response['APPROVAL_IND'] = "Y"; } elseif ($status->status == "Gen07") { $response['APPROVAL_IND'] = "N"; $response['REJECT_REASON_CODE'] = "Gen07"; } else { $response['APPROVAL_IND'] = "N"; $response['REJECT_REASON_CODE'] = $status->status; } if ($this->params['MSG_TYPE'] == "Execute") { $time = isset($status->DISCONNECT_TIME) ? $status->DISCONNECT_TIME : null; $response['DISCONNECT_TIME'] = Application_Model_General::getDateTimeIso($time); } if ($response['MSG_TYPE'] == "Inquire_number_response") { $response['CURRENT_OPERATOR'] = isset($status->current_operator) ? $status->current_operator : $status->more->current_operator; } if (isset($status->resultCode) && !empty($status->resultCode)) { $response['REJECT_REASON_CODE'] = $status->resultCode; } $reqModel = new Application_Model_Request($response); $reqModel->ExecuteFromInternal(FALSE); // ExecuteResponse(); }
/** * sets status = 0 to any "Check_response" requests that have timedout * * @return int number of affected rows */ public static function setTimeoutChecks($msg_type = "Check", $time = 1, $checkTransferTimeNotExists = false) { // $setTimeOutArray = array('Check'=>'30','Check_response'=>'30','Request'=>'30',); $dateInTimeStamp = time() - $time * 60; $compareTime = Application_Model_General::getDateTimeInSqlFormat($dateInTimeStamp); $tbl = new Application_Model_DbTable_Requests(Np_Db::master()); $update_arr = array('status' => 0); $where_arr = array('last_transaction =?' => $msg_type, 'last_request_time < ?' => $compareTime, 'status =?' => 1); if ($checkTransferTimeNotExists) { $where_arr[] = "transfer_time IS NULL OR transfer_time = ''"; } $res = $tbl->update($update_arr, $where_arr); return $res; }
public function createXml() { $xml = parent::createXml(); $msgType = $this->getHeaderField('MSG_TYPE'); $networkType = Application_Model_General::getSettings("NetworkType"); $numberType = $this->getBodyField('NUMBER_TYPE'); $requestId = $this->getHeaderField('REQUEST_ID'); $requestRecord = Application_Model_General::getFieldFromRequests(array('flags', 'transfer_time'), $requestId, 'request_id'); $flags = json_decode($requestRecord['flags'], true); if (empty($numberType)) { $numberType = isset($flags['number_type']) ? $flags['number_type'] : Application_Model_General::getSettings("NumberType"); } $number = $this->getBodyField('NUMBER'); $portTime = Application_Model_General::getDateTimeIso($requestRecord['transfer_time']); $process_type = $this->getHeaderField('PROCESS_TYPE'); if ($process_type == "PORT") { $path =& $xml->{$msgType}->updateRequestType; $path->updateType = "REQUEST"; $path->portingDateTime = $portTime; } else { if ($process_type == "CANCEL") { $path =& $xml->{$msgType}->updateCancelTypeType; $path->updateType = "CANCEL"; $path->portingDateTime = $portTime; } else { if ($process_type == "UPDATE") { $path =& $xml->{$msgType}->updateUpdateTypeType; $path->updateType = "UPDATE"; $path->portingDateTime = $portTime; } } } if ($networkType === "M") { $networkType = "mobile"; } else { $networkType = "fixed"; } $path->{$networkType}; $path->{$networkType}->networkType = "M"; if ($numberType === "I") { $path->{$networkType}->mobileNumberIdentified; $path->{$networkType}->mobileNumberIdentified->numberType = $numberType; $path->{$networkType}->mobileNumberIdentified->identificationValue = isset($flags['identification_value']) ? $flags['identification_value'] : 'default'; $path->{$networkType}->mobileNumberIdentified->identificationValue2nd = 'default'; $path->{$networkType}->mobileNumberIdentified->identificationValue3rd = 'default'; $path->{$networkType}->mobileNumberIdentified->number = $number; } else { $path->{$networkType}->mobileNumberUnidentified; $path->{$networkType}->mobileNumberUnidentified->numberType = $numberType; $path->{$networkType}->mobileNumberUnidentified->number = $number; } return $xml; }
/** * convert Xml data to associative array * * @param simple_xml $xmlObject simple xml object * * @return array converted data from hierarchical xml to flat array */ public function convertArray($xmlObject) { $ret = array(); $networkTypeConfig = Application_Model_General::getSettings("NetworkType"); if ($networkTypeConfig === "M") { $networkType = "mobile"; $ret['NETWORK_TYPE'] = (string) $networkTypeConfig; } else { $networkType = "fixed"; $ret['NETWORK_TYPE'] = (string) $networkTypeConfig; } if (!empty($xmlObject->{$networkType}->mobileNumberIdentified) && $xmlObject->{$networkType}->mobileNumberIdentified !== NULL) { $ret['IDENTIFICATION_VALUE'] = (string) $xmlObject->{$networkType}->mobileNumberIdentified->identificationValue; $ret['IDENTIFICATION_VALUE_2ND'] = (string) $xmlObject->{$networkType}->mobileNumberIdentified->identificationValue2nd; $ret['IDENTIFICATION_VALUE_3RD'] = (string) $xmlObject->{$networkType}->mobileNumberIdentified->identificationValue3rd; $ret['NUMBER_TYPE'] = (string) $xmlObject->{$networkType}->mobileNumberIdentified->numberType; $ret['PHONE_NUMBER'] = (string) $xmlObject->{$networkType}->mobileNumberIdentified->number; } else { $ret['NUMBER_TYPE'] = (string) $xmlObject->{$networkType}->mobileNumberUnidentified->numberType; $ret['PHONE_NUMBER'] = (string) $xmlObject->{$networkType}->mobileNumberUnidentified->number; } return $ret; }
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)); }
public function getReqLog($request_id) { $logPath = Application_Model_General::getRequestFilePath($request_id); if (file_exists($logPath)) { return file_get_contents($logPath); } return ''; }
/** * overridden from np_method ,updates requests , sets status to 1 , * last transaction to msg_type and requested transfer time * * @return int number of affected rows */ public function saveToDB() { if ($this->checkApprove() === FALSE) { return FALSE; } $updateArray = array('status' => 1, 'last_transaction' => $this->getHeaderField("MSG_TYPE"), 'transfer_time' => Application_Model_General::getTrxPortTime($this->getBodyField("REQUEST_TRX_NO"))); $whereArray = array('request_id =?' => $this->getHeaderField("REQUEST_ID")); $tbl = new Application_Model_DbTable_Requests(Np_Db::master()); return $tbl->update($updateArray, $whereArray); }
/** * Method to validate request timers * * @param object $request Request Object * @return boolean true when the request timing is valid * string when request timing is not valid with the correct ack */ public static function validate($request) { //reset the failure for next validation self::$failure = FALSE; $ret = TRUE; $isTimeout = FALSE; //we're on check - no timers if (!isset($request->last_method_time) && !$request->last_method_time) { return TRUE; } $msg_type = strtolower($request->getHeaderField('MSG_TYPE')); self::$last_transaction = $request->last_method; self::$last_request_time = $request->last_method_time; self::$last_port_time = $request->last_transfer_time; self::$port_time = $request->getBodyField("PORT_TIME"); // current port time if (isset(self::$timerMethodArr[$msg_type])) { $timer = self::$timerMethodArr[$msg_type]; // Application_Model_Agg::insertInvalidProcessByTimer($timer, $request->getHeaderField('MSG_TYPE') , $waiting); if ($timer['time'] == "PORT") { $input_time = self::$last_port_time; } else { $input_time = self::$last_request_time; } if ($timer['lt']) { $isTimeout = self::isTimeout($timer['code'], $input_time); //true of false } else { $isTimeout = self::isTimeout($timer['code'], $input_time, null, FALSE); //true of false } } // the first timeout should return true or false (no further use for the timer code) if ($isTimeout === TRUE) { Application_Model_General::writeToTimersActivity($request->getHeaders(), self::$failure); if (self::isDebug()) { error_log("Timer is not valid: " . $ret); } return "Gen07"; } $method_name = $msg_type . "Timeout"; if (in_array($method_name, get_class_methods("Np_Timers"))) { self::$method_name(); if (self::$failure !== FALSE) { $ret = ucfirst(strtolower(self::$failure)); Application_Model_General::writeToTimersActivity($request->getHeaders(), $ret); if (self::isDebug()) { error_log("Timer is not valid: " . $ret); } return $ret; } } return $ret; }
/** * method to create xml from the request * * @return SimpleXml xml object */ public function createXml() { $xml = parent::createXml(); $msgType = $this->getHeaderField('MSG_TYPE'); $numberType = $this->getBodyField('NUMBER_TYPE'); $xml->{$msgType}->number = $this->getBodyField('NUMBER'); if (Application_Model_General::getSettings("NetworkType") === "M") { $xml->{$msgType}->mobile; $xml->{$msgType}->mobile->networkType = "M"; $xml->{$msgType}->mobile->numberType = $numberType; } else { $xml->{$msgType}->fixed->networkType = "M"; $xml->{$msgType}->fixed->numberType = $numberType; } return $xml; }