[1/2] Current system time in WebUI Footer

Message ID 20200323212746.4424-1-list@md5collisions.eu
State New
Headers show
Series [1/2] Current system time in WebUI Footer | expand

Commit Message

Stephan Mending March 23, 2020, 9:27 p.m. UTC
These changes add the current system time to the footer of the
webinterface. Because of differing themes one has to differentiate
between legacy themes (ipfire-legacy, darkdos, maniac) and the current standard (ipfire, ipfire-rounded).

---
 html/html/themes/darkdos/include/functions.pl |  4 ++
 .../themes/ipfire-legacy/include/functions.pl | 36 ++++++++-------
 html/html/themes/ipfire/include/functions.pl  | 33 +++++++------
 html/html/themes/maniac/include/functions.pl  | 46 ++++++++++---------
 4 files changed, 67 insertions(+), 52 deletions(-)

Patch

diff --git a/html/html/themes/darkdos/include/functions.pl b/html/html/themes/darkdos/include/functions.pl
index ed3f546b0..9f3547237 100644
--- a/html/html/themes/darkdos/include/functions.pl
+++ b/html/html/themes/darkdos/include/functions.pl
@@ -19,6 +19,8 @@ 
 #                                                                             #
 ###############################################################################
 
+use POSIX;
+
 sub showmenu() {
     print <<EOF
 		<div id="menu">
@@ -322,6 +324,7 @@  END
 
 sub closepage () {
 	my $status = &connectionstatus();
+	my $localtime_now = strftime "%H:%M:%S", localtime;
 	my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
 	$uptime =~ s/year(s|)/$Lang::tr{'year'}/;
 	$uptime =~ s/month(s|)/$Lang::tr{'month'}/;
@@ -354,6 +357,7 @@  print <<END
                         <br />
                                 <b>$Lang::tr{'bandwidth usage'}:</b>
 				$Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>
+				<b>time:</b> $localtime_now
 
 END
 ;
diff --git a/html/html/themes/ipfire-legacy/include/functions.pl b/html/html/themes/ipfire-legacy/include/functions.pl
index 26a8763c1..3ce62ea41 100644
--- a/html/html/themes/ipfire-legacy/include/functions.pl
+++ b/html/html/themes/ipfire-legacy/include/functions.pl
@@ -19,6 +19,8 @@ 
 #                                                                             #
 ###############################################################################
 
+use POSIX;
+
 sub showmenu() {
     print <<EOF
                 <div id="menu">
@@ -321,14 +323,15 @@  END
 }
 
 sub closepage () {
-	my $status = &connectionstatus();
-	my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
-	$uptime =~ s/year(s|)/$Lang::tr{'year'}/;
-	$uptime =~ s/month(s|)/$Lang::tr{'month'}/;
-	$uptime =~ s/day(s|)/$Lang::tr{'day'}/;
-	$uptime =~ s/user(s|)/$Lang::tr{'user'}/;
-	$uptime =~ s/load average/$Lang::tr{'uptime load average'}/;     
-				
+        my $status = &connectionstatus();
+        my $localtime_now = strftime "%H:%M:%S", localtime;
+        my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
+        $uptime =~ s/year(s|)/$Lang::tr{'year'}/;
+        $uptime =~ s/month(s|)/$Lang::tr{'month'}/;
+        $uptime =~ s/day(s|)/$Lang::tr{'day'}/;
+        $uptime =~ s/user(s|)/$Lang::tr{'user'}/;
+        $uptime =~ s/load average/$Lang::tr{'uptime load average'}/;
+
     print <<END
                         </div>
                 </div>
@@ -341,19 +344,20 @@  END
     &showsubsection($menu);
     &showsubsubsection($menu);
 
-        print <<END                     
-				</div>
-            </div>
-            <br class="clear" />    
-			<div id="footer" class="fixed">
-				<b>Status:</b> $status <b>Uptime:</b> $uptime
+        print <<END
+                                </div>
+                        </div>
+                        <br class="clear" />    
+                        <div id="footer" class="fixed">
+                                <b>Status:</b> $status <b>Uptime:</b> $uptime
 END
 ;
 if ($settings{'SPEED'} ne 'off') {
-print <<END                        
+print <<END
                         <br />
                                 <b>$Lang::tr{'bandwidth usage'}:</b>
-				$Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>
+                                $Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>                                                                            
+				<b>time:</b> $localtime_now
 
 END
 ;
diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl
index 9aec77497..9e3063476 100644
--- a/html/html/themes/ipfire/include/functions.pl
+++ b/html/html/themes/ipfire/include/functions.pl
@@ -32,6 +32,7 @@ 
 ###############################################################################
 
 require "${General::swroot}/lang.pl";
+use POSIX;
 
 ###############################################################################
 #
@@ -194,29 +195,31 @@  sub openpagewithoutmenu {
 # print page closing html layout
 
 sub closepage () {
-	open(FILE, "</etc/system-release");
-	my $system_release = <FILE>;
-	$system_release =~ s/core/Core Update /;
-	close(FILE);
+        open(FILE, "</etc/system-release");
+        my $system_release = <FILE>;
+        $system_release =~ s/core/Core Update /;
+        close(FILE);
+        $localtime_now = strftime "%H:%M:%S", localtime;
 
 print <<END;
-		</div>
-	</div>
-
-	<div id="footer" class='bigbox fixed'>
-		<span class="pull-right">
-			<a href="https://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
-			<a href="https://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
-		</span>
-
-		<strong>$system_release</strong>
-	</div>
+                </div>
+        </div>
+
+        <div id="footer" class='bigbox fixed'>
+                <span class="pull-right">
+                        <a href="https://www.ipfire.org/" target="_blank"><strong>IPFire.org</strong></a> &bull;
+                        <a href="https://www.ipfire.org/donate" target="_blank">$Lang::tr{'support donation'}</a>
+                </span>
+                <strong>$system_release</strong>
+                <strong> - $localtime_now<strong>
+        </div>
 </body>
 </html>
 END
 ;
 }
 
+
 ###############################################################################
 #
 # print big box opening html layout
diff --git a/html/html/themes/maniac/include/functions.pl b/html/html/themes/maniac/include/functions.pl
index 1c0aea1c4..c50357070 100644
--- a/html/html/themes/maniac/include/functions.pl
+++ b/html/html/themes/maniac/include/functions.pl
@@ -19,6 +19,8 @@ 
 #                                                                             #
 ###############################################################################
 
+use POSIX;
+
 sub showmenu() {
     print <<EOF
 		<div id="menu">
@@ -321,39 +323,41 @@  END
 }
 
 sub closepage () {
-	my $status = &connectionstatus();
-	my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
-	$uptime =~ s/year(s|)/$Lang::tr{'year'}/;
-	$uptime =~ s/month(s|)/$Lang::tr{'month'}/;
-	$uptime =~ s/day(s|)/$Lang::tr{'day'}/;
-	$uptime =~ s/user(s|)/$Lang::tr{'user'}/;
-	$uptime =~ s/load average/$Lang::tr{'uptime load average'}/;     
-				
+        my $status = &connectionstatus();
+        my $localtime_now = strftime "%H:%M:%S", localtime;
+        my $uptime = `/usr/bin/uptime|cut -d \" \" -f 4-`;
+        $uptime =~ s/year(s|)/$Lang::tr{'year'}/;
+        $uptime =~ s/month(s|)/$Lang::tr{'month'}/;
+        $uptime =~ s/day(s|)/$Lang::tr{'day'}/;
+        $uptime =~ s/user(s|)/$Lang::tr{'user'}/;
+        $uptime =~ s/load average/$Lang::tr{'uptime load average'}/;
+
     print <<END
-			</div>
-		</div>
+                        </div>
+                </div>
 
-		<div id="secondaryContent_2columns">
-		
-			<div id="columnC_2columns">
+                <div id="secondaryContent_2columns">
+                
+                        <div id="columnC_2columns">
 END
 ;
     &showsubsection($menu);
     &showsubsubsection($menu);
 
-	print <<END
-				</div>
-			</div>
-			<br class="clear" />	
-			<div id="footer" class="fixed">
-				<b>Status:</b> $status <b>Uptime:</b> $uptime
+        print <<END
+                                </div>
+                        </div>
+                        <br class="clear" />    
+                        <div id="footer" class="fixed">
+                                <b>Status:</b> $status <b>Uptime:</b> $uptime
 END
 ;
 if ($settings{'SPEED'} ne 'off') {
-print <<END                        
+print <<END
                         <br />
                                 <b>$Lang::tr{'bandwidth usage'}:</b>
-				$Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>
+                                $Lang::tr{'incoming'}: <span id="rx_kbs"></span>&nbsp;$Lang::tr{'outgoing'}: <span id="tx_kbs"></span>                                                                            
+                                <b>time:</b> $localtime_now
 
 END
 ;