<!-- Put IE into quirks mode -->
<!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="en">
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>n e t  d i s c o \
% if (defined $netdisco::CONFIG{customer}) {
-  <% $netdisco::CONFIG{customer} %> \
% }
<& SELF:title &> </TITLE>
<LINK REL="stylesheet" HREF="<%$path%>/netdisco.css" TYPE="text/css" MEDIA="screen">
<LINK REL="stylesheet" HREF="<%$path%>/mktree.css" TYPE="text/css" MEDIA="screen">
<LINK REL="SHORTCUT ICON" HREF="<%$path%>/netdisco.ico">
<& SELF:html_head &>
% if (defined($netdisco::CONFIG{fp_overlib}) && $netdisco::CONFIG{fp_overlib} == 'true') { 
	<script type="text/javascript" src="overlib_mini.js"><!-- overLIB (c) Erik Bosrup --></script>
% }
<script type="text/javascript" src="<%$path%>/mktree.js"></script>
</HEAD>
<BODY>
% if (defined($netdisco::CONFIG{fp_overlib}) && $netdisco::CONFIG{fp_overlib} == 'true') { 
    <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
% }
    <div id="topbar">
    <TABLE CLASS="topbar">
    <TR>
        <TD VALIGN=MIDDLE ROWSPAN=2 CLASS="logo">
            <A HREF="<%$path%>/index.html" TITLE="Netdisco Main Menu"><IMG SRC="<%$src%>" style="border: 0;" width=<%$width%> height=<%$height%> alt="<%$alt%>"></A>
        </TD>
% if ($ok) {
        <TD ALIGN=CENTER ROWSPAN=2 CLASS="search">
            <FORM ACTION="search.html" METHOD=GET>
            <DIV>
                <INPUT TYPE="text" SIZE=30 NAME="s" MAXLENGTH=255 VALUE="<%$s_term|h%>">
                <BR>
                <INPUT TYPE="RADIO" NAME="stype" VALUE="device"<%$s_type eq 'device'? ' CHECKED' : ''%>>Device
                <INPUT TYPE="RADIO" NAME="stype" VALUE="node"<%$s_type eq 'node'? ' CHECKED' : ''%>>Node
                <INPUT TYPE="RADIO" NAME="stype" VALUE="vlan"<%$s_type eq 'vlan'? ' CHECKED' : ''%>>VLAN
                <INPUT TYPE="submit" class="topbutton" VALUE="Search">
            </DIV>
            </FORM>
        </TD>
        <TD CLASS="navtop">
            ADVANCED SEARCH:
            <A class="topbutton" HREF="<%$path%>/netmap.html">NetMap</A> 
            <A class="topbutton" HREF="<%$path%>/device_search.html">Device</A> 
            <A class="topbutton" HREF="<%$path%>/device_module_search.html">Module</A> 
            <A class="topbutton" HREF="<%$path%>/node.html">Node</A>
% if ($netdisco::CONFIG{traceroute}) {
            <A class="topbutton" HREF="<%$path%>/traceroute.html">TraceRoute</A>
% }
        </TD></TR>
        <TR><TD CLASS="navbot">
            REPORT:
            <A class="topbutton" HREF="<%$path%>/device_inv.html" TITLE="Device Inventory by Vendor and Model">Inventory</A>
            <A class="topbutton" HREF="<%$path%>/port_report.html" TITLE="Search and Report on switch ports that have been administratively disabled.">Ports</A>
            <A class="topbutton" HREF="<%$path%>/ip_search.html" TITLE="Show inventory of IP Address space">IP</A>
            <A class="topbutton" HREF="<%$path%>/ip_search.html" TITLE="Show inventory of Netbios Domains">SMB</A>
            <A class="topbutton" HREF="<%$path%>/log.html" TITLE="Backend Log">Log</A>
            <A class="topbutton" HREF="<%$path%>/duplex.html" TITLE="Duplex Mismatch Finder">Duplex</A>
            <A class="topbutton" HREF="<%$path%>/reports.html" TITLE="More reports">More</A>
        </TD></TR>
% } else {
	<TD COLSPAN=2 ROWSPAN=2>
	<!-- not logged in -->
	<!-- wish logo could be pushed more to the left -->
        &nbsp;
	</TD>
	</TR>
% }
        </TABLE>
    </div>
    <div id="content">
%       $m->call_next;
    </div>
    <div id="botbar">
    <TABLE CLASS="botbar">
    <TR>
        <TD CLASS="ver"><SPAN CLASS="logotext">netdisco </SPAN><%$netdisco::VERSION%></TD>
% if ($ok) {
        <TD CLASS="nav"><A HREF="<%$path%>/stats.html" CLASS="navbutton">About</A>
            <A HREF="<%$path%>/doc" class="navbutton">Documentation</A>
% if ($admin and $secure) {
            <A HREF="<%$path%>/admin.html" class="navbutton">Administration Panel</A>
% }
        </TD>
% } else {
        <TD>
        &nbsp;
        </TD>
% }
        <TD CLASS="login">
% if ($secure and $netdisco::CONFIG{secure_server} ) {
            <IMG SRC="<%$path%>/icon_lock.gif" ALT="Secure Connection" TITLE="Secure Connection" HEIGHT=15 WIDTH=15>
% } elsif (!$secure) {
            <A HREF="<%$url%>" ALT="Switch to Secure Connection for more features" TITLE="Switch to Secure Connection for more features"><IMG SRC="<%$path%>/icon_up.gif" WIDTH=11 HEIGHT=10 BORDER=0></A> 
% }
% if ($user and $ok) {
            <span class="u">User</span>: <%$user%> <A HREF="<%$path%>/logout.html" CLASS="navbutton">Logout</A>
%   if ($useuserdb) {
            <A HREF="<%$path%>/change_pw.html" class="navbutton">Change Password</A>
%   } else {
            <A HREF="<%$path%>/login.html" class="navbutton">Netdisco Login</A>
%   }
% } else {
%   if ($netdisco::CONFIG{apache_auth}) {
            <A HREF="<%$path%>/apache_login.html" class="navbutton">Login</A>
            <A HREF="<%$path%>/login.html" class="navbutton">Netdisco Login</A>
%   } else {
            <A HREF="<%$path%>/login.html" class="navbutton">Login</A>
%   }
% }
    </TD>
  </TR>
</TABLE>
    </div>
</BODY>
</HTML>
<%init>
my $cfgupdate = netdisco::updateconfig();
my $session_timeout = $netdisco::CONFIG{websession} || 60; # min
my $s_term = $m->session->{_s_term} || '';
my $s_type = $m->session->{_s_type} || 'device';

my $ok = 0;

# Authentication - Logged in and not expired?
if (defined $m->session->{_logged_in} and $m->session->{_logged_in} ){
    if (defined $m->session->{start}) {
        my $age = time - $m->session->{start};
        $ok = $age < 60*$session_timeout;
    } 
}

# Redirect to Login page unless we're ok
my $path   = $netdisco::CONFIG{webpath};
my $target = $m->fetch_next->name;
unless ($ok or $target =~ /(apache_)?login.html/ or $target =~ /^public/) {
    my $target_uri = $r->uri;
    my $target_args = $r->args;
    my $url = $target_uri;
    $url .= "?$target_args" if (defined $target_args and length($target_args));
    HTML::Mason::Escapes::url_escape(\$url);
    my $page = $netdisco::CONFIG{apache_auth} ? "apache_login" : "login";
    $m->redirect("$path/$page.html?done=$url");
} 

# For Logging, tell apache what user is in:
$r->connection->user($m->session->{user}) if ($ok && defined($m->session->{user}));

# Discoball image
my $width = 60;
my $height = 65;
my $src = $path . "/discoball2.gif";
my $alt = "[Disco Ball]";
if (defined $netdisco::CONFIG{customericon}) {
   my ($iconname, $iconwidth, $iconheight) = split(/\s*,\s*/, $netdisco::CONFIG{customericon});
   $src = ($iconname =~ m|/|) ? $iconname : $path . "/" . $iconname;
   $width = $iconwidth if defined($iconwidth);
   $height = $iconheight if defined($iconheight);
   $alt = "[Home]";
}

</%init>
<%shared>
my $path   = $netdisco::CONFIG{webpath};
my $user   = $m->session->{user};
my $secure = &is_secure;
my $admin  = $m->session->{user_admin};
my $useuserdb = $m->session->{useuserdb};
my $port_info = (defined $netdisco::CONFIG{port_info} and $netdisco::CONFIG{port_info} =~ /^(1|t|y)/i) ? 1 : 0;
my $url    = $r->uri;
my $args   = $r->args;
$url .= "?$args" if (defined $args and length($args));
$url = url_secure($url);
</%shared>
<%flags>
inherit=>undef
</%flags>
<%method topbar>
\
</%method>
<%method html_head>
\
</%method>
<%method title>
\
</%method>
%# $Id: autohandler,v 1.39 2009/06/03 00:46:43 maxbaker Exp $
%# vim:syntax=mason
