]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/test.php
bacula-web: Added Y axis title in graphs (unit GB)
[bacula/bacula] / gui / bacula-web / test.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  require_once ("config.inc.php");
19  $bw = new Bweb();
20
21  // Check result icon
22  $check_result = array( true => 'ok.png', false => 'error.png' );
23
24  // Checks list
25  $check_list = array( array( 'check_cmd'                => 'php-gettext', 
26                                                          'check_label'          => 'PHP - Gettext support', 
27                                                          'check_descr'          => 'If you want Bacula-web in your language, please compile PHP with Gettext support' ),
28                                           array( 'check_cmd'            => 'pear-db', 
29                                                          'check_label'          => 'PEAR DB module', 
30                                                          'check_descr'          => 'PEAR DB support not found, please read the Bacula-web installation document'),
31                                           array( 'check_cmd'            => 'php-gd',
32                                                          'check_label'          => 'PHP - GD support',
33                                                          'check_descr'          => 'This is required by phplot, please compile php with GD support'),
34                                           array( 'check_cmd'            => 'php-mysql',
35                                                          'check_label'          => 'PHP - MySQL support',
36                                                          'check_descr'          => 'PHP MySQL support must be installed in order to run bacula-web with MySQL bacula catalog'),
37                                           array( 'check_cmd'            => 'php-postgres',
38                                                          'check_label'          => 'PHP - PostgreSQL support',
39                                                          'check_descr'          => 'PHP PostgreSQL support must be installed in order to run bacula-web with PostgreSQL bacula catalog'),                                                               
40                                           array( 'check_cmd'            => 'smarty-cache',
41                                                          'check_label'          => 'Smarty cache folder write permission',
42                                                          'check_descr'          => 'Smarty template engine need write permissions to templates_c folder')
43                                         );
44
45  // Doing all checks
46  foreach( $check_list as &$check ) {
47          switch( $check['check_cmd'] )
48          {
49                  case 'php-gettext':
50                          $check['check_result'] = $check_result[ function_exists( 'gettext' ) ];                                        
51                  break;
52                  case 'php-gd':
53                          $check['check_result'] = $check_result[ function_exists( 'gd_info') ];
54                  break;
55                  case 'pear-db':
56                          $check['check_result'] = $check_result[ class_exists('DB') ];
57                  break;
58                  case 'php-mysql':
59                          $check['check_result'] = $check_result[ function_exists('mysql_connect') ];
60                  break;
61                  case 'php-postgres':
62                          $check['check_result'] = $check_result[ function_exists('pg_connect') ];
63                  break;
64                  case 'smarty-cache':
65                          $check['check_result'] = $check_result[ is_writable( "./templates_c" ) ];
66                  break;
67          }
68  }
69  
70  // Generate test graph
71  $data = array( array('test', 100, 100, 200, 100), array('test1', 150, 100, 150, 100 ) );       
72  $graph = new BGraph( "graph3.png" );
73  $graph->SetColors( array('green', 'red' ) );
74
75  $graph->SetData( $data, 'pie', 'text-data-single' );
76  $graph->SetGraphSize( 400, 230 );
77
78  $graph->Render();
79
80  // Parse to template
81  $bw->tpl->assign( 'checks', $check_list );
82  $bw->tpl->assign('graph_test', $graph->Get_Image_file() );
83  $bw->tpl->display('test.tpl');
84 ?>