|
|
|
|
|
|
| |
| <?php
/***************************************************************************
* ipchecker.php
*
* Wed Mar 26 00:16:06 2003
* Copyright 2003 peterflor
* Author : J. Pedro Flor
* E-Mail : peterflor@yahoo.com
*
* This function check the integrity of an IPv4 number.
*
* (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.
*/
//
// Chequeo de No. IPv4
//
function check_ip($ip_target) {
$length = strlen($ip_target);
$counter = 0;
$digit_number = 0;
$octet_number = 0;
$temporal_octet = "";
$dot_number = 0;
// Checking string length.
if (($length == 0) || ($length > 15)) {
print("Error.");
exit;
}
//
// Checking octet by octet
//
while($counter < $length){
if (ctype_digit($ip_target[$counter]) == TRUE ) {
$digit_number++;
if ($digit_number > 3){
print("Error.");
exit;
} else {
$temporal_octet= $temporal_octet. $ip_target[$counter];
}
} else {
if ($ip_target[$counter] == ".") {
$dot_number++;
$octet_number++;
if ($dot_number > 3) {
print("Error.");
exit;
}
if($octet_number == 1) {
if(($temporal_octet > 0) && ($temporal_octet < 256)) {
$temporal_octet= "";
} else {
print("Error.");
exit;
}
} else {
if(($temporal_octet >= 0) && ($temporal_octet < 256)) {
$temporal_octet= "";
} else {
print("Error.");
exit;
}
}
$digit_number = 0;
} else {
print("Error.");
exit;
}
}
$counter++;
}
//
// Tips and TRICKS ;)
//
if($octet_number < 3) {
print("Error.");
exit;
}
if(($temporal_octet >= 0) && ($temporal_octet < 256)) {
if ($temporal_octet == "") {
print("Error.");
exit;
}
} else {
print("Error.");
exit;
}
//
// Success.
//
return $ip_target;
}
?> | | |
|
| Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Boolean Keyword Interpreter Categories : PHP, Algorithms, Search Engines | | | Diffusion-Limited Aggregation visualization Categories : PHP, Graphics, Algorithms, Math. | | | Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL, Complete Programs, Algorithms, PHP, Databases | | | Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms | | | Fast PI calculator. Can easily find the 1000th decimal place of pi in 5 seconds. Categories : PHP, BC math, Algorithms | | | Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users). Categories : Algorithms, Email, PHP | | | A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays, PHP, Algorithms | | | The Porter Word Stemming Algorithm in PHP
Reduces words to their base stem for search engines and indexing Categories : Algorithms, PHP, Strings | | | SHA: Implementation of the Secure Hash Algorithm in pure PHP. This is a secure one-way function that can be used to perform challenge
response login algorithms over an insecure connection. Categories : Algorithms, PHP, Security | | | minus - subtract arrays. Send two arrays and get an array with the operation A-B, elements on A that are not included on B. Categories : PHP, Arrays, Algorithms | | | Calculate Body Mass Index Categories : PHP, Algorithms, Regexps | | | A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array. Categories : Algorithms, Arrays, PHP, Complete Programs | | | Paginating the mySQL data Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP | |
|
|
|