From: Michael Tremer Date: Tue, 19 Mar 2024 15:29:30 +0000 (+0100) Subject: ovpnmain.cgi: Use the formatting function we already have X-Git-Tag: v2.29-core197~25^2~197 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92460a7c047778a6e152e019f047990fe399b711;p=ipfire-2.x.git ovpnmain.cgi: Use the formatting function we already have Signed-off-by: Michael Tremer --- 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;