You are here: Re: Source of the user « PHP Programming Language « IT news, forums, messages
Re: Source of the user

Posted by IchBin on 09/21/06 14:22

Bob Bedford wrote:
> Hi all,
>
> We are having serious problem with scammers on our website
> To avoid this, we would like not to allow some countries to access our site.
> Is that possible ? how ? It is really precise ? I mean it's there any risk
> that we miss some clients due to the limitation ?
>
> Please help
>
> Bob
>
>
>

Off the top you can check out a recipe written for pmWiki that builds
website statics. One is statistics by countries.

The recipe is called TotalCounter:
http://www.pmwiki.org/wiki/Cookbook/TotalCounter

You can get the code here:
http://www.pmwiki.org/pmwiki/uploads/Cookbook/totalcounter.php

The code lines you will be interested in are:

// find location
if ($_SERVER['HTTP_X_FORWARDED_FOR'] != ''){
if (strstr($_SERVER['HTTP_X_FORWARDED_FOR'], ', ')){
$ips = explode(', ', $_SERVER['HTTP_X_FORWARDED_FOR']);
$thehost = $ips[0];
}else{
$thehost = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
}else{
if (strstr($_SERVER['REMOTE_HOST'], ', ')){
$ips = explode(', ', $_SERVER['REMOTE_HOST']);
$thehost = $ips[0];
}else{
$thehost = $_SERVER['REMOTE_HOST'];
}
}
if (preg_match("/[^\.0-9]+$/", $thehost, $matches) != 0) $loc =
$matches[0];
if ($loc != ''){
$tc_location = $loc;
}else{
if ($TotalCounterEnableLookup == 1){
$thehost =
@gethostbyaddr($_SERVER['REMOTE_ADDR']);
if (preg_match("/[^\.0-9]+$/", $thehost, $matches) != 0) $loc =
$matches[0];
if ($loc != ''){
$tc_location = $loc;
}else{
$tc_location = 'Unknown';
EMailForm('Location', $_SERVER['HTTP_USER_AGENT']);
}
}else{
$tc_location = 'Unknown';
EMailForm('Location', $_SERVER['HTTP_USER_AGENT']);
}
}
if ($tc_location != 'Unknown'){
$tc_location
=strtolower($tc_location);
EMailForm('Location', $_SERVER['HTTP_USER_AGENT']);
}
}


There is also a table of countries:

$alllocations = array(
'localhost'=>'localhost', 'Unknown'=>'Unknown',

'com'=>'Commercial', 'net'=>'Networks', 'org'=>'Organizations',
'aero'=>'Aviation', 'biz'=>'Business organizations',
'coop'=>'Co-operative organizations',
'edu'=>'Educational', 'gov'=>'US Government', 'info'=>'Info',
'int'=>'International organizations',
'mil'=>'US Dept of Defense', 'museum'=>'Museums', 'name'=>'Personal',
'travel'=>'Travelling',

'ac'=>'Ascension Island', 'ad'=>'Andorra', 'ae'=>'United Arab
Emirates', 'af'=>'Afghanistan',
'ag'=>'Antigua & Barbuda', 'ai'=>'Anguilla', 'al'=>'Albania',
'am'=>'Armenia',
'an'=>'Netherlands Antilles', 'ao'=>'Angola', 'aq'=>'Antarctica',
'ar'=>'Argentina',
'as'=>'American Samoa', 'at'=>'Austria', 'au'=>'Australia',
'aw'=>'Aruba', 'az'=>'Azerbaijan',

'ba'=>'Bosnia & Herzegovina', 'bb'=>'Barbados', 'bd'=>'Bangladesh',
'be'=>'Belgium',
'bf'=>'Burkina Faso', 'bg'=>'Bulgaria', 'bh'=>'Bahrain',
'bi'=>'Burundi', 'bj'=>'Benin',
'bm'=>'Bermuda', 'bn'=>'Brunei Darussalam', 'bo'=>'Bolivia',
'br'=>'Brazil', 'bs'=>'Bahamas',
'bt'=>'Bhutan', 'bv'=>'Bouvet Island', 'bw'=>'Botswana',
'by'=>'Belarus', 'bz'=>'Belize',

'ca'=>'Canada', 'cc'=>'Cocos (Keeling) Islands', 'cd'=>'Democratic
republic of Congo',
'cf'=>'Central African Republic', 'cg'=>'Congo', 'ch'=>'Switzerland',
'ci'=>'Ivory Coast',
'ck'=>'Cook Islands', 'cl'=>'Chile', 'cm'=>'Cameroon', 'cn'=>'China',
'co'=>'Colombia',
'cr'=>'Costa Rica', 'cs'=>'Czechoslovakia', 'cu'=>'Cuba', 'cv'=>'Cape
Verde',
'cx'=>'Christmas Island', 'cy'=>'Cyprus', 'cz'=>'Czech Republic',

'de'=>'Germany', 'dj'=>'Djibouti', 'dk'=>'Denmark', 'dm'=>'Dominica',
'do'=>'Dominican Republic', 'dz'=>'Algeria',

'ec'=>'Ecuador', 'ee'=>'Estonia', 'eg'=>'Egypt', 'eh'=>'Western
Sahara', 'er'=>'Eritrea',
'es'=>'Spain', 'et'=>'Ethiopia', 'eu'=>'European Union',

'fi'=>'Finland', 'fj'=>'Fiji', 'fk'=>'Falkland Islands',
'fm'=>'Micronesia',
'fo'=>'Faroe Islands', 'fr'=>'France',

'ga'=>'Gabon', 'gb'=>'United Kingdom', 'gd'=>'Grenada',
'ge'=>'Georgia', 'gf'=>'French Guiana',
'gg'=>'Guernsey', 'gh'=>'Ghana', 'gi'=>'Gibraltar',
'gl'=>'Greenland', 'gm'=>'Gambia',
'gn'=>'Guinea', 'gp'=>'Guadeloupe', 'gq'=>'Equatorial Guinea',
'gr'=>'Greece',
'gs'=>'South Georgia & South Sandwich Islands', 'gt'=>'Guatemala',
'gu'=>'Guam',
'gw'=>'Guinea-Bissau', 'gy'=>'Guyana',

'hk'=>'Hong Kong', 'hm'=>'Heard & McDonald Islands',
'hn'=>'Honduras', 'hr'=>'Croatia',
'ht'=>'Haiti', 'hu'=>'Hungary',

'id'=>'Indonesia', 'ie'=>'Ireland', 'il'=>'Israel', 'im'=>'Isle of
Man', 'in'=>'India',
'io'=>'British Indian Ocean Territory', 'iq'=>'Iraq', 'ir'=>'Iran',
'is'=>'Iceland', 'it'=>'Italy',

'je'=>'Jersey', 'jm'=>'Jamaica', 'jo'=>'Jordan', 'jp'=>'Japan',

'ke'=>'Kenya', 'kg'=>'Kyrgyzstan', 'kh'=>'Cambodia',
'ki'=>'Kiribati', 'km'=>'Comoros',
'kn'=>'Saint Kitts & Nevis', 'kp', 'North Korea', 'kr'=>'South
Korea', 'kw'=>'Kuwait',
'ky'=>'Cayman Islands', 'kz'=>'Kazakhstan',

'la'=>'Laos', 'lb'=>'Lebanon', 'lc'=>'Saint Lucia',
'li'=>'Liechtenstein', 'lk'=>'Sri Lanka',
'lr'=>'Liberia', 'ls'=>'Lesotho', 'lt'=>'Lithuania',
'lu'=>'Luxembourg', 'lv'=>'Latvia',
'ly'=>'Libyan Arab Jamahiriya',

'ma'=>'Morocco', 'mc'=>'Monaco', 'md'=>'Moldova',
'mg'=>'Madagascar','mh'=>'Marshall Islands',
'mk'=>'Macedonia', 'ml'=>'Mali', 'mm'=>'Myanmar', 'mn'=>'Mongolia',
'mo'=>'Macau',
'mp'=>'Northern Mariana Islands', 'mq'=>'Martinique',
'mr'=>'Mauritania', 'ms'=>'Montserrat',
'mt'=>'Malta', 'mu'=>'Mauritius', 'mv'=>'Maldives', 'mw'=>'Malawi',
'mx'=>'Mexico',
'my'=>'Malaysia', 'mz'=>'Mozambique',

'na'=>'Namibia', 'nc'=>'New Caledonia', 'ne'=>'Niger', 'nf'=>'Norfolk
Island', 'ng'=>'Nigeria',
'ni'=>'Nicaragua', 'nl'=>'The Netherlands', 'no'=>'Norway',
'np'=>'Nepal', 'nr'=>'Nauru',
'nu'=>'Niue', 'nz'=>'New Zealand',

'om'=>'Oman',

'pa'=>'Panama', 'pe'=>'Peru', 'pf'=>'French Polynesia', 'pg'=>'Papua
New Guinea',
'ph'=>'Philippines', 'pk'=>'Pakistan', 'pl'=>'Poland', 'pm'=>'St.
Pierre & Miquelon',
'pn'=>'Pitcairn', 'pr'=>'Puerto Rico', 'ps'=>'Palestine',
'pt'=>'Portugal', 'pw'=>'Palau',
'py'=>'Paraguay',

'qa'=>'Qatar',

're'=>'Reunion', 'ro'=>'Romania', 'ru'=>'Russia', 'rw'=>'Rwanda',

'sa'=>'Saudi Arabia', 'sb'=>'Solomon Islands', 'sc'=>'Seychelles',
'sd'=>'Sudan', 'se'=>'Sweden',
'sg'=>'Singapore', 'sh'=>'St. Helena', 'si'=>'Slovenia',
'sj'=>'Svalbard & Jan Mayen Islands',
'sk'=>'Slovakia', 'sl'=>'Sierra Leone', 'sm'=>'San Marino',
'sn'=>'Senegal', 'so'=>'Somalia',
'sr'=>'Surinam', 'st'=>'Sao Tome & Principe', 'su'=>'USSR', 'sv'=>'El
Salvador',
'sy'=>'Syrian Arab Republic', 'sz'=>'Swaziland',

'tc'=>'The Turks & Caicos Islands', 'td'=>'Chad', 'tf'=>'French
Southern Territories',
'tg'=>'Togo', 'th'=>'Thailand', 'tj'=>'Tajikistan', 'tk'=>'Tokelau',
'tm'=>'Turkmenistan',
'tn'=>'Tunisia', 'to'=>'Tonga', 'tp'=>'East Timor', 'tr'=>'Turkey',
'tt'=>'Trinidad & Tobago',
'tv'=>'Tuvalu', 'tw'=>'Taiwan', 'tz'=>'Tanzania', 'ua'=>'Ukraine',
'ug'=>'Uganda',
'uk'=>'United Kingdom', 'um'=>'United States Minor Outlying Islands',
'us'=>'United States',
'uy'=>'Uruguay', 'uz'=>'Uzbekistan',

'va'=>'Vatican City', 'vc'=>'Saint Vincent & the Grenadines',
've'=>'Venezuela',
'vg'=>'British Virgin Islands', 'vi'=>'US Virgin Islands',
'vn'=>'Vietnam', 'vu'=>'Vanuatu',

'wf'=>'Wallis & Futuna Islands', 'ws'=>'Samoa',

'ye'=>'Yemen', 'yt'=>'Mayotte', 'yu'=>'Yugoslavia',

'za'=>'South Africa', 'zm'=>'Zambia', 'zr'=>'Zaire', 'zw'=>'Zimbabwe',
);

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация