]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/includes/bweb.inc.php
bacula-web: Replaced Get_human_file_size() function by Utils::Get_Human_Size
[bacula/bacula] / gui / bacula-web / includes / bweb.inc.php
1 <?php
2 /* 
3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004 Juan Luis Francés Jiménez                                                    |
5 | Copyright 2010-2011, Davide Franco                                              |
6 |                                                                         |
7 | This program is free software; you can redistribute it and/or           |
8 | modify it under the terms of the GNU General Public License             |
9 | as published by the Free Software Foundation; either version 2          |
10 | of the License, or (at your option) any later version.                  |
11 |                                                                         |
12 | This program is distributed in the hope that it will be useful,         |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
15 | GNU General Public License for more details.                            |
16 +-------------------------------------------------------------------------+ 
17 */
18 class Bweb extends DB {
19
20     var $StartDate;
21     var $EndDate;
22
23     var $driver;
24         
25         public  $tpl;
26         public  $db_link;                                               // Database link
27         
28         private $config_file;                                   // Config filename
29         private $config;                                                // Loaded config from bacula.conf
30         private $catalogs = array();                    // Catalog array
31         public  $catalog_nb;
32         private $bwcfg;
33
34     function __construct()
35         {             
36                 $this->bwcfg = new BW_Config();
37                 $dsn = array();
38                 
39                 // Loading configuration from config file
40                 $this->bwcfg->Load_Config();
41                 $this->catalog_nb = $this->bwcfg->Count_Catalogs();
42                 
43                 // Select which catalog to connect to
44                 if( isset( $_POST['catalog_id'] ) )
45                         $dsn = $this->bwcfg->Get_Dsn( $_POST['catalog_id'] );
46                 else
47                         $dsn = $this->bwcfg->Get_Dsn( 0 );
48                 
49                 // Connect to the database
50                 $this->db_link = $this->connect( $dsn );
51         
52                 if (DB::isError($this->db_link)) {
53                         die( 'Unable to connect to catalog <br />' . $this->db_link->getMessage());
54                 }else {
55                         $this->driver = $dsn['phptype'];                            
56             register_shutdown_function(array(&$this,'close') );
57                 }
58                 
59                 // Initialize smarty template classe
60                 $this->init_tpl();
61                 // Initialize smarty gettext function
62                 $this->init_gettext();
63                 
64                 // Catalog selection            
65                 if( $this->catalog_nb > 1 ) {
66                         // Set current catalog in header template
67                         if(isset( $_POST['catalog_id'] ) )
68                                 $this->tpl->assign( 'catalog_current', $_POST['catalog_id'] );
69                         
70                         $this->tpl->assign( 'catalogs', $this->bwcfg->Get_Catalogs() );                 
71                 }
72         }
73                 
74     // Initialize Smarty template classe
75         function init_tpl()
76         {
77                 $this->tpl = new Smarty();
78                 
79                 $this->tpl->compile_check       = true;
80                 $this->tpl->debugging           = false;
81                 $this->tpl->force_compile       = true;
82
83                 $this->tpl->template_dir        = "./templates";
84                 $this->tpl->compile_dir         = "./templates_c";
85                 $this->tpl->config_dir          = "./configs";
86         }
87         
88         function init_gettext()
89         {
90                 global $smarty_gettext_path;
91                 
92                 if ( function_exists("gettext") ) {
93                         require_once( BW_SMARTY_GETTEXT . "smarty_gettext.php" );     
94                         $this->tpl->register_block('t','smarty_translate');
95         
96                         $language = $this->bwcfg->Get_Config_Param("lang");
97                         $domain = "messages";   
98                         putenv("LANG=$language"); 
99                         setlocale(LC_ALL, $language);
100                         bindtextdomain($domain,"./locale");
101                         textdomain($domain);
102                 }
103                 else {
104                         function smarty_translate($params, $text, &$smarty) {
105                 return $text;
106                         }
107                         $smarty->register_block('t','smarty_translate');
108                 }
109         }
110         
111         function close() 
112         {
113                 $this->db_link->disconnect();
114     }      
115          
116         // Return humanized size with default unit of GB
117         // if auto provide for unit argument, automaticaly decide which unit
118         function human_file_size( $size, $decimal = 2, $unit = 'auto' )
119         {
120                 $unit_id = 0;
121                 $lisible = false;
122                 $units = array('B','KB','MB','GB','TB');
123                 $hsize = $size;
124
125                 switch( $unit )
126                 {
127                         case 'auto';
128                                 while( !$lisible ) {
129                                         if ( $hsize >= 1024 ) {
130                                                 $hsize    = $hsize / 1024;
131                                                 $unit_id += 1;
132                                         }        
133                                         else
134                                                 $lisible = true;
135                                 } // end while
136                         break;
137                         
138                         default:
139                                 $p = array_search( $unit, $units);
140                                 $hsize = $hsize / pow(1024,$p);
141                         break;
142                 } // end switch
143                 
144                 $hsize = sprintf("%." . $decimal . "f", $hsize);
145                 $hsize = $hsize . ' ' . $units[$unit_id];
146                 return $hsize;
147         } // end function
148
149         
150         function GetDbSize() 
151         {
152                 $database_size  = 0;
153                 $query                  = "";
154                 
155                 switch( $this->driver )
156                 {
157                         case 'mysql':
158                                 $query  = "SELECT table_schema AS 'database', sum( data_length + index_length) AS 'dbsize' ";
159                                 $query .= "FROM information_schema.TABLES ";
160                                 $query .= "WHERE table_schema = 'bacula' ";
161                                 $query .= "GROUP BY table_schema";
162                         break;
163                         case 'pgsql':
164                                 $query  = "SELECT pg_database_size('bacula') AS dbsize";
165                         break;
166                         case 'sqlite':
167                                 // Not yet implemented
168                                 return "0 MB";
169                         break;
170                 }
171                 
172                 $result = $this->db_link->query( $query );
173                 
174                 if(! PEAR::isError( $result ) )
175                 {
176                         $db = $result->fetchRow( DB_FETCHMODE_ASSOC );
177                         $database_size = $db['dbsize'];
178                 }else
179                         die( "Unable to get database size<br />" . $result->getMessage() );
180                 
181                 return Utils::Get_Human_Size( $database_size );
182         } // end function GetDbSize()
183         
184         public function Get_Nb_Clients()
185         {
186                 $clients = $this->db_link->query("SELECT COUNT(*) AS nb_client FROM Client");
187                 if( PEAR::isError($clients) )
188                         die( "Unable to get client number" );
189                 else
190                         return $clients->fetchRow( DB_FETCHMODE_ASSOC );
191         }
192   
193         // Return an array of volumes ordered by poolid and volume name
194         function GetVolumeList() {
195
196                         $volumes   = array();
197                         $query     = "";
198                         $debug     = false;
199                         
200                         // Get the list of pools id
201                         $query = "SELECT Pool.poolid, Pool.name FROM Pool ORDER BY Pool.poolid";
202                         
203                         //$this->db_link->setFetchMode(DB_FETCHMODE_ASSOC);
204                         $pools = $this->db_link->query( $query );
205                         
206                         if( PEAR::isError( $pools ) )
207                                 die("Error: Failed to get pool list <br />SQL Query: $query<br />" . $pools->getMessage() );
208                         
209                         while( $pool = $pools->fetchRow( DB_FETCHMODE_ASSOC ) ) {
210                                 switch( $this->driver )
211                                 {
212                                         case 'mysql':
213                                                 $query  = "SELECT Media.volumename, Media.volbytes, Media.volstatus, Media.mediatype, Media.lastwritten, Media.volretention
214                                                                    FROM Media LEFT JOIN Pool ON Media.poolid = Pool.poolid
215                                                                    WHERE Media.poolid = '". $pool['poolid'] . "' ORDER BY Media.volumename";
216                                         break;
217                                         case 'pgsql':
218                                                 $query  = "SELECT media.volumename, media.volbytes, media.volstatus, media.mediatype, media.lastwritten, media.volretention
219                                                                    FROM media LEFT JOIN pool ON media.poolid = pool.poolid
220                                                                    WHERE media.poolid = '". $pool['poolid'] . "' ORDER BY media.volumename";
221                                         break;
222                                         case 'sqlite':
223                                                 $query  = "";           // not yet implemented
224                                         break;
225                                         default:
226                                         break;
227                                 } // end switch
228                                 
229                                 $medias = $this->db_link->query( $query );
230
231                                 if( PEAR::isError( $medias ) ) {
232                                         die( "Failed to get media list for pool $volume[0] <br /> " . $medias->getMessage() );
233                                 }else {
234                                         if( $debug ) echo "Found " . $medias->numRows() . " medias for pool " . $pool['name'] . " <br />";
235                                 
236                                         // Create array key for each pool
237                                         if( !array_key_exists( $pool['name'], $volumes) )
238                                         {
239                                                 $volumes[ $pool['name'] ] = array();
240                                         }
241                                         while( $media = $medias->fetchRow( DB_FETCHMODE_ASSOC ) ) {
242                                                 if( $debug ) {
243                                                         var_dump( $media );
244                                                 }
245                                                 // If the pool is empty (no volumes in this pool)
246                                                 if( $medias->numRows() == 0 ) {
247                                                         if( $debug ) echo "No media in pool " . $pool['name'] . "<br />";
248                                                 } else {
249                                                                 if( $media['lastwritten'] != "0000-00-00 00:00:00" ) {
250                                                                         // Calculate expiration date if the volume is Full
251                                                                         if( $media['volstatus'] == 'Full' ) {
252                                                                                 $expire_date     = strtotime($media['lastwritten']) + $media['volretention'];
253                                                                                 $media['expire'] = strftime("%Y-%m-%d", $expire_date);
254                                                                         }else {
255                                                                                 $media['expire'] = 'N/A';
256                                                                         }
257                                                                         // Media used bytes in a human format
258                                                                         $media['volbytes'] = Utils::Get_Human_Size( $media['volbytes'] );
259                                                                 } else {
260                                                                         $media['lastwritten'] = "N/A";
261                                                                         $media['expire']      = "N/A";
262                                                                         $media['volbytes']        = "0 KB";
263                                                                 }                                                               
264                                                         
265                                                         // Odd or even row
266                                                         if( count(  $volumes[ $pool['name'] ] ) % 2)
267                                                                         $media['class'] = 'odd';
268
269                                                         // Add the media in pool array
270                                                         array_push( $volumes[ $pool['name']], $media);
271                                                 }
272                                         } // end while
273                                 } // end if else
274                         } // end while
275                         return $volumes;
276         } // end function GetVolumeList()
277         
278         public function CountJobsbyLevel( $delay = LAST_DAY, $level = 'F' )
279         {
280                 $end_date    = mktime();
281                 $start_date  = $end_date - $delay;
282                 
283                 $start_date  = date( "Y-m-d H:i:s", $start_date );
284                 $end_date    = date( "Y-m-d H:i:s", $end_date );
285                 
286                 $query   = "SELECT COUNT(JobId) as jobs FROM Job ";
287                 $query  .= "WHERE (EndTime BETWEEN '$start_date' AND '$end_date') AND ";
288                 $query  .= "Level = '$level' ";
289                 
290                 $result  = $this->db_link->query( $query );
291                 
292                 if (PEAR::isError( $result ) ) {
293                         die( "Unable to get number of jobs with $level status from catalog <br />" . $result->getMessage() );
294                 }else {
295                         $jobs = $result->fetchRow( DB_FETCHMODE_ASSOC ); 
296                         return $jobs['jobs'];
297                 }
298                 
299         }
300         
301         public function CountJobs( $delay = LAST_DAY, $status = 'any' )
302         {
303                 $query                  = "SELECT COUNT(JobId) AS job_nb FROM Job ";
304                 $where_delay    = "";
305                 $where_status   = "";
306                 
307                 // Interval condition for SQL query
308                 if( $delay != ALL ) {
309                         $end_date    = mktime();
310                         $start_date  = $end_date - $delay;
311                 
312                         $start_date  = date( "Y-m-d H:i:s", $start_date );
313                         $end_date    = date( "Y-m-d H:i:s", $end_date );
314                 
315                         $where_delay = "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
316                 }
317                 
318                 if( $status != 'any' ) {
319                         switch( $status )
320                         {
321                                 case 'completed':
322                                         $where_status = "JobStatus = 'T' ";
323                                 break;
324                                 case 'failed':
325                                         $where_status = "JobStatus IN ('f','E') ";
326                                 break;
327                                 case 'canceled':
328                                         $where_status = "JobStatus = 'A' ";
329                                 break;
330                                 case 'waiting':
331                                         $where_status = "JobStatus IN ('F','S','M','m','s','j','c','d','t') ";
332                                 break;
333                         } // end switch
334                 }
335                 
336                 if( !empty($where_delay) )
337                         $query = $query . $where_delay . 'AND ' . $where_status;
338                 else {
339                         if( !empty($where_status) )
340                                 $query = $query . 'WHERE ' . $where_status;
341                 }
342                         
343                 $jobs = $this->db_link->query( $query );
344         
345                 if (PEAR::isError( $jobs ) ) {
346                         die( "Unable to get last $status jobs number from catalog <br />" . $jobs->getMessage() );
347                 }else {
348                         $jobs = $jobs->fetchRow( DB_FETCHMODE_ASSOC ); 
349                         return $jobs['job_nb'];
350                 }
351         }
352         
353         // Return the list of Pools in a array
354         public function Get_Pools_List()
355         {
356                 $pool_list = array();
357                 $result    = "";
358                 
359                 $query = "SELECT Name, PoolId FROM Pool";
360                 
361                 $result = $this->db_link->query ( $query );
362
363                 if( PEAR::isError( $result ) ) {
364                         die( "Unable to get the pool list from catalog" );                              
365                 }else {
366                         while( $pool = $result->fetchRow(DB_FETCHMODE_ASSOC) ) {
367                                 array_push( $pool_list, array( $pool['Name'] => $pool['PoolId'] ) );
368                         }
369                         return $pool_list;
370                 }
371         }
372         
373         public function Get_BackupJob_Names()
374         {
375                 $query          = "SELECT Name FROM Job GROUP BY Name";
376                 $backupjobs = array();
377                 
378                 $result = $this->db_link->query( $query );
379                 
380                 if (PEAR::isError( $result ) ) {
381                         die("Unable to get BackupJobs list from catalog" );
382                 }else{
383                         while( $backupjob = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) {
384                                 array_push( $backupjobs, $backupjob["Name"] );
385                         }
386                         return $backupjobs;
387                 }
388         }
389         
390         // Return elasped time string for a job
391         function Get_ElapsedTime( $start_time, $end_time ) 
392         { 
393                 $diff = $end_time - $start_time;
394                 
395                 $daysDiff = sprintf("%02d", floor($diff/60/60/24) );
396                 $diff -= $daysDiff*60*60*24;
397                 
398                 $hrsDiff = sprintf("%02d", floor($diff/60/60) );
399                 $diff -= $hrsDiff*60*60;
400                 
401                 $minsDiff = sprintf("%02d", floor($diff/60) );
402                 $diff -= $minsDiff*60;
403                 $secsDiff = sprintf("%02d", $diff );
404                 
405                 if( $daysDiff > 0 )
406                         return $daysDiff . 'day(s) ' . $hrsDiff.':' . $minsDiff . ':' . $secsDiff;
407                 else
408                         return $hrsDiff . ':' . $minsDiff . ':' . $secsDiff;
409         }
410         
411         public function Get_ElapsedTime_Job( $delay = LAST_DAY )
412         {
413                 $query                  = "";
414                 $total_elapsed  = 0;
415                 
416                 // Interval calculation
417                 $end_date   = mktime();
418                 $start_date = $end_date - $delay;
419                 
420                 $start_date = date( "Y-m-d H:i:s", $start_date );
421                 $end_date   = date( "Y-m-d H:i:s", $end_date );
422                 
423                 switch( $this->driver )
424                 {
425                         case 'mysql':
426                                 $query  = "SELECT UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime) AS elapsed from Job ";
427                                 $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date'";
428                         break;
429                 }
430                 $result = $this->db_link->query( $query );
431                 
432                 if( PEAR::isError($result) ){
433                         die( "Unable to get elapsed time for jobs from catalog<br />query = $query <br />" . $result->getMessage() );
434                 }else {
435                         while( $time = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) {
436                                 //echo 'elapsed = ' . $time['elapsed'] . '<br />';
437                                 $total_elapsed += $time['elapsed'];
438                         }
439                         // Verify if elapsed time is more than 1 day
440                         if ( $total_elapsed > LAST_DAY ) {
441                                 return date("%d days H:i:s", $total_elapsed );
442                         }else {
443                                 return date("H:i:s", $total_elapsed );
444                         }
445                 }
446         }
447         
448         // Return Jobs statistics for a specific interval such as
449         // - Completed jobs number
450         // - Failed jobs number
451         // - Waiting jobs number
452         // The returned values will be used by a Bgraph classe
453         public function GetJobsStatistics( $type = 'completed', $delay = LAST_DAY )
454         {
455                 $query  = "";
456                 $where  = "";
457                 $jobs   = "";
458                 $label  = "";
459                 $res    = "";
460                 
461                 // Interval calculation
462                 $end_date   = mktime();
463                 $start_date = $end_date - $delay;
464                 
465                 $start_date = date( "Y-m-d H:i:s", $start_date );
466                 $end_date   = date( "Y-m-d H:i:s", $end_date );
467                 
468                 $interval_where = "(EndTime BETWEEN '$start_date' AND '$end_date') AND ";
469                 
470                 // Job status
471                 switch( $type )
472                 {
473                         case 'completed':
474                                 $where = $interval_where . "JobStatus = 'T' ";
475                                 $label = "Completed";
476                         break;
477                         case 'terminated_errors':
478                                 $where = $interval_where . "JobStatus = 'E' ";
479                                 $label = "Terminated with errors";
480                         break;
481                         case 'failed':
482                                 $where = $interval_where . "JobStatus = 'f' ";
483                                 $label = "Failed";
484                         break;
485                         case 'waiting':
486                                 $where = "JobStatus IN ('F','S','M','m','s','j','c','d','t') ";
487                                 $label = "Waiting";
488                         break;
489                         case 'created':
490                                 $where = "JobStatus = 'C' ";
491                                 $label = "Created but not running";
492                         break;
493                         case 'running':
494                                 $where = "JobStatus = 'R' ";
495                                 $label = "Running";
496                         break;
497                         case 'error':
498                                 $where = $interval_where . "JobStatus IN ('e','f') ";
499                                 $label = "Errors";
500                         break;
501                 }
502                 
503                 $query  = 'SELECT COUNT(JobId) AS ' . $type . ' ';
504                 $query .= 'FROM Job ';
505                 $query .= "WHERE $where ";
506         
507                 //echo 'query = ' . $query . '<br />';
508                 
509                 $jobs = $this->db_link->query( $query );
510         
511                 if (PEAR::isError( $jobs ) ) {
512                         die( "Unable to get last $type jobs status from catalog<br />" . $status->getMessage() );
513                 }else {
514                         $res = $jobs->fetchRow();
515                         return array( $label , current($res) );
516                 }
517         } // end function GetJobsStatistics()
518         
519         public function CountVolumesByPool( $pools )
520         {
521                 foreach( $pools as $pool_name => $pool ) {
522                         //var_dump( $pool );
523                         $query = "SELECT COUNT(*) AS nb_vol FROM Media WHERE PoolId = '$pool'";
524                         //echo $query . '<br />';
525                         //echo 'Pool name ' . $pool_name . '<br />';
526                         $result = $this->db_link->query( $query );
527                         
528                         if( PEAR::isError( $result ) ) {
529                                 die("Unable to get volume number from catalog");
530                         }else{
531                                 $nb_vol = $result->fetchRow(DB_FETCHMODE_ASSOC);
532                                 return array( $pool_name, $nb_vol['nb_vol'] );
533                         }
534                 }
535         }
536         
537         public function GetStoredFiles( $delay = LAST_DAY )
538         {
539                 $totalfiles = 0;
540
541                 $query = "SELECT SUM(JobFiles) AS stored_files FROM Job ";
542                 
543                 // Interval calculation
544                 $end_date   = mktime();
545                 $start_date = $end_date - $delay;
546                 
547                 $start_date = date( "Y-m-d H:i:s", $start_date );
548                 $end_date   = date( "Y-m-d H:i:s", $end_date );                 
549
550                 if( $delay != ALL )
551                         $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date'";
552                         
553                 $result = $this->db_link->query( $query );
554                 
555                 if( !PEAR::isError($result) ) {
556                         $nbfiles        = $result->fetchRow(DB_FETCHMODE_ASSOC);
557                         $totalfiles = $totalfiles + $nbfiles['stored_files'];
558                 }else{
559                         die("Unable to get protected files from catalog <br />" . $result->getMessage() );
560                 }
561                 
562                 return $totalfiles;
563         }
564         
565         public function GetStoredBytes( $delay = LAST_DAY )
566         {
567                 $query = "SELECT SUM(JobBytes) as stored_bytes FROM Job ";
568                 
569                 // Interval calculation
570                 $end_date   = mktime();
571                 $start_date = $end_date - $delay;
572                 
573                 $start_date = date( "Y-m-d H:i:s", $start_date );
574                 $end_date   = date( "Y-m-d H:i:s", $end_date );
575                 
576                 if( $delay != ALL )
577                         $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date'";
578                 
579                 $result = $this->db_link->query( $query );
580                 
581                 if( PEAR::isError( $result ) ) {
582                         die( "Unable to get Job Bytes from catalog" );
583                 }else{
584                         return $result->fetchRow( DB_FETCHMODE_ASSOC );
585                 }
586         }
587         
588         public function GetStoredBytesByInterval( $start_date, $end_date )
589         {
590                 $query = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job WHERE EndTime BETWEEN '$start_date' AND '$end_date'";
591                 
592                 $result = $this->db_link->query( $query );
593                 
594                 if( PEAR::isError( $result ) ) {
595                         die( "Unable to get Job Bytes from catalog" );
596                 }else{
597                         $stored_bytes = 0;
598                         $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC );
599                         
600                         $day = date( "D d", strtotime($end_date) );
601                         
602                         if( isset( $tmp['stored_bytes'] ) ) {
603                                 $hbytes = Utils::Get_Human_Size( $tmp['stored_bytes'], 3, 'GB' );
604                                 $hbytes = explode( " ", $hbytes );
605                                 $stored_bytes = $hbytes[0];
606                         }
607                         
608                         return array( $day, $stored_bytes );
609                 }
610         }
611         
612         public function GetStoredBytesByJob( $jobname, $start_date, $end_date )
613         {
614                 $query  = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job ";
615                 $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND ";
616                 $query .= "Name = '$jobname'";
617                 
618                 $result = $this->db_link->query( $query );
619                 
620                 if( PEAR::isError( $result ) ) {
621                         die( "Unable to get Job Bytes from catalog" );
622                 }else{
623                         $stored_bytes = 0;
624                         $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC );
625                         
626                         $day = date( "D d", strtotime($end_date) );
627                         
628                         if( isset( $tmp['stored_bytes'] ) ) {
629                                 $hbytes = Utils::Get_Human_Size( $tmp['stored_bytes'], 3, 'GB' );
630                                 $hbytes = explode( " ", $hbytes );
631                                 $stored_bytes = $hbytes[0];
632                         }
633                         
634                         return array( $day, $stored_bytes );
635                 }                       
636         }
637         
638         public function GetStoredFilesByJob( $jobname, $start_date, $end_date )
639         {
640                 $query  = "SELECT SUM(JobFiles) as stored_files, EndTime FROM Job ";
641                 $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND ";
642                 $query .= "Name = '$jobname'";
643                 
644                 $result = $this->db_link->query( $query );
645                 
646                 if( PEAR::isError( $result ) ) {
647                         die( "Unable to get Job Files from catalog" );
648                 }else{
649                         $stored_bytes = 0;
650                         $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC );
651                         
652                         $day                    = date( "D d", strtotime($end_date) );
653                         $stored_files   = $tmp['stored_files'];
654                         
655                         return array( $day, $stored_files );
656                 }                       
657         }
658 } // end class Bweb
659 ?>