Skip to content

Commit

Permalink
Added 3rd party API into main project
Browse files Browse the repository at this point in the history
Max 150 requests per min.

added 3rd party api for getting ISP and country into write.php

Added 2 sql files with populated example data

Chanched index.html and the JS files integrating the new DB model
  • Loading branch information
Slober3 committed Jul 5, 2017
1 parent b36c231 commit ceefc00
Show file tree
Hide file tree
Showing 10 changed files with 6,469 additions and 57 deletions.
1,678 changes: 1,678 additions & 0 deletions Website+Backend/SQL-files/iplog.sql

Large diffs are not rendered by default.

3,579 changes: 3,579 additions & 0 deletions Website+Backend/SQL-files/loginput.sql

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion Website+Backend/api/write.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,30 @@
$ip=$ipExplodeDataArray[0];
$portHacker=$ipExplodeDataArray[1];

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://ip-api.com/json/'.$ip);
$result = curl_exec($ch);
curl_close($ch);

$obj = json_decode($result);
$country = $obj->country;
$isp= $obj->isp;


try {
$dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

if (!isset($_POST["input"])) {
$stmt = $dbh->prepare("INSERT INTO iplog (ip, port, portHacker) VALUES (:ip, :port, :portHacker)");
$stmt = $dbh->prepare("INSERT INTO iplog (ip, port, country, isp, portHacker) VALUES (:ip, :port, :country, :isp, :portHacker)");
$stmt->bindParam(':ip', $ip);
$stmt->bindParam(':port', $_POST["port"]);
$stmt->bindParam(':portHacker', $portHacker);
$stmt->bindParam(':country', $country);
$stmt->bindParam(':isp', $isp);
// use exec() because no results are returned
$stmt->execute();
}
Expand Down
2 changes: 1 addition & 1 deletion Website+Backend/css/bootstrap-theme.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Website+Backend/css/bootstrap.min.css

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions Website+Backend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1><span class="blue">&lt;</span>PotHead<span class="blue">&gt;</span> <span cl
</div>


<table class="container">
<table class="container myTable" id="myTable">
<thead>
<tr>
<th>
Expand All @@ -57,10 +57,17 @@ <h1><span class="blue">&lt;</span>PotHead<span class="blue">&gt;</span> <span cl
</th>
<th>
Internet Protocol address
</th>
<th>
Port
</th>
</th>
<th id="onlyconnC">
Country
</th>
</th>
<th id="onlyconnI">
ISP.
</th>
<th id="hiddenth" class="hide">
Input
</th>
Expand Down
2 changes: 1 addition & 1 deletion Website+Backend/js/bootstrap.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Website+Backend/js/jquery.min.js

Large diffs are not rendered by default.

29 changes: 13 additions & 16 deletions Website+Backend/js/scriptv2.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
function getLast(number) {
$.getJSON("http://7ol.eu/api/api.php/connection/last/" + number, function(data) {
var items = [];
var i = 0;
$.each(data, function(key, val) {
items.push("<tr>" + "<td>" + val.id + "</td>" + "<td>" + val.time + "</td>" + "<td>" + "<a href='http://www.ipvoid.com/scan/" + val.ip + "/'>" + val.ip + "</a>" + "</td>" + "<td>" + val.port + "</td>" + "<td>" + val.portHacker + "</td>" + "</tr>");
getCountry(val.ip, i)
i++;
items.push("<tr>" + "<td>" + val.id + "</td>" + "<td>" + val.time + "</td>" + "<td>" + "<a href='http://www.ipvoid.com/scan/" + val.ip + "/'>" + val.ip + "</a>" + "</td>" + "<td>" + val.port + "</td>" + "<td>" + val.country+ "</td>" + "<td>" + val.isp+ "</td>" + "<td>" + val.portHacker + "</td>" + "</tr>");
});

$("<tbody/>", {
Expand All @@ -14,18 +11,7 @@ function getLast(number) {
});
}

function getCountry(ip, i) {
$.getJSON("http://ip-api.com/json/" + ip, function(data) {

var firstRow = document.getElementById("myTable").rows[i + 1];
var x = firstRow.insertCell(3);
$("#hiddencountry").removeClass("hide");
x.setAttribute('id', 'hiddencountry');
x.innerHTML = data.country;
$("#hiddencountrytd").hide();
$("#hiddencountrytd").show("slow");
});
}

getLast(10);

Expand All @@ -37,13 +23,24 @@ $("#ipInput").keyup(function(event) {

function getIP() {
$("#hiddenth").removeClass("hide");
$("#onlyconnC").addClass("hide");
$("#onlyconnI").addClass("hide");



$("tbody").remove();

if (!$("#ipInput").val()) {
$("#hiddenth").addClass("hide");
$("#onlyconnC").removeClass("hide");
$("#onlyconnI").removeClass("hide");


getLast(10);
} else {
$("#hiddencountry").addClass("hide");
$("#onlyconnC").addClass("hide");
$("#onlyconnI").addClass("hide");

$.getJSON("http://7ol.eu/api/api.php/cinput/ip/" + $("#ipInput").val(), function(data) {
var items = [];
$.each(data, function(key, val) {
Expand Down
1,203 changes: 1,170 additions & 33 deletions Website+Backend/logs/PotHeadLog.txt

Large diffs are not rendered by default.

0 comments on commit ceefc00

Please sign in to comment.