Commit 8dbf2131 authored by Antonio.Suerte's avatar Antonio.Suerte

Remittance API Request Header Logger

parent 9c20d48b
...@@ -103,6 +103,12 @@ class MoneyRequest extends System { ...@@ -103,6 +103,12 @@ class MoneyRequest extends System {
private $toFee = NO_COUNT; private $toFee = NO_COUNT;
// end-of-case-to-case-basis-variables // end-of-case-to-case-basis-variables
/**
*
* @var string
*/
private $accessLogDir = NO_STRING;
public function __construct(){ public function __construct(){
parent::__construct(); parent::__construct();
...@@ -124,8 +130,39 @@ class MoneyRequest extends System { ...@@ -124,8 +130,39 @@ class MoneyRequest extends System {
$this -> referer = $this -> getColumnData($_SERVER, "HTTP_REFERER"); $this -> referer = $this -> getColumnData($_SERVER, "HTTP_REFERER");
} }
private function logDetails($content, $logType){
$logDate = date("Y-m-d");
$logTimestamp = date("[Y-m-d H:i:s]");
$logFile = NO_STRING;
switch($logType){
case VAL_INT_1:
$logFile = $this -> accessLogDir;
break;
}
error_log(
"{$logTimestamp}\r\n{$content}\r\n", VAL_INT_3,
"{$logFile}/Log_{$logDate}.log");
}
public function validate(){ public function validate(){
$userAgent = $this -> getColumnData($_SERVER, "HTTP_USER_AGENT"); $this -> accessLogDir = "Logs/remittance/access";
if(!@file_exists($this -> accessLogDir)){
mkdir($this -> accessLogDir, 0777, true);
}
$requestDetails = [
"IP_Address" => $this -> getColumnData($_SERVER, "REMOTE_ADDR"),
"Program_Code" => $this -> pnum
];
$requestDetails = print_r(array_merge($requestDetails, apache_request_headers()), true);
$this -> logDetails($requestDetails, VAL_INT_1);
$userAgent = $this -> getColumnData($_SERVER, "HTTP_USER_AGENT");
$referer = $this -> getColumnData($_SERVER, "HTTP_REFERER");
$whitelisitingValidationPassed = true; $whitelisitingValidationPassed = true;
...@@ -135,7 +172,7 @@ class MoneyRequest extends System { ...@@ -135,7 +172,7 @@ class MoneyRequest extends System {
// second layer of validation (Whitelisted Domains) // second layer of validation (Whitelisted Domains)
$isDomainInRemittanceDisabled = false; $isDomainInRemittanceDisabled = false;
if($userAgent){ if($userAgent && $referer){
// this condition will be considered if this was triggered in browser // this condition will be considered if this was triggered in browser
if(!$this -> checkSettlementIpAddress($this -> pnum, "allow_ip_in_remittance", $isIpInRemittanceDisabled)){ if(!$this -> checkSettlementIpAddress($this -> pnum, "allow_ip_in_remittance", $isIpInRemittanceDisabled)){
if(!$isIpInRemittanceDisabled) if(!$isIpInRemittanceDisabled)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment