|
165 | 165 | Utils.callService('ping', 'id='+uuid+'&time='+time+'&rnd='+Utils.generateUUID(), null, function(data){ |
166 | 166 | successCallback(data.valid); |
167 | 167 | }, failureCallback); |
| 168 | + }, |
| 169 | + callWhoisService : function(ip, successCallback, failureCallback){ |
| 170 | + Utils.callService('ipwhois', 'ip='+ip, null, function(data){ |
| 171 | + successCallback(data.whoisResults); |
| 172 | + }, failureCallback); |
168 | 173 | } |
169 | 174 | }, |
170 | 175 |
|
|
271 | 276 | }, { |
272 | 277 | name : 'whois.com', |
273 | 278 | url : 'https://www.whois.com/whois/'+ip |
| 279 | + }, { |
| 280 | + name : 'ripe.net statistics', |
| 281 | + url : 'https://stat.ripe.net/'+ip |
274 | 282 | }]; |
275 | 283 | //http://freegeoip.net/json/83.65.190.82 |
276 | 284 | //https://stackoverflow.com/questions/17290256/get-google-map-link-with-latitude-longitude |
| 285 | + //https://apps.db.ripe.net/search/query.html?searchtext=83.65.190.82&bflag=false&source=RIPE#resultsAnchor#resultsAnchor |
| 286 | + //https://whois.arin.net/rest/nets;q=8.8.8.8?showDetails=true&showARIN=false&showNonArinTopLevelNet=false&ext=netref2 |
277 | 287 |
|
278 | 288 | var list = ''; |
279 | 289 | ipAnalyzeServiceList.forEach(function(ipAnalyzeService){ |
|
300 | 310 | var domId = Utils.generateUUID(); |
301 | 311 | $('#reportsDiv').prepend( |
302 | 312 | $('<div class="list-group-item">').append( |
303 | | - $('<div class="row link" title="Click for details">').append( |
| 313 | + $('<div class="row link" id="'+domId+'_overview_div" title="Click for details">').append( |
304 | 314 | $('<div class="col-lg-2">').append( |
305 | 315 | '<h4><span class="label label-default">'+track.time+'</span></h4>' |
306 | 316 | ) |
|
317 | 327 | _generateAnalyzeIPButtons(track.ip) |
318 | 328 | ) |
319 | 329 | ) |
320 | | - ).click(function(e){ |
| 330 | + ).append( |
| 331 | + $('<div class="col-lg-4">').append( |
| 332 | + $('<div class="input-group">').append( |
| 333 | + '<span class="input-group-addon">Owner: </span>' |
| 334 | + ).append( |
| 335 | + $('<input type="text" id="'+domId+'_ip_owner_txt" class="form-control" readonly>').click(function(e){ |
| 336 | + $(this).select(); |
| 337 | + document.execCommand("copy"); |
| 338 | + }) |
| 339 | + ) |
| 340 | + ) |
| 341 | + ) |
| 342 | + .click(function(e){ |
321 | 343 | if (e.target.tagName != 'BUTTON' && e.target.tagName != 'A' && e.target.tagName != 'INPUT') |
322 | 344 | $('#'+domId+'_headers_div').toggle(); |
323 | 345 | }) |
|
346 | 368 | ) |
347 | 369 | ).hide().fadeIn(500) |
348 | 370 | ); |
| 371 | + Dashboard.services.callWhoisService(track.ip, function(whoisResults){ |
| 372 | + $('#'+domId+'_ip_owner_txt').val(whoisResults.netName).popover({ |
| 373 | + placement : 'auto right', |
| 374 | + container : 'body', |
| 375 | + html : true, |
| 376 | + title : 'WHOIS ' + track.ip, |
| 377 | + content : function(){ |
| 378 | + var html = '<pre>'+whoisResults.output+'</pre>'; |
| 379 | + return html; |
| 380 | + }(), |
| 381 | + |
| 382 | + trigger : 'hover click' |
| 383 | + }); |
| 384 | + }, function(error){ |
| 385 | + Utils.showError(error, $('#reportsTable')); |
| 386 | + }); |
| 387 | + |
349 | 388 | }); |
350 | 389 |
|
351 | 390 | }, function(error){ |
|
770 | 809 | .link:hover{ |
771 | 810 | color: #FFFFFF; |
772 | 811 | background-color: #428bca; |
| 812 | +} |
| 813 | +.popover { |
| 814 | + max-width: 50em !important; |
773 | 815 | } |
774 | 816 | </style> |
775 | 817 | </head> |
|
985 | 1027 | if(isset($_GET['op']) && $_GET['op'] == 'shortening'){ |
986 | 1028 | header('Content-Type: application/json'); |
987 | 1029 | try{ |
988 | | - if(!isset($_GET['url'])) |
| 1030 | + if(!isset($_GET['url']) || $_GET['url']=='') |
989 | 1031 | throw new Exception('url parameter required'); |
990 | 1032 | $shortenedUrl = @file_get_contents('http://tinyurl.com/api-create.php?url='.$_GET['url']); |
991 | 1033 | echo '{"status" : 0, "shortenedUrl" : "'.$shortenedUrl.'"}'; |
|
1032 | 1074 | if(isset($_GET['op']) && $_GET['op'] == 'loadConfig'){ |
1033 | 1075 | header('Content-Type: application/json'); |
1034 | 1076 | try{ |
1035 | | - if(!isset($_GET['id'])) |
| 1077 | + if(!isset($_GET['id']) || $_GET['id']=='') |
1036 | 1078 | throw new Exception('id parameter required'); |
1037 | 1079 | $configUUID = $_GET['id']; |
1038 | 1080 | if(!file_exists(getcwd().'/'.$configFolder.'/'.$configUUID.'.json')) |
|
1049 | 1091 | if(isset($_GET['op']) && $_GET['op'] == 'loadTrack'){ |
1050 | 1092 | header('Content-Type: application/json'); |
1051 | 1093 | try{ |
1052 | | - if(!isset($_GET['id'])) |
| 1094 | + if(!isset($_GET['id']) || $_GET['id']=='') |
1053 | 1095 | throw new Exception('id parameter required'); |
1054 | 1096 | $configUUID = $_GET['id']; |
1055 | 1097 | if(!file_exists(getcwd().'/'.$configFolder.'/'.$configUUID.'.json')) |
|
1070 | 1112 | if(isset($_GET['op']) && $_GET['op'] == 'ping'){ |
1071 | 1113 | header('Content-Type: application/json'); |
1072 | 1114 | try{ |
1073 | | - if(!isset($_GET['id'])) |
| 1115 | + if(!isset($_GET['id']) || $_GET['id']=='') |
1074 | 1116 | throw new Exception('id parameter required'); |
1075 | | - if(!isset($_GET['time'])) |
| 1117 | + if(!isset($_GET['time']) || $_GET['time']=='') |
1076 | 1118 | throw new Exception('time parameter required'); |
1077 | 1119 | $trackUUID = $_GET['id']; |
1078 | 1120 | $localTime = $_GET['time']; |
|
1087 | 1129 | exit(); |
1088 | 1130 | } |
1089 | 1131 |
|
| 1132 | +if(isset($_GET['op']) && $_GET['op'] == 'ipwhois'){ |
| 1133 | + header('Content-Type: application/json; charset=utf8'); |
| 1134 | + try{ |
| 1135 | + if(!isset($_GET['ip']) || $_GET['ip']=='') |
| 1136 | + throw new Exception('ip parameter required'); |
| 1137 | + $ip = $_GET['ip']; |
| 1138 | + /*WHOIS IP Server list |
| 1139 | + whois.afrinic.net -> Africa - but returns data for ALL locations worldwide |
| 1140 | + whois.lacnic.net -> Latin America and Caribbean but returns data for ALL locations worldwide |
| 1141 | + whois.apnic.net -> Asia/Pacific only |
| 1142 | + whois.arin.net -> North America only |
| 1143 | + whois.ripe.net -> Europe, Middle East and Central Asia only |
| 1144 | + */ |
| 1145 | + $whoisserver = 'whois.lacnic.net'; |
| 1146 | + if(!($fp = fsockopen($whoisserver, 43, $errno, $errstr, 10))) |
| 1147 | + throw new Exception("Error contacting the WHOIS server $whoisserver : $errstr ($errno)"); |
| 1148 | + |
| 1149 | + fprintf($fp, "%s\r\n", $ip); |
| 1150 | + $whoisResultString = ""; |
| 1151 | + $netNameString = ""; |
| 1152 | + $lineCount = 0; |
| 1153 | + while(!feof($fp)){ |
| 1154 | + $line = fgets($fp); |
| 1155 | + if(trim($line[0])!='' && $line[0]!='#' && $line[0]!='%'){ |
| 1156 | + $whoisResultString.=$line; |
| 1157 | + $lineCount++; |
| 1158 | + if(strpos($line, ':') !== false){ |
| 1159 | + $lineSplit = explode(':', $line); |
| 1160 | + if(strtolower($lineSplit[0])=='netname') |
| 1161 | + $netNameString = trim($lineSplit[1]); |
| 1162 | + } else { |
| 1163 | + if($lineCount == 2) |
| 1164 | + $netNameString = trim(explode('(NET', $line)[0]); |
| 1165 | + } |
| 1166 | + } |
| 1167 | + } |
| 1168 | + fclose($fp); |
| 1169 | + |
| 1170 | + $ret = json_encode((object) array( |
| 1171 | + 'status' => 0, |
| 1172 | + 'whoisResults' => (object) array( |
| 1173 | + 'output' => utf8_encode($whoisResultString), |
| 1174 | + 'netName' => utf8_encode($netNameString) |
| 1175 | + ) |
| 1176 | + )); |
| 1177 | + |
| 1178 | + if(json_last_error()!=0) |
| 1179 | + throw new Exception("Error encoding the JSON response"); |
| 1180 | + echo $ret; |
| 1181 | + }catch(Exception $ex){ |
| 1182 | + echo '{"status" : -1, "error" : "'.$ex->getMessage().'"}'; |
| 1183 | + $logError($ex->getMessage()); |
| 1184 | + } |
| 1185 | + exit(); |
| 1186 | +} |
| 1187 | + |
1090 | 1188 | if(isset($_GET['op']) && $_GET['op'] == 'i'){ |
1091 | 1189 | try{ |
1092 | | - if(!isset($_GET['tid'])) |
| 1190 | + if(!isset($_GET['tid']) || $_GET['tid']=='') |
1093 | 1191 | throw new Exception('tid parameter required'); |
1094 | 1192 | $trackUUID = $_GET['tid']; |
1095 | 1193 | if(!file_exists(getcwd().'/'.$reportFolder.'/'.$trackUUID.'.json')) |
|
1129 | 1227 |
|
1130 | 1228 | if(isset($_GET['op']) && $_GET['op'] == 'l'){ |
1131 | 1229 | try{ |
1132 | | - if(!isset($_GET['tid'])) |
| 1230 | + if(!isset($_GET['tid']) || $_GET['tid']=='') |
1133 | 1231 | throw new Exception('tid parameter required'); |
1134 | | - if(!isset($_GET['lid'])) |
| 1232 | + if(!isset($_GET['lid']) || $_GET['lid']=='') |
1135 | 1233 | throw new Exception('lid parameter required'); |
1136 | 1234 | $trackUUID = $_GET['tid']; |
1137 | 1235 | $linkUUID = $_GET['lid']; |
|
0 commit comments