Implement version check to the init.php script to check for correct version of libvir...
authorMichal Novotny <minovotn@redhat.com>
Fri, 22 Jul 2011 13:23:27 +0000 (15:23 +0200)
committerMichal Novotny <minovotn@redhat.com>
Fri, 22 Jul 2011 13:23:27 +0000 (15:23 +0200)
Signed-off-by: Michal Novotny <minovotn@redhat.com>

classes/language.php
error-missing.php [new file with mode: 0644]
error-need-update.php [new file with mode: 0644]
init.php
lang/cs.php
lang/en.php

index 2f064fc..e079697 100644 (file)
                                        'error_page_title' => 'Error',
                                        'error_page_label' => 'Page not found:',
                                        'error_page_text' => 'The page you were looking for was not found. Please report to the administrator and try again later.',
+                                       'error_missing_label' => 'Missing dependency:',
+                                       'error_missing_text' => 'Your PHP configuration is missing libvirt-php module which is necessary to maintain virtual machines. Please install libvirt-php from <a href="http://libvirt.org/php">http://libvirt.php</a> first.',
+                                       'error_need_update_label' => 'Update needed:',
+                                       'error_need_update_text' => 'Your version of libvirt-php module is too old for this application to work properly. Please upgrade your libvirt-php version from <a href="http://libvirt.org/php">http://libvirt.php</a> first.',
                                        'host_details' => 'Host details',
                                        'model' => 'Model',
                                        'pcpus' => 'CPUs/cores',
diff --git a/error-missing.php b/error-missing.php
new file mode 100644 (file)
index 0000000..36e30b8
--- /dev/null
@@ -0,0 +1,26 @@
+
+<html> 
+<head> 
+ <title>php-virt-control - <?= $lang->get('title_vmc') ?></title> 
+ <link rel="STYLESHEET" type="text/css" href="manager.css"> 
+</head> 
+<body> 
+  <div id="header"> 
+    <div id="headerLogo"></div> 
+  </div> 
+  <!-- CONTENTS --> 
+  <div id="content"> 
+
+    <div class="section"><?= $lang->get('error_page_title') ?></div>
+    <div class="item">
+      <div class="label"><?= $lang->get('error_missing_label') ?></div>
+      <div class="value"><?= $lang->get('error_missing_text') ?></div>
+      <div class="nl" />
+    </div>
+    </form> 
+  </div> 
+</body> 
+</html> 
diff --git a/error-need-update.php b/error-need-update.php
new file mode 100644 (file)
index 0000000..30ac0d0
--- /dev/null
@@ -0,0 +1,26 @@
+
+<html> 
+<head> 
+ <title>php-virt-control - <?= $lang->get('title_vmc') ?></title> 
+ <link rel="STYLESHEET" type="text/css" href="manager.css"> 
+</head> 
+<body> 
+  <div id="header"> 
+    <div id="headerLogo"></div> 
+  </div> 
+  <!-- CONTENTS --> 
+  <div id="content"> 
+
+    <div class="section"><?= $lang->get('error_page_title') ?></div>
+    <div class="item">
+      <div class="label"><?= $lang->get('error_need_update_label') ?></div>
+      <div class="value"><?= $lang->get('error_need_update_text') ?></div>
+      <div class="nl" />
+    </div>
+    </form> 
+  </div> 
+</body> 
+</html> 
index ae3d6b6..b179d93 100644 (file)
--- a/init.php
+++ b/init.php
@@ -1,4 +1,10 @@
 <?php
+       define('LOGDIR', getcwd().'/logs');
+       define('LIBVIRT_PHP_REQ_VERSION', '0.4.3');
+       define('PHPVIRTCONTROL_VERSION', '0.0.2');
+       define('PHPVIRTCONTROL_WEBSITE', 'http://www.php-virt-control.org');
+       define('ALLOW_EXPERIMENTAL_VNC', false);
+
        session_start();
 
        if (array_key_exists('lang-override', $_GET)) {
        else
                $lang_str = $_SESSION['language'];
 
-       define('LOGDIR', getcwd().'/logs');
-       define('PHPVIRTCONTROL_VERSION', '0.0.1');
-       define('PHPVIRTCONTROL_WEBSITE', 'http://www.php-virt-control.org');
-       define('ALLOW_EXPERIMENTAL_VNC', false);
-
        if (!File_Exists(LOGDIR)) {
                if (!mkdir(LOGDIR, 0777))
                        define(LOGDIR, false);
        require('classes/database-file.php');
 
        $lang = new Language($lang_str);
+
+       /* Check for libvirt-php */
+       if (!function_exists('libvirt_check_version')) {
+               include('error-missing.php');
+               exit;
+       }
+
+       /* Now check for correct version of libvirt-php */
+       $tmp = explode('.', LIBVIRT_PHP_REQ_VERSION);
+       if (!libvirt_check_version($tmp[0], $tmp[1], $tmp[2])) {
+               include('error-need-update.php');
+               exit;
+       }
+
        $db = getDBObject('file:data/test.dat');
 ?>
index 595be3f..809437d 100644 (file)
                                        'error_page_title' => 'Chyba',
                                        'error_page_label' => 'Stránka nenalezena:',
                                        'error_page_text' => 'Stránka, kterou hledáte, nebyla nalezena. Prosím reportujte tuto chybu správci a zkuste znovu později.',
+                                       'error_missing_label' => 'Chybějící závislost:',
+                                       'error_missing_text' => 'Vaší konfigurace PHP chybí modul libvirt-php, která je nezbytný pro správu virtuálních strojů. Prosím nainstalujte prvně libvirt-php z <a href="http://libvirt.org/php">http://libvirt.php</a>.',
+                                       'error_need_update_label' => 'Nutná aktualizace:',
+                                       'error_need_update_text' => 'Vaše verze modulu libvirt-php je příliš zastaralá pro potřeby této aplikace. Prosím aktualizujte prvně verzi libvirt-php na aktuální verzi ze stránky <a href="http://libvirt.org/php">http://libvirt.php</a>.',
                                        'host_details' => 'Detaily hostitele',
                                        'model' => 'Model',
                                        'pcpus' => 'Procesory/jádra',
index d92802e..734f27d 100644 (file)
                                        'error_page_title' => 'Error',
                                        'error_page_label' => 'Page not found:',
                                        'error_page_text' => 'The page you were looking for was not found. Please report to the administrator and try again later.',
+                                       'error_missing_label' => 'Missing dependency:',
+                                       'error_missing_text' => 'Your PHP configuration is missing libvirt-php module which is necessary to maintain virtual machines. Please install libvirt-php from <a href="http://libvirt.org/php">http://libvirt.php</a> first.',
+                                       'error_need_update_label' => 'Update needed:',
+                                       'error_need_update_text' => 'Your version of libvirt-php module is too old for this application to work properly. Please upgrade your libvirt-php version from <a href="http://libvirt.org/php">http://libvirt.php</a> first.',
                                        'host_details' => 'Host details',
                                        'model' => 'Model',
                                        'pcpus' => 'CPUs/cores',