-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·65 lines (57 loc) · 2.26 KB
/
index.php
File metadata and controls
executable file
·65 lines (57 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
header('Content-type: text/html; charset=utf-8');
include 'config.php';
require 'vendor/autoload.php';
$config['displayErrorDetails'] = true;
$config['addContentLengthHeader'] = true;
$config['determineRouteBeforeAppMiddleware'] = true;
use Slim\Views\PhpRenderer;
$app = new \Slim\App(["settings" => $config]);
$container = $app->getContainer();
$container['renderer'] = new PhpRenderer("./views");
//$app->get('/ip[/{ip1}[/{ip2}[/{status}]]]', function ($request, $response, $args) {
$app->get('/ip[/{ip1}[/{ip2}]]', function ($request, $response, $args) {
// IP block:
$ip1 = (isset($args['ip1']) ? $args['ip1'] : null);
// filter status:
$ip2 = (isset($args['ip2']) ? $args['ip2'] : null);
$args['baseUri'] = $request->getUri()->getBasePath();
$args['title'] = TITLE;
echo 0;
if ($ip1 != null) {
$db = new ezSQL_mysqli(USER, PASS, DB, HOST);
echo 1;
if (isset($ip1) and isset($ip2)) {
echo 2;
if ($ip2 == "up" || $ip2 == "down") {
echo 3;
$like = '160.75.' . $ip1 . '.%';
$sql = "SELECT ip, host, mac, vendor, status, timestr FROM netmon";
$sql .= " WHERE ip LIKE '$like' AND status='$ip2' ORDER BY INET_ATON(ip)";
} else {
echo 4;
$like = '160.75.' . $ip1 . '.' . $ip2;
$sql = "SELECT netmon.ip, netmon.host, iplog.mac, iplog.vendor, iplog.status, iplog.timestr FROM netmon
LEFT JOIN iplog ON netmon.id = iplog.netmon_id
WHERE netmon.ip = '$like'
ORDER BY iplog.timestr DESC";
}
} elseif (isset($ip1)) {
$like = '160.75.' . $ip1 . '.%';
$sql = "SELECT ip, host, mac, vendor, status, timestr FROM netmon";
$sql .= " WHERE ip LIKE '$like' ORDER BY INET_ATON(ip)";
}
$args['result'] = $db->get_results($sql);
}
return $this->renderer->render($response, "/index.phtml", $args);
});
$app->run();
function url($path = null, $absolute = false)
{
$url = pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME) . "/" . $path;
$url = preg_replace("/\/\/+/", "/", $url);
if ($absolute) {
$url = "http://" . $_SERVER["SERVER_NAME"] . $url;
}
return $url;
};