Skip to content

Instantly share code, notes, and snippets.

@alecnunn
Last active December 31, 2015 17:49
Show Gist options
  • Select an option

  • Save alecnunn/8023082 to your computer and use it in GitHub Desktop.

Select an option

Save alecnunn/8023082 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="" name="description">
<meta content="Alec Nunn" name="author">
<link href="" rel="shortcut icon">
<title>DB Results</title><!-- Bootstrap core CSS -->
<link href="css/spacelab.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="well">
<h2>Scan Results v0.1</h2>
<h4>Created by IT3 Nunn</h4>
</div>
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
Please be aware that this is still in the very early stages and is nowhere near completion.
</div>
<div class="navbar">
<div class="navbar-inner">
<form class="navbar-form pull-left">
<button class="btn"><i class="icon-list-alt"></i> Generate Report</button>
</form>
</div>
</div>
<div class="well">
<table class="table table-condensed table-striped table-hover table-bordered">
<!--we create here table heading-->
<thead>
<tr>
<th>Machine ID</th>
<th>IP Address</th>
<th>Hostname</th>
<th>Operating System</th>
<th>Port [80]</th>
<th>Port [8080]</th>
<th>Port [443]</th>
</tr>
</thead>
<tbody>
<?php
//set up mysql connection
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'P@ssw0rd';
//number of results to show per page
$rec_limit = 20;
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
//select database
mysql_select_db('pbnjout');
/* Get total number of records */
$sql = "SELECT count(mid) FROM results ";
$retval = mysql_query($sql, $conn);
if (!$retval) {
die('Could not get data: ' . mysql_error());
}
$row = mysql_fetch_array($retval, MYSQL_NUM);
$rec_count = $row[0];
if (isset($_GET{'page'})) { //get the current page
$page = $_GET{'page'} + 1;
$offset = $rec_limit * $page;
} else {
// show first set of results
$page = 0;
$offset = 0;
}
$left_rec = $rec_count - ($page * $rec_limit);
//we set the specific query to display in the table
$sql = "SELECT `mid`, `ip`, `hostname`, `os`, `80`, `8080`, `443` " ."FROM results ". "LIMIT $offset, $rec_limit";
$retval = mysql_query($sql, $conn);
if (!$retval) {
die('Could not get data: ' . mysql_error());
}
//we loop through each records
while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
//populate and display results data in each row
echo '<tr>';
echo '<td>' . $row['mid'] . '</td>';
echo '<td>' . $row['ip'] . '</td>';
echo '<td>' . $row['hostname'] . '</td>';
echo '<td>' . $row['os'] . '</td>';
echo '<td><center><span class="label label-' . $row['80'] . '">80</span></center></td>';
echo '<td><center><span class="label label-' . $row['8080'] . '">8080</span></center></td>';
echo '<td><center><span class="label label-' . $row['443'] . '">443</span></center></td>';
}
echo '</tr>';
echo '</tbody>';
echo '</table>';
//we display here the pagination
echo "<center>"; //echo '<ul class="pager">';
if ($left_rec < $rec_limit) {
$last = $page - 2;
echo @"<a class=\"btn\" href=\"$_PHP_SELF?page=$last\">Previous</a>";
echo @"<a class=\"btn disabled\">Next</a>";
} else if ($page == 0) {
echo @"<a class=\"btn disabled\">Previous</a>";
echo @"<a class=\"btn\" href=\"$_PHP_SELF?page=$page\">Next</a>";
} else if ($page > 0) {
$last = $page - 2;
echo @"<a class=\"btn\" href=\"$_PHP_SELF?page=$last\">Previous</a> ";
echo @"<a class=\"btn\" href=\"$_PHP_SELF?page=$page\">Next</a>";
}
echo @'</center>';
mysql_close($conn);
?>
</tbody>
</table>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment