mirror of
https://github.com/bcit-ci/CodeIgniter.git
synced 2025-02-20 11:13:29 +08:00
...
parent
a09190a3af
commit
88da2e1c75
@ -338,63 +338,3 @@ function valid_country($countrycode='') {
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
}[/code]
|
}[/code]
|
||||||
|
|
||||||
|
|
||||||
=================[size=4]Code[/size]========================
|
|
||||||
|
|
||||||
[size=3]valid_ip[/size]
|
|
||||||
|
|
||||||
[size=5][b]
|
|
||||||
NOTE: Why this function ?
|
|
||||||
We have in CI $this->input->valid_ip($ip)
|
|
||||||
|
|
||||||
Edit by Elite Media
|
|
||||||
[/b][/size]
|
|
||||||
|
|
||||||
|
|
||||||
[url=http://codeigniter.com/forums/member/49849/]Author: Higher Logic[/url]
|
|
||||||
[code]
|
|
||||||
/**
|
|
||||||
* Checks for a valid IP address
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function is_ipaddress($ip='') {
|
|
||||||
if(empty($ip)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strlen($ip) > 15) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = eregi_replace('([0-9\.]+)', '', $ip);
|
|
||||||
|
|
||||||
if(!empty($data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$chunks = explode('.', $ip);
|
|
||||||
|
|
||||||
if(count($churnks) != 4) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(list($key, $val) = each($chunks)) {
|
|
||||||
if(ereg('^0', $val)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = $val;
|
|
||||||
settype($num, 'integer');
|
|
||||||
|
|
||||||
if($num > 255) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}[/code]
|
|
Loading…
x
Reference in New Issue
Block a user