• پایان فعالیت بخشهای انجمن: امکان ایجاد موضوع یا نوشته جدید برای عموم کاربران غیرفعال شده است

هدایت کردن خارجی ها به بخش انگلیسی

elnaz85

Registered User
تاریخ عضویت
22 ژانویه 2007
نوشته‌ها
364
لایک‌ها
1
من یه کد می خوام که هر کسی که از خارج از کشور وارد سایتم میشه رو به یه صفحه انگلیسی سایت هدایت کنه
 

Neo.BHK

کاربر تازه وارد
تاریخ عضویت
22 آپریل 2007
نوشته‌ها
338
لایک‌ها
1
محل سکونت
Tehran
سلام.
يعني از روي IP منظورته ؟؟
 

Neo.BHK

کاربر تازه وارد
تاریخ عضویت
22 آپریل 2007
نوشته‌ها
338
لایک‌ها
1
محل سکونت
Tehran
براي اينكه همه به جز ايراني ها برن به اون صفحه اي كه مي خواي بايد اونا رو از طريق ip‌ تفكيك كني ...
اين كار هم نياز به اين داره كه شما از يه جا بدوني كه چه ip براي چه كشوري هست ... ؟!
كه همون ديتابيس ip‌ لازمه احتمالا ...
ولي اگر فقط براي چند جا رو بخوي كه هدايت كني بايد مثل اين كد عمل كني :​


کد:
    <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesLocationCode,GeobytesCode,GeobytesInternet"></script> 
    <script language="Javascript"> 
    if(typeof(sGeobytesLocationCode)=="undefined" 
       ||typeof(sGeobytesCode)=="undefined" 
       ||typeof(sGeobytesInternet)=="undefined") 
    { 
       // Something has gone wrong with the variables, so set them to some default value, 
       // maybe set a error flag to check for later on. 
       var sGeobytesLocationCode="unknown"; 
       var sGeobytesCode="unknown"; 
       var sGeobytesInternet="unknown"; 
    } 
    if(sGeobytesLocationCode=="UKENGRIM") 
    { 
       // Visitors from Grimsby would go here 
       window.open("enter Grimsby URL here"); 
    }else if(sGeobytesCode=="EN") 
    { 
       // Visitors from England would go here 
       window.open("enter England URL here"); 
    }else if(sGeobytesInternet=="UK") 
    { 
       // Visitors from The United Kingdom would go here 
       window.open("enter United Kingdom URL here"); 
    } 
    </script>
 

Neo.BHK

کاربر تازه وارد
تاریخ عضویت
22 آپریل 2007
نوشته‌ها
338
لایک‌ها
1
محل سکونت
Tehran
راستي اين لينك رو الان پيدا كردم ...
يه نگاهي بنداز شايد كمكت كنه
23.gif


لينك
 

elnaz85

Registered User
تاریخ عضویت
22 ژانویه 2007
نوشته‌ها
364
لایک‌ها
1
براي اينكه همه به جز ايراني ها برن به اون صفحه اي كه مي خواي بايد اونا رو از طريق ip‌ تفكيك كني ...
اين كار هم نياز به اين داره كه شما از يه جا بدوني كه چه ip براي چه كشوري هست ... ؟!
كه همون ديتابيس ip‌ لازمه احتمالا ...
ولي اگر فقط براي چند جا رو بخوي كه هدايت كني بايد مثل اين كد عمل كني :​


کد:
    <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesLocationCode,GeobytesCode,GeobytesInternet"></script> 
    <script language="Javascript"> 
    if(typeof(sGeobytesLocationCode)=="undefined" 
       ||typeof(sGeobytesCode)=="undefined" 
       ||typeof(sGeobytesInternet)=="undefined") 
    { 
       // Something has gone wrong with the variables, so set them to some default value, 
       // maybe set a error flag to check for later on. 
       var sGeobytesLocationCode="unknown"; 
       var sGeobytesCode="unknown"; 
       var sGeobytesInternet="unknown"; 
    } 
    if(sGeobytesLocationCode=="UKENGRIM") 
    { 
       // Visitors from Grimsby would go here 
       window.open("enter Grimsby URL here"); 
    }else if(sGeobytesCode=="EN") 
    { 
       // Visitors from England would go here 
       window.open("enter England URL here"); 
    }else if(sGeobytesInternet=="UK") 
    { 
       // Visitors from The United Kingdom would go here 
       window.open("enter United Kingdom URL here"); 
    } 
    </script>

میشه از این کد برای تشخیص دادن کاربران ایرانی استفاده کرد؟ اگه میشه، چه تغیری باید تو کد بدم فکر میکنم UK روباید تغییر داد درسته؟ اگه اینجوری بشه مشکلم حل میشه.
یه چیز دیگه، میشه این کد رو در سرور اجرا کرد؟ چجوری؟
 

IRDownload.ORG

کاربر تازه وارد
تاریخ عضویت
22 می 2007
نوشته‌ها
4
لایک‌ها
0
<?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 let the folks from american go to CNN
header('Location: http://www.cnn.com/');
exit;
default:
// The rest can go to BBC
header('Location: http://www.bbc.co.uk/');
exit;
}

?>
تو این کد برای اران باید چی بزاریم IR ???
 

firebird

Registered User
تاریخ عضویت
2 جولای 2005
نوشته‌ها
1,424
لایک‌ها
10
سن
47
PHP:
.
.
.
case 'ir':
header('Location: http://www.persiantools.com/');
exit;
.
.
.
 
بالا