-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
161 lines (123 loc) · 4.19 KB
/
index.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
include( "./net_funcs.php" );
include( "./cache.php" );
?>
<html>
<head>
<title>Network Monitor Tools</title>
<META http-equiv="REFRESH" content="120">
</head>
<body>
<?php
//debug mode:
error_reporting(1);
//echo "Izaberi mapu:" ;
if (!$mapa) {
$mapa="etf";
print "<a href=\"$fajl?crtaj=1\">crtaj</a>"; //link za rucno skeniranje
}
// ImageMagic path
$put="/usr/local/bin/";
$fajl= "index.php";
// Mysql data
$mysql_host = "localhost";
$mysql_user = "milan";
$mysql_pass = "urukalo";
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
mysql_select_db("milan");
if (!$d) {
if ($crtaj!=1){
$cache = $mapa.".jpg";
//kesiranje
//debug:
//error_reporting( E_ALL & ~E_NOTICE );
if ( $aResult = DumpCacheFile( $cache, 3 * 60 ) )
{
// ok, ucitali smo kesiranu stranicu, prekidamo
exit;
}
ob_start(); //funkcija koja skuplja izlaz
}
// generisanje mape:
print ("<MAP NAME=phmap>\n");
$obrisi = $put."convert -size 700x550 xc:skyblue map/".$mapa.".jpg ";
echo exec($obrisi); //resetovanje slike
//kupimo podatke iz baze:
$query = mysql_query(" SELECT naziv,ip,x,y,a,b,tip,servis,status from $mapa ORDER BY `id` DESC ");
while ($row = mysql_fetch_array($query))
{
$ime = $row["naziv"];
$host = $row["ip"];
$poz1 = $row["x"];
$poz2 = $row["y"];
$link1 = $row["a"];
$link2 = $row["b"];
$servis = $row ["servis"]; //niz servisa koji se prate (monitor trenutno ne podrzava sve ove servise)
$status = $row ["status"];
list($icmp,$http,$smtp,$pop3,$ssh,$dns) = split("/",$servis);
list($sicmp,$shttp,$ssmtp,$spop3,$sssh,$sdns) = split("/",$status);
$tip = $row["tip"];
// echo $ime,$icmp,$http,$smtp,$pop3,$ssh,$dns,"<br>";
//odabir slike:
if($tip == "AP") $slika="bridge.jpg";
elseif ($tip == "Ruter") $slika="ruter.jpg";
else $slika="server.gif";
//odabir boje:
$boja="LawnGreen";
if ($icmp==1){
if ($shttp==0 && $http==1) $boja = "Plum";
if ($ssmtp==0 && $smtp==1) $boja = "Plum";
if ($spop3==0 && $pop3==1) $boja = "Plum";
if ($sssh==0 && $ssh==1) $boja = "Plum";
if ($sdns==0 && $dns==1) $boja = "Plum";
if ($sicmp==0 && $icmp==1) $boja = "Tomato";
} else $boja = "Silver";
$potpis = $put."montage -frame 2 -geometry '50x40+0+0>' -pointsize 9 -mattecolor ". $boja ." -label '". $ime . "' slike/".$slika." 'slike/".$ime.".jpg'" ;
$dodaj = $put."composite -geometry +".$poz1."+".$poz2." 'slike/". $ime .".jpg' map/".$mapa.".jpg map/".$mapa.".jpg";
$linija = $put."convert -stroke black -linewidth 3 -draw \"line ".($poz1+25).",".($poz2+30)." ".($link1+25).",".($link2+30)."\" map/".$mapa.".jpg map/".$mapa.".jpg";
//echo $dodaj."<br>".$obrisi."<br>".$linija."<br>".$potpis."<br>";
print ("<AREA onMouseOver=\"showtext('$ime ip: $host')\" onMouseOut=\"showtext('')\" HREF=\"$file?d=$ime&mapa=$mapa\" ALT=\"$ime\" COORDS=\"$poz1,$poz2,".($poz1+54).",".($poz2+60)."\">\n");
echo exec ($potpis);
echo exec($linija);
echo exec($dodaj);
}
print "</MAP>\n";
print "<img src=\"map/".$mapa.".jpg\" alt=\"\" USEMAP=\"#phmap\" WIDTH=700 HEIGHT=550 align=\"left\">";
}
else {
$aSQL="SELECT naziv,ip,mac,tip, servis, status from $mapa WHERE `naziv` = '$d'";
//echo "$d $aSQL<br>";
$query = mysql_query($aSQL);
$row = mysql_fetch_array($query);
$ime = $row["naziv"];
$host = $row["ip"];
$mac = $row["mac"];
$tip = $row["tip"];
$servis = $row ["servis"];
$status = $row ["status"];
list($icmp,$http,$smtp,$pop3,$ssh,$dns) = split("/",$servis);
list($sicmp,$shttp,$ssmtp,$spop3,$sssh,$sdns) = split("/",$status);
if (!$edit){
print "Naziv: $ime <br> IP: $host <br> MAC: $mac <br> TIP: $tip <br>";
print "<br>Servisi koji se provjeravaju:
<br>ICMP:$icmp status: $sicmp
<br>HTTP:$http status: $shttp
<br>SMTP:$smtp status: $ssmtp
<br>POP3:$pop3 status: $spop3
<br>SSH:$ssh status: $sssh
<br>DNS:$dns status: $sdns
<br>";
print "<a href=\"$fajl?d=$d&mapa=$mapa&edit=1\">Promjeni</a>";
}
else {
print "U izradi !!!";
}
}
?>
</body>
</html>
<?
if ($crtaj!=1){
SaveCacheFile( $cache, ob_get_contents() );
}
?>