From 92460a7c047778a6e152e019f047990fe399b711 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 19 Mar 2024 16:29:30 +0100 Subject: [PATCH] ovpnmain.cgi: Use the formatting function we already have Signed-off-by: Michael Tremer --- html/cgi-bin/ovpnmain.cgi | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index b2c219e42..e201a86c7 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -147,21 +147,6 @@ sub iscertlegacy return 0; } -sub sizeformat{ - my $bytesize = shift; - my $i = 0; - - while(abs($bytesize) >= 1024){ - $bytesize=$bytesize/1024; - $i++; - last if($i==6); - } - - my @units = ("Bytes","KB","MB","GB","TB","PB","EB"); - my $newsize=(int($bytesize*100 +0.5))/100; - return("$newsize $units[$i]"); -} - sub cleanssldatabase { if (open(FILE, ">${General::swroot}/ovpn/certs/serial")) { @@ -2966,8 +2951,8 @@ END $userlookup{$match[2]} = $uid; $users[$uid]{'CommonName'} = $match[1]; $users[$uid]{'RealAddress'} = $match[2]; - $users[$uid]{'BytesReceived'} = &sizeformat($match[3]); - $users[$uid]{'BytesSent'} = &sizeformat($match[4]); + $users[$uid]{'BytesReceived'} = &General::formatBytes($match[3]); + $users[$uid]{'BytesSent'} = &General::formatBytes($match[4]); $users[$uid]{'Since'} = $match[5]; $users[$uid]{'Proto'} = $proto; -- 2.47.3