function getGeo($ip) { $geoplugin = new geoPlugin(); $geoplugin->locate($ip); $geoip = geoip_record_by_name($ip); $geo = false; if (!empty($geoip)) { $geoip = array2object($geoip); // geoip delivers (sometimes)the strings in ISO-8859-1, convert non utf-8 into UTF8 ( not UTF-8 ) foreach ($geoip as $key => $val) { if (in_array($key, array('city', 'country_name'))) { $encoding = mb_detect_encoding($geoip->{$key}); if ($encoding != 'UTF-8') { $geoip->{$key} = iconv($encoding, 'UTF8//IGNORE', $geoip->{$key}); } } } $geo = normalize_geo(false, $geoplugin); utf8_encode_deep($geo); } return $geo; }
</div> </div> <?php } ?> <div id="sections"> <div class="section"> <!--<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>--> <?php require_once 'geoplugin.class.php'; $geoplugin = new geoPlugin(); //$ip = $_SERVER['REMOTE_ADDR']; //$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json")); //locate the IP $geoplugin->locate(); $ct = $geoplugin->city; $rg = $geoplugin->region; $cy = $geoplugin->countryName; //echo "$cy"; ?> <div class="latestbylocation"> <div class="container"> <div class="row"> <div class="col-md-12"> <h3><?php if ($ct == null) { if ($rg == null) { if ($cy == null) { echo "No listings";
<h1><b>Especialidad:</b> Ingeniería del Software</h1> <h1><b>Universidad:</b> UPV/EHU</h1> <p align = center> <img src="imagenes/silueta.gif" alt="Imagen Victor Lana" width="300em" height="300em"/> </p> <p align = center> <a href="layout.html">Ir al Layout</a> </p> <?php require_once './php/geoplugin.class/geoplugin.class.php'; $geoplugin = new geoPlugin(); //Remote address $geoplugin->locate(); $remote_ip_address = $geoplugin->ip; $remote_city = $geoplugin->city; $remote_country = $geoplugin->countryName; $remote_long = $geoplugin->longitude; $remote_lat = $geoplugin->latitude; //Local address $servlocal = $_SERVER['SERVER_ADDR']; $geoplugin->locate($servlocal); $local_ip_address = $geoplugin->ip; $local_city = $geoplugin->city; $local_country = $geoplugin->countryName; $local_long = $geoplugin->longitude; $local_lat = $geoplugin->latitude; ?>
public static function find() { $g = new geoPlugin(); $g->locate(); }
} if (strlen($row['geoplugin_longitude']) > 0) { Flight::set('longitude', $row['geoplugin_longitude']); } if (strlen($row['geoplugin_regionCode']) > 0) { Flight::set('regionCode', $row['geoplugin_regionCode']); } if (strlen($row['geoplugin_regionName']) > 0) { Flight::set('regionName', $row['geoplugin_regionName']); } } Flight::set('geoinfo', true); } else { require 'includes/geoplugin.class.php'; $geoplugin = new geoPlugin(); $geoplugin->locate($ip); // geoplugin.com API up? if (strlen($geoplugin->ip) > 0) { $ipquery = "INSERT INTO geo (ip, geoplugin_city, geoplugin_region, geoplugin_areaCode, geoplugin_dmaCode, geoplugin_countryCode, geoplugin_countryName, geoplugin_continentCode, geoplugin_latitude, geoplugin_longitude, geoplugin_regionCode, geoplugin_regionName) VALUES(:ip, :geoplugin_city, :geoplugin_region, :geoplugin_areaCode, :geoplugin_dmaCode, :geoplugin_countryCode, :geoplugin_countryName, :geoplugin_continentCode, :geoplugin_latitude, :geoplugin_longitude, :geoplugin_regionCode, :geoplugin_regionName)"; $stmt = $db->prepare($ipquery); $stmt->bindParam(':ip', $geoplugin->ip); $stmt->bindParam(':geoplugin_city', $geoplugin->city); $stmt->bindParam(':geoplugin_region', $geoplugin->region); $stmt->bindParam(':geoplugin_areaCode', $geoplugin->areaCode); $stmt->bindParam(':geoplugin_dmaCode', $geoplugin->dmaCode); $stmt->bindParam(':geoplugin_countryCode', $geoplugin->countryCode); $stmt->bindParam(':geoplugin_countryName', $geoplugin->countryName); $stmt->bindParam(':geoplugin_continentCode', $geoplugin->continentCode); $stmt->bindParam(':geoplugin_latitude', $geoplugin->latitude); $stmt->bindParam(':geoplugin_longitude', $geoplugin->longitude); $stmt->bindParam(':geoplugin_regionCode', $geoplugin->regionCode);
echo '<th>Region</th>'; echo '<th>Country Name</th>'; echo '<th>Code</th>'; echo '<th>Latitude</th>'; echo '<th>Longitude</th>'; echo '<th>Hostname</th>'; echo '<th>IP Lookup</th>'; echo '</tr></thead><tbody>'; //We need to add data on the correct Map columns. The columns are always 0 or 1 or 2 for every repetition //so we can hardcode it into our code, but we need a way to automatically increase the row index. So we //create a dummy index variable to be increased after every repetition (as many db results we have) $col = 0; //For every row returned from the database... foreach ($rows as $row) { //We call the geoplugin service to get the geolocation data for the ip $geoplugin->locate($row['source_ip']); //We prepare the label for our vertical bar chart and add the point $geoip = $row['source_ip'] . " - " . $geoplugin->countryCode; $dataSet->addPoint(new Point($geoip, $row['COUNT(source_ip)'])); //We next prepare the marker's tooltip inside Google Map $geostats = "<strong>TOP {$counter}/10:</strong> " . $row['source_ip'] . "<br />" . "<strong>Probes:</strong> " . $row['COUNT(source_ip)'] . "<br />" . "<strong>City:</strong> " . $geoplugin->city . "<br />" . "<strong>Region:</strong> " . $geoplugin->region . "<br />" . "<strong>Country:</strong> " . $geoplugin->countryName . "<br />" . "<strong>Latitude:</strong> " . $geoplugin->latitude . "<br />" . "<strong>Longitude:</strong> " . $geoplugin->longitude . "<br />"; //And add the marker to the map $gMapTop10->setValues(array(array($col, 0, (double) $geoplugin->latitude), array($col, 1, (double) $geoplugin->longitude), array($col, 2, $geostats))); //We prepare the data that will be inserted in our temporary table $ip = $row['source_ip']; $ip_count = $row['COUNT(source_ip)']; $CC = $geoplugin->countryCode; $country_query_sql = "INSERT INTO temp_ip VALUES('{$ip}', '{$ip_count}', '{$CC}')"; R::exec($country_query_sql); //For every row returned from the database we create a new table row with the data as columns echo '<tr class="light">';
function kento_pvc_display($cont) { $kento_pvc_posttype = get_option('kento_pvc_posttype'); if ($kento_pvc_posttype == NULL) { $type = "none"; } else { $type = ""; foreach ($kento_pvc_posttype as $post_type => $post_type_value) { $type .= $post_type . ","; } } if (is_singular(explode(',', $type))) { $post_id = get_the_id(); $cookie_nam = "kentopvc_" . $post_id; if (isset($_COOKIE[$cookie_nam])) { $visited = "yes"; $kento_pvc_uniq = get_option('kento_pvc_uniq'); if (empty($kento_pvc_uniq)) { $visited = "no"; } } else { ?> <script> document.cookie="<?php echo $cookie_nam; ?> =yes"; </script> <?php $visited = "no"; } if ($visited == "yes") { } elseif ($visited == "no") { global $wpdb; $table = $wpdb->prefix . "kento_pvc"; $result = $wpdb->get_results("SELECT count FROM {$table} WHERE postid = {$post_id}", ARRAY_A); if (empty($result[0]['count'])) { $view_count = 0; } else { $view_count = $result[0]['count']; } $already_insert = $wpdb->num_rows; if ($already_insert > 0) { $wpdb->query("UPDATE {$table} SET count = count+1 WHERE postid = '{$post_id}'"); } else { $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t\t\t( id, postid, count )\r\n\t\t\t\t\t\t\t\tVALUES\t( %d, %d, %d )", array('', $post_id, 1))); } $date = date('Y-m-d', strtotime('+' . get_option('gmt_offset') . ' hour')); global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $result = $wpdb->get_results("SELECT * FROM {$table} WHERE date = '{$date}' AND postid = {$post_id}", ARRAY_A); $already_insert = $wpdb->num_rows; if ($already_insert > 0) { global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $wpdb->query("UPDATE {$table} SET count = count+1 WHERE (date = '{$date}') AND (postid = {$post_id})"); } else { global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t\t\t( id, postid, count, date )\r\n\t\t\t\t\t\t\t\tVALUES\t( %d, %d, %d, %s)", array('', $post_id, 1, $date))); } $ip = $_SERVER['REMOTE_ADDR']; /* $content = file_get_contents("http://www.geoplugin.net/xml.gp?ip=".$ip); preg_match('/<geoplugin_city>(.*)/i', $content, $matches); $city = !empty($matches[1]) ? $matches[1] : 0; $city = substr($city,0,-17); if($city == "") { $city = "none"; } else { $city = $city; } preg_match('/<geoplugin_countryName>(.*)/i', $content, $matches); $country= !empty($matches[1]) ? $matches[1] : 0; $country = substr($country,0,-24); if($country == ""){ $country = "none";} else { $country = $country; } */ $geoplugin = new geoPlugin(); $geoplugin->locate(); $city = $geoplugin->city; $country = $geoplugin->countryName; if ($country == "") { $country = "none"; } else { $country = $country; } if ($city == "") { $city = "none"; } else { $city = $city; } global $wpdb; $table = $wpdb->prefix . "kento_pvc_city"; $post_id = get_the_id(); $datetime = date('Y-m-d H:i:s', strtotime('+' . get_option('gmt_offset') . ' hour')); $referer = get_referer($_SERVER["HTTP_REFERER"]); $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t( id, postid, ip, city, country, datetime, referer )\r\n\t\t\t\t\t\tVALUES\t( %d, %d, %s, %s, %s, %s, %s)", array('', $post_id, $ip, $city, $country, $datetime, $referer))); } // end of $visited if global $wpdb; $table = $wpdb->prefix . "kento_pvc"; $result = $wpdb->get_results("SELECT count FROM {$table} WHERE postid = {$post_id}", ARRAY_A); if (empty($result[0]['count'])) { $view_count = 0; } else { $view_count = $result[0]['count']; } $kento_pvc_today_text = get_option('kento_pvc_today_text'); $kento_pvc_total_text = get_option('kento_pvc_total_text'); if (!empty($kento_pvc_today_text)) { $kento_pvc_today_text = $kento_pvc_today_text; } else { $kento_pvc_today_text = "Views Today "; } if (!empty($kento_pvc_total_text)) { $kento_pvc_total_text = $kento_pvc_total_text; } else { $kento_pvc_total_text = "Total Views "; } $cont .= "<div id='kento-pvc'><span class='kento-pvc-total'> " . kento_pvc_convert_lang($view_count) . " " . $kento_pvc_total_text . "</span> <span class='kento-pvc-today'>" . kento_pvc_convert_lang(kento_pvc_today_total()) . " " . $kento_pvc_today_text . "</span>"; $cont .= "</div>"; return $cont; } else { return $cont; } }