];
Civi::log()->debug("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api4().",
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
'reason' => 'CSRF suspected',
];
Civi::log()->debug("SECURITY: All requests that modify the database must be http POST, not GET.",
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
'reason' => 'Destructive HTTP GET',
*/
private function log($result, $reaction = 0) {
// Include X_FORWARD_FOR ip address if set as per IDS patten.
- $ip = $_SERVER['REMOTE_ADDR'] . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')' : '');
+ $ip = CRM_Utils_System::ipAddress() . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? ' (' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ')' : '');
$data = [];
$session = CRM_Core_Session::singleton();
$error = civicrm_api3_create_error(
$msg,
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'error_code' => 'IDS_KICK',
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
require_once 'api/v3/utils.php';
$results[$key] = civicrm_api3_create_error("SECURITY ALERT: Attaching files via AJAX requires a recent, valid token.",
[
- 'IP' => $server['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $server['HTTP_REFERER'],
'reason' => 'CSRF suspected',
require_once 'api/v3/utils.php';
return civicrm_api3_create_error("SECURITY: All requests that modify the database must be http POST, not GET.",
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
'reason' => 'Destructive HTTP GET',
if (!$config->debug && !self::isWebServiceRequest()) {
$error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3().",
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
'reason' => 'CSRF suspected',
require_once 'api/v3/utils.php';
$error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3().",
[
- 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'IP' => CRM_Utils_System::ipAddress(),
'level' => 'security',
'referer' => $_SERVER['HTTP_REFERER'],
'reason' => 'CSRF suspected',
}
/**
- * Get logged in user's IP address.
+ * Get the client's IP address.
*
* Get IP address from HTTP REMOTE_ADDR header. If the CMS is Drupal then use
* the Drupal function as this also handles reverse proxies (based on proper
require_once E::path('lib/recaptcha/recaptchalib.php');
$resp = recaptcha_check_answer(CRM_Core_Config::singleton()->recaptchaPrivateKey,
- $_SERVER['REMOTE_ADDR'],
+ CRM_Utils_System::ipAddress(),
$response
);
return $resp->is_valid;