From 4509adfd71ff9aeb6bcae225ae126ed437e8fa20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C3=B6lfel=20Kim?= Date: Tue, 11 Aug 2015 00:26:24 +0200 Subject: [PATCH] add actual system time and timezone info-bar to ipfire theme. position can be configured in GUI user-settings, default is off. --- html/cgi-bin/gui.cgi | 27 ++++++++++++ html/cgi-bin/uptime.cgi | 50 ++++++++++++++++++++++ html/html/themes/ipfire/include/css/style.css | 21 +++++++++ html/html/themes/ipfire/include/functions.pl | 40 ++++++++++++++++- .../themes/ipfire/include/js/refreshUpTimeInfo.js | 29 +++++++++++++ langs/de/cgi-bin/de.pl | 5 +++ langs/en/cgi-bin/en.pl | 5 +++ langs/es/cgi-bin/es.pl | 7 +++ langs/fr/cgi-bin/fr.pl | 7 +++ langs/it/cgi-bin/it.pl | 5 +++ langs/nl/cgi-bin/nl.pl | 7 +++ langs/pl/cgi-bin/pl.pl | 7 +++ langs/ru/cgi-bin/ru.pl | 7 +++ langs/tr/cgi-bin/tr.pl | 5 +++ 14 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 html/cgi-bin/uptime.cgi create mode 100644 html/html/themes/ipfire/include/js/refreshUpTimeInfo.js diff --git a/html/cgi-bin/gui.cgi b/html/cgi-bin/gui.cgi index 726abf7..111e01d 100644 --- a/html/cgi-bin/gui.cgi +++ b/html/cgi-bin/gui.cgi @@ -37,6 +37,7 @@ my $errormessage=''; $cgiparams{'SPEED'} = 'off'; +$cgiparams{'UPTIME'} = 'off'; $cgiparams{'WINDOWWITHHOSTNAME'} = 'off'; $cgiparams{'REFRESHINDEX'} = 'off'; $cgiparams{'ACTION'} = ''; @@ -88,6 +89,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") $mainsettings{'WINDOWWITHHOSTNAME'} = $cgiparams{'WINDOWWITHHOSTNAME'}; $mainsettings{'PPPUPDOWNBEEP'} = $cgiparams{'PPPUPDOWNBEEP'}; $mainsettings{'SPEED'} = $cgiparams{'SPEED'}; + $mainsettings{'UPTIME'} = $cgiparams{'UPTIME'}; $mainsettings{'THEME'} = $cgiparams{'theme'}; $mainsettings{'REFRESHINDEX'} = $cgiparams{'REFRESHINDEX'}; &General::writehash("${General::swroot}/main/settings", \%mainsettings); @@ -125,6 +127,11 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") # by manually setting the var to off $cgiparams{'SPEED'} = 'on'; } + if($mainsettings{'UPTIME'}) { + $cgiparams{'UPTIME'} = $mainsettings{'UPTIME'}; + } else { + $cgiparams{'UPTIME'} = 'off'; + } } # Default settings @@ -134,6 +141,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'restore defaults'}") $cgiparams{'PPPUPDOWNBEEP'} = 'on'; $cgiparams{'REFRESHINDEX'} = 'off'; $cgiparams{'SPEED'} = 'on'; + $cgiparams{'UPTIME'} = 'off'; $cgiparams{'THEME'} = 'ipfire'; } @@ -153,6 +161,11 @@ $checked{'SPEED'}{'off'} = ''; $checked{'SPEED'}{'on'} = ''; $checked{'SPEED'}{$cgiparams{'SPEED'}} = "checked='checked'"; +$checked{'UPTIME'}{'off'} = ''; +$checked{'UPTIME'}{'header'} = ''; +$checked{'UPTIME'}{'footer'} = ''; +$checked{'UPTIME'}{$cgiparams{'UPTIME'}} = "selected='selected'"; + &Header::openpage($Lang::tr{'gui settings'}, 1, ''); &Header::openbigbox('100%', 'left', '', $errormessage); @@ -181,6 +194,20 @@ print <   + $Lang::tr{'uptime infobar show'} + + +   + + + + + +   $Lang::tr{'languagepurpose'} diff --git a/html/cgi-bin/uptime.cgi b/html/cgi-bin/uptime.cgi new file mode 100644 index 0000000..19411bf --- /dev/null +++ b/html/cgi-bin/uptime.cgi @@ -0,0 +1,50 @@ +#!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +use strict; +use POSIX qw(strftime); + +my $uptime = (); +my $uptime = qx(/usr/bin/uptime); + +$uptime =~ /\s(\d+:\d+:\d+)\sup\s(.+),.*?(\d+)\suser.*?,.*?(\d+\.\d+),\s(\d+\.\d+),\s(\d+\.\d+)/; + +my $time = strftime "%Y-%m-%d %H:%M:%S %Z (%z)", localtime; +my $up = $2; +my $user = $3; +my $load_a = $4; +my $load_b = $5; +my $load_c = $6; + +print "pragma: no-cache\n"; +print "Content-type: text/xml\n\n"; +print "\n"; +print < + + $up + $user + $load_a + $load_b + $load_c + +END +; diff --git a/html/html/themes/ipfire/include/css/style.css b/html/html/themes/ipfire/include/css/style.css index 1cc18f8..3b3deb9 100644 --- a/html/html/themes/ipfire/include/css/style.css +++ b/html/html/themes/ipfire/include/css/style.css @@ -115,6 +115,7 @@ iframe { #logo { height: 65px; margin-top: 1em; + background: url('../../images/tux2.png') no-repeat; } #logo h1 { @@ -207,6 +208,26 @@ input.text { line-height: 32px; } +#uptime { + float: left; + min-width: 20em; + line-height: 32px; +} + +#help { + float: right; + min-width: 20em; + line-height: 32px; +} + +#cssajax{ + margin-bottom: 0.5em; + padding-top: 0; + font-weight: 600; + height: 32px; + border: 1px solid black; +} + /* Menu */ #cssmenu { margin: 0 auto; diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl index eedf069..e13abc8 100644 --- a/html/html/themes/ipfire/include/functions.pl +++ b/html/html/themes/ipfire/include/functions.pl @@ -64,6 +64,21 @@ sub showsubmenu() { # # print menu html elements sub showmenu() { + + if ($settings{'UPTIME'} eq 'header') { + print < +
+ --   + $Lang::tr{'uptime'}: --   + $Lang::tr{'user'}: -- $Lang::tr{'user'}   + $Lang::tr{'load'}: -- +
+ +EOF +; + } + print '
'; if ($settings{'SPEED'} ne 'off') { @@ -147,6 +162,13 @@ END ; } +if ($settings{'UPTIME'} ne 'off') { +print < +END +; +} + print < @@ -202,7 +224,23 @@ sub closepage () { print <
- +END +; +if ($settings{'UPTIME'} eq 'footer') { + print < +
+ --   + $Lang::tr{'uptime'}: --   + $Lang::tr{'user'}: -- $Lang::tr{'user'}   + $Lang::tr{'load'}: -- +
+ +EOF +; +} + +print < IPFire.org • diff --git a/html/html/themes/ipfire/include/js/refreshUpTimeInfo.js b/html/html/themes/ipfire/include/js/refreshUpTimeInfo.js new file mode 100644 index 0000000..07bd889 --- /dev/null +++ b/html/html/themes/ipfire/include/js/refreshUpTimeInfo.js @@ -0,0 +1,29 @@ +/* refreshUptimeInfo.js +* functions for retrieving status information via jQuery +* Visit http://www.ipfire.org/ +*/ + +$(document).ready(function(){ + refreshUpTimeInfo(); +}); + +function refreshUpTimeInfo() { + $.ajax({ + url: '/cgi-bin/uptime.cgi', + success: function(xml) { + + var up = $("up", xml).text(); + var time = $("time", xml).text(); + var user = $("user", xml).text(); + var load = $("load_a", xml).text() + ", " + $("load_b", xml).text() + ", " + $("load_c", xml).text(); + + $("#up").text(up); + $("#time").text(time); + $("#user").text(user); + $("#load").text(load); + + } + }); + + window.setTimeout("refreshUpTimeInfo()", 1000); +} diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 48ade28..cb7b1d9 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -1393,6 +1393,7 @@ 'lifetime' => 'Lebensdauer:', 'line' => 'Leitung', 'linkq' => 'Antwortzeit', +'load' => 'Last', 'load printer' => 'Load Printer', 'loaded modules' => 'Geladene Module:', 'local hard disk' => 'Festplatte', @@ -2350,6 +2351,10 @@ 'uptime' => 'Betriebszeit', 'uptime and users' => 'Uptime und Benutzer:', 'uptime load average' => 'Systemlast', +'uptime infobar show' => 'Zeige Infoleiste', +'uptime infobar off' => 'AUS', +'uptime infobar header' => 'im Kopfbereich', +'uptime infobar footer' => 'im Fußbereich', 'url filter' => 'URL-Filter', 'urlfilter access' => 'Zugriff', 'urlfilter activity detection' => 'Aktivitätserkennung', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index af7fda9..d93f35d 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1423,6 +1423,7 @@ 'lifetime' => 'Lifetime:', 'line' => 'Line', 'linkq' => 'Link Quality', +'load' => 'Load', 'load printer' => 'Load Printer', 'loaded modules' => 'Loaded modules:', 'local hard disk' => 'Hard disk', @@ -2392,6 +2393,10 @@ 'uptime' => 'Uptime', 'uptime and users' => 'Uptime and users:', 'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'URL Filter', 'urlfilter access' => 'Access', 'urlfilter activity detection' => 'Activity detection', diff --git a/langs/es/cgi-bin/es.pl b/langs/es/cgi-bin/es.pl index 90f4237..c53a578 100644 --- a/langs/es/cgi-bin/es.pl +++ b/langs/es/cgi-bin/es.pl @@ -1074,6 +1074,7 @@ 'length' => 'Longitud', 'line' => 'Línea', 'linkq' => 'Link Quality', +'load' => 'Load', 'load printer' => 'Cargar impresora', 'loaded modules' => 'Módulos cargados:', 'local hard disk' => 'Disco duro', @@ -1862,7 +1863,13 @@ 'upstream password' => 'Password de subida:', 'upstream proxy host:port' => 'Proxy de subida (host:puerto)', 'upstream username' => 'Nombre de usuario de subida', +'uptime' => 'Uptime', 'uptime and users' => 'Tiempo encendido y usuarios:', +'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'Filtro de contenido', 'urlfilter access' => 'Acceso', 'urlfilter activity detection' => 'Detección de actividad', diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl index 40053a0..a9bd7fd 100644 --- a/langs/fr/cgi-bin/fr.pl +++ b/langs/fr/cgi-bin/fr.pl @@ -1065,6 +1065,7 @@ 'length' => 'Longueur', 'line' => 'Ligne', 'linkq' => 'Qualité du lien', +'load' => 'Load', 'load printer' => 'Charger imprimante', 'loaded modules' => 'Modules chargés :', 'local hard disk' => 'Disque Dur', @@ -1866,7 +1867,13 @@ 'upstream password' => 'Mot de passe de la liaison montante :', 'upstream proxy host:port' => 'Proxy de la liaison montante (hôte:port)', 'upstream username' => 'Nom d\'utilisateur de la liaison montante:', +'uptime' => 'Uptime', 'uptime and users' => 'Temps de service et utilisateurs:', +'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'Filtre de contenu', 'urlfilter access' => 'Accès', 'urlfilter activity detection' => 'Détection d\'activité', diff --git a/langs/it/cgi-bin/it.pl b/langs/it/cgi-bin/it.pl index 4fde313..ac2ef25 100644 --- a/langs/it/cgi-bin/it.pl +++ b/langs/it/cgi-bin/it.pl @@ -1389,6 +1389,7 @@ 'lifetime' => 'Lifetime:', 'line' => 'Line', 'linkq' => 'Link Quality', +'load' => 'Load', 'load printer' => 'Load Printer', 'loaded modules' => 'Loaded modules:', 'local hard disk' => 'Hard disk', @@ -2338,6 +2339,10 @@ 'uptime' => 'Uptime', 'uptime and users' => 'Uptime and users:', 'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'Filtro URL', 'urlfilter access' => 'Accesso', 'urlfilter activity detection' => 'Activity detection', diff --git a/langs/nl/cgi-bin/nl.pl b/langs/nl/cgi-bin/nl.pl index 7468eb9..a67e478 100644 --- a/langs/nl/cgi-bin/nl.pl +++ b/langs/nl/cgi-bin/nl.pl @@ -1367,6 +1367,7 @@ 'lifetime' => 'Levensduur:', 'line' => 'Lijn', 'linkq' => 'Lijnkwaliteit', +'load' => 'Load', 'load printer' => 'Laad printer', 'loaded modules' => 'Geladen modules:', 'local hard disk' => 'Harddisk', @@ -2182,6 +2183,12 @@ 'update' => 'Vernieuwen', 'update accelerator' => 'Updateversneller', 'update time' => 'Bijwerken van de tijd:', +'uptime and users' => 'Uptime and users:', +'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'update transcript' => 'Update transcript', 'updatedatabase' => 'Update database met het laatste rapport', 'updates' => 'Updates', diff --git a/langs/pl/cgi-bin/pl.pl b/langs/pl/cgi-bin/pl.pl index 02fb531..9d5df57 100644 --- a/langs/pl/cgi-bin/pl.pl +++ b/langs/pl/cgi-bin/pl.pl @@ -1073,6 +1073,7 @@ 'length' => 'Długość', 'line' => 'Linia', 'linkq' => 'Jakosc polaczenia', +'load' => 'Load', 'load printer' => 'Załaduj drukarkę', 'loaded modules' => 'Załadowane moduły:', 'local hard disk' => 'Dysk twardy', @@ -1782,6 +1783,12 @@ 'update' => 'Aktualizuj', 'update accelerator' => 'Update Accelerator', 'update time' => 'Aktualizuj czas:', +'uptime and users' => 'Uptime and users:', +'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'update transcript' => 'Update transcript', 'updatedatabase' => 'Aktualizuj bazę danych z ostatniego raportu', 'updates' => 'Aktualizacje', diff --git a/langs/ru/cgi-bin/ru.pl b/langs/ru/cgi-bin/ru.pl index a2a3693..aa4596c 100644 --- a/langs/ru/cgi-bin/ru.pl +++ b/langs/ru/cgi-bin/ru.pl @@ -1066,6 +1066,7 @@ 'length' => 'Length', 'line' => 'Line', 'linkq' => 'Link Quality', +'load' => 'Load', 'load printer' => 'Load Printer', 'loaded modules' => 'Loaded modules:', 'local hard disk' => 'Hard disk', @@ -1870,7 +1871,13 @@ 'upstream password' => 'Upstream password:', 'upstream proxy host:port' => 'Upstream proxy (host:port)', 'upstream username' => 'Upstream username:', +'uptime' => 'Uptime', 'uptime and users' => 'Uptime and users:', +'uptime load average' => 'Load average', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'Контентный Фильтр', 'urlfilter access' => 'Доступ', 'urlfilter activity detection' => 'Activity detection', diff --git a/langs/tr/cgi-bin/tr.pl b/langs/tr/cgi-bin/tr.pl index 89f753e..2a32cb4 100644 --- a/langs/tr/cgi-bin/tr.pl +++ b/langs/tr/cgi-bin/tr.pl @@ -1403,6 +1403,7 @@ 'lifetime' => 'Yaşam süresi:', 'line' => 'Satırı', 'linkq' => 'bağlantı kalitesi', +'load' => 'Load', 'load printer' => 'Yazıcı Yükle', 'loaded modules' => 'Yüklü modüller:', 'local hard disk' => 'Sabit disk', @@ -2361,6 +2362,10 @@ 'uptime' => 'Çalışma süresi', 'uptime and users' => 'Çalışma süresi ve kullanıcı:', 'uptime load average' => 'Ortalama yük', +'uptime infobar show' => 'Show Infobar', +'uptime infobar off' => 'OFF', +'uptime infobar header' => 'in header', +'uptime infobar footer' => 'in footer', 'url filter' => 'İçerik Filtreleme', 'urlfilter access' => 'Erişim', 'urlfilter activity detection' => 'Etkinlik algılama', -- 1.9.5.msysgit.1