<?php
/***************************************************************************
* ipchecker.php
*
* Wed Mar 31 11:20:01 2003
* Copyright 2003 peterflor
* Author : J. Pedro Flor
* E-Mail : peterflor@yahoo.com
*
* This function check the integrity of an IPv4 number.
* Also, allow to check octet by octet after first validation.
* The result value can be a plain "string" or (for more flexibility) an array.
*
* array = [octet-1][dot-1][octet-2][dot-2][octet-3][dot-3][octet-4]
* elements = [0] [1] [2] [3] [4] [5] [6]
* ==> A.B.C.D <==
*
* (Created with Anjuta)
*
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* TODO LIST
*
* First of all: correct my english and of course, correct variable names.
*
*/
// IPv4 PHP-Checker
function check_ip($ip_target) {
Adam Namejko wrote :918
Could the function not be made more simple by using regular expression matching. I`m not the best out there, but this works I believe.
if (!preg_match("/^$pattern$/", $ip_target)) {
print(`Error.`);
exit;
}
return $ip_target;
}
tomas dzurilla wrote :922
hi,
i was trying to use the function, but on the 20th (not counting comments) line there is an undefined function "ctype_digit". what is that function? thanks. t