Commit b6f34ce8 authored by David Morley's avatar David Morley

new geo ip api

parent ff02b57f
......@@ -147,7 +147,7 @@ $ipv6="yes";
}
//curl ip
$hostip = curl_init();
curl_setopt($hostip, CURLOPT_URL, "http://api.ip2locationapi.com/?user=".$geouser."&key=".$geokey."&format=text&ip=".$ipnum);
curl_setopt($hostip, CURLOPT_URL, "http://api.infochimps.com/web/analytics/ip_mapping/digital_element/geo?apikey=".$chimpkey."&ip=".$ipnum);
curl_setopt($hostip, CURLOPT_POST, 0);
curl_setopt($hostip, CURLOPT_HEADER, 0);
curl_setopt($hostip, CURLOPT_RETURNTRANSFER, 1);
......@@ -157,11 +157,12 @@ $ipv6="yes";
curl_setopt($hostip, CURLOPT_FOLLOWLOCATION, true);
$ipraw = curl_exec($hostip);
curl_close($hostip);
$iparray = explode(",",$ipraw);
if ($iparray[1] != "-") {$ipdata = "Country: $iparray[1]\n";}
if ($iparray[3] != "-") {$ipdata .= "City: $iparray[3]\n";}
$obj = json_decode($ipraw);
$ipdata = "Country: ".$obj->{'country'}."\n";
$whois = "Country: ".$obj->{'country'}." City: ".$obj->{'city'}."\n Postal Code:".$obj->{'postal_code'}." Lat:".$obj->{'latitude'}." Long:".$obj->{'longitude'}." Connection:".$obj->{'conn_speed'};
echo $ipdata;
//curl the pingdom page
$ping = curl_init();
$thismonth = "/".date("Y")."/".date("m");
......@@ -226,7 +227,7 @@ else {$live="error";}
//sql it
$timenow = date('Y-m-d H:i:s');
$sql = "UPDATE pods SET Hgitdate='$gitdate', Hencoding='$encoding', secure='$secure', hidden='$hidden', Hruntime='$runtime', Hgitref='$gitrev', ip='$ipnum', ipv6='$ipv6', monthsmonitored='$months', uptimelast7='$uptime', status='$live', dateLaststats='$pingdomdate', dateUpdated='$timenow', responsetimelast7='$responsetime', score='$score', adminrating='$adminrating', country='$ipdata', userrating='$userrating' WHERE domain='$domain'";
$sql = "UPDATE pods SET Hgitdate='$gitdate', Hencoding='$encoding', secure='$secure', hidden='$hidden', Hruntime='$runtime', Hgitref='$gitrev', ip='$ipnum', ipv6='$ipv6', monthsmonitored='$months', uptimelast7='$uptime', status='$live', dateLaststats='$pingdomdate', dateUpdated='$timenow', responsetimelast7='$responsetime', score='$score', adminrating='$adminrating', country='$ipdata', whois='$whois', userrating='$userrating' WHERE domain='$domain'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
......
<!doctype html><html><head><meta charset="utf-8"><title>Diaspora Pod uptime - Find your new social home</title>
<meta name="keywords" content="diaspora, podupti.me, diasp, diasporg, diasp.org, facebook, open source social, open source facebook, open source social network" />
<meta name="description" content="Diaspora Pod Live Status. Find a Diaspora pod to sign up for, rate pods, find one close to you!" />
<script type="text/javascript" src="http://c807316.r16.cf2.rackcdn.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="http://c807316.r16.cf2.rackcdn.com/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="http://c807316.r16.cf2.rackcdn.com/jquery.loading.1.6.4.min.js"></script>
<script type="text/javascript" src="http://c807316.r16.cf2.rackcdn.com/jquery.tipsy.js"></script>
......
......@@ -53,7 +53,7 @@ echo "✪";
echo "</div></a></td>";
echo "<td>" . $row["responsetimelast7"] . "</td>";
echo "<td>" . $row["ipv6"] . "</td>\n";
echo "<td class='tipsy' title='IP Address ".$row["ip"]." '>" . $row["country"] . "</td></tr>\n";
echo "<td class='tipsy' title='".$row["whois"]." '>" . $row["country"] . "</td></tr>\n";
}
pg_free_result($result);
pg_close($dbh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment