-
-sub showmenu() {
- print <<EOF
- <div id="menu-top">
- <ul>
-EOF
-;
- foreach my $k1 ( sort keys %$menu ) {
- if (! $menu->{$k1}{'enabled'}) {
- next;
- }
-
- my $link = getlink($menu->{$k1});
- if ($link eq '') {
- next;
- }
- if (! is_menu_visible($link)) {
- next;
- }
- if ($menu->{$k1}->{'selected'}) {
- print '<li class="selected">';
- } else {
- print '<li>';
- }
-
- print <<EOF
- <div class="rcorner">
- <a href="$link">$menu->{$k1}{'caption'}</a>
- </div>
- </li>
-EOF
-;
- }
-
- print <<EOF
- </ul>
- </div>
-EOF
-;
-}
-
-sub getselected($) {
- my $root = shift;
- if (!$root) {
- return 0;
- }
-
- foreach my $item (%$root) {
- if ($root->{$item}{'selected'}) {
- return $root->{$item};
- }
- }
-}
-
-sub showsubsection($$) {
- my $root = shift;
- my $id = shift;
- if ($id eq '') {
- $id = 'menu-left';
- }
-
- if (! $root) {
- return;
- }
- my $selected = getselected($root);
- if (! $selected) {
- return;
- }
- my $submenus = $selected->{'subMenu'};
- if (! $submenus) {
- return;
- }
-
- print <<EOF
- <div id="$id">
- <ul>
-EOF
-;
- foreach my $item (sort keys %$submenus) {
- my $hash = $submenus->{$item};
- if (! $hash->{'enabled'}) {
- next;
- }
-
- my $link = getlink($hash);
- if ($link eq '') {
- next;
- }
- if (! is_menu_visible($link)) {
- next;
- }
- if ($hash->{'selected'}) {
- print '<li class="selected">';
- } else {
- print '<li>';
- }
-
- print <<EOF
- <a href="$link">$hash->{'caption'}</a>
- </li>
-EOF
-;
- }
-
- print <<EOF
- </ul>
- </div>
-EOF
-;
-
-}
-
-
-sub showsubsubsection($) {
- my $root = shift;
- if (!$root) {
- return;
- }
- my $selected = getselected($root);
- if (! $selected) {
- return
- }
- if (! $selected->{'subMenu'}) {
- return
- }
-
- showsubsection($selected->{'subMenu'}, 'menu-subtop');
-}
-
-
-sub get_helpuri() {
- my $helpfile = '';
- if ($URI[0] =~ /.*\/([^\/]+)\.cgi/) {
- $helpfile = $1;
- } else {
- return '';
- }
- $helpfile .= '.help.html';
-
- my $helpuri = '/doc/'.$language.'/'.$helpfile;
- if (! -e $ENV{'DOCUMENT_ROOT'}.$helpuri) {
- return '';
- }
- return $helpuri;
-}
-
-
-sub openpage {
- my $title = shift;
- my $boh = shift;
- my $extrahead = shift;
-
- @URI=split ('\?', $ENV{'REQUEST_URI'} );
- &readhash("${swroot}/main/settings", \%settings);
- &genmenu();
-
- my $h2 = gettitle($menu);
- my $helpuri = get_helpuri();
-
- $title = "IPFire - $title";
- if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
- $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
- }
-
- print <<END
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html>
- <head>
- <title>$title</title>
-
- $extrahead
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-END
-;
- if ($settings{'FX'} ne 'off') {
- print <<END
- <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)">
- <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)">
-END
-;
- }
- print <<END
- <link rel="shortcut icon" href="/favicon.ico" />
- <style type="text/css">\@import url(/include/style.css);</style>
- <style type="text/css">\@import url(/include/menu.css);</style>
- <style type="text/css">\@import url(/include/content.css);</style>
- <script language="javascript" type="text/javascript">
-
- function swapVisibility(id) {
- el = document.getElementById(id);
- if(el.style.display != 'block') {
- el.style.display = 'block'
- }
- else {
- el.style.display = 'none'
- }
- }
- </script>
-
- </head>
- <body>
-<!-- IPFIRE HEADER -->
-
-<div id="main">
-
-<div id="header">
- <img id="logo-product" src="/images/logo_ipfire.gif">
- <div id="header-icons">
- <a href="http://users.ipfire.eu/" target="_blank"><img border="0" src="/images/help.gif"></a>
- </div>
-</div>
-
-END
-;
-
- &showmenu();
-
-print <<END
-<div id="content">
- <table width="90%">
- <tr>
- <td valign="top">
-END
-;
-
- &showsubsection($menu);
-
- print <<END
- <p><center><img src="/images/iptux.png" width='160px' height='160px'></center></p>
- </td>
- <td width="100%" valign="top">
- <div id="page-content">
- <h2>$h2</h2>
-END
- ;
-
- &showsubsubsection($menu);
-
- eval {
- require 'ipfire-network.pl';
- $supported = check_support();
- warn_unsupported($supported);
- };
-}
-
-sub openpagewithoutmenu {
- my $title = shift;
- my $boh = shift;
- my $extrahead = shift;
-
- @URI=split ('\?', $ENV{'REQUEST_URI'} );
- &readhash("${swroot}/main/settings", \%settings);
- &genmenu();
-
- my $h2 = gettitle($menu);
- my $helpuri = get_helpuri();
-
- $title = "IPFire - $title";
- if ($settings{'WINDOWWITHHOSTNAME'} eq 'on') {
- $title = "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'} - $title";
- }
-
- print <<END
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html>
- <head>
- <title>$title</title>
-
- $extrahead
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-END
-;
- if ($settings{'FX'} eq 'on') {
- print <<END
- <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.5,Transition=12)">
- <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5,Transition=12)">
-END
-;
- }
- print <<END
- <link rel="shortcut icon" href="/favicon.ico" />
- <style type="text/css">\@import url(/include/style.css);</style>
- <style type="text/css">\@import url(/include/menu.css);</style>
- <style type="text/css">\@import url(/include/content.css);</style>
- <script language="javascript" type="text/javascript">
-
- function swapVisibility(id) {
- el = document.getElementById(id);
- if(el.style.display != 'block') {
- el.style.display = 'block'
- }
- else {
- el.style.display = 'none'
- }
- }
- </script>
-
- </head>
- <body>
-<!-- IPFIRE HEADER -->
-
-<div id="main">
-
-<div id="header">
- <img id="logo-product" src="/images/logo_ipfire.gif">
- <div id="header-icons">
- <a href="http://users.ipfire.eu/" target="_blank"><img border="0" src="/images/help.gif"></a>
- </div>
-</div>
-
-END
-;
-print <<END
-<div id="content">
- <table width="90%">
- <tr>
- <td valign="top">
- <p><center><img src="/images/iptux.png" width='160px' height='160px'></center></p>
- </td>
- <td width="100%" valign="top">
- <div id="page-content">
- <h2>$h2</h2>
-END
- ;
-}
-
-sub closepage () {
- my $status = &connectionstatus();
- $uptime = `/usr/bin/uptime`;
-
- print <<END
- <div align="center">
- <p>
- <div style="font-size: 9px"><b>Status:</b> $status <b>Uptime:</b>$uptime <b>Version:</b> $FIREBUILD</div>
- </p>
- </div>
- </body>
-</html>
-END
-;
-}
-
-sub openbigbox
-{
- my $width = $_[0];
- my $align = $_[1];
- my $sideimg = $_[2];
-
- if ($errormessage) {
- $bgcolor = "style='background-color: $colourerr;'";
- } else {
- $bgcolor = '';
- }
-}
-
-sub closebigbox
-{
-# print "</td></tr></table></td></tr></table>\n"
-}
-
-sub openbox
-{
- $width = $_[0];
- $align = $_[1];
- $caption = $_[2];
-
- if ($caption) { print "<h3>$caption</h3>\n"; } else { print " "; }
-
- print "<table class=\"list\"><tr><td align=\"$align\">\n";
-}
-
-sub closebox
-{
- print "</td></tr></table><br><br>";
-}
-
-sub writehash
-{
- my $filename = $_[0];
- my $hash = $_[1];
-
- # write cgi vars to the file.
- open(FILE, ">${filename}") or die "Unable to write file $filename";
- flock FILE, 2;
- foreach $var (keys %$hash)
- {
- $val = $hash->{$var};
- # Darren Critchley Jan 17, 2003 added the following because when submitting with a graphic, the x and y
- # location of the mouse are submitted as well, this was being written to the settings file causing
- # some serious grief! This skips the variable.x and variable.y
- if (!($var =~ /(.x|.y)$/)) {
- if ($val =~ / /) {
- $val = "\'$val\'"; }
- if (!($var =~ /^ACTION/)) {
- print FILE "${var}=${val}\n"; }
- }
- }
- close FILE;
-}
-
-sub readhash
-{
- my $filename = $_[0];
- my $hash = $_[1];
- my ($var, $val);
-
- open(FILE, $filename) or die "Unable to read file $filename";
-
- while (<FILE>)
- {
- chop;
- ($var, $val) = split /=/, $_, 2;
- if ($var)
- {
- $val =~ s/^\'//g;
- $val =~ s/\'$//g;
-
- # Untaint variables read from hash
- $var =~ /([A-Za-z0-9_-]*)/; $var = $1;
- $val =~ /([\w\W]*)/; $val = $1;
- $hash->{$var} = $val;
- }
- }
- close FILE;
-}
-