]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New function GetStoredFiles() in bweb.inc.php
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 14 Dec 2010 14:51:42 +0000 (15:51 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Mar 2011 09:39:08 +0000 (10:39 +0100)
 - Replaced totalfiles value with GetStoredFiles in index.php

gui/bacula-web/bweb.inc.php
gui/bacula-web/index.php

index 95b631ab40113b1bc96217d240155aeb6452220d..8ff3eb90f3d69c2e2f3af7b8691fd7bd62379b8f 100644 (file)
@@ -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 ";
index 1c8b01dd57176b0c18058789cbbb3c3b070dfd7d..ac5d90cf377bd89a328aab49dfde03719a2bfaac 100644 (file)
@@ -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());