From 3a0e7e34c9c39fafd935357bed0d4bf27522c42b Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 28 Jun 2015 20:41:36 +0545 Subject: Backup pkg check if byte_convert function exists As reported in forum https://forum.pfsense.org/index.php?topic=95790.0 When Backup and Vhosts package are both installed there can be errors logged about Cannot redeclare byte_convert(). --- config/backup/backup.inc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'config/backup') diff --git a/config/backup/backup.inc b/config/backup/backup.inc index df508775..748b7fc6 100644 --- a/config/backup/backup.inc +++ b/config/backup/backup.inc @@ -32,16 +32,17 @@ */ -function byte_convert( $bytes ) { - if ($bytes<=0) - return '0 Byte'; - - $convention=1000; //[1000->10^x|1024->2^x] - $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e=floor(log($bytes,$convention)); - return round($bytes/pow($convention,$e),2).' '.$s[$e]; +if (!function_exists("byte_convert")) { + function byte_convert( $bytes ) { + if ($bytes<=0) + return '0 Byte'; + + $convention=1000; //[1000->10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; + } } - function backup_sync_package_php() { -- cgit v1.2.3