X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fbrowse%2Fnas.cgi;h=b5e0ef8b704c7bb2295f8cd073ad805c5386b16e;hb=04a69f9d197efee6fa396bd35d04ae553e669978;hp=9ccbfe6325761cd75c0fff37e73c95d3d62d36a7;hpb=b8cfd0780aa40bb07f3215bf9cb58011f5e32a35;p=freeside.git
diff --git a/httemplate/browse/nas.cgi b/httemplate/browse/nas.cgi
index 9ccbfe632..b5e0ef8b7 100755
--- a/httemplate/browse/nas.cgi
+++ b/httemplate/browse/nas.cgi
@@ -1,80 +1,82 @@
-
-<%
+%print header('NAS ports');
+%
+%my $now = time;
+%
+%foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) {
+% print $nas->nasnum. ": ". $nas->nas. " ".
+% $nas->nasfqdn. " (". $nas->nasip. ") ".
+% "as of ". time2str("%c",$nas->last).
+% " (". &pretty_interval($now - $nas->last). " ago)
".
+% &table(). "
Nas Port # | Global Port # | ".
+% "IP address | User | Since | Duration |
---|
",
+% ;
+% foreach my $port ( sort {
+% $a->nasport <=> $b->nasport || $a->portnum <=> $b->portnum
+% } qsearch( 'port', { 'nasnum' => $nas->nasnum } ) ) {
+% my $session = $port->session;
+% my($user, $since, $pretty_since, $duration);
+% if ( ! $session ) {
+% $user = "(empty)";
+% $since = 0;
+% $pretty_since = "(never)";
+% $duration = '';
+% } elsif ( $session->logout ) {
+% $user = "(empty)";
+% $since = $session->logout;
+% } else {
+% my $svc_acct = $session->svc_acct;
+% $user = "svcnum. "\">".
+% $svc_acct->username. "";
+% $since = $session->login;
+% }
+% $pretty_since = time2str("%c", $since) if $since;
+% $duration = pretty_interval( $now - $since ). " ago"
+% unless defined($duration);
+% print "
". $port->nasport. " | ". $port->portnum. " | ".
+% $port->ip. " | $user | $pretty_since".
+% " | $duration |
"
+% ;
+% }
+% print "
";
+%}
+%
+%#Time::Duration??
+%sub pretty_interval {
+% my $interval = shift;
+% my %howlong = (
+% '604800' => 'week',
+% '86400' => 'day',
+% '3600' => 'hour',
+% '60' => 'minute',
+% '1' => 'second',
+% );
+%
+% my $pretty = "";
+% foreach my $key ( sort { $b <=> $a } keys %howlong ) {
+% my $value = int( $interval / $key );
+% if ( $value ) {
+% if ( $value == 1 ) {
+% $pretty .=
+% ( $howlong{$key} eq 'hour' ? 'an ' : 'a ' ). $howlong{$key}. " "
+% } else {
+% $pretty .= $value. ' '. $howlong{$key}. 's ';
+% }
+% }
+% $interval -= $value * $key;
+% }
+% $pretty =~ /^\s*(\S.*\S)\s*$/;
+% $1;
+%}
+%
+%#print &table(), <
+%# # |
+%# NAS
+%
-print header('NAS ports', menubar(
- 'Main Menu' => $p,
-));
+<%init>
-my $now = time;
+#this hasn't been used in ages, and isn't linked from anywhere...
+die 'NAS browse not currently active';
-foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) {
- print $nas->nasnum. ": ". $nas->nas. " ".
- $nas->nasfqdn. " (". $nas->nasip. ") ".
- "as of ". time2str("%c",$nas->last).
- " (". &pretty_interval($now - $nas->last). " ago) ".
- &table(). " | Nas Port # | Global Port # | ".
- "IP address | User | Since | Duration |
---|
",
- ;
- foreach my $port ( sort {
- $a->nasport <=> $b->nasport || $a->portnum <=> $b->portnum
- } qsearch( 'port', { 'nasnum' => $nas->nasnum } ) ) {
- my $session = $port->session;
- my($user, $since, $pretty_since, $duration);
- if ( ! $session ) {
- $user = "(empty)";
- $since = 0;
- $pretty_since = "(never)";
- $duration = '';
- } elsif ( $session->logout ) {
- $user = "(empty)";
- $since = $session->logout;
- } else {
- my $svc_acct = $session->svc_acct;
- $user = "svcnum. "\">".
- $svc_acct->username. "";
- $since = $session->login;
- }
- $pretty_since = time2str("%c", $since) if $since;
- $duration = pretty_interval( $now - $since ). " ago"
- unless defined($duration);
- print "
". $port->nasport. " | ". $port->portnum. " | ".
- $port->ip. " | $user | $pretty_since".
- " | $duration |
"
- ;
- }
- print "
";
-}
-
-#Time::Duration??
-sub pretty_interval {
- my $interval = shift;
- my %howlong = (
- '604800' => 'week',
- '86400' => 'day',
- '3600' => 'hour',
- '60' => 'minute',
- '1' => 'second',
- );
-
- my $pretty = "";
- foreach my $key ( sort { $b <=> $a } keys %howlong ) {
- my $value = int( $interval / $key );
- if ( $value ) {
- if ( $value == 1 ) {
- $pretty .=
- ( $howlong{$key} eq 'hour' ? 'an ' : 'a ' ). $howlong{$key}. " "
- } else {
- $pretty .= $value. ' '. $howlong{$key}. 's ';
- }
- }
- $interval -= $value * $key;
- }
- $pretty =~ /^\s*(\S.*\S)\s*$/;
- $1;
-}
-
-#print &table(), <
-# # |
-# NAS
-%>
+%init>
|