From 8e46dab7b170e5fcd8e65b7f531616b697b0257c Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Tue, 14 Dec 2010 15:51:42 +0100 Subject: [PATCH] bacula-web: New function GetStoredFiles() in bweb.inc.php - Replaced totalfiles value with GetStoredFiles in index.php --- gui/bacula-web/bweb.inc.php | 15 +++++++++++++ gui/bacula-web/index.php | 43 +++---------------------------------- 2 files changed, 18 insertions(+), 40 deletions(-) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index 95b631ab40..8ff3eb90f3 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -573,6 +573,21 @@ class Bweb extends DB { } } + public function GetStoredFiles() + { + $nbfiles = 0; + $query = "SELECT COUNT(FilenameId) AS nbfiles FROM Filename"; + $result = $this->db_link->query( $query ); + + if( !PEAR::isError($result) ) { + $nbfiles = $result->fetchRow(DB_FETCHMODE_ASSOC); + $nbfiles = $nbfiles['nbfiles']; + }else{ + die("Unable to get protected files from catalog"); + } + return $nbfiles; + } + public function GetStoredBytes( $delay = LAST_DAY ) { $query = "SELECT SUM(JobBytes) as stored_bytes FROM Job "; diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 1c8b01dd57..ac5d90cf37 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -70,47 +70,10 @@ if ( count($dbSql->dbs) >1 ) { $last24bytes = ""; $query = ""; -/*$client = $dbSql->db_link->query("select count(*) from Client") - or die ("Error query: 1");*/ - $totalfiles = $dbSql->db_link->query("select count(FilenameId) from Filename") or die ("Error query: 2"); +// Stored files number +$totalfiles = $dbSql->GetStoredFiles(); +$smarty->assign('files_totales',$totalfiles); - if ( PEAR::isError( $totalfiles ) ) { - die( "Unable to get Total Files information from catalog" . $totalfiles->getMessage() ); - }else { - $tmp = $totalfiles->fetchRow(); - $smarty->assign('files_totales',$tmp[0]); - } - $totalfiles->free(); - - /* - switch( $dbSql->driver ) - { - case 'mysql': - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400"; - break; - case 'pgsql': - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'"; - break; - default: - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400"; - break; - } - - $last24bytes = $dbSql->db_link->query( $query ) or die ("Failed to get Total Job Bytes from catalog"); - - if ( PEAR::isError( $last24bytes ) ) { - die( "Unable to get Total Job Bytes from catalog" . $last24bytes->getMessage() ); - }else { - $tmp = $last24bytes->fetchRow(); - //var_dump( $tmp ); - // Transfered bytes since last 24 hours - $smarty->assign('bytes_totales', $dbSql->human_file_size( $tmp[0] ) ); - - $smarty->assign('total_jobs', $tmp[1]); - - $last24bytes->free(); - }*/ - // Database size $smarty->assign('database_size', $dbSql->GetDbSize()); -- 2.39.5