Skip to content

Commit

Permalink
Added oc_get_ip() function as per MB
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCartpenter committed May 16, 2024
1 parent 66b42a5 commit b85052e
Show file tree
Hide file tree
Showing 39 changed files with 102 additions and 84 deletions.
2 changes: 1 addition & 1 deletion upload/admin/controller/common/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function validate(): bool {
$this->session->data['user_token'] = oc_token(32);

$login_data = [
'ip' => $this->request->server['REMOTE_ADDR'],
'ip' => oc_get_ip(),
'user_agent' => $this->request->server['HTTP_USER_AGENT']
];

Expand Down
12 changes: 6 additions & 6 deletions upload/admin/controller/extension/payment/squareup.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function index(): void {
$session->start();

$this->model_user_api->deleteSessionBySessionId($session->getId());
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -442,7 +442,7 @@ public function transaction_info(): void {
$session->start();

$this->model_user_api->deleteSessionBySessionId($session->getId());
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -835,7 +835,7 @@ public function order(): string {
$session->start();

$this->model_user_api->deleteSessionBySessionId($session->getId());
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -913,7 +913,7 @@ public function recurringButtons(): string {
$session->start();

$this->model_user_api->deleteSessionBySessionId($session->getId());
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -993,8 +993,8 @@ public function addRecurringReport(): void {
if (!$order_recurring_report_info) {
$json['error'] = $this->language->get('error_recurring_report');
} else {
if (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/controller/mail/forgotten.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function deny(string &$route, array &$args, &$output): void {

$data['text_greeting'] = sprintf($this->language->get('text_greeting'), $store_name);
$data['reset'] = $this->url->link('common/reset', 'email=' . urlencode($args[0]) . '&code=' . $args[1], true);
$data['ip'] = $this->request->server['REMOTE_ADDR'];
$data['ip'] = oc_get_ip();
$data['store'] = $store_name;
$data['store_url'] = $this->config->get('config_store_url');

Expand Down
8 changes: 4 additions & 4 deletions upload/admin/controller/sale/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ protected function getList(): void {

$this->model_user_api->deleteSessionBySessionId($session->getId());

$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -758,7 +758,7 @@ public function getForm(): void {

$this->model_user_api->deleteSessionBySessionId($session->getId());

$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down Expand Up @@ -792,7 +792,7 @@ public function info(): void {

$this->document->setTitle($this->language->get('heading_title'));

$data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), $this->request->server['REMOTE_ADDR']);
$data['text_ip_add'] = sprintf($this->language->get('text_ip_add'), oc_get_ip());
$data['text_order'] = sprintf($this->language->get('text_order'), $this->request->get['order_id']);

$url = '';
Expand Down Expand Up @@ -1344,7 +1344,7 @@ public function info(): void {
$session->start();

$this->model_user_api->deleteSessionBySessionId($session->getId());
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_user_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down
2 changes: 1 addition & 1 deletion upload/admin/controller/user/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ protected function getList(): void {
*/
protected function getForm(): void {
$data['text_form'] = !isset($this->request->get['api_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
$data['text_ip'] = sprintf($this->language->get('text_ip'), $this->request->server['REMOTE_ADDR']);
$data['text_ip'] = sprintf($this->language->get('text_ip'), oc_get_ip());

$data['user_token'] = $this->session->data['user_token'];

Expand Down
12 changes: 6 additions & 6 deletions upload/admin/model/extension/payment/bluepay_hosted.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function void(int $order_id): array {
$tamper_proof_data = $this->config->get('payment_bluepay_hosted_secret_key') . $void_data['MERCHANT'] . $void_data['TRANSACTION_TYPE'] . $void_data['RRNO'] . $void_data['MODE'];
$void_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$void_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$void_data['REMOTE_IP'] = oc_get_ip();
}

$this->logger('$void_data:\r\n' . print_r($void_data, 1));
Expand Down Expand Up @@ -150,8 +150,8 @@ public function release(int $order_id, float $amount): array {

$release_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$release_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$release_data['REMOTE_IP'] = oc_get_ip();
}

return $this->sendCurl('https://secure.bluepay.com/interfaces/bp10emu', $release_data);
Expand Down Expand Up @@ -197,8 +197,8 @@ public function rebate(int $order_id, float $amount): array {
$tamper_proof_data = $this->config->get('payment_bluepay_hosted_secret_key') . $rebate_data['MERCHANT'] . $rebate_data['TRANSACTION_TYPE'] . $rebate_data['AMOUNT'] . $rebate_data['RRNO'] . $rebate_data['MODE'];
$rebate_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$rebate_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$rebate_data['REMOTE_IP'] = oc_get_ip();
}

return $this->sendCurl('https://secure.bluepay.com/interfaces/bp10emu', $rebate_data);
Expand Down
12 changes: 6 additions & 6 deletions upload/admin/model/extension/payment/bluepay_redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function void(int $order_id): array {
$tamper_proof_data = $this->config->get('payment_bluepay_redirect_secret_key') . $void_data['MERCHANT'] . $void_data['TRANSACTION_TYPE'] . $void_data['RRNO'] . $void_data['MODE'];
$void_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$void_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$void_data['REMOTE_IP'] = oc_get_ip();
}

return $this->sendCurl('https://secure.bluepay.com/interfaces/bp10emu', $void_data);
Expand Down Expand Up @@ -132,8 +132,8 @@ public function release(int $order_id, float $amount): array {
$tamper_proof_data = $this->config->get('payment_bluepay_redirect_secret_key') . $release_data['MERCHANT'] . $release_data['TRANSACTION_TYPE'] . $release_data['AMOUNT'] . $release_data['RRNO'] . $release_data['MODE'];
$release_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$release_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$release_data['REMOTE_IP'] = oc_get_ip();
}

return $this->sendCurl('https://secure.bluepay.com/interfaces/bp10emu', $release_data);
Expand Down Expand Up @@ -179,8 +179,8 @@ public function rebate(int $order_id, float $amount): array {
$tamper_proof_data = $this->config->get('payment_bluepay_redirect_secret_key') . $rebate_data['MERCHANT'] . $rebate_data['TRANSACTION_TYPE'] . $rebate_data['AMOUNT'] . $rebate_data['RRNO'] . $rebate_data['MODE'];
$rebate_data['TAMPER_PROOF_SEAL'] = md5($tamper_proof_data);

if (isset($this->request->server['REMOTE_ADDR'])) {
$rebate_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$rebate_data['REMOTE_IP'] = oc_get_ip();
}

return $this->sendCurl('https://secure.bluepay.com/interfaces/bp10emu', $rebate_data);
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/account/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected function validate(): bool {

$this->model_account_customer->addLoginAttempt($this->request->post['email']);
} else {
$this->model_account_customer->addLogin($this->customer->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_account_customer->addLogin($this->customer->getId(), oc_get_ip());

// Create customer token
$this->session->data['customer_token'] = oc_token(26);
Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/controller/api/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function index(): void {
$ip_data[] = trim($result['ip']);
}

if (!in_array($this->request->server['REMOTE_ADDR'], $ip_data)) {
$json['error']['ip'] = sprintf($this->language->get('error_ip'), $this->request->server['REMOTE_ADDR']);
if (!in_array(oc_get_ip(), $ip_data)) {
$json['error']['ip'] = sprintf($this->language->get('error_ip'), oc_get_ip());
}

if (!$json) {
Expand All @@ -46,7 +46,7 @@ public function index(): void {
$session = new \Session($this->config->get('session_engine'), $this->registry);
$session->start();

$this->model_account_api->addSession($api_info['api_id'], $session->getId(), $this->request->server['REMOTE_ADDR']);
$this->model_account_api->addSession($api_info['api_id'], $session->getId(), oc_get_ip());

$session->data['api_id'] = $api_info['api_id'];

Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/api/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function add(): void {
$order_data['currency_id'] = $this->currency->getId($this->session->data['currency']);
$order_data['currency_code'] = $this->session->data['currency'];
$order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']);
$order_data['ip'] = $this->request->server['REMOTE_ADDR'];
$order_data['ip'] = oc_get_ip();

if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
$order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/checkout/confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function index(): void {
$order_data['currency_id'] = $this->currency->getId($this->session->data['currency']);
$order_data['currency_code'] = $this->session->data['currency'];
$order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']);
$order_data['ip'] = $this->request->server['REMOTE_ADDR'];
$order_data['ip'] = oc_get_ip();

if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
$order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/controller/common/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function index(): string {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/extension/captcha/google.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function validate(): string {
return $this->language->get('error_captcha');
}

$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('captcha_google_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('captcha_google_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . oc_get_ip());
$recaptcha = json_decode($recaptcha, true);

if ((!isset($recaptcha['success']) || !$recaptcha['success']) || (!isset($this->session->data['gcaptcha'])) || ($this->session->data['gcaptcha'] != $this->request->post['g-recaptcha-response'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ public function completeOrder(): void {
$order_data['currency_id'] = $this->currency->getId($this->session->data['currency']);
$order_data['currency_code'] = $this->session->data['currency'];
$order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']);
$order_data['ip'] = $this->request->server['REMOTE_ADDR'];
$order_data['ip'] = oc_get_ip();

if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
$order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function send(): void {
$post_data['x_zip'] = $order_info['payment_postcode'];
$post_data['x_country'] = $order_info['payment_country'];
$post_data['x_phone'] = $order_info['telephone'];
$post_data['x_customer_ip'] = $this->request->server['REMOTE_ADDR'];
$post_data['x_customer_ip'] = oc_get_ip();
$post_data['x_email'] = $order_info['email'];
$post_data['x_description'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
$post_data['x_amount'] = $this->currency->format($order_info['total'], $order_info['currency_code'], 1.00000, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function index(): string {
$data['x_ship_to_state'] = $order_info['shipping_zone'];
$data['x_ship_to_zip'] = $order_info['shipping_postcode'];
$data['x_ship_to_country'] = $order_info['shipping_country'];
$data['x_customer_ip'] = $this->request->server['REMOTE_ADDR'];
$data['x_customer_ip'] = oc_get_ip();
$data['x_email'] = $order_info['email'];
$data['x_relay_response'] = 'true';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public function send(): void {
$post_data['DECLINED_URL'] = $this->url->link('extension/payment/bluepay_redirect/callback', '', true);
$post_data['MISSING_URL'] = $this->url->link('extension/payment/bluepay_redirect/callback', '', true);

if (isset($this->request->server['REMOTE_ADDR'])) {
$post_data['REMOTE_IP'] = $this->request->server['REMOTE_ADDR'];
if (oc_get_ip()) {
$post_data['REMOTE_IP'] = oc_get_ip();
}

$tamper_proof_data = $this->config->get('payment_bluepay_redirect_secret_key') . $post_data['MERCHANT'] . $post_data['TRANSACTION_TYPE'] . $post_data['AMOUNT'] . $post_data['RRNO'] . $post_data['MODE'];
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/extension/payment/eway.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function index(): string {

$request->TransactionType = 'Purchase';
$request->DeviceID = 'opencart-' . VERSION . ' eway-trans-2.1.2';
$request->CustomerIP = $this->request->server['REMOTE_ADDR'];
$request->CustomerIP = oc_get_ip();
$request->PartnerID = '0f1bec3642814f89a2ea06e7d2800b7f';

// Eway
Expand Down
10 changes: 5 additions & 5 deletions upload/catalog/controller/extension/payment/opayo.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function confirm(): void {
$payment_data['Basket'] = $str_basket;

$payment_data['CustomerEMail'] = substr($order_info['email'], 0, 255);
$payment_data['ClientIPAddress'] = $this->request->server['REMOTE_ADDR'];
$payment_data['ClientIPAddress'] = oc_get_ip();
$payment_data['ChallengeWindowSize'] = '01';
$payment_data['Apply3DSecure'] = '0';
$payment_data['ThreeDSNotificationURL'] = str_replace('&', '&', $this->url->link('extension/payment/opayo/threeDSnotify', 'order_id=' . $this->session->data['order_id'], true));
Expand Down Expand Up @@ -352,8 +352,8 @@ public function confirm(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down Expand Up @@ -524,8 +524,8 @@ public function threeDSnotify(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down
18 changes: 9 additions & 9 deletions upload/catalog/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,8 +1344,8 @@ public function approveOrder(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down Expand Up @@ -1485,8 +1485,8 @@ public function approveOrder(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down Expand Up @@ -2224,7 +2224,7 @@ public function completeOrder(): void {
$order_data['currency_id'] = $this->currency->getId($this->session->data['currency']);
$order_data['currency_code'] = $this->session->data['currency'];
$order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']);
$order_data['ip'] = $this->request->server['REMOTE_ADDR'];
$order_data['ip'] = oc_get_ip();

if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
$order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
Expand Down Expand Up @@ -2575,8 +2575,8 @@ public function completeOrder(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down Expand Up @@ -2720,8 +2720,8 @@ public function completeOrder(): void {

if (isset($this->request->server['HTTP_X_REAL_IP'])) {
$ip = $this->request->server['HTTP_X_REAL_IP'];
} elseif (isset($this->request->server['REMOTE_ADDR'])) {
$ip = $this->request->server['REMOTE_ADDR'];
} elseif (oc_get_ip()) {
$ip = oc_get_ip();
} else {
$ip = '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function send(): void {
'cust_country' => $order_info['payment_iso_code_2'],
'cust_postcode' => $order_info['payment_postcode'],
'cust_tel' => $order_info['telephone'],
'cust_ip' => $this->request->server['REMOTE_ADDR'],
'cust_ip' => oc_get_ip(),
'cust_email' => $order_info['email'],
'tran_ref' => $order_info['order_id'],
'tran_amount' => $this->currency->format($order_info['total'], $order_info['currency_code'], 1.00000, false),
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/extension/payment/pilibaba.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function express(): void {
$order_data['currency_id'] = $this->currency->getId($this->session->data['currency']);
$order_data['currency_code'] = $this->session->data['currency'];
$order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']);
$order_data['ip'] = $this->request->server['REMOTE_ADDR'];
$order_data['ip'] = oc_get_ip();

if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
$order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
Expand Down
Loading

0 comments on commit b85052e

Please sign in to comment.