WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Sample usage of IPv6 and IPv4 with PHP
Categories : PHP, PHP Classes, Network Click here to Update Your Picture
Ben Yacoub Hatem
Date : Jun 19th 2004
Grade : 2 of 5 (graded 3 times)
Viewed : 5979
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ben Yacoub Hatem
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 



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";
?>



Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
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
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
News management class
Categories : PHP, PHP Classes, Beginner Guides
A Timing Class
Categories : PHP, PHP Classes, Date Time
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags.
Categories : PHP, PHP Classes, Algorithms, Security
RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
MS Word Mail Merge Automation (COM)
Categories : PHP, PHP Classes, COM
Very minimal templating engine
Categories : PHP, PHP Classes, Templates