Functions:ipBlockCheck

From Whirlwind eCommerce Wiki
Jump to: navigation, search

Description

eV::ipBlockCheck($ipAddress,$forwardOnBlock) checks if the passed IP address has been selected in administration as a 'blocked' address. Blocked addresses have been selected in administration from form submission tools including campaign subscribers, custom forms, poll/forum postings, etc. IP blocking is used to curve spam and inappropriate form submission on the web site. An IP is blocked with the intention of not allowing visitors from the blocked IP to submit form data anywhere on the site.

Syntax

$bool = eV::ipBlockCheck($ipAddress[,$forwardOnBlock]);

Paramaters

  • $ipAddress STRING REQUIRED
IP address to be checked.
  • $forwardOnBlock STRING OPTIONAL
URL to redirect visitor to, if ip block check returns TRUE (meaning they are designated as blocked). If not passed, boolean TRUE/FALSE will be returned instead.

Return Values

Boolean TRUE/FALSE is returns IF $forwardOnBlock is not passed or empty. TRUE is returned if the IP address IS BLOCKED. FALSE is returned if IP address IS NOT BLOCKED.

Examples

Example using redirect
// forward to home page with message
// if visitor's IP is blocked
// recommend placing in the pre-process block of the template
eV::ipBlockCheck($_SERVER['REMOTE_ADDR'],'index.php?message=You are blocked and cannot view the requested page');
Example not using redirect
// Check if ip address is blocked
// return content appropriate
$isBlocked = eV::ipBlockCheck($_SERVER['REMOTE_ADDR']);
if($isBlocked){
echo "Your IP is blocked";
} else {
echo "YOur IP is not blocked";
};