<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Eric,</div>
<div><br>
</div>
<div>I cannot replicate your problem. For the query you specify, JSON is being returned. See below:</div>
<div>
<div><br>
</div>
<div>$ curl http://whois.arin.net/rest/ip/204.12.8.28.json</div>
<div>{"net":{"@xmlns":{"ns3":"http:\/\/www.arin.net\/whoisrws\/netref\/v2","ns2":"http:\/\/www.arin.net\/whoisrws\/rdns\/v1","$":"http:\/\/www.arin.net\/whoisrws\/core\/v1"},"@termsOfUse":"https:\/\/www.arin.net\/whois_tou.html","registrationDate":{"$":"2011-02-03T11:23:31-05:00"},"ref":{"$":"http:\/\/whois.arin.net\/rest\/net\/NET-204-12-8-24-1"},"customerRef":{"@name":"Stylelife","@handle":"C02687103","$":"http:\/\/whois.arin.net\/rest\/customer\/C02687103"},"endAddress":{"$":"204.12.8.31"},"handle":{"$":"NET-204-12-8-24-1"},"name":{"$":"STYLELIFE"},"netBlocks":{"netBlock":{"cidrLength":{"$":"29"},"endAddress":{"$":"204.12.8.31"},"description":{"$":"Reassigned"},"type":{"$":"S"},"startAddress":{"$":"204.12.8.24"}}},"originASes":{"originAS":{"$":"AS20021"}},"parentNetRef":{"@name":"HOSTMYSITE","@handle":"NET-204-12-0-0-1","$":"http:\/\/whois.arin.net\/rest\/net\/NET-204-12-0-0-1"},"startAddress":{"$":"204.12.8.24"},"updateDate":{"$":"2011-02-03T11:23:31-05:00"},"version":{"$":"4"}}}</div>
</div>
<div><br>
</div>
<div>If you can provide the date and time this anomaly occurred, we can check our server logs to see if there were any issues on our side.</div>
<div><br>
</div>
<div>Andy Newton,</div>
<div>Chief Engineer, ARIN</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Eric Dynamic <<a href="mailto:ecsd@transpacific.net">ecsd@transpacific.net</a>><br>
<span style="font-weight:bold">Date: </span>Saturday, January 4, 2014 8:08 PM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:arin-tech-discuss@arin.net">arin-tech-discuss@arin.net</a>" <<a href="mailto:arin-tech-discuss@arin.net">arin-tech-discuss@arin.net</a>><br>
<span style="font-weight:bold">Subject: </span>[arin-tech-discuss] This is getting a little irritating ...<br>
</div>
<div><br>
</div>
<blockquote id="MAC_OUTLOOK_ATTRIBUTION_BLOCKQUOTE" style="BORDER-LEFT: #b5c4df 5 solid; PADDING:0 0 0 5; MARGIN:0 0 0 5;">
<div>
<div bgcolor="#ffffff" text="#000000">Now after having written a script that worked
<u>marvelously</u> for at least several says, <u>all of a sudden</u> now it is failing.<br>
<br>
Why? Because once again, your service is returning <u>what it feels like</u> versus what I asked for.<br>
<br>
Here is what I got from asking for JSON:<br>
<br>
processing 204.12.8.28<br>
<br>
<tt><?xml version='1.0'?><?xml-stylesheet type='text/xsl' href='<a class="moz-txt-link-freetext" href="http://whois.arin.net/xsl/website.xsl">http://whois.arin.net/xsl/website.xsl</a>' ?><net xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.arin.net/whoisrws/core/v1">"http://www.arin.net/whoisrws/core/v1"</a>
xmlns:ns2=<a class="moz-txt-link-rfc2396E" href="http://www.arin.net/whoisrws/rdns/v1">"http://www.arin.net/whoisrws/rdns/v1"</a> xmlns:ns3="<a class="moz-txt-link-freetext" href="http://ww">http://ww</a><br>
w.arin.net/whoisrws/netref/v2" termsOfUse=<a class="moz-txt-link-rfc2396E" href="https://www.arin.net/whois_tou.html">"https://www.arin.net/whois_tou.html"</a>><registrationDate>2011-02-03T11:23:31-05:00</registrationDate><ref><a class="moz-txt-link-freetext" href="http://whois.arin.net/rest/net/NET-204-12-8-24-1">http://whois.arin.net/rest/net/NET-204-12-8-24-1</a></ref><customerRef
name="<br>
Stylelife" handle="C02687103"><a class="moz-txt-link-freetext" href="http://whois.arin.net/rest/customer/C02687103">http://whois.arin.net/rest/customer/C02687103</a></customerRef><endAddress>204.12.8.31</endAddress><handle>NET-204-12-8-24-1</handle><name>STYLELIFE</name><netBlocks><netBlock><cidrLength>29</ci<br>
drLength><endAddress>204.12.8.31</endAddress><description>Reassigned</description><type>S</type><startAddress>204.12.8.24</startAddress></netBlock></netBlocks><originASes><originAS>AS20021</originAS></originASes><parentN<br>
etRef name="HOSTMYSITE" handle="NET-204-12-0-0-1"><a class="moz-txt-link-freetext" href="http://whois.arin.net/rest/net/NET-204-12-0-0-1">http://whois.arin.net/rest/net/NET-204-12-0-0-1</a></parentNetRef><startAddress>204.12.8.24</startAddress><updateDate>2011-02-03T11:23:31-05:00</updateDate><version>4</versio<br>
n></net><br>
204.12.8.28<br>
no ns4:pft</tt><br>
<br>
Now I am getting XML.<br>
<br>
I don't have time to keep figuring out new parsers. I already write the code for the JSON. And it was working, as I said, for several days
<b>just fine.</b><br>
Now for no reason I can see, <b>suddenly</b>, asking for JSON gives me XML. I don't feel like writing something that has to try to
<u>figure out what you actually sent versus what I requested.</u><br>
This time I request that you FIX THIS.<br>
<br>
=================<br>
<br>
<tt>#!/usr/local/bin/php<br>
<?php<br>
// SQL #####################################################################################################################################################################################<br>
function sqlerr() //$ER_DUP_Entry=1062;<br>
{ if(($e = mysql_errno()) == 1062) $h = "Duplicate Key, ignored."; else $h = mysql_error(); $h = str_replace("'","",$h); $m = "DB:$e:$h"; echo "$m\n"; }<br>
function gqquery($q) { if(mysql_query("$q")) return 0; sqlerr(); return 1; }<br>
function mqquery($q) { if($qr = mysql_query("$q")) return $qr; sqlerr(); return 0; }<br>
function sqquery($q) { $r = false; if($qr = mqquery($q)) { $r = mysql_fetch_object($qr); if(!$r) $r = false; mysql_free_result($qr); } return($r); }<br>
function attach() { global $db; $db = mysql_connect("localhost","*****","*****"); if(!$db) return(0); return(mysql_select_db("sdfilter",$db)); }<br>
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br>
// MAIN<br>
$aTZ = "America/Los_Angeles"; date_default_timezone_set($aTZ); // timezone (absurd format)<br>
global $errno, $fh, $db; $db=0; // globals<br>
error_reporting(0x1F); // complain about anything<br>
$db = attach(); if(!$db) {echo("open db failed."); return(1);} // sordid error handling<br>
<br>
$buf = "";<br>
$v = array();<br>
if(!($C = curl_init())) exit(0);<br>
curl_setopt($C,CURLOPT_RETURNTRANSFER,true);<br>
<br>
if(!($fh=fopen("php://stdin","r"))) exit(0);<br>
for($line = 1;;$line++) {<br>
if(!($A = fgets($fh))) break;<br>
echo "processing $A\n";<br>
if(4 != sscanf($A,"%d.%d.%d.%d",&$n3,&$n2,&$n1,&$n0)) break;<br>
$AA = sprintf("%02X%02X%02X%02X",$n3,$n2,$n1,$n0);<br>
if($r = sqquery("select afrom,ato,contact from abuse where afrom <= '$AA' and '$AA' <= ato limit 1")) {<br>
echo "$A already found in abuse $r->afrom <= $AA <= $r->ato *$r->contact), ignoring request.\n";<br>
continue;<br>
}<br>
curl_setopt($C,CURLOPT_URL,<a class="moz-txt-link-rfc2396E" href="http://whois.arin.net/rest/ip/$A/pft.json">"http://whois.arin.net/rest/ip/$A/pft.json"</a>);<br>
$pft = curl_exec($C);<br>
<b>echo "$pft\n"; // gives the output shown above</b><br>
for($rc = 1;;) {<br>
if(!$pft) { echo "$A: no pft\n"; break; }<br>
$Q = json_decode($pft,true); $Q = $Q["ns4:pft"]; if(!$Q) { echo "$A no ns4:pft\n"; break; }<br>
if(!isset($Q["poc"])) { echo "$A: no poc\n"; break; }<br>
if(!isset($Q["poc"][0])) { echo "$A: no poc[0]\n"; break; }<br>
$F = $Q["net"]["startAddress"]["$"]; if( 4 != sscanf($F,"%d.%d.%d.%d",&$n3,&$n2,&$n1,&$n0) ) break;<br>
$afrom = sprintf("%02X%02X%02X%02X",$n3,$n2,$n1,$n0);<br>
$T = $Q["net"]["endAddress"]["$"]; if( 4 != sscanf($T,"%d.%d.%d.%d",&$n3,&$n2,&$n1,&$n0) ) break;<br>
$ato = sprintf("%02X%02X%02X%02X",$n3,$n2,$n1,$n0);<br>
if( $afrom > $ato ) break;<br>
$n = count($Q["poc"]); $contact = "";<br>
for( $j = 0; $j < $n; $j++ ) {<br>
//echo "$A poc $j description " . $Q["poc"][$j]["@relatedDescription"] ."\n";<br>
if($Q["poc"][$j]["@relatedDescription"] == "Abuse") {<br>
$m = count($Q["poc"][$j]["emails"]["email"]); // we either get [$] or [0]...[n] in this modern world<br>
if($m == 1) {<br>
$contact = $Q["poc"][$j]["emails"]["email"]["$"];<br>
//echo "single records, $contact.\n";<br>
}<br>
else { // save the first contact in any case and if it or a later one contains "abuse", use that.<br>
$contact = strtolower($Q["poc"][$j]["emails"]["email"][0]);<br>
//echo "$A multiple records, default $contact.\n";<br>
if(strstr($contact,"abuse")) break;<br>
else for($k=1, $x = strtolower($Q["poc"][$j]["emails"]["email"][$k]); $k<$m;$k++) if(strstr($x,"abuse")) { $contact = $x; break; }<br>
echo "$A multiple records, using $contact.\n";<br>
}<br>
break;<br>
}<br>
}<br>
if(!$contact || $contact == <a class="moz-txt-link-rfc2396E" href="mailto:abuse@ripe.net">
"abuse@ripe.net"</a> || $contact == <a class="moz-txt-link-rfc2396E" href="mailto:abuse@arin.net">
"abuse@arin.net"</a> || $contact == <a class="moz-txt-link-rfc2396E" href="mailto:abuse@apnic.net">
"abuse@apnic.net"</a>) break; // if <a class="moz-txt-link-abbreviated" href="mailto:abuse@ripe.net">
abuse@ripe.net</a> e.g. then should ask RIPE.<br>
echo "RESULT:: $afrom - $ato\t$contact\n";<br>
$afrom = sprintf("%08X",$afrom); $ato = sprintf("%08X",$ato);<br>
gqquery("insert into abuse (afrom,ato,contact) values ('$afrom','$ato','$contact')");<br>
gqquery("update counts set count = count + 1 where class='database/reqfilled'");<br>
$rc = 0;<br>
break;<br>
}<br>
// we no longer insert (a,0) into abuse to remember what we want.<br>
}<br>
<br>
curl_close($C);<br>
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br>
?><br>
</tt><br>
</div>
</div>
</blockquote>
</span>
<div><br>
</div>
<div><br>
</div>
</body>
</html>