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