Mogex
Active Member
- Joined
- May 29, 2010
- Messages
- 1,513
- Reaction score
- 25
missing call to Account::setGroupId in createaccount.php
How to patch it so?
missing call to Account::setGroupId in createaccount.php
Added geolocation script. When people register it geolocates their IP and save in table `accounts`, column 'flag' [2 letters country code]. Geolocation takes around 0.0002 second [uses 38 files with information about IPs location, all together got 4MB, it loads one file for one geolocation]. No more stupid question 'where are you from?' and list of 200 countries.
Added 'flag' (image) to highscores.php, characters.php, whoisonline.php (method that doesn't use any extra query, not like popular old version.. [400 SQL queries per 1 highscore page])
Geolocation is in class 'Website', code:
Data (IPs location) prepared by script:PHP:public static function getCountryCode($IP) { $a = explode(".",$IP); if($a[0] == 10) // IPs 10.0.0.0 - 10.255.255.255 = private network, so can't geolocate return ''; if($a[0] == 127) // IPs 127.0.0.0 - 127.255.255.255 = local network, so can't geolocate return ''; if($a[0] == 172 && ($a[1] >= 16 && $a[1] <= 31)) // IPs 172.16.0.0 - 172.31.255.255 = private network, so can't geolocate return ''; if($a[0] == 192 && $a[1] == 168) // IPs 192.168.0.0 - 192.168.255.255 = private network, so can't geolocate return ''; if($a[0] >= 224) // IPs over 224.0.0.0 are not assigned, so can't geolocate return ''; $longIP = $a[0] * 256 * 256 * 256 + $a[1] * 256 * 256 + $a[2] * 256 + $a[3]; // we need unsigned value $countries = unserialize(file_get_contents('cache/flags/flag' . bcdiv($longIP, 100000000, 0))); // load file $lastCountryCode = ''; foreach($countries as $fromLong => $countryCode) { if($fromLong > $longIP) break; $lastCountryCode = $countryCode; } return $lastCountryCode; }
Newest list of IPs location (that you must parse by script above and add to folder /cache/flags/ in acc. maker) you can get free:PHP:$lines = file('GeoIPCountryWhois.csv'); $lastIP = 0; $lastCountry = ''; $fileC = -1; $data = array(); foreach ($lines as $line_num => $line) { $info = explode(",", $line, 6); $iIP = trim($info[2], '"'); $iC = trim($info[4], '"'); if(bcdiv($iIP, 100000000, 0) != $fileC) { $fileC = bcdiv($iIP, 100000000, 0); $data[$fileC][$lastIP] = $lastCountry; } $data[$fileC][$iIP] = strtolower($iC); $lastIP = $iIP; $lastCountry = strtolower($iC); } foreach($data as $i => $dat) { file_put_contents('flags/flag' . $i, serialize($dat)); }
MaxMind - GeoLite Databases | Free IP Geolocation Database
Get 'GeoLite Country' [not city] in '.csv' format (in .zip, unzip before you run PHP script).
Files updated!
.zip
http://ots.me/gesior/Gesior_2012_beta_0.3.6_2012_10_07.zip
file viewer
GESIOR 2012 ver. 1.0.0 BETA for 0.3.6
--enable-bcmath
there are newer (and better) functions that could be used in this case
...
By default, PHP is not configured withCode:--enable-bcmath[/CODE[/QUOTE] Then tell me what function should I use to divide [B]unsigned 32bit number[/B] with precision up to '1'? You mean operations on string and not divide anything? I found BCMath library few years ago when I tried to calculate some BIG numbers [and it was in XAMPP, no problems to install/enable it] and about 2 years ago I had problem with values over 2 billions and 'int' in PHP, so this time I decided to use BCMath. I didn't know that it will be problem for anyone. [QUOTE=http://www.php.net/manual/en/bc.requirements.php]Requirements Since PHP 4.0.4, libbcmath is bundled with PHP. You don't need any external libraries for this extension.[/QUOTE] [COLOR="silver"]- - - Updated - - -[/COLOR] Fixed characters creation (bugs found on anderion.net). Now new characters got 'save on' characters, not 'save off' and it copys items and skills. Added: [PHP]$reg_account->setGroupID(1);[/PHP] in [B]createaccount.php[/B] Thank you for report [B][I]averatec[/I][/B] Geolocation script changed to: [PHP] public static function getCountryCode($IP) { $a = explode(".",$IP); if($a[0] == 10) // IPs 10.0.0.0 - 10.255.255.255 = private network, so can't geolocate return ''; if($a[0] == 127) // IPs 127.0.0.0 - 127.255.255.255 = local network, so can't geolocate return ''; if($a[0] == 172 && ($a[1] >= 16 && $a[1] <= 31)) // IPs 172.16.0.0 - 172.31.255.255 = private network, so can't geolocate return ''; if($a[0] == 192 && $a[1] == 168) // IPs 192.168.0.0 - 192.168.255.255 = private network, so can't geolocate return ''; if($a[0] >= 224) // IPs over 224.0.0.0 are not assigned, so can't geolocate return ''; $longIP = $a[0] * 256 * 256 * 256 + $a[1] * 256 * 256 + $a[2] * 256 + $a[3]; // we need unsigned value $countries = unserialize(file_get_contents('cache/flags/flag' . $a[0])); // load file $lastCountryCode = ''; foreach($countries as $fromLong => $countryCode) { if($fromLong > $longIP) break; $lastCountryCode = $countryCode; } return $lastCountryCode; }[/PHP] Genarator: [PHP] $lines = file('GeoIPCountryWhois.csv'); $lastIP = 0; $lastCountry = ''; $fileC = -1; $data = array(); foreach ($lines as $line_num => $line) { $info = explode(",", $line, 6); $nIP = trim($info[0], '"'); // from IP human format $iIP = trim($info[2], '"'); // from IP long $iC = trim($info[4], '"'); // country code $startOfIP = explode('.', $nIP); if($startOfIP[0] != $fileC) { $fileC = $startOfIP[0]; $data[$fileC][$lastIP] = $lastCountry; } $data[$fileC][$iIP] = strtolower($iC); $lastIP = $iIP; $lastCountry = strtolower($iC); } foreach($data as $i => $dat) { file_put_contents('flags/flag' . $i, serialize($dat)); } [/PHP] [COLOR="silver"]- - - Updated - - -[/COLOR] Added folder with changed files to make acc. maker work with TFS 0.4 without problems [salt in accounts table]: http://gesior2012.ots.me/?dir=account+maker/trunk/TFS_0_4_rev_any Added 'readme.txt' files on gesior2012.ots.me with instructions what/why/how change in acc. maker to install 'thing that is in this folder'.
hows progress so far? what is still to be done? I want to use it!!! :w00t:News - only admin can create new thread on forum on board 'News'. First post from these threads is visible on 'latestnews'. In first post on forum on board News you can use HTML (and BB code).
Creatures / Spells pages are not available, so there is no button to reload their info in admin panel.
In new shop script you can sell ONLY items and containers with items. Script to add items and containers you can find in 'LUA -> Talkactions':
http://otland.net/f81/add-items-sms-shop-116887/ (that link is also on page shopadmin.php in current acc. maker).
Then code it/share code and I will add to acc. maker.
I don't see any reason to waste few hours to make new shop when on 90% of otses admins dont even config item images. People don't care about how shop looks like, they just want good items and low prices. Want better shop? Offer someone (ME!) 10-20 euro and you will get it
// Gesior.pl
'll have to use the old pages in this new website?
What do you mean with "the old pages"???
he made the first AAC?
<?php
if(!isset($GLOBALS['initialized']))
exit;
<?php
if(!isset($initialized))
exit;
<?php
$response = file_get_contents("http://api.hostip.info/get_json.php?ip=74.122.197.102");
if (!$response)
return "UN" /*Unknown*/;
return json_decode($response)->country_code;
?>
I could also load images of items from my server (ots.me), not tell people to download them in .zip to their dedics, but I don't trust external services. If it goes offline someday/get ddosed all acc. maker users on all OTSes will get 1-5 seconds [server config] load time of ots website [PHP waits for answer from hostip.info].For "geolocation" you should use external server with always current data - of course this is only my humble opinion.
Example of script (of course, you should implement cache system, or save it somewhere):
PHP:<?php $response = file_get_contents("http://api.hostip.info/get_json.php?ip=74.122.197.102"); if (!$response) return "UN" /*Unknown*/; return json_decode($response)->country_code; ?>
http://www.maxmind.com/en/geolite said:GeoLite Country and GeoLite City are free IP geolocation databases, updated on the first Tuesday of each month.
What if someone hack hostip.info and in place of country code put '<script>here some baad code</script>'? Hack ots users?
bugtracker/changelog?Are there any scripts missing in new acc. maker?
Player Mana: 55333080/12302280