Addic73d Posted July 20, 2011 Report Posted July 20, 2011 Am gasit un fisier cu lista tarilor si clasele de ip-uri aferente fiecarei tari.Acum am cateva nelamuriti...1.0.0.0 1.0.0.255 16777216 16777471 AU Australia1.0.1.0 1.0.3.255 16777472 16778239 CN China1.0.4.0 1.0.7.255 16778240 16779263 AU Australia1.0.8.0 1.0.15.255 16779264 16781311 CN China1.0.16.0 1.0.31.255 16781312 16785407 JP Japan1.0.32.0 1.0.63.255 16785408 16793599 CN China1.0.64.0 1.0.127.255 16793600 16809983 JP Japan1.0.128.0 1.0.255.255 16809984 16842751 TH Thailand1.1.0.0 1.1.0.255 16842752 16843007 CN China1.1.1.0 1.1.1.255 16843008 16843263 AU Australia1.1.2.0 1.1.63.255 16843264 16859135 CN China1.1.64.0 1.1.127.255 16859136 16875519 JP JapanFisierul arata asa...Acum am inteles ca, prima coloana reprezinta inceputul clasei, a doua reprezinta sfarsitul clasei, dar ce reprezinta coloanele 3 si 4??? Quote
phreak Posted July 20, 2011 Report Posted July 20, 2011 IP converterreprezinta adresa IP in format unsigned int, adica daca ai luat cei 4 bytes si i-ai pune unu langa altu .. ti-ar iesi numaru ala Quote
Xander Posted July 20, 2011 Report Posted July 20, 2011 sunt reprezentarea ip-urilor prin numere Quote
Zatarra Posted July 20, 2011 Report Posted July 20, 2011 Daca vrei sa faci un geoip iti sugerez sa nu folosesti metoda asta.. mai bine faci un script pt asta IP location XML API :: IPInfoDB Quote
Addic73d Posted July 20, 2011 Author Report Posted July 20, 2011 (edited) Mersi pentru raspunsuri, m-am lamurit cum sta treaba...Conversia se face dupa formula: 16777216*w + 65536*x + 256*y + z unde IP = w.x.y.zAm facut si un script simplu..<?phpecho '<strong>IP converter</strong><br />';echo "<form name='scan_ip' method='post' action='' > IP: <input type='text' name='ip' /> <input type='submit' name='calc' value='Hit >>' /> </form>"; if((isset($_POST['calc']) && (empty($_POST['ip'])))) { echo 'An empty field can not be converted.'; } else if((isset($_POST['calc']) && (!empty($_POST['ip'])))) { $ip = $_POST['ip']; $div = explode('.', $ip); $w = ($div[0]*16777216); $x = ($div[1]*65536); $y = ($div[2]*256); $z = ($div[3]*1); echo '<strong>'.($w + $x + $y + $z).'</strong>'; } ?>@Zatarra am incercat si o metoda asemanatoare si de foarte multe ori la oras returneaza 'unknown location'. Edited July 20, 2011 by Addic73d Quote
Zatarra Posted July 20, 2011 Report Posted July 20, 2011 Daca cu ala nu obtii orasul doar cu geolocation de la HTML5 cred ca il mai poti obtine. Quote