¿ù°£ Àα⠰Խù°

°Ô½Ã¹° 30°Ç
   
Á¢¼Ó±¹°¡ È®ÀÎ ¹× ¸®´ÙÀÌ·ºÆ®
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2011-05-20 (±Ý) 14:03 Á¶È¸ : 7423
±ÛÁÖ¼Ò :
                          

 

Sample scripts: Output full country name

<?php
	
	$server   = ''; // MySQL hostname
	$username = ''; // MySQL username
	$password = ''; // MySQL password
	$dbname   = ''; // MySQL db name
	
	
	$db = mysql_connect($server, $username, $password) or die(mysql_error());
	      mysql_select_db($dbname) or die(mysql_error());
	
	$sql = 'SELECT 
	            c.country 
	        FROM 
	            ip2nationCountries c,
	            ip2nation i 
	        WHERE 
	            i.ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") 
	            AND 
	            c.code = i.country 
	        ORDER BY 
	            i.ip DESC 
	        LIMIT 0,1';
	
	list($countryName) = mysql_fetch_row(mysql_query($sql));
	
	// Output full country name
	echo $countryName;
	
?>			
 
 

Sample scripts: Country based redirection

<?php
	
	$server   = ''; // MySQL hostname
	$username = ''; // MySQL username
	$password = ''; // MySQL password
	$dbname   = ''; // MySQL db name
	
	
	$db = mysql_connect($server, $username, $password) or die(mysql_error());
	      mysql_select_db($dbname) or die(mysql_error());
			
	$sql = 'SELECT 
	            country
	        FROM 
	            ip2nation
	        WHERE 
	            ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") 
	        ORDER BY 
	            ip DESC 
	        LIMIT 0,1';
	
	list($country) = mysql_fetch_row(mysql_query($sql));
	
	switch ($country) {
		case 'se':
			// Get the Swedish to a Swedish newssite
			header('Location: http://www.thelocal.se/');
			exit;
		case 'us':
			// And redirect US visitors to CNN
			header('Location: http://www.cnn.com/');
			exit;
		default:
			// The rest of the world can go to BBC
			header('Location: http://www.bbc.co.uk/');
			exit;
	}
	
?>			

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.