Szerző Téma: IpToCountry  (Megtekintve 3957 alkalommal)

IpToCountry
« Dátum: 2011. Március 19. - 19:54:29 »
+1 Show voters
Update 2013.03.16

Download
http://www.solidfiles.com/d/9f8a5ce0fb/



/* ¤¤¤¤¤¤¤ [ IpToCountry by Zsolesszka ] ¤¤¤¤¤¤¤¤¤ Date 2011.03.19
Update [2013.03.16]
How to update countrydatabase.db?
Go to http://software77.net/geo-ip/ and download \"IPV4 csv (gz)\"  (IpToCountry.csv file),
extract and copy ../myserver/scriptfiles folder,
and run samp_server.exe and wait 7-8 minute.
¤¤¤¤¤¤¤¤¤¤ [ SQLite version ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤*/
#include <a_samp>
#include <sscanf2>
 
#define Database_N \"countrydatabase.db\"
stock const
IpToCountry_csv[] = \"IpToCountry.csv\";
new
DB:database;
public
OnFilterScriptInit()
{
SetTimer(\"IPTC_start\", 1000, false);
print(\"°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°\");
print(\"   IpToCountry_db by Zsolesszka\");
print(\"°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°\");
return 1;
}
forward IPTC_start(); public
IPTC_start()
{
UpDate_DataBase();
database = db_open(Database_N);
//   Teszt();
}
public
OnFilterScriptExit()
{
db_close(database);
return 1;
}
public
OnPlayerConnect(playerid)
{
new
    MaxPlayers = GetMaxPlayers(),
    string[144],
    IP[16];
GetPlayerIp(playerid, IP, sizeof IP);
format(string, sizeof string, \"*** %s has joined the server | Country: %s |\", pName(playerid), GetCountry(IP));
for(new p; p < MaxPlayers; p++)
{
    if(!IsPlayerConnected(p) || IsPlayerNPC(p) || p == playerid) continue;
    SendClientMessage(p, 0x33AA33AA, string);
}
format(string, sizeof string, \" %s IP Adress: %s |\", string, IP);
SendClientMessage(playerid, 0x33AA33AA, string);
return 1;
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ Teszt ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
stock
Teszt()
{
new
randomip[16];
for(new i = 0; i < 20; i++)
{
format(randomip, sizeof randomip, \"%d.%d.%d.%d\", random(256), random(256), random(256), random(256));
new
   starttime = GetTickCount();
printf(\"Time test | random ip: %s | COUNTRY: %s --> Time: %dms\", randomip, GetCountry(randomip), GetTickCount() - starttime);
}
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ sql version ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
GetCountry(Ip[])
{
new
Split_Ip[4 char],
DBResult:result,
query[128];
if(database)
{
if(!strcmp(\"127.0.0.1\", Ip, true))
{
   query = \"Localhost\";
} else {
   Split_Ip[0] = IptoInt(Ip);
   format(query, sizeof query,
      \"SELECT `Country` FROM `countrydetected` WHERE ((16777216*%d) + (65536*%d) + (256*%d) + %d) BETWEEN `Ip_From` AND `Ip_to`\",
      Split_Ip{0}, Split_Ip{1}, Split_Ip{2}, Split_Ip{3});
   printf(\"strlen %d\", strlen(query));
   result = db_query(database, query);
   if(!db_get_field_assoc(result, \"Country\", query, sizeof query))
   {
      query = \"Unknown\";
   }
   db_free_result(result);
}
} else format(query, sizeof query, \"Failed. Not Open \\\"%s\\\" Read IpToCountry.pwn\" , Database_N);
return query;
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ IptoInt ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
IptoInt(const Ip[])
{
new
Byte[1],
Count = 1,
Pos = 0;
Byte{0} = strval(Ip[0]);
while(Ip[++Pos]) { if(Ip[Pos] == \'.\') Byte{Count++} = strval(Ip[Pos + 1]); }
return Byte[0];
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ Return PlayerName ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
pName(playerid)
{
    new
name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
return name;
}
 
 
 
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ Update script database ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
UpDate_DataBase()
{
if(fexist(IpToCountry_csv))
{
new
   starttime = GetTickCount();
print(\"Update \"Database_N\" file, please wait......\");
if(fexist(Database_N)) fremove(Database_N);
new
   count = 1,
   str[256],
   File:IPC = fopen(IpToCountry_csv),
   DB:data_base = db_open(Database_N);
if(IPC && data_base)
{
   new
      query[512],
      Ip_From[24],
      Ip_To[24],
      TEXT[64],
      Assigned[24],
      Ctry[24],
      Cntry[24],
      Country[128];
   db_query(data_base, \"CREATE TABLE IF NOT EXISTS `countrydetected` (ID INTEGER PRIMARY KEY, Ip_From NUMERIC, Ip_To NUMERIC, Registry TEXT, Assigned NUMERIC, Ctry TEXT, Cntry TEXT, Country TEXT);\");
   while(fread(IPC, str))
   {
      if(str[0] == \'#\') continue;
      else
      {
         Replace_Double_Prime(str);
         if(sscanf(str, \"p<,>s[24]s[24]s[63]s[24]s[24]s[24]s[128]\", Ip_From, Ip_To, TEXT, Assigned, Ctry, Cntry, Country)) continue;
         else
         {
            format(query, sizeof query,
               \"INSERT INTO `countrydetected` (ID,Ip_From,Ip_To,Registry,Assigned,Ctry,Cntry,Country) VALUES (%d,%s,%s,%s,%s,%s,%s,%s);\",
                  count, Ip_From, Ip_To, TEXT, Assigned, Ctry, Cntry, Country);
            db_query(data_base, query);
         }
      }
      count++;
   }
   fclose(IPC);
   db_close(data_base);
}
fremove(IpToCountry_csv); // Delete IpToCountry.csv file
printf(\"\"Database_N\" file update done time: %f m, and deleted %s file. \\n\", float((((GetTickCount() - starttime) / 1000) / 60)), IpToCountry_csv);
}
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ Remove_Double_Prime ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
stock
Remove_Double_Prime(str[])
{
new
i = 0,
pos = 0,
lenght = strlen(str);
while(pos < lenght)
{
if(str[pos] != \'\"\')
{
   str = str[pos];
   i++;
}
pos++;
}
str = EOS;
}
// ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ [ Replace_Double_Prime ] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Replace_Double_Prime(str[], ch = \'\\\'\')
{
new
i = 0;
while(str)
{
if(str == \'\"\') str = ch;
i++;
}
}

 
 


GeoIp Country filterscript. Joined message:
             \"countryw.th.jpg\"
Example mysql verzion:
 

public
OnPlayerConnect(playerid)
{
new
    string[144],
    IP[16];
GetPlayerIp(playerid, IP, sizeof IP);
GetPlayerName(playerid, string, 24);
format(string, sizeof string, \"*** %s has joined the server | Country: %s |\", string, GetIpCountry_mysql(IP));
SendClientMessageToAll(0xC00000FF, string);
return 1;
}

 
 Credits:
 

Time test SQLite verzion:
 

[19:13:35]   Loading filter script \'IpToCountry.db.amx\'...
[19:13:35] °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
[19:13:35]    IpToCountry_db by Phento
[19:13:35] °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
[19:13:35] Time test | random ip: 92.237.111.236 | COUNTRY: United Kingdom
[19:13:35] Time: 20ms
[19:13:35] Time test | random ip: 100.133.235.249 | COUNTRY: Unknown
[19:13:35] Time: 101ms
[19:13:35] Time test | random ip: 149.190.35.91 | COUNTRY: European Union
[19:13:35] Time: 30ms
[19:13:35] Time test | random ip: 42.13.26.61 | COUNTRY: Korea Republic of
[19:13:35] Time: 7ms
[19:13:35] Time test | random ip: 28.47.77.75 | COUNTRY: United States
[19:13:35] Time: 4ms
[19:13:35] Time test | random ip: 74.94.102.93 | COUNTRY: United States
[19:13:35] Time: 27ms
[19:13:35] Time test | random ip: 242.188.7.163 | COUNTRY: Reserved
[19:13:35] Time: 97ms
[19:13:35] Time test | random ip: 39.239.152.142 | COUNTRY: Unknown
[19:13:35] Time: 89ms
[19:13:35] Time test | random ip: 14.156.24.48 | COUNTRY: China
[19:13:35] Time: 4ms
[19:13:35] Time test | random ip: 115.20.122.117 | COUNTRY: Korea Republic of
[19:13:35] Time: 58ms

 
 Download:
Mysql verzion:
             http://solidfiles.com/d/a7ce/
SQLite verzion:
             http://solidfiles.com/d/9069/
HIVATALOS LINK (mint egy ****** lassan már)
Gondoltam közzé teszem itt is ezt a scriptet hátha vannak akik nem látogatják a hivatalos fórumot.
Kérem a hozzászólásokban mellõzni az ilyen olyan plugin verziókat hogy már van ilyen ezer, mindenki azt használja amelyik neki jobban tetszik. Igen és arról is tudok hogy Slice is írt egyet ami http-n keresztül kérdezi le.
Ez a két fajta script elég gyors ahhoz hogy ne okozzon akadásokat játékos csatlakozáskor.
Ennek ellenõrzésére írtam bele tesztet is az SQLite verzióba, amivel bárki letudja ellenõrizni.
Edit:
Letöltési link javítva.
« Utoljára szerkesztve: 2013. Március 17. - 11:56:20 írta ɐʞzssǝlosz »

Nem elérhető Buba

  • 540
    • Profil megtekintése
IpToCountry
« Válasz #1 Dátum: 2011. Március 19. - 20:54:26 »
0 Show voters
Készítõ? Eredeti téma link?

Nem elérhető SoAP

  • 182
    • Profil megtekintése
IpToCountry
« Válasz #2 Dátum: 2011. Március 19. - 20:58:50 »
0 Show voters
Ennek most nem vágom mi értelme :-\\

IpToCountry
« Válasz #3 Dátum: 2011. Március 19. - 21:02:50 »
+1 Show voters
Idézetet írta: Buba date=1300564466\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"6966\" data-ipsquote-contentclass=\"forums_Topic
Készítõ? Eredeti téma link?
 
Az eredeti script nevének megváltoztatása rám tartozik, akkor a készítõ vajon ki is lehet?
És oda linkelem a hivatalos forum oldal linkjét is hacsak ez kell. :D
És minden segítség amit felhasználtam hozzá linkelve, egyéb kérdés?
 

Ennek most nem vágom mi értelme :-\\
 
[/quote]
Akkor ne is foglalkozz vele.  ;D
« Utoljára szerkesztve: 2011. Március 19. - 21:09:13 írta Zsolesszka »

Nem elérhető DrAkE

  • 2078
    • Profil megtekintése
IpToCountry
« Válasz #4 Dátum: 2011. Március 19. - 21:09:57 »
0 Show voters
Idézetet írta: Zsolesszka date=1300564970\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"6966\" data-ipsquote-contentclass=\"forums_Topic
Az eredeti script nevének megváltoztatása rám tartozik, akkor a készítõ vajon ki is lehet?
 
Ezt most nem értem.

IpToCountry
« Válasz #5 Dátum: 2011. Március 19. - 21:12:37 »
0 Show voters
Idézetet írta: DrAkE date=1300565397\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"6966\" data-ipsquote-contentclass=\"forums_Topic


Az eredeti script nevének megváltoztatása rám tartozik, akkor a készítõ vajon ki is lehet?
 
Ezt most nem értem.
 
[/quote]
:D
Zsolesszka aka smeti and Phento
Így érthetõ?

Nem elérhető Popec16

  • 1267
    • Profil megtekintése
IpToCountry
« Válasz #6 Dátum: 2011. Március 19. - 21:14:10 »
0 Show voters
Drake: Ne legyél már ennyire szelektív felfogású! :D :D :D
Lényegnek a lényege a scriptet Zsoleszka írta csak angol az az hivatalos fórumon is õ publikálta és itt is!
Én tudom hogy nem fog átverni senkit , elég jó scripterrõl beszélünk!!

Nem elérhető SoAP

  • 182
    • Profil megtekintése
IpToCountry
« Válasz #7 Dátum: 2011. Március 19. - 21:44:38 »
0 Show voters
Az eredeti topic hiv. fórumon nem is létezik.. nem jön be :-\\

Nem elérhető Popec16

  • 1267
    • Profil megtekintése
IpToCountry
« Válasz #8 Dátum: 2011. Március 19. - 22:02:51 »
0 Show voters
Érdekes módon nekem bejön ! :O

IpToCountry
« Válasz #9 Dátum: 2011. Március 19. - 22:08:48 »
0 Show voters
Ez azt jelenti, hogy visszatértél közénk, Phento?  :D
E: Szép.

IpToCountry
« Válasz #10 Dátum: 2011. Március 19. - 22:12:40 »
0 Show voters
Idézetet írta: SoAP date=1300567478\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"6966\" data-ipsquote-contentclass=\"forums_Topic
Az eredeti topic hiv. fórumon nem is létezik.. nem jön be :-\\
 
És azt meg hogy csinálod elárulod? Tudod szép kéken van kiírva HIVATALOS LINK és rá kell vinni az egér mutatót és egy bal egérgombot egyszer megnyomni.
De ezek szerint nem megy, talán így sikerül kimásolni?
 

http://forum.sa-mp.com/showthread.php?t=131554

 
http://forum.sa-mp.com/showthread.php?t=131554
 

Ez azt jelenti, hogy visszatértél közénk, Phento?  :D
E: Szép.
 
[/quote]
Hát igen, hátha már más helyzet mint anno volt.
Teszek egy kísérletet újból, remélem nem gond. :D

Nem elérhető Popec16

  • 1267
    • Profil megtekintése
IpToCountry
« Válasz #11 Dátum: 2011. Március 19. - 22:26:56 »
0 Show voters
Aki phentoval kötözködik szarul fog járni ! :)

Nem elérhető kurta999

  • 2759
  • Éllő fédisznó
    • Profil megtekintése
IpToCountry
« Válasz #12 Dátum: 2011. Március 19. - 23:29:47 »
0 Show voters
Ez így jónak néz ki, de én maradok a plugin mellett :D.
Amúgy ottvan az elején a cellmax, azt megmondanátok, hogy mit csinál ? ( Hol kéri le és mit jelent )

IpToCountry
« Válasz #13 Dátum: 2011. Március 19. - 23:51:14 »
0 Show voters
Idézetet írta: kurta999 date=1300573787\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"6966\" data-ipsquote-contentclass=\"forums_Topic
Ez így jónak néz ki, de én maradok a plugin mellett :D.
Amúgy ottvan az elején a cellmax, azt megmondanátok, hogy mit csinál ? ( Hol kéri le és mit jelent )
 
cellmax azaz érték amelyiknél nem tudsz pawn nyelvben nagyobb számot megadni emiatt szalad például /givecash playerid 3333333333  beírása után minuszba a játékos pénze. (már ahol ez nincs javítva)
Végsõ soron limit értéket jelent.
Ezeknek az értékét megtudod nézni a következõképpen.
 

printf(\"cellmax: %d\", cellmax);
printf(\"cellmin: %d\", cellmin);

 
És az IpToCountry ennél kétszer nagyobb számokkal dolgozik a vége felé ezért kellett áttennem
sql-hez a számítások elvégzését.
« Utoljára szerkesztve: 2011. Március 19. - 23:53:52 írta Zsolesszka »

Nem elérhető SoAP

  • 182
    • Profil megtekintése
IpToCountry
« Válasz #14 Dátum: 2011. Március 19. - 23:56:12 »
0 Show voters
Nem tudom miért nem jött be :-\\
 
És azt meg hogy csinálod elárulod? Tudod szép kéken van kiírva HIVATALOS LINK és rá kell vinni az egér mutatót és egy bal egérgombot egyszer megnyomni.[/quote]
Mostmár bejön de azért kicsit visszábvehetnél... -.-\'\'\'\' Nem ismerlek, s nem is akarlak..... a szép kéken kivan írva szövegedbõl már tudom minden paramétered -.-\'\'\'

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal