X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=gui%2Fbacula-web%2Findex.php;h=976fb832a7adcf8bd2a63f5966d978a670589301;hb=bed4d6c620101ad0893a1eb28bfdb7bcf7511b00;hp=3b086eddb2230d7889b489206aac9319239376d7;hpb=06063462d2af98e46f74de7814c4c2cf081a710e;p=bacula%2Fbacula diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 3b086eddb2..976fb832a7 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -15,48 +15,24 @@ +-------------------------------------------------------------------------+ */ session_start(); -require ("paths.php"); -require($smarty_path."Smarty.class.php"); -include "classes.inc"; +require_once('paths.php'); +include_once( 'bweb.inc.php' ); -$smarty = new Smarty; $dbSql = new Bweb(); -require("lang.php"); - $mode = ""; -$smarty->compile_check = true; -$smarty->debugging = false; -$smarty->force_compile = true; - -$smarty->template_dir = "./templates"; -$smarty->compile_dir = "./templates_c"; -$smarty->config_dir = "./configs"; - /* -$smarty->config_load("bacula.conf"); // Load config file -$mode = $smarty->get_config_vars("mode"); -*/ // Lite o Extend? - // Getting mode from config file $mode = $dbSql->get_config_param("mode"); if( $mode == false ) $mode = "Lite"; $smarty->assign( "mode", $mode ); - -// Determine which template to show -$indexreport = $dbSql->get_config_param( "IndexReport" ); - -if( $indexreport == 0 ) { - $smarty->assign( "last_report", "last_run_report.tpl" ); -}else { - $smarty->assign( "last_report", "report_select.tpl" ); -} +*/ // Assign to template catalogs number -$smarty->assign( "dbs", $dbSql->Get_Nb_Catalogs() ); +$dbSql->tpl->assign( "dbs", $dbSql->Get_Nb_Catalogs() ); //Assign dbs /* @@ -66,167 +42,131 @@ if ( count($dbSql->dbs) >1 ) { } */ -// generaldata.tpl & last_run_report.tpl ( Last 24 hours report ) -$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( ALL ); +$dbSql->tpl->assign('stored_files',$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()); +$dbSql->tpl->assign('database_size', $dbSql->GetDbSize()); + +// Overall stored bytes +$result = $dbSql->GetStoredBytes( ALL ); +$dbSql->tpl->assign('stored_bytes', $dbSql->human_file_size($result['stored_bytes']) ); + +// Total stored bytes since last 24 hours +$result = $dbSql->GetStoredBytes( LAST_DAY ); +$dbSql->tpl->assign('bytes_last', $dbSql->human_file_size($result['stored_bytes']) ); + +// Total stored files since last 24 hours +$files_last = $dbSql->GetStoredFiles( LAST_DAY ); +$dbSql->tpl->assign('files_last', $files_last ); -// Total bytes stored -$bytes_stored = $dbSql->db_link->getOne("select SUM(VolBytes) from Media") or die ("Failed to get Total stored Bytes from catalog"); -$smarty->assign('bytes_stored', $dbSql->human_file_size($bytes_stored) ); // Number of clients $nb_clients = $dbSql->Get_Nb_Clients(); -$smarty->assign('clientes_totales',$nb_clients["nb_client"] ); - -/*if ( empty($tmp[0]) ) { // No data for last 24, search last 48 - if ( $dbSql->driver == "mysql" ) - $last24bytes = $dbSql->db_link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" ); - if ( $dbSql->driver == "pgsql") - $last24bytes = $dbSql->db_link->query("select sum(JobBytes) from Job where Endtime <= NOW() and EndTime > NOW()-172800 * interval '1 second'" ) - or die ("Error query: 4.1"); - $smarty->assign('when',"yesterday"); - $tmp = $last24bytes->fetchRow(); -}*/ - -// report_select.tpl & last_run_report.tpl -$res = $dbSql->db_link->query("select Name from Job group by Name"); - -$a_jobs = array(); -while ( $tmp = $res->fetchRow() ) - array_push($a_jobs, $tmp[0]); -$smarty->assign('total_name_jobs',$a_jobs); -$smarty->assign('time2',( (time())-2678400) ); // Current time - 1 month.