]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/test.php
a8407a53ed72d67365bd64d6bbf6814fd866c1f1
[bacula/bacula] / gui / bacula-web / test.php
1 <?php
2         require_once ("paths.php");
3         require_once ($smarty_path."Smarty.class.php");
4         require_once ("bweb.inc.php");
5
6         $smarty = new Smarty(); 
7
8         // Smarty configuration
9         $smarty->compile_check  = true;
10         $smarty->debugging              = false;
11         $smarty->force_compile  = true;
12
13         $smarty->template_dir   = "./templates";
14         $smarty->compile_dir    = "./templates_c";
15         $smarty->config_dir     = "./configs";  
16   
17         // Check result icon
18     $check_result = array( true => 's_ok.png', false => 's_error.gif' );
19         
20         // Checks list
21         $check_list = array( array( 'check_cmd'                 => 'php-gettext', 
22                                                                 'check_label'           => 'PHP - Gettext support', 
23                                                                 'check_descr'           => 'If you want Bacula-web in your language, please compile PHP with Gettext support' ),
24                                                  array( 'check_cmd'             => 'pear-db', 
25                                                                 'check_label'           => 'PEAR DB module', 
26                                                                 'check_descr'           => 'PEAR DB support not found, please read the Bacula-web installation document'),
27                                                  array( 'check_cmd'             => 'php-gd',
28                                                                 'check_label'           => 'PHP - GD support',
29                                                                 'check_descr'           => 'This is required by phplot, please compile php with GD support'),
30                                                  array( 'check_cmd'             => 'php-mysql',
31                                                                 'check_label'           => 'PHP - MySQL support',
32                                                                 'check_descr'           => 'PHP MySQL support must be installed in order to run bacula-web with MySQL bacula catalog'),
33                                                  array( 'check_cmd'             => 'php-postgres',
34                                                                 'check_label'           => 'PHP - PostgreSQL support',
35                                                                 'check_descr'           => 'PHP PostgreSQL support must be installed in order to run bacula-web with PostgreSQL bacula catalog'),                                                               
36                                                  array( 'check_cmd'             => 'smarty-cache',
37                                                                 'check_label'           => 'Smarty cache folder write permission',
38                                                                 'check_descr'           => 'Smarty template engine need write permissions to templates_c folder')
39                                   );
40         
41         // Doing all checks
42         foreach( $check_list as &$check ) {
43                 switch( $check['check_cmd'] )
44                 {
45                         case 'php-gettext':
46                                 $check['check_result'] = $check_result[ function_exists( 'gettext' ) ];                                 
47                         break;
48                         case 'php-gd':
49                                 $check['check_result'] = $check_result[ function_exists( 'gd_info') ];
50                         break;
51                         case 'pear-db':
52                                 $check['check_result'] = $check_result[ class_exists('DB') ];
53                         break;
54                         case 'php-mysql':
55                                 $check['check_result'] = $check_result[ function_exists('mysql_connect') ];
56                         break;
57                         case 'php-postgres':
58                                 $check['check_result'] = $check_result[ function_exists('pg_connect') ];
59                         break;
60                         case 'smarty-cache':
61                                 $check['check_result'] = $check_result[ is_writable( "./templates_c" ) ];
62                         break;
63                 }
64                 
65         }
66
67         // Generate test graph
68         $data = array( array('test', 100, 100, 200, 100), array('test1', 150, 100, 150, 100 ) );        
69         $graph = new BGraph( "graph3.png" );
70         $graph->SetColors( array('green', 'red' ) );
71
72         $graph->SetData( $data, 'pie', 'text-data-single' );
73         $graph->SetGraphSize( 400, 230 );
74         
75         $graph->Render();
76
77         // Parse to template
78         $smarty->assign( 'checks', $check_list );
79         $smarty->assign('graph_test', $graph->Get_Image_file() );
80         $smarty->display('test.tpl');
81 ?>