Files
scripts-conlxsyslog03/root/observium/port_config/site2.php
conetadm 5718e70f15 init
2024-11-14 21:11:06 +01:00

63 lines
2.3 KiB
PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-DE" lang="de-DE">
<head>
<title>Port Config</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
// Zeige Eingabefeld
if( $_POST["hostname"] == "" or $_POST["ifname"] == "" ) {
?>
<form action='site2.php' method='post'>
<input type='text' name='hostname' list='hostnamelist' size='30'>
<datalist id='hostnamelist'>
<?php
$pdo = new PDO('mysql:host=10.101.0.11;dbname=observium', 'root', 'lunakoshix');
$sql = "select hostname from devices where devices.type = 'network' order by hostname asc";
foreach ($pdo->query($sql) as $row) {
echo " <option value='$row[hostname]'>";
}
?>
</datalist>
<input type='text' name='ifname' list='ifnamelist' size='30'>
<datalist id='ifnamelist'>
<?php
$sql = "select distinct port_label from ports inner join devices on ports.device_id = devices.device_id where devices.type = 'network' order by port_label asc";
foreach ($pdo->query($sql) as $row) {
echo " <option value='$row[port_label]'>";
}
?>
</datalist>
<input type=submit value='show'>
</form>
Wenn der Fokus auf einem Eingabefeld liegt, zeigt ein weiterer Klick alle Optionen<br>
Die Felder haben eine Autofilloption, d.h. einfach Tippen und es werden alle m&ouml;glichen Treffer angezeigt.<br>
Den gew&uuml;nschten per Klick annehmen<br>
<br>
Skripte unter root@conlxsyslog03:/scripts/root/observium/port_config/
<?php
}
else {
// Zeige Suchergebnis
echo "Hostname: $_POST[hostname] Interface: $_POST[ifname]<br>\n";
$if=$_POST['ifname'];
$line = file_get_contents("/home/rancid/var/rancid/network/configs/$_POST[hostname]");
$pattern = '#(interface ' . $if . '\n( (.*)\n)*)#i';
preg_match($pattern, $line, $match);
$str=$match[0];
$str2 = str_replace("\n","<br>\n",$str);
echo "<br><br>\n$str2\n<br><br>\n";
echo "<a href='site2.php'>back</a>";
?>
<?php
}
?>
</body>
</html>