--- lib/PXElator/httpd.pm 2009/08/29 17:03:35 347
+++ lib/PXElator/httpd.pm 2009/09/07 21:57:35 392
@@ -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 '/' ) {
@@ -154,12 +173,15 @@
;
}
- if ( $name->can('fork_if_active') ) {
- $html .= qq|
$_| foreach $name->fork_if_active;
+ my $class = $name;
+ $class =~ s{\.\d+$}{};
+
+ if ( $class->can('fork_if_active') ) {
+ $html .= qq|
$_| foreach $class->fork_if_active;
}
- if ( $name->can('actions') ) {
- $html .= qq|
$_| foreach $name->actions;
+ if ( $class->can('actions') ) {
+ $html .= qq|
$_| foreach $class->actions;
}
} else {
if ( $pid =~ m{^\d+$} ) {
@@ -201,16 +223,23 @@
;
} elsif ( $path =~ m{^/server} ) {
+ if ( my $c = $param->{new_clients} ) {
+ server::shared( 'new_clients', $c );
+ }
print $client ok
+ , qq|
|
;
} 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 +278,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||,
@@ -257,8 +289,6 @@
html::conf( $ip, $conf, 'edit', @editable )
);
-warn "XX conf ",dump( $conf );
-
print $client ok
, qq|