Skip to content

Commit

Permalink
Remote getInstance() from validation protected methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Jan 5, 2010
1 parent 1302fba commit 485570d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions cake/libs/validation.php
Expand Up @@ -556,10 +556,10 @@ function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
function ip($check, $type = 'both') {
$_this =& Validation::getInstance();
$success = false;
if ($type === 'IPv4' || $type === 'both') {
if ($type === 'ipv4' || $type === 'both') {
$success |= $_this->_ipv4($check);
}
if ($type === 'IPv6' || $type === 'both') {
if ($type === 'ipv6' || $type === 'both') {
$success |= $_this->_ipv6($check);
}
return $success;
Expand All @@ -576,11 +576,10 @@ function _ipv4($check) {
if (function_exists('filter_var')) {
return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)) !== false;
}
$_this =& Validation::getInstance();
$_this->__populateIp();
$_this->check = $check;
$_this->regex = '/^' . $_this->__pattern['IPv4'] . '$/';
return $_this->_check();
$this->__populateIp();
$this->check = $check;
$this->regex = '/^' . $this->__pattern['IPv4'] . '$/';
return $this->_check();
}

/**
Expand All @@ -594,11 +593,10 @@ function _ipv6($check) {
if (function_exists('filter_var')) {
return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)) !== false;
}
$_this =& Validation::getInstance();
$_this->__populateIp();
$_this->check = $check;
$_this->regex = '/^' . $_this->__pattern['IPv6'] . '$/';
return $_this->_check();
$this->__populateIp();
$this->check = $check;
$this->regex = '/^' . $this->__pattern['IPv6'] . '$/';
return $this->_check();
}

/**
Expand Down

0 comments on commit 485570d

Please sign in to comment.