--- lib/PXElator/httpd.pm 2009/08/30 11:20:18 363
+++ lib/PXElator/httpd.pm 2009/08/30 15:54:30 379
@@ -19,8 +19,25 @@
use IO::Socket::INET;
use Regexp::Common qw/net/;
-sub menu {qq{
+our $title;
+sub html_start {
+qq{
+
+
+
home
server
@@ -109,7 +126,7 @@
}
sub ok {
- qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . menu()
+ qq|HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n| . html_start() . menu()
}
sub redirect {
@@ -125,6 +142,8 @@
CouchDB::audit( 'request', { path => $path, param => $param, peerhost => $client->peerhost } );
+ $title = $path;
+
if ( my $found = static( $client,$path ) ) {
warn "static $found" if $debug;
} elsif ( $path eq '/' ) {
@@ -211,6 +230,7 @@
;
} elsif ( $path =~ m!^/client(?:/$RE{net}{IPv4}{-keep})?! ) {
my $ip = $1;
+ $title = $ip;
if ( $param->{action} eq 'remove' ) {
client::remove( $param->{change_ip} );
@@ -249,7 +269,10 @@
my $nmap = qq|
nmap|;
my @table = (
- 'ping' => ping::host($ip) ? qq|
up $nmap| : qq|
down wol $nmap|,
+ 'ping' => ping::host($ip)
+ ? qq|
up $nmap|
+ : qq|
down wol $nmap|
+ ,
'ip' => qq|
old: $ip|,
'mac' => format::mac( delete $conf->{mac}, 'html' ),
'hostname' => qq||,
@@ -272,9 +295,7 @@
}
}
- if ( my $amt = client::conf( $ip, 'amt' ) ) {
- print $client qq|AMT
|, amt::info( $amt, $ip );
- }
+ print $client qq|amt info
|, amt::info( $ip ) if $conf->{amt};
} else {
@@ -350,6 +371,9 @@
}
} elsif ( $path =~ m{^/wol/(\S+)} ) {
print $client redirect( "$url/client/$1" ), wol::power_on($1);
+ } elsif ( $path =~ m!^/amt/(\w+)/$RE{net}{IPv4}{-keep}! ) {
+ my ( $run, $ip ) = ( $1, $2 );
+ print $client redirect( "$url/client/$ip" ), amt::RemoteControl( $ip, $run );
} elsif ( $path =~ m{^/our/(\w+)/(\S+)} ) {
eval 'our $' . $1 . ' = ' . $2;
warn $@ if $@;
@@ -413,7 +437,7 @@
warn "500 $request";
}
- print $client menu() if $client->connected;
+ print $client menu() . html_end() if $client->connected;
}