init III
This commit is contained in:
91
Perl CGI C2/admin/edit_host.pl
Normal file
91
Perl CGI C2/admin/edit_host.pl
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/bin/perl
|
||||
use strict;
|
||||
use mysql;
|
||||
use CGI qw(:standard);
|
||||
|
||||
my $edit = param('edit');
|
||||
my $edit1 = param('edit1');
|
||||
my $descr=param('descr');
|
||||
my $hostn=param('hostname');
|
||||
my $ipadd=param('ip');
|
||||
my $rocom=param('roc');
|
||||
my $rwcom=param('rwc');
|
||||
my $snmpp=param('port');
|
||||
|
||||
my $dbh = DBI->connect("DBI:mysql:database=c2;host=localhost",'root','', {RaiseError => 1});
|
||||
|
||||
print header();
|
||||
print "<html>\n";
|
||||
print "<head>\n";
|
||||
print "<style type='text/css'>\n";
|
||||
print "select { font-size:8pt }\n";
|
||||
|
||||
print "</style>\n";
|
||||
|
||||
print "</head>\n";
|
||||
print "<body>\n";
|
||||
print "<b><u>Host editieren</u></b>\n";
|
||||
if ($edit eq "") {
|
||||
my $sth = $dbh->prepare("select ind,description,hostname,ip from hosts order by 'hostname'");
|
||||
$sth->execute;
|
||||
print "<form action='edit_host.pl'>\n";
|
||||
print "<table>\n";
|
||||
while (my $ref = $sth->fetchrow_arrayref()) {
|
||||
print "<tr>\n";
|
||||
print "<td><input type='radio' name='edit' value='$ref->[0]'></td>\n";
|
||||
print "<td><input type='text' readonly value='$ref->[1]'></td>\n";
|
||||
print "<td><input type='text' readonly value='$ref->[2]'></td>\n";
|
||||
print "<td><input type='text' readonly value='$ref->[3]'></td>\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "<tr><td></td>\n<td><input type='submit' name='edit1' value='Edit'></td></tr>\n";
|
||||
print "</table>\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
else {
|
||||
if ($edit1 eq "Edit") {
|
||||
my $sth = $dbh->prepare("select ind,description,hostname,ip,rw_community,ro_community,snmp_port from hosts where ind='$edit'");
|
||||
$sth->execute;
|
||||
while (my $ref = $sth->fetchrow_arrayref()) {
|
||||
print "<form action='edit_host.pl'>\n";
|
||||
print "<table border='1'>\n";
|
||||
print "<tr>\n<td>Description</td>\n";
|
||||
print "<td><input name='descr' type='text' value='$ref->[1]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td>Hostname</td>\n";
|
||||
print "<td><input name='hostname' type='text' value='$ref->[2]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td>IP</td>\n";
|
||||
print "<td><input name='ip' type='text' value='$ref->[3]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td>RO-community</td>\n";
|
||||
print "<td><input name='roc' type='text' value='$ref->[5]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td>RW-community</td>\n";
|
||||
print "<td><input name='rwc' type='text' value='$ref->[4]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td>SNMP-Port</td>\n";
|
||||
print "<td><input name='port' type='text' value='$ref->[6]'></td>\n";
|
||||
print "</tr>\n";
|
||||
print "</table>\n";
|
||||
print "<input type='submit' name='edit1' value='Speichern'>\n";
|
||||
print "<input type='hidden' name='edit' value='$edit'>\n";
|
||||
print "</form>\n";
|
||||
}
|
||||
}
|
||||
if ($edit1 eq "Speichern") {
|
||||
$dbh->do("update hosts set description='$descr', hostname='$hostn', ip='$ipadd', rw_community='$rwcom', ro_community='$rocom', snmp_port='$snmpp' where ind='$edit'");
|
||||
#$dbh->do(
|
||||
print "<br>Gespeichert\n";
|
||||
}
|
||||
|
||||
#print "Löschen durchgeführt!";
|
||||
}
|
||||
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
||||
Reference in New Issue
Block a user