]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/test.php
bacula-web: Renamed SQLite class php file
[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                                       array( 'check_cmd'                => 'php-version',
44                                                          'check_label'          => 'PHP version',
45                                                          'check_descr'          => 'PHP version must be at least 5.0.0 (current = ' . PHP_VERSION . ')' )
46                                         );
47
48  // Doing all checks
49  foreach( $check_list as &$check ) {
50          switch( $check['check_cmd'] )
51          {
52                  case 'php-gettext':
53                          $check['check_result'] = $check_result[ function_exists( 'gettext' ) ];                                        
54                  break;
55                  case 'php-gd':
56                          $check['check_result'] = $check_result[ function_exists( 'gd_info') ];
57                  break;
58                  case 'pear-db':
59                          $check['check_result'] = $check_result[ class_exists('DB') ];
60                  break;
61                  case 'php-mysql':
62                          $check['check_result'] = $check_result[ function_exists('mysql_connect') ];
63                  break;
64                  case 'php-postgres':
65                          $check['check_result'] = $check_result[ function_exists('pg_connect') ];
66                  break;
67                  case 'smarty-cache':
68                          $check['check_result'] = $check_result[ is_writable( "./templates_c" ) ];
69                  break;
70                  case 'php-version':
71                          $phpversion = explode( '.', PHP_VERSION );
72                          $phpversion = $phpversion[0];
73                          $check['check_result'] = $check_result[ $phpversion >= 5 ];
74                  break;
75          }
76  }
77  
78  // Generate test graph
79  $data = array( array('test', 100, 100, 200, 100), array('test1', 150, 100, 150, 100 ) );       
80  $graph = new BGraph( "graph3.png" );
81  $graph->SetColors( array('green', 'red' ) );
82
83  $graph->SetData( $data, 'pie', 'text-data-single' );
84  $graph->SetGraphSize( 400, 230 );
85
86  $graph->Render();
87
88  // Parse to template
89  $bw->tpl->assign( 'checks', $check_list );
90  $bw->tpl->assign('graph_test', $graph->Get_Image_file() );
91  $bw->tpl->display('test.tpl');
92 ?>