Track visitors using Google Maps
Create a table in your database, like 'visitor_map'. We will have these fields: id, ref, ip, location, longitude and latitude, execute the following code:
CREATE TABLE IF NOT EXISTS `visitor_map` ( `id` int(11) NOT NULL auto_increment, `ref` varchar(255) NOT NULL, `ip` varchar(15) NOT NULL, `location` varchar(32) NOT NULL, `longitude` float NOT NULL, `latitude` float NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
For ease of use, we'll now create a configuration file. Create a file called config.php and insert the following, changing the constant values to suit your database setup and Google Maps API key.
define('DB_HOST', 'localhost'); // Database host define('DB_NAME', 'Database'); // Database being used define('DB_USER', 'user'); // Database user define('DB_PASS', 'password'); // Database user's password /* Your Google Maps API key */ define('API_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); function IPtoCoords($ip) { $dom = new DOMDocument(); $ipcheck = ip2long($ip); if($ipcheck == -1 || $ipcheck === false) trigger_error('Invalid IP, what are you doing? :|', E_USER_ERROR); else $uri = 'http://api.hostip.info/?ip=' . $ip; $dom->load($uri); $location = (strpos($dom->getElementsByTagName('name')->item(1)->nodeValue, 'Unknown') === false) ? $dom->getElementsByTagName('name')->item(1)->nodeValue : $dom->getElementsByTagName('countryAbbrev')->item(0)->nodeValue; if($location == 'XX') return false; else { $dom->load('http://local.yahooapis.com/MapsService/V1/geocode?appid=' . Yahoo_Key . '&location=' . $location); $longitude = $dom->getElementsByTagName('Longitude')->item(0)->nodeValue; $latitude = $dom->getElementsByTagName('Latitude')->item(0)->nodeValue; return array('location' => $location, 'longitude' => $longitude, 'latitude' => $latitude); } }
Now that we can successfully gain the visitor's location, we can use this to build our finished visitor map.
Now paste this code to /templates/your_skin_dir_name/main/main.tpl and index.tpl
{php} require 'config.php'; mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $ref = $_SERVER["HTTP_REFERER"]; $ip = $_SERVER['REMOTE_ADDR']; $userinfo = IPtoCoords($ip); $user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = '' . $userinfo['location'] . '''); if(!mysql_fetch_row($user) && $userinfo) mysql_query('INSERT INTO `visitor_map` (`ref`, `ip`, `location`, `longitude`, `latitude`) VALUES ('' . mysql_real_escape_string($ref) . '', '' . mysql_real_escape_string($ip) . '', '' . $userinfo['location'] . '', ' . $userinfo['longitude'] . ', ' . $userinfo['latitude'] . ')') or die(mysql_error()); {/php}
06.07.2009. 09:21
Comments
d, cialis viagra, furosemide tab 40mg, clomid cycle ovulation, acomplia sanofi, nu-cotrimox, cheap erythromycin, buspar forum, avelox, avodart, baclofen 25mg, effects side tamiflu,
c, retin a gel, buy acomplia cheap, celebrex, acne cause does propecia, buy cialis, clomid protocol repronex,
c, elimite doctor, plavix, celebrex, diflucan, buy liquid zithromax online, seroquel, cialis.com, buy liquid zithromax online, online cialis, levitra, levitra.com,
b, diflucan, retin a micro before and after picture, levitra price, retin-a.com, vicodin viagra cialis, generic medication celebrex, buy cialis online, prednisolone sod, propecia, clomid ovulation cycle,
b, diflucan online pharmacy, retin-a, online diflucan prescription, plavix and alcohol, antabuse alcohol, cialis cialis.asp zebrahaifa.com, antabuse.com,, cheap viagra, levitra professional 20 mg, cialis, absolute cheapest cialis, order tetracycline, cipro problem vision,
b, viagra mexico, book buy generic, discount online viagra, cheap seroquel, buy propecia online, retin a too much, acomplia 120 pills, acomplia, diflucan does it long take work, viagra, cipro for kidney infection,
b, celebrex, celebrex ingredient, cialis no prescription, cipro online, buy online viagra,
f, diflucan, celebrex cost, erythromycin dosage, diflucan 150, cheap plavix, retin a acne, cialis.com, viagra.com,
b, diflucan dosage, generic viagra, seroquel online, cialis levitra vs, retin-a, cheap cialis, buy cialis now, viagra oral jelly, where can i buy tetracycline online, cialis online, elimite.com, over the counter clomid,
c, retin a benefits, order acomplia, sildenafil, erythromycin.com, buy zithromax liquid, buy seroquel, best cialis price, prednisolone steroid, levitra buy levitra online viagra, cipro.com,
b, cialis, viagra, cialis, zithromax, buy acomplia, antabuse 180 pills, cheap genric cialis, diflucan online,
c, levitra.com, acomplia online, discount pharmacy purchase zithromax, acomplia rimonabant it, cheap seroquel, order propecia, seroquel, cheap levitra online vardenafil, prednisolone side effects,
f, fluconazole diflucan, cialis viagra vs, acomplia.com, plavix.com, viagra for sale, pravachol actos allopurinol, online for diflucan, cafergot, buy online viagra,
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
ap.txt;5;10
b, секс под одеялом,
b, можно ли стирать шерстяное одеяло,
e, lasix prescription online, baclofen effects side, diflucan, levitra.com, plavix side effects, antabuse 180 pills, bliss pharmacy cialis, viagra, abortion cytotec risk,
d, lasix dose, accutane chicago lawyer, intrathecal baclofen pump, antabuse 500mg, order cialis, cytotec,
f, accutane, diflucan, levitra online, generic plavix, antabuse side effects, cialis.com, 6 cytotec in month pregnancy,
f, levitra webster university film series, accutane success, baclofen 25 mg, diflucan, cheap cialis, will byetta block levitra, buy plavix, effects of viagra, cheap cytotec,
f, levitra, accutane discussion, baclofen, soft pill cialis, order levitra online, plavix, keywords cialis vardenafil, antabuse alcohol, cheap nolvadex,
f, mail order levitra, accutane, levitra, buy plavix online, antabuse,
i can agree with the article
Write a comment
* = required field