Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Graphics sample source codes
Couple of functions that convert an IP address into its color code and not-color-code
Couple of functions that convert an IP address into its color code and not-color-code /*this function converts $ipaddr into a color string*/ function IP2Color($ipaddr) { $pieces=explode(".",$ipaddr); $color=""; for($i=0;$i<3;$i++) { if(($pieces[$i]>=0) && ($pieces[$i]<=255)) { $color.=dechex($pieces[$i]); } } $color=substr($color."000000",0,6); return("#".strtoupper($color)); } /*this function converts $ipaddr to anti color string*/ function IP2NotColor($ipaddr) { $pieces=explode(".",$ipaddr); $color=""; for($i=0;$i<3;$i++) { if(($pieces[$i]>=0) && ($pieces[$i]<=255)) { $color.=dechex((128+$pieces[$i]) % 255); } } $color=substr($color."000000",0,6); return("#".strtoupper($color)); } Example: $IP=getenv("REMOTE_ADDR"); print "
\n"; print "
$IP</font></td>\n"; print "</tr></table>\n"; ?>
Privacy Policy
|
Link to Us
|
Links