randomize banners
<script language="JavaScript"> <!-- function adArray() { for (i=0; i*2<adArray.arguments.length; i++) { this = new Object(); this.src = adArray.arguments[i*2]; this.href = adArray.arguments[i*2+1]; } this.length = i; } function getAdNum() { dat = new Date(); dat = (dat.getTime()+"").charAt(; if (dat.length == 1) ad_num = dat%ads.length; else ad_num = 0; return ad_num; } var ads = new adArray( "http://www.simpleplan-il.com/ps/pro-sky.jpg","http://www.simpleplan-il.com", "http://www.simpleplan-il.com/templates/AA.gif","http://www.simpleplan-il.com", "http://www.simpleplan-il.com/templates/ab.gif","http://www.simpleplan-il.com"); var ad_num = getAdNum(); // don't change this line document.write('' +'The script by' +'Alon Askalsky ' +'<A HREF="'+ads[ad_num].href+'">'); // ****** YOU NEED NOT MODIFY ANYTHING THAT IS NOT IN BETWEEN THESE TWO COMMENTS **** link_num = document.links.length-1; function rotateSponsor() { if (document.images) { ad_num = (ad_num+1)%ads.length; document.js_ad.src = ads[ad_num].src; document.links[link_num].href = ads[ad_num].href; setTimeout("rotateSponsor()",45000); } } setTimeout("rotateSponsor()",45000); // --> </script>Source codes, small scripts...
Started on the old forum in June 2006 · view the original in the archive · old links redirect here
TL;DR · summary of 124 replies
- - The scripts and codes related to redirection, user online status, image resizer, PHP file upload script, and environment variables were discussed.
- - No specific fix or code approach was provided for the Wap Useronline Sql tables script or the randomize banners script.
- - The existence of a function to detect spammer emails was mentioned but no detailed code approach was given.
Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.
Function to get the real ip, eg if someony is using proxy server.
function getRemoteInfo () {
$proxy="";
$IP = "";
if (isSet($_SERVER)) {
if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
$proxy = $_SERVER["REMOTE_ADDR"];
} elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
$IP = $_SERVER["HTTP_CLIENT_IP"];
} else {
$IP = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$IP = getenv( 'HTTP_X_FORWARDED_FOR' );
$proxy = getenv( 'REMOTE_ADDR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$IP = getenv( 'HTTP_CLIENT_IP' );
} else {
$IP = getenv( 'REMOTE_ADDR' );
}
}
if (strstr($IP, ',')) {
$ips = explode(',', $IP);
$IP = $ips[0];
}
$RemoteInfo[0]=$IP;
$RemoteInfo[1]=@GetHostByAddr($IP);
$RemoteInfo[2]=$proxy;
return $RemoteInfo;
}
Advertise your mobile site for FREE with AdTwirl
If you use the explode user agent to get the mobile phone model, you will find out that on most new nokia phones you will get Mozilla instaed of NokiaN95 etc, here is a small function which helps to get the phone model from useragent.
function mobile_phone($_mob_ua)
{
$_position=strpos($_mob_ua,"Nokia");
if($_position)$_mob_ua = substr($_mob_ua, $_position,25);
else $_mob_ua=$_mob_ua;
$phone = explode ('/', $_mob_ua);
return $phone[0];
}
usage :
echo 'Best for '.mobile_phone($_SERVER['HTTP_USER_AGENT']).'
';
Advertise your mobile site for FREE with AdTwirl
none of shown source code viewers work, so i create my own, here it is,
<?include("header.php");?>
<?
if(isset($_GET['go']) && $_GET['go'] == 'view')
** {
?>
<wml>
<card id="rezultat" title="Source Viewer">
<p align="center">
Source Sajta: [url="$(url)"]$(url)[/url]
<? $url = $_POST['url']; $ff= @htmlspecialchars(file_get_contents($url)); if(!$ff) {?>
Greska: Sajt ne postoji!
<anchor><prev/>Nazad</anchor>
-----
<?} if(ereg("http://",$url)) { echo"$ff"; } else { ?>
Greska: Adresa sajta nije validna!
<anchor><prev/>Nazad</anchor>
<? } ?>
-----
<anchor><prev/>Nazad</anchor>
[url="http://coding-talk.com/f14/?go=main"]Glavna[/url]
</p>
</card>
</wml>
<?
exit;
}
?>
<wml>
<card id="index" title="Source Viewer">
<p align="center">
Unesite URL:
<input type="text" name="url" maxlength="30" emptyok="false" value="http://"/>
<anchor>Ok<go href="<?echo $PHP_SELF;?>?go=view" method="post">
<postfield name="url" value="$(url)"/></go></anchor>
-----
[url="http://coding-talk.com/f14/?go=main"]Glavna[/url]
</p>
</card></wml>
it is good looking script External image (may be gone) and it works 100%, on every hosting... o yes, External image (may be gone) here is the header.php
<?
header("Content-type: text/vnd.wap.wml");
header("Cache-control: no-store,no-cache,must-revalidate");
print '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';
?>
generate a random password, eg if you want to send it by email to a user:
$password = substr(preg_replace('/\W/', '', md5(rand())), 0, 8);
Advertise your mobile site for FREE with AdTwirl
bb code function:
function bbcode($text)
{
// global $smilies;
$text=htmlspecialchars($text);
$text=preg_replace("/\[b\]\[big\](.*?)\[\/b\]\[\/big\]/i","[b]<big>\\1</big>[/b]", $text);
$text=preg_replace("/\[big\]\[b\](.*?)\[\/big\]\[\/b\]/i","[b]<big>\\1</big>[/b]", $text);
$text=preg_replace("/\[u\]\[big\](.*?)\[\/u\]\[\/big\]/i","[u]<big>\\1</big>[/u]", $text);
$text=preg_replace("/\[big\]\[u\](.*?)\[\/big\]\[\/u\]/i","[u]<big>\\1</big>[/u]", $text);
$text=preg_replace("/\[b\]\[u\](.*?)\[\/b\]\[\/u\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[u\]\[b\](.*?)\[\/u\]\[\/b\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[b\]\[i\](.*?)\[\/b\]\[\/i\]/i","[b][i]\\1[/i][/b]", $text);
$text=preg_replace("/\[i\]\[b\](.*?)\[\/i\]\[\/b\]/i","[b][i]\\1[/i][/b]", $text);
$text=preg_replace("/\[b\]\[u\](.*?)\[\/b\]\[\/u\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[u\]\[b\](.*?)\[\/u\]\[\/b\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[b\]\[small\](.*?)\[\/b\]\[\/small\]/i","[size="1"][b]\\1[/b][/size]", $text);
$text=preg_replace("/\[small\]\[b\](.*?)\[\/small\]\[\/b\]/i","[size="1"][b]\\1[/b][/size]", $text);
$text=preg_replace("/\[i\]\[small\](.*?)\[\/i\]\[\/small\]/i","[size="1"][i]\\1[/i][/size]", $text);
$text=preg_replace("/\[small\]\[i\](.*?)\[\/small\]\[\/i\]/i","[size="1"][i]\\1[/i][/size]", $text);
$text=preg_replace("/\[u\]\[small\](.*?)\[\/u\]\[\/small\]/i","[size="1"][u]\\1[/u][/size]", $text);
$text=preg_replace("/\[small\]\[u\](.*?)\[\/small\]\[\/u\]/i","[size="1"][u]\\1[/u][/size]", $text);
$text=preg_replace("/\[b\]\[big\](.*?)\[\/b\]\[\/big\]/i","<big>[b]\\1[/b]</big>", $text);
$text=preg_replace("/\[big\]\[b\](.*?)\[\/big\]\[\/b\]/i","<big>[b]\\1[/b]</big>", $text);
$text=preg_replace("/\[i\]\[big\](.*?)\[\/i\]\[\/big\]/i","<big>[i]\\1[/i]</big>", $text);
$text=preg_replace("/\[big\]\[i\](.*?)\[\/big\]\[\/i\]/i","<big>[i]\\1[/i]</big>", $text);
$text=preg_replace("/\[u\]\[big\](.*?)\[\/u\]\[\/big\]/i","<big>[u]\\1[/u]</big>", $text);
$text=preg_replace("/\[big\]\[u\](.*?)\[\/big\]\[\/u\]/i","<big>[u]\\1[/u]</big>", $text);
$text=preg_replace("/\[b\](.*?)\[\/b\]/i","[b]\\1[/b]", $text);
$text=preg_replace("/\[u\](.*?)\[\/u\]/i","[u]\\1[/u]", $text);
$text=preg_replace("/\[i\](.*?)\[\/i\]/i","[i]\\1[/i]", $text);
$text=preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>", $text);
$text=preg_replace("/\[small\](.*?)\[\/small\]/i","[size="1"]\\1[/size]", $text);
$text=preg_replace("/\[br\/\]/i","
", $text);
$text=preg_replace("/\[url\](.*?)\[\/url\]/i","<a href=\"\\1\">\\1</a>", $text);
$text=preg_replace("/\[link\=(.*?)\](.*?)\[\/link\]/i","<a href=\"\\1\">\\2</a>", $text);
$text=preg_replace("/\[img\=((.*?)(.jpg|jpeg))\]/i","<a href=\"\\1\"><img src=\"\\1\" alt=\"***\"/></a>", $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','[email="\\1"]\\1[/email]', $text);
}
Advertise your mobile site for FREE with AdTwirl
function to get members age :
////////////////////////////GET USERS AGE//////////////////////////////////
function getage($birthdate)
{
list($day, $month, $year) = split('-', $birthdate);
$tmonth = date('n');
$tday = date('j');
$tyear = date('Y');
$years = $tyear - $year;
if ($tmonth <= $month)
{
if ($month == $tmonth)
{
if ($day > $tday)$years--;
}
else $years--;
}
return $years;
}
usage
echo getage("30-05-1982");
Advertise your mobile site for FREE with AdTwirl
Function to cut html tags from a text, can be used to remove html tags from rss news
function theRealStripTags($string)
{
//while there are tags left to remove
while(strstr($string, '>'))
{
//find position of first carrot
$currentBeg = strpos($string, '<');
//find position of end carrot
$currentEnd = strpos($string, '>');
//find out if there is string before first carrot
//if so save it in $tmpstring
$tmpStringBeg = @substr($string, 0, $currentBeg);
//find out if there is string after last carrot
//if so save it in $tmpStringEnd
$tmpStringEnd = @substr($string, $currentEnd + 1, strlen($string));
//cut the tag from the string
$string = $tmpStringBeg.$tmpStringEnd;
}
return $string;
}
Advertise your mobile site for FREE with AdTwirl
It displays a random quote on a web page. Quotes are picked from a list that you define.
<?php
/**
* Add this line of code in your page:
* <?php include "random_quote.php"; ?>
*/
$quotes[] = "This is a quote";
$quotes[] = "This is another";
$quotes[] = "quote 3";
$quotes[] = "quote 4";
$quotes[] = "quote 5";
$quotes[] = "quote 6";
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo "
" . $quotes[$randomquote] . "</p>";
?>
It allows visitors to your site to read your guestbook entries and post a message of their own. Very simple setup, only requires you to change 4 settings. Uses MySQL to store the entries.
<?php
/**
* Create the table in your MySQL database:
*
* CREATE TABLE guests (
* id int(10) NOT NULL auto_increment,
* name varchar(50) NOT NULL,
* message varchar(255) NOT NULL,
* date timestamp(14) NOT NULL,
* PRIMARY KEY (id)
* )
*
* Change the database login settings to your own
*
* The script is now ready to run
*/
// Change these to your own database settings
$host = "localhost";
$user = "username";
$pass = "password";
$db = "database";
mysql_connect($host, $user, $pass) OR die ("Could not connect to the server.");
mysql_select_db($db) OR die("Could not connect to the database.");
$name = stripslashes($_POST['txtName']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
$query = "SELECT id, name, message, DATE_FORMAT(date, '%D %M, %Y @ %H:%i') as newdate FROM guests ORDER BY id DESC";
$result = mysql_query($query);
while ($row = mysql_fetch_object($result)) {
?>
<?php echo $row->message; ?>
Posted by <?php echo $row->name; ?> on <?php echo $row->newdate; ?></p>
<?php
}
?>
Post a message</p>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<label for="txtName">Name:</label>
<input type="text" title="Enter your name" name="txtName" /></p>
<label for="txtMessage">Your message:</label>
<textarea title="Enter your message" name="txtMessage"></textarea></p>
<label title="Send your message">
<input type="submit" value="Send" /></label></p>
</form>
<?php
}
else {
// Adds the new entry to the database
$query = "INSERT INTO guests SET message='$message', name='$name', date=NOW()";
$result = mysql_query($query);
// Takes us back to the entries
$ref = $_SERVER['HTTP_REFERER'];
header ("Location: $ref");
}
?>
hit counter
<?php
/**
* Create an empty text file called counterlog.txt ,Chmod 777 it and**
* upload to the same directory as the page you want to**
* count hits for.
***
* Add this line of code on your page:
* <?php include "text_file_hit_counter.php"; ?>
*/
// Open the file for reading
$fp = fopen("counterlog.txt", "r");
// Get the existing count
$count = fread($fp, 1024);
// Close the file
fclose($fp);
// Add 1 to the existing count
$count = $count + 1;
// Display the number of hits
// If you don't want to display it, comment out this line
echo "
Page views:" . $count . "</p>";
// Reopen the file and erase the contents
$fp = fopen("counterlog.txt", "w");
// Write the new count to the file
fwrite($fp, $count);
// Close the file
fclose($fp);
?>
It displays a hyperlinked list of all the files contained in a specified folder. A really simple way to have your own directory browser, just drop the file in the folder and it will show an index of all files in the directory on your webspace.
<?
/**
* Change the path to your folder.
*
* This must be the full path from the root of your
* web space. If you're not sure what it is, ask your host.
*
* Name this file index.php and place in the directory.
*/
// Define the full path to your folder from root
$path = "/home/user/public/foldername/";
// Open the folder
$dir_handle = @opendir($path) or die("Unable to open $path");
// Loop through the files
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo "<a href=\"$file\">$file</a>
";
}
// Close
closedir($dir_handle);
?>
A simple form mail PHP script that displays a contact form to allow visitors to your site to send you a message via email. Built in security prevents spammers hijacking it from another domain.
<?php
/**
* Change the email address to your own.
*
* $empty_fields_message and $thankyou_message can be changed
* if you wish.
*/
// Change to your own email address
$your_email = "you@example.com";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "Message via your contact form";
// This is displayed if all the fields are not filled in
$empty_fields_message = "
Please go back and complete all the fields in the form.</p>";
// This is displayed when the email has been sent
$thankyou_message = "
Thankyou. Your message has been sent.</p>";
// You do not need to edit below this line
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<label for="txtName">Name:</label>
<input type="text" title="Enter your name" name="txtName" /></p>
<label for="txtEmail">Email:</label>
<input type="text" title="Enter your email address" name="txtEmail" /></p>
<label for="txtMessage">Your message:</label>
<textarea title="Enter your message" name="txtMessage"></textarea></p>
<label title="Send your message">
<input type="submit" value="Send" /></label></p>
</form>
<?php
}
elseif (empty($name) || empty($email) || empty($message)) {
echo $empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL.";
exit;
}
// The URLs matched so send the email
mail($your_email, $subject, $message, "From: $name <$email>");
// Display the thankyou message
echo $thankyou_message;
}
?>
Detect mobile os:
function detect_os ($ua) {
if (preg_match('#PalmOS#i', $ua)) {
$os_name = "Palm OS";
$os_code = "palm";
} elseif (preg_match('#Windows CE#i', $ua)) {
$os_name = "Windows CE";
$os_code = "windows";
} elseif (preg_match('#QtEmbedded#i', $ua)) {
$os_name = "Qtopia";
$os_code = "linux";
} elseif (preg_match('#Zaurus#i', $ua)) {
$os_name = "Linux";
$os_code = "linux";
} elseif (preg_match('#Symbian#i', $ua)) {
$os_name = "Symbian OS";
$os_code = "symbian";
}
if (preg_match('#PalmOS/sony/model#i', $ua)) {
$pda_name = "Sony Clie";
$pda_code = "sony";
} elseif (preg_match('#Zaurus ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$pda_name = "Sharp Zaurus " . $matches[1];
$pda_code = "zaurus";
$pda_ver = $matches[1];
} elseif (preg_match('#Series ([0-9]+)#i', $ua, $matches)) {
$pda_name = "Series";
$pda_code = "nokia";
$pda_ver = $matches[1];
} elseif (preg_match('#Nokia ([0-9]+)#i', $ua, $matches)) {
$pda_name = "Nokia";
$pda_code = "nokia";
$pda_ver = $matches[1];
} elseif (preg_match('#SIE-([a-zA-Z0-9]+)#i', $ua, $matches)) {
$pda_name = "Siemens";
$pda_code = "siemens";
$pda_ver = $matches[1];
} elseif (preg_match('#dopod([a-zA-Z0-9]+)#i', $ua, $matches)) {
$pda_name = "Dopod";
$pda_code = "dopod";
$pda_ver = $matches[1];
} elseif (preg_match('#o2 xda ([a-zA-Z0-9 ]+);#i', $ua, $matches)) {
$pda_name = "O2 XDA";
$pda_code = "o2";
$pda_ver = $matches[1];
} elseif (preg_match('#SEC-([a-zA-Z0-9]+)#i', $ua, $matches)) {
$pda_name = "Samsung";
$pda_code = "samsung";
$pda_ver = $matches[1];
} elseif (preg_match('#SonyEricsson ?([a-zA-Z0-9]+)#i', $ua, $matches)) {
$pda_name = "SonyEricsson";
$pda_code = "sonyericsson";
$pda_ver = $matches[1];
} elseif (preg_match('#Wii#i', $ua, $matches)) {
$pda_name = "Nintendo Wii";
$pda_code = "wii";
}
return array($os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver);
}
usage:
$info=detect_os ($_SERVER['HTTP_USER_AGENT']);
echo 'OS name: '.$info[0].'
';
echo 'OS code: '.$info[1].'
';
echo 'OS version: '.$info[2].'
';
echo 'Brand: '.$info[3].'
';
//echo 'Phone code: '.$info[4].'
';
echo 'Model: '.$info[5].'
';
this function I took from counterize mod for wordpress (_http://wordpress.org/extend/plugins/counterizeii/) but its also useful for your mobile sites
Advertise your mobile site for FREE with AdTwirl
Near begining of index.php find $brws line and change to this
$brws = explode(" ",$_SERVER['HTTP_USER_AGENT']);
$ubr = $brws[0];
$uip = getip();
$action = $_GET["action"];
$sid = $_GET["sid"];
$page = $_GET["page"];
$who = $_GET["who"];
It works at my place and detect Opera,Nokia,Samsung ... and their versions too (:
Ban IP range:
$getip = $_SERVER["REMOTE_ADDR"];
$banned_ip = array();
$banned_ip[] = '194.9.94.*';
$banned_ip[] = '77.105.2.*';
foreach($banned_ip as $banned)
{
$blacked=str_replace('*', '', $banned);
$len=strlen($blacked);
if ($ip==$blacked || substr($getip, 0, $len)==$blacked)
{
echo 'You are banned!';
exit;
}
}
Advertise your mobile site for FREE with AdTwirl
Unique Hitcounter
<?php
$ip=$_SERVER[REMOTE_ADDR];
$file=file_get_contents("ipLog.txt");
if(substr_count($file, $ip)==0) {
$file.="\n" . $ip;
}
file_put_contents("ipLog.txt", $file);
$total=substr_count($file, "\n");
echo "$total";
?>
make a ipLog.txt in the same directory and chmod777
Siple WML guestbook Create a WML Form to Collect user's comments, name and email address. Save following code as Guestbook.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd" >
<wml>
<card>
<p align="center">Guest Book!</p>
Your Name : <input type="text" name="user_name"/>
Your Email: <input type="text" name="user_email"/>
Your Comments : <input type="text" name="user_comments"/>
<anchor>
<go href="save_comments.php" method="post">
<postfield name="user_name" value="$user_name"/>
<postfield name="user_email" value="$user_email"/>
<postfield name="user_commetns" value="$user_comments"/>
</go>
Please Click Here To SEND
</anchor>
</card>
</wml>
</FONT> And now create an-other file. This file contains PHP code to Create text file (user_comments.txt) in C:\. User_comments.txt file will hold all data submit by Users.
(Note : Save following file as save_comments.php and don't forget to save this both files in same directory)
<FONT FACE="Courier New" COLOR="#008000"> /* Before Commercial use don't forget to ask me [email]yadish_sahar@hotmail.com[/email]</FONT><FONT FACE="Courier New" COLOR="#008000"> */
<? header("Content-type:text/vnd.wap.wml");
if (isset($user_name) and isset($user_email)
and isset($user_comments) and ($user_name and $user_email and $user_comments != ""))
{
$file_name="c:\user_comments.txt";
$file_data = fopen($file_name ,"a");
$data_to_write = "User Name is :".$user_name."\n".
"Email Address is :".$user_email."\n".
"He/She Submit this Comments :".$user_comments."\n".
"*************************\n\n";
fwrite($file_data,$data_to_write);
fclose($file_data);
echo "<?xml version=\"1.0\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\" >
<wml>
<card>
<p align=\"center\">Thank You!</p>
Your Comments is Saved. Thank you very much again
</card></wml>";
}
else
{
Echo "<?xml version=\"1.0\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\" >
<wml>
<card>
Some thing is Wrong with Your Form Submission!
</p>
</card></wml>";
}
?>
get country by ip address, you need url_fopen enabled
<?php
/**
* @author Milomir
* @copyright 2008
*/
function GetCountry($IpAddr){
$APIUrl = "http://api.hostip.info/country.php?ip=" . $IpAdds . "";
$GetCID = fopen($APIUrl, "r");
while($CIData = fread($GetCID, 1024)){
**$ReadCID .= $CIData;
}
if(($ReadCID == "YU") or ($ReadCID == "RS")){
**$Country = "Serbia";
} elseif($ReadCID == "US"){
**$Country = "United States";
} else {
**$Country = "Unknown";
}
fclose($GetCID);
return $Country;
}
?>
usage
<?php
echo "Ip: " . $_SERVER["REMOTE_ADDR"] . "
\n";
echo "Country: " . GetCountry($_SERVER["REMOTE_ADDR"]) . "\n";
?>
i have added only two countrys to this, you need to add others by yourself, follow my example..