|
|
|
|
|
|
|
|
|
| |
IPv6 Detection class
@copyright 2002-2003 by Dynamix SARL
@author Ben Yacoub Hatem <hatem@php.net>
detect if an IP is IPv6
@param ip adresse ip א tester
@return true / false
|
<?php
class ipv6
{
function is_ipv6($ip = "")
{
if ($ip == "")
{
$ip = ipv6::get_ip();
}
if (substr_count($ip,":") > 0 && substr_count($ip,".") == 0){
return true;
} else {
return false;
}
}
/*
* Detect if an IP is IPv4
*
* @param ip adresse ip א tester
* @return true / false
*/
function is_ipv4($ip = "")
{
return !ipv6::is_ipv6($ip);
}
/*
* return user IP
*
* @return IP
*/
function get_ip()
{
return getenv ("REMOTE_ADDR");
}
/*
* Uncompress an IPv6 address
*
* @param ip adresse IP IPv6 א dיcompresser
* @return ip adresse IP IPv6 dיcompressי
*/
function uncompress_ipv6($ip ="")
{
if ($ip == "")
{
$ip = ipv6::get_ip();
}
if(strstr($ip,"::" ))
{
$e = explode(":", $ip);
$s = 8-sizeof($e)+1;
foreach($e as $key=>$val)
{
if ($val == "")
{
for($i==0;$i<=$s;$i++)
$newip[] = 0;
} else {
$newip[] = $val;
}
}
$ip = implode(":", $newip);
}
return $ip;
}
/*
* Compress an IPv6 address
*
* @param ip adresse IP IPv6 א compresser
* @return ip adresse IP IPv6 compressי
*/
function compress_ipv6($ip ="")
{
if ($ip == "")
{
$ip = ipv6::get_ip();
}
if(!strstr($ip,"::" ))
{
$e = explode(":", $ip);
$zeros = array(0);
$result = array_intersect ($e, $zeros );
if (sizeof($result) >= 6)
{
if ($e[0]==0) {$newip[] = "";}
foreach($e as $key=>$val)
{
if ($val !=="0")
{
$newip[] = $val;
}
}
$ip = implode("::", $newip);
}
}
return $ip;
}
}
/*
* IPv6 Compression
*/
echo " IPv6 compression : ".ipv6::compress_ipv6("0:0:0:0:0:0:0:1")."
n";
/*
* IPv6 Uncompression
*/
echo "IPv6 Uncompression : ".ipv6::uncompress_ipv6("::1")."
n";
/*
* Tester IPv6
*/
echo "Your IP is ".ipv6::get_ip()." et You're using : ";
echo (ipv6::is_ipv6())? "IPv6":"IPv4";
?> | | |
|
| Client classes for Dictionary servers UPDATED: 2000-06-06 Categories : Network, Search, Complete Programs, PHP Classes, PHP | | | Class that allows the PHP developer to establish connections with a POP3 mail server amd be able to list, retrieve and delete mail messages from a given mail box.
Categories : Network, Email, PHP, PHP Classes | | | base class to query the whois database Categories : Network, PHP, PHP Classes | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | DbObject - A PHP wrapper for working with various databases Categories : Databases, PHP, PHP Classes | | | The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP, PHP Classes, Java Script, AJAX, Databases | | | How to get the exit code and result of an exec() command. Categories : PHP, Network | | | Filter - A simple class that lets you use multiple functions to create custom filters. Categories : PHP, PHP Classes, Strings | | | PHP5 SQLite Abstraction class Categories : PHP, PHP Classes, SQLite, Databases | | | Customizable Calendar Class Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | Browser Detecor Class Categories : PHP Classes, PHP, HTML | | | Bs_IniHandler is a class that can read and write ini-style files (and strings) Categories : PHP, Filesystem, PHP Classes | | | PostGreSQL and MySQL 2 in 1 db Manager Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL | | | [PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more. Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL | |
| |
| |
|