Files

82 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2015-11-18 19:15:23 +01:00
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$pagetitle[] = 'RIPE NCC - API Tools';
2019-01-25 15:30:58 -06:00
$no_refresh = true;
2015-11-18 19:15:23 +01:00
?>
<h3> RIPE NCC API Tools </h3>
<hr>
<form class="form-horizontal" action="" method="post">
2019-07-17 07:20:26 -05:00
<?php echo csrf_field() ?>
2015-11-21 00:44:13 +01:00
<div class="radio">
2015-11-21 01:05:50 +01:00
<label><input type="radio" name="data_radio" value="abuse-contact-finder">Abuse Contact Finder</label>
2015-11-21 00:44:13 +01:00
</div>
<div class="radio">
2015-11-21 01:05:50 +01:00
<label><input type="radio" name="data_radio" value="whois">Whois</label>
2015-11-21 00:44:13 +01:00
</div>
2015-11-21 01:11:42 +01:00
<br />
2015-11-21 00:44:13 +01:00
<div class="input-group">
<input type="text" class="form-control" id="input-parameter" placeholder="IP, ASN etc.">
<span class="input-group-btn">
<button type="submit" name="btn-query" id="btn-query" class="btn btn-primary">Query</button>
</span>
</div>
2015-11-18 19:15:23 +01:00
</form>
<br />
2019-01-25 15:30:58 -06:00
<div class="alert alert-success" style="display: none;">
<pre id="ripe-output"></pre>
</div>
2015-11-18 19:15:23 +01:00
<br />
<script>
2015-11-21 00:44:13 +01:00
$("[name='btn-query']").on('click', function(event) {
event.preventDefault();
2015-11-21 01:05:50 +01:00
var data_param = $('input[name=data_radio]:checked').val();
2015-11-21 00:44:13 +01:00
var query_param = $("#input-parameter").val();
$.ajax({
type: 'POST',
2019-01-25 15:30:58 -06:00
url: 'ajax/ripe/raw',
2015-11-21 00:44:13 +01:00
data: {
data_param: data_param,
query_param: query_param
},
dataType: "json",
success: function(data) {
2019-01-25 15:30:58 -06:00
var output = $('#ripe-output');
output.empty();
output.parent().show();
2015-11-21 00:44:13 +01:00
if (data.output.data.records)
$.each(data.output.data.records[0], function(row, value) {
$('#ripe-output').append(value['key'] + ' = ' + value['value'] + '<br />');
});
else if (data.output.data.anti_abuse_contacts.abuse_c)
$.each(data.output.data.anti_abuse_contacts.abuse_c, function(row, value) {
$('#ripe-output').append(value['description'] + ' = ' + value['email'] + '<br />');
});
},
2019-01-25 15:30:58 -06:00
error: function(data) {
if (data.status === 422) {
var json = data.responseJSON;
var errors = [];
for (var attrib in json) {
errors.push(json[attrib]);
}
toastr.error('Error: ' + errors.join("<br />"));
} else {
toastr.error(data.responseJSON.message);
}
2015-11-18 19:15:23 +01:00
}
2015-11-21 00:44:13 +01:00
});
2015-11-18 19:15:23 +01:00
});
</script>