function sf_notifications_allowed_ips in Salesforce Suite 7.2
Same name and namespace in other branches
- 6.2 sf_notifications/sf_notifications.module \sf_notifications_allowed_ips()
Access callback for SALESFORCE_PATH_NOTIFICATIONS_ENDPOINT
Return value
TRUE if IP is in whitelist and FALSE if not.
1 call to sf_notifications_allowed_ips()
- sf_notifications_endpoint in sf_notifications/
sf_notifications.module - Menu callback for Salesforce notifications endpoint @todo Add authentication. see "Downloading the Salesforce.com Client Certificate" at http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax...
1 string reference to 'sf_notifications_allowed_ips'
- sf_notifications_settings_form in sf_notifications/
sf_notifications.admin.inc - Salesforce Notifications settings
File
- sf_notifications/
sf_notifications.module, line 61
Code
function sf_notifications_allowed_ips() {
$ip = $_SERVER['REMOTE_ADDR'];
$ips = variable_get('sf_notifications_allowed_ips', FALSE);
$allowed_ips = $ips === FALSE ? sf_notifications_default_allowed_ips() : explode("\n", $ips);
$access = FALSE;
if (in_array($ip, $allowed_ips, TRUE)) {
$access = TRUE;
}
else {
foreach ($allowed_ips as $range) {
if (_sf_notifications_cidr_match($ip, $range)) {
$access = TRUE;
}
}
}
if ($access) {
salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce Notifications: IP address @ip accessed @endpoint successfully.', array(
'@ip' => $_SERVER['REMOTE_ADDR'],
'@endpoint' => SALESFORCE_PATH_NOTIFICATIONS_ENDPOINT,
));
}
else {
salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce Notifications: Access denied to IP address @ip in attempt to access @endpoint.', array(
'@ip' => $_SERVER['REMOTE_ADDR'],
'@endpoint' => SALESFORCE_PATH_NOTIFICATIONS_ENDPOINT,
));
}
return $access;
}