Nej, for jeg har taget det meste af det fra scriptet du har fundet(det som også er linket til i dette fora)
Jeg har brugt
http://ipinfodb.com til API omkring by og land i forhold til IP, der skal man lige downloade en fil(Denne fil) der ligger en i i ZIPen som hedder
ip2locationlite.class.phpher er koden
- <?php
- $server = "";
- $brugernavn = "";
- $kode = "";
- $db = "";
-
- $mysqli = new mysqli($server, $brugernavn, $kode, $db);
-
- if(mysqli_connect_errno()){
- echo "Der opstod en fejl ved forbindelsen: " . mysqli_connect_error();
- exit();
- }
-
- $mysqli->set_charset("UFT8");
-
- $ip = $_SERVER['REMOTE_ADDR'];
- $query_string = $_SERVER['QUERY_STRING'];
- $http_referer = $_SERVER['HTTP_REFERER'];
- $http_user_agent = $_SERVER['HTTP_USER_AGENT'];
-
- function is_bot()
- {
- $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
- "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
- "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
- "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
- "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
- "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
- "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
- "Butterfly","Twitturls","Me.dium","Twiceler");
- foreach($botlist as $bot)
- {
- if(strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
- return true;
- }
- return false;
- }
-
- include('ip2locationlite.class.php');
-
- //Load the class
- $ipLite = new ip2location_lite;
- $ipLite->setKey('DIN KEY HER); // Fra din bruger her: http://ipinfodb.com
-
- //Get errors and locations
- $locations = $ipLite->getCity($ip);
-
- $errors = $ipLite->getError();
-
- if (!empty($locations) && is_array($locations)) {
- foreach ($locations as $field => $val) {
- if($field == "countryName"){
- $country = $val;
- }
- if($field == "cityName"){
- $city = $val;
- }
- }
- }
-
- if(is_bot())
- $isbot = 1;
- else
- $isbot = 0;
-
-
- $date = date("Y-m-d");
- $time = date("H:i:s");
-
-
- //echo '-'.$date.'<br>-'.$time.'<br>-'.$ip.'<br>-'.$country.'<br>-'.$city.'<br>-'.$query_string.'<br>-'.$http_referer.'<br>-'.$http_user_agent.'<br>-'.is_bot();
- if($ins=$mysqli->prepare("INSERT INTO `tracker` (`date`,`time`,`ip`,`country`,`city`,`query_string`,`http_referer`,`http_user_agent`,`isbot`) VALUES (?,?,?,?,?,?,?,?,?)")){
- $ins->bind_param("sssssssss", $date, $time, $ip, $country, $city, $query_string, $http_referer, $http_user_agent, is_bot());
- $ins->execute();
- $ins->fetch();
- $ins->close();
- }
-
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Test til guides</title>
- </head>
- <body>
- <table>
- <tr>
- <td>ID</td>
- <td>Date</td>
- <td>Time</td>
- <td>IP</td>
- <td>Country</td>
- <td>City</td>
- <td>Query_string</td>
- <td>HTTP_Referer</td>
- <td>HTTP_User_Agent</td>
- <td>ISBOT</td>
- </tr>
- <?php
- if($get=$mysqli->prepare("SELECT `id`,`date`,`time`,`ip`,`country`,`city`,`query_string`,`http_referer`,`http_user_agent`,`isbot` FROM `tracker`")){
- $get->execute();
- $get->bind_result($id, $date, $time, $ip, $country, $city, $query_string, $http_referer, $http_user_agent, $isbot);
- while($get->fetch()){
- echo '<tr>';
- echo '<td>'.$id.'</td>';
- echo '<td>'.$date.'</td>';
- echo '<td>'.$time.'</td>';
- echo '<td>'.$ip.'</td>';
- echo '<td>'.$country.'</td>';
- echo '<td>'.$city.'</td>';
- echo '<td>'.$query_string.'</td>';
- echo '<td>'.$http_referer.'</td>';
- echo '<td>'.$http_user_agent.'</td>';
- echo '<td>'.$isbot.'</td>';
- echo '</tr>';
- }
- $get->close();
- }
- ?>
- </table>
-
- </body>
- </html>
Så må du selv lige tilrette hvis der er andre ting du skal have... samt at få den til at oprette alle, for lige pt oprettet den ikke hvis man gå direkte til siden.
Indlæg senest redigeret d. 22.06.2013 13:36 af Bruger #7056