Add settings page to set language
authorMichal Novotny <minovotn@redhat.com>
Thu, 21 Jul 2011 11:15:10 +0000 (13:15 +0200)
committerMichal Novotny <minovotn@redhat.com>
Thu, 21 Jul 2011 11:15:10 +0000 (13:15 +0200)
Signed-off-by: Michal Novotny <minovotn@redhat.com>

16 files changed:
classes/database-file.php
classes/language.php
data/test.dat
html/contact.html
html/contributions.html
html/downloads.html
html/index.html
html/links.html
html/news.html
html/php-virt-control.css
init.php
lang/cs.php
lang/en.php [new file with mode: 0644]
main-menu.php
pages/overview.php
pages/settings.php [new file with mode: 0644]

index 818d1e6..f6674c7 100644 (file)
@@ -5,8 +5,8 @@
                File-Version: 0.0.1
                Tab: connections
                START_TAB
-               name,hv,type,method,user,host,logfile
-               name1,qemu,0,,,,,
+               name,hv,type,method,require_pwd,user,host,logfile
+               name1,qemu,0,,0,,,,
                END_TAB
        */
        class DatabaseFile extends Database {
                                                                'hypervisor'    => Trim($tmp[1]),
                                                                'remote'        => Trim($tmp[2]),
                                                                'method'        => Trim($tmp[3]),
-                                                               'user'          => Trim($tmp[4]),
-                                                               'host'          => Trim($tmp[5]),
-                                                               'logfile'       => Trim($tmp[6])
+                                                               'require_pwd'   => Trim($tmp[4]),
+                                                               'user'          => Trim($tmp[5]),
+                                                               'host'          => Trim($tmp[6]),
+                                                               'logfile'       => Trim($tmp[7])
                                                        );
 
                                                $this->connections[] = $e;
                }
 
                /* Add/edit/remove functions */
-               function add_connection($name, $hv, $type, $method, $user, $host, $logfile) {
+               function add_connection($name, $hv, $type, $method, $require_pwd, $user, $host, $logfile) {
                        $fp = fopen($this->filename, 'w');
                        if (!$fp)
                                return false;
 
+                       if ($require_pwd)
+                               $require_pwd = 1;
+                       else
+                               $require_pwd = 0;
+
                        fputs($fp, "File-Version: {$this->req_version}\n");
                        fputs($fp, "Tab: connections\n");
                        fputs($fp, "START_TAB\n");
                                $hv1 = $this->connections[$i]['hypervisor'];
                                $type1 = $this->connections[$i]['remote'];
                                $method1 = $this->connections[$i]['method'];
+                               $require_pwd1 = $this->connections[$i]['require_pwd'];
                                $user1 = $this->connections[$i]['user'];
                                $host1 = $this->connections[$i]['host'];
                                $logfile1 = $this->connections[$i]['logfile'];
 
-                               fputs($fp, "$name1,$hv1,$type1,$method1,$user1,$host1,$logfile1\n");
+                               fputs($fp, "$name1,$hv1,$type1,$method1,$require_pwd1,$user1,$host1,$logfile1\n");
                        }
-                       fputs($fp, "$name,$hv,$type,$method,$user,$host,$logfile\n");
+                       fputs($fp, "$name,$hv,$type,$method,$require_pwd,$user,$host,$logfile\n");
                        fputs($fp, "END_TAB\n");
                        
                        fclose($fp);
                        return true;
                }
 
-               function edit_connection($id, $name, $hv, $type, $method, $user, $host, $logfile) {
+               function edit_connection($id, $name, $hv, $type, $method, $require_pwd, $user, $host, $logfile) {
                        $fp = fopen($this->filename, 'w');
                        if (!$fp)
                                return false;
 
+                       if ($require_pwd)
+                               $require_pwd = 1;
+                       else
+                               $require_pwd = 0;
+
                        fputs($fp, "File-Version: {$this->req_version}\n");
                        fputs($fp, "Tab: connections\n");
                        fputs($fp, "START_TAB\n");
                                $hv1 = $this->connections[$i]['hypervisor'];
                                $type1 = $this->connections[$i]['remote'];
                                $method1 = $this->connections[$i]['method'];
+                               $require_pwd1 = $this->connections[$i]['require_pwd'];
                                $user1 = $this->connections[$i]['user'];
                                $host1 = $this->connections[$i]['host'];
                                $logfile1 = $this->connections[$i]['logfile'];
 
                                if ($i + 1 != $id)
-                                       fputs($fp, "$name1,$hv1,$type1,$method1,$user1,$host1,$logfile1\n");
+                                       fputs($fp, "$name1,$hv1,$type1,$method1,$require_pwd1,$user1,$host1,$logfile1\n");
                                else
-                                       fputs($fp, "$name,$hv,$type,$method,$user,$host,$logfile\n");
+                                       fputs($fp, "$name,$hv,$type,$method,$require_pwd,$user,$host,$logfile\n");
                        }
                        fputs($fp, "END_TAB\n");
                        
                                $hv1 = $this->connections[$i]['hypervisor'];
                                $type1 = $this->connections[$i]['remote'];
                                $method1 = $this->connections[$i]['method'];
+                               $require_pwd1 = $this->connections[$i]['require_pwd'];
                                $user1 = $this->connections[$i]['user'];
                                $host1 = $this->connections[$i]['host'];
                                $logfile1 = $this->connections[$i]['logfile'];
 
                                if ($i + 1 != $id)
-                                       fputs($fp, "$name1,$hv1,$type1,$method1,$user1,$host1,$logfile1\n");
+                                       fputs($fp, "$name1,$hv1,$type1,$method1,$require_pwd1,$user1,$host1,$logfile1\n");
                        }
                        fputs($fp, "END_TAB\n");
                        
index a16f20d..0f5c99f 100644 (file)
@@ -19,6 +19,7 @@
                }
 
                function initlang() {
+                       /* Default to English however implemented in here as well for case lang directory is missing */
                        $trans = array(
                                        'title_vmc' => 'Virtual Machine Controller',
                                        'info'   => 'Information',
@@ -29,6 +30,7 @@
                                        'conn_secure' => 'Secure',
                                        'hypervisor_limit' => 'Hypervisor limit',
                                        'hostname' => 'Hostname',
+                                       'password' => 'Password',
                                        'Yes' => 'Yes',
                                        'No' => 'No',
                                        'host_details' => 'Host details',
                                        'dom_none' => 'No valid domain defined',
                                        'main_menu' => 'Main menu',
                                        'cannot_connect' => 'Cannot connect to hypervisor. Please change connection information.',
+                                       'language' => 'Language',
+                                       'usig-ssh-auth' => 'Using SSH authentication',
+                                       'info-apache-key-copy' => 'There\'s an utility called <b>apache-key-copy</b> included to this web-application (can be found in tools subdir)'.
+                                                               'that\'s useful to setup SSH keys for password-less SSH connection. The SSH connection '.
+                                                               'transport <b>does not</b> support passing credentials to the SSH process and that\'s why '.
+                                                               'password-less SSH connection settings is necesary. <b>Apache-key-copy</b> utility have to '.
+                                                               'be run from shell by the system administrator (root account). This application find the home '.
+                                                               'directory for the apache user (you will most likely need to change it if you are using a '.
+                                                               'different user name to run Apache/php) and creates the hidden SSH settings directory. Then '.
+                                                               'a SSH key is being generated (if it doesn\'t exist yet) and copied to the destination machine.',
                                        );
 
                        $this->trans = $trans;
index 39e0681..94367c1 100755 (executable)
@@ -1,6 +1,6 @@
 File-Version: 0.0.1
 Tab: connections
 START_TAB
-Local QEMU,qemu,0,ssh,,,
-Local Xen,xen,0,ssh,,,
+Local QEMU,qemu,0,ssh,0,,,
+Local Xen,xen,0,ssh,0,,,
 END_TAB
index 8aec634..6c7cf51 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
             </div>
           </li><li>
index 498d913..9cba268 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <a title="Downloads" class="inactive" href="downloads.html">Downloads</a>
             </div>
           </li><li>
@@ -67,7 +63,7 @@
         <p>
       If you want to implement new features to php-virt-control or fix some bugs you have found you can download the source from
       our GIT repository using</p>
-        <pre>git://git.php-virt-control.org/php-virt-control.git</pre>
+        <pre>git://git.fedorahosted.org/php-virt-control.git</pre>
         <p>
       Please make sure you're using the coding style in which the code is already written (beware of spaces instead of tabs etc).
       When you have the patch prepared please send us the patch using the procedure mentioned in <a href="#sending">Sending patches</a> paragraph.
index 95f2fed..440d8a6 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <span class="active">Downloads</span>
             </div>
           </li><li>
@@ -57,7 +53,7 @@
         <p>
       You can clone the development version of php-virt-control from GIT repository:
     </p>
-        <pre>git://git.php-virt-control.org/php-virt-control.git</pre>
+        <pre>git://git.fedorahosted.org/php-virt-control.git</pre>
         <p>If you want to contribute to the php-virt-control project please refer to <a href="contributions.html">Contributions</a>.</p>
       </div>
     </div>
index d43517e..9f24650 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
             </div>
           </li><li>
index bed7a3e..a4f4b0a 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
             </div>
           </li><li>
@@ -50,7 +46,7 @@
       <div id="content">
         <h1>Related links</h1>
         <p>
-      Those links are related to php-virt-control project:
+      Those links are related to libvirt-php project:
     </p>
         <ul>
         <li><a href="http://libvirt.org">Libvirt</a></li>
index c305fd7..161e812 100644 (file)
             </div>
           </li><li>
             <div>
-              <a title="Screenshots of php-virt-control tool" class="inactive" href="screenshots.html">Screenshots</a>
-            </div>
-          </li><li>
-            <div>
               <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
             </div>
           </li><li>
         <h1>News</h1>
         <p>Here will the list of official releases of php-virt-control project but it's empty now since no release has been done yet.</p>
         <p>If you want to see the commits or download the source from <a href="http://git-scm.com">git</a> please refer to project's GIT repository at:</p>
-        <pre>git://git.php-virt-control.org/php-virt-control.git</pre>
-        <p>or you can browse the repository in your browser at:</p>
-        <pre>http://php-virt-control.org/git/?p=php-virt-control.git;a=summary</pre>
+        <pre>git://git.fedorahosted.org/php-virt-control.git</pre>
         <p>
-    If you want to see the latest patches committed to the repository can also refer to <a href="http://php-virt-control.org/git/?p=php-virt-control.git;a=log">GIT log</a>.
+    If you want to see the latest patches committed to the repository can also refer to <a href="http://git.fedorahosted.org/git/?p=php-virt-control.git;a=log">GIT log</a>.
     </p>
       </div>
     </div>
index 704b4ca..98a325f 100644 (file)
@@ -12,10 +12,6 @@ h2, h3, h4, h5, h6 {
     color: #3c857c;
 }
 
-img {
-    border: 0;
-}
-
 #header {
     margin: 0px;
     height: 104px;
index b611b05..ae3d6b6 100644 (file)
--- a/init.php
+++ b/init.php
@@ -1,10 +1,24 @@
 <?php
-       $tmp = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
-       $tmp = explode('-', $tmp[0]);
-       $lang_str = $tmp[0];
-       unset($tmp);
-
        session_start();
+
+       if (array_key_exists('lang-override', $_GET)) {
+               $_SESSION['language'] = $_GET['lang-override'];
+               if (array_key_exists('page', $_GET))
+                       Header('Location: ?page='.$_GET['page']);
+               else
+                       Header('Location: ?');
+               exit;
+       }
+
+       if (!array_key_exists('language', $_SESSION)) {
+               $tmp = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+               $tmp = explode('-', $tmp[0]);
+               $lang_str = $tmp[0];
+               unset($tmp);
+       }
+       else
+               $lang_str = $_SESSION['language'];
+
        define('LOGDIR', getcwd().'/logs');
        define('PHPVIRTCONTROL_VERSION', '0.0.1');
        define('PHPVIRTCONTROL_WEBSITE', 'http://www.php-virt-control.org');
index 394e9fe..5ad4d4a 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+               $lang_name = 'Čeština (Czech)';
+               $lang_code = 'cs';
                $trans = array(
                                        'title_vmc' => 'Ovládací panel virtuálních strojů',
                                        'for_php' => 'pro PHP',
@@ -10,6 +12,7 @@
                                        'conn_secure' => 'Zabezpečení',
                                        'hypervisor_limit' => 'Limit hypervisoru',
                                        'hostname' => 'Jméno hostitele',
+                                       'password' => 'Heslo',
                                        'Yes' => 'Ano',
                                        'No' => 'Ne',
                                        'host_details' => 'Detaily hostitele',
                                        'dom_none' => 'Žádná platná doména zde není definovaná',
                                        'main_menu' => 'Hlavní menu',
                                        'cannot_connect' => 'Nezdařilo se připojení k hypervisoru. Prosím zkontrolujte nastavení.',
+                                       'language' => 'Jazyk',
+                                       'using-ssh-auth' => 'Jak používat SSH authentizaci',
+                                       'info-apache-key-copy' => 'K projektu php-virt-control je přibalena utilita <b>apache-key-copy</b> (možno nalézt v podadresáři tools), '.
+                                                               'která umožňuje nastavení SSH klíčů pro použití serverem Apache a jazykem PHP. Toto je užitečné především pro '.
+                                                               'nastavení SSH authentizace bez hesla (password-less authentization), protože SSH transport nepodporuje předávání '.
+                                                               'přihlašovacích informací SSH procesu a tedy je nezbytné použít tento typ authentizace pro SSH transport. Utilita '.
+                                                               '<b>apache-key-copy</b> musí být spuštěna v kontextu superuživatele root, aby byla schopná přepnutí do uživatele '.
+                                                               'apache i v případě, že uživatel nemá přiřazený žádný shell. Zde bude aplikace přistupovat domovský adresář '.
+                                                               'uživatele apache, kde vytvoří SSH klíč (pokud neexistuje) a zkopíruje veřejný klíč na vzdálený systém, který '.
+                                                               'chcete spravovat.'
                                        );
 ?>
diff --git a/lang/en.php b/lang/en.php
new file mode 100644 (file)
index 0000000..44cfed1
--- /dev/null
@@ -0,0 +1,180 @@
+<?php
+               $lang_name = 'English';
+               $lang_code = 'en';
+               $trans = array(
+                                       'title_vmc' => 'Virtual Machine Controller',
+                                       'info'   => 'Information',
+                                       'for_php' => 'for PHP',
+                                       'conn_details' => 'Connection details',
+                                       'conn_uri' => 'Connection URI',
+                                       'conn_encrypted' => 'Encrypted',
+                                       'conn_secure' => 'Secure',
+                                       'hypervisor_limit' => 'Hypervisor limit',
+                                       'hostname' => 'Hostname',
+                                       'password' => 'Password',
+                                       'Yes' => 'Yes',
+                                       'No' => 'No',
+                                       'host_details' => 'Host details',
+                                       'model' => 'Model',
+                                       'pcpus' => 'CPUs/cores',
+                                       'cpu_speed' => 'CPU Speed',
+                                       'modinfo' => 'libvirt PHP module information',
+                                       'version' => 'Version',
+                                       'website' => 'Website',
+                                       'pool_not_running' => 'Not running',
+                                       'pool_building' => 'Building pool',
+                                       'pool_running' => 'Running',
+                                       'pool_running_deg' => 'Running degraded',
+                                       'pool_running_inac' => 'Running but inaccessible',
+                                       'unknown' => 'Unknown',
+                                       'dom_running' => 'running',
+                                       'dom_nostate' => 'no state',
+                                       'dom_blocked' => 'blocked',
+                                       'dom_paused' =>  'paused',
+                                       'dom_shutdown' => 'shutdown',
+                                       'dom_shutoff' => 'shutoff',
+                                       'dom_crashed' => 'crashed',
+                                       'cur_phys_size' => 'Current physical size',
+                                       'diskless' => 'diskless',
+                                       'changes' => 'Changes',
+                                       'btn_apply' => 'Apply changes',
+                                       'btn_discard' => 'Discard changes',
+                                       'ask_apply' => 'Do you really want to apply your changes?',
+                                       'ask_discard' => 'Do you really want to discard your changes?',
+                                       'general' => 'General',
+                                       'description' => 'Description',
+                                       'vm_details' => 'Machine details',
+                                       'host_pcpu_info' => 'Host processor information',
+                                       'max_per_guest' => 'Max. per guest',
+                                       'vm_vcpu_info' => 'Machine processor information',
+                                       'host_mem_info' => 'Host memory information',
+                                       'vm_mem_info' => 'Machine memory information',
+                                       'total_mem' => 'Total memory',
+                                       'mem_alloc_cur' => 'Current allocation',
+                                       'mem_alloc_max' => 'Max. allocation',
+                                       'vm_boot_opts' => 'Virtual machine boot options',
+                                       'vm_boot_dev1' => 'First boot device',
+                                       'vm_boot_dev2' => 'Second boot device',
+                                       'vm_boot_hdd' => 'Hard-drive',
+                                       'vm_boot_cd' => 'CD-ROM',
+                                       'vm_boot_fda' => 'Floppy',
+                                       'vm_boot_pxe' => 'Network boot (PXE)',
+                                       'vm_boot_none' => 'none',
+                                       'vm_disk_num' => 'Number of disks',
+                                       'vm_disk_storage' => 'Storage',
+                                       'vm_disk_type' => 'Driver type',
+                                       'vm_disk_dev' => 'Domain device',
+                                       'vm_disk_capacity' => 'Capacity',
+                                       'vm_disk_allocation' => 'Allocation',
+                                       'vm_disk_physical' => 'Physical disk size',
+                                       'vm_disk_remove' => 'Remove disk',
+                                       'vm_disk_add' => 'Add new disk',
+                                       'vm_disk_image' => 'Disk image',
+                                       'vm_disk_location' => 'Disk location',
+                                       'vm_disk_details' => 'Machine disk device details',
+                                       'vm_disk_askdel' => 'Are you sure you want to delete disk \'+disk+\' from the guest?',
+                                       'vm_disk_askadd' => 'Are you sure you want to add disk to the guest?',
+                                       'vm_network_title' => 'Machine network devices',
+                                       'vm_network_num' => 'Number of NICs',
+                                       'vm_network_nic' => 'Network interface card ',
+                                       'vm_network_mac' => 'MAC Address',
+                                       'vm_network_net' => 'Network',
+                                       'vm_network_type' => 'NIC Type',
+                                       'vm_network_add' => 'Add a new network interface',
+                                       'vm_network_del' => 'Remove network interface',
+                                       'vm_network_askadd' => 'Do you really want to add a new network interface card ?',
+                                       'vm_network_askdel' => 'Are you sure you want to delete interface with MAC address \'+mac+\' from the guest?',
+                                       'vm_title' => 'Virtual machine',
+                                       'vm_multimedia_title' => 'Machine multimedia devices',
+                                       'vm_multimedia_console' => 'Console',
+                                       'vm_multimedia_input' => 'Input device',
+                                       'vm_multimedia_graphics' => 'Graphics device',
+                                       'vm_multimedia_video' => 'Video device',
+                                       'details_readonly' => 'None (this page is currently read-only)',
+                                       'host_devices_title' => 'Machine host devices',
+                                       'host_devices' => 'Host devices',
+                                       'settings' => 'Settings',
+                                       'interval_sec' => 'Interval (sec)',
+                                       'change' => 'Change',
+                                       'menu_overview' => 'Overview',
+                                       'menu_processor' => 'Processor',
+                                       'menu_memory' => 'Memory',
+                                       'menu_boot' => 'Boot options',
+                                       'menu_disk' => 'Disk devices',
+                                       'menu_network' => 'Network devices',
+                                       'menu_multimedia' => 'Multimedia devices',
+                                       'menu_hostdev' => 'Host devices',
+                                       'menu_screenshot' => 'Screenshot',
+                                       'info_msg' => '<p>This is the virtual machine controller tool written in PHP language.'.
+                                                       'You can manage virtual machines (guests) on your machines using this web-based '.
+                                                       'controlling interface. For the navigation please use the upper menu and select '.
+                                                       'the domain from the <i>Domain list</i> link to see the virtual machines available '.
+                                                       'on the current machine. You can also see the information about the hypervisor '.
+                                                       'connection, host machine and libvirt PHP module (used by this system) on the '.
+                                                       '<i>Information</i> page.</p> '.
+                                                       '<p>The hypervisor on the machine running Apache with PHP is being probed automatically '.
+                                                       'if applicable however you can override the definition to connect to any other hypervisor '.
+                                                       'on remote machine. To achieve this you need to select a connection and change the host '.
+                                                       'using the form below. If you experience any issues (e.g. not working connectivity to '.
+                                                       'SSH-based remote host) please make sure you\'re having all the prerequisites met. For '.
+                                                       'more reference please check <a href="http://libvirt.org/auth.html" target="_blank">libvirt '.
+                                                       'authentication documentation.</a></p>',
+                                       'conns'  => 'Connections',
+                                       'connname' => 'Connection name',
+                                       'hypervisor' => 'Hypervisor',
+                                       'host_type' => 'Host type',
+                                       'type_local' => 'Local',
+                                       'type_remote' => 'Remote',
+                                       'host' => 'Host',
+                                       'logfile' => 'Log file',
+                                       'actions' => 'Actions',
+                                       'log_opts' => 'Logging options',
+                                       'host_opts' => 'Host options',
+                                       'save_conn' => 'Save connection',
+                                       'connect_new' => 'Connect to the new host',
+                                       'change_conn' => 'Change host connection',
+                                       'conn_method' => 'Connection method',
+                                       'user' => 'User name',
+                                       'conn_setup' => 'Setup connection',
+                                       'connect' => 'Connect',
+                                       'conn_remove' => 'Remove connection',
+                                       'empty_disable_log' => 'Leave empty to disable logging',
+                                       'empty_disable_save' => 'Leave empty not to save connection',
+                                       'conn_none' => 'No connection defined',
+                                       'hostdev_none' => 'None',
+                                       'name'   => 'Name',
+                                       'arch'   => 'Architecture',
+                                       'vcpus'  => 'vCPUs',
+                                       'mem'    => 'Memory',
+                                       'disk/s' => 'Disk(s)',
+                                       'nics'   => 'NICs',
+                                       'state'  => 'State',
+                                       'id'     => 'ID',
+                                       'msg'    => 'Message',
+                                       'dom_start' => 'Start domain',
+                                       'dom_stop'  => 'Stop domain',
+                                       'dom_destroy' => 'Destroy domain',
+                                       'dom_dumpxml' => 'Dump domain XML',
+                                       'dom_editxml' => 'Edit domain XML',
+                                       'dom_xmldesc' => 'Domain XML description',
+                                       'changed_uri' => 'Changed connection URI to',
+                                       'click_reload' => 'Click here to reload and connect using new URI',
+                                       'conn_saved' => 'Connection has been saved to the list.',
+                                       'conn_failed' => 'Connection has failed',
+                                       'domain_list' => 'Domain list',
+                                       'dom_screenshot' => 'Screenshot',
+                                       'dom_none' => 'No valid domain defined',
+                                       'main_menu' => 'Main menu',
+                                       'cannot_connect' => 'Cannot connect to hypervisor. Please change connection information.',
+                                       'language' => 'Language',
+                                       'using-ssh-auth' => 'Using SSH authentication',
+                                       'info-apache-key-copy' => 'There\'s an utility called <b>apache-key-copy</b> included to this web-application (can be found in tools subdir) '.
+                                                               'that\'s useful to setup SSH keys for password-less SSH connection. The SSH connection '.
+                                                               'transport <b>does not</b> support passing credentials to the SSH process and that\'s why '.
+                                                               'password-less SSH connection settings is necesary. <b>Apache-key-copy</b> utility have to '.
+                                                               'be run from shell by the system administrator (root account). This application find the home '.
+                                                               'directory for the apache user (you will most likely need to change it if you are using a '.
+                                                               'different user name to run Apache/php) and creates the hidden SSH settings directory. Then '.
+                                                               'a SSH key is being generated (if it doesn\'t exist yet) and copied to the destination machine.',
+                                       );
+?>
index a72a2b0..7446083 100644 (file)
@@ -3,4 +3,5 @@
     <a href="?"><?= $lang->get('main_menu') ?></a>
     | <a href="?page=domain-list"><?= $lang->get('domain_list') ?></a>
     | <a href="?page=info"><?= $lang->get('info') ?></a>
+    | <a href="?page=settings"><?= $lang->get('settings') ?></a>
   </div>
index b30a581..c92938d 100644 (file)
@@ -66,6 +66,7 @@
        $hv = array_key_exists('lvchypervisor', $_POST) ? $_POST['lvchypervisor'] : false;
        $rh = array_key_exists('lvcremotehost', $_POST) ? $_POST['lvcremotehost'] : false;
        $rm = array_key_exists('lvcremotemethod', $_POST) ? $_POST['lvcremotemethod'] : false;
+       $rp = array_key_exists('lvcrequirepwd', $_POST) ? $_POST['lvcrequirepwd'] : false;
        $un = array_key_exists('lvcusername', $_POST) ? $_POST['lvcusername'] : false;
        $hn = array_key_exists('lvchostname', $_POST) ? $_POST['lvchostname'] : false;
        $lg = array_key_exists('lvclogging', $_POST) ? $_POST['lvclogging'] : false;
@@ -77,6 +78,7 @@
                 $hv = $tmp[$i]['hypervisor'];
                 $rh = $tmp[$i]['remote'];
                 $rm = $tmp[$i]['method'];
+               $rp = $tmp[$i]['require_pwd'];
                 $un = $tmp[$i]['user'];
                 $hn = $tmp[$i]['host'];
                 $lg = $tmp[$i]['logfile'];
 
        if ($hv) {
                $uri = $lv->generate_connection_uri($hv, $rh, $rm, $un, $hn);
-               $test = libvirt_connect($uri);
+               if ($rp) {
+                       $credentials = array(VIR_CRED_AUTHNAME => $un, VIR_CRED_PASSPHRASE => $rp);
+                       $test = libvirt_connect($uri, false, $credentials);
+               }
+               else
+                       $test = libvirt_connect($uri);
                $ok = is_resource($test);
                unset($test);
 
                        echo '<p>'.$lang->get('changed_uri').' <b>'.$uri.'</b></p>';
 
                        if ((array_key_exists('lvcname', $_POST)) && ($_POST['lvcname']))
-                               if ($db->add_connection($_POST['lvcname'], $hv, $rh, $rm, $un, $hn, $lg))
-                                       echo $lang->get('conn_saved');
+                               if ($db->add_connection($_POST['lvcname'], $hv, $rh, $rm, $rp, $un, $hn, $lg))
+                                       echo '<p>'.$lang->get('conn_saved').'</p>';
 
                        echo '<a href="?">'.$lang->get('click_reload').'</a>';
                        die('</div>');
     document.getElementById('remote1').style.display = style;
     document.getElementById('remote2').style.display = style;
     document.getElementById('remote3').style.display = style;
+    document.getElementById('remote4').style.display = style;
   }
 -->
 </script>
     </td>
   </tr>
   <tr id="remote3" style="display: <?= $ds ?>">
+    <td><?= $lang->get('password')?>: </td>
+    <td align="right">
+      <input type="password" name="lvcrequirepwd" value="<?= $rp ?>" />
+    </td>
+  </tr>
+  <tr id="remote4" style="display: <?= $ds ?>">
     <td><?= $lang->get('host') ?>: </td>
     <td align="right">
       <input type="text" name="lvchostname" value="<?= $hn ?>" />
diff --git a/pages/settings.php b/pages/settings.php
new file mode 100644 (file)
index 0000000..b284f00
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+       function get_languages()
+       {
+               $dh = opendir('lang');
+
+               if (!$dh)
+                       return false;
+
+               $langs = array();
+               while (($file = readdir($dh)) !== false) {
+                       if (strpos($file, '.php')) {
+                               include('lang/'.$file);
+
+                               $langs[] = array(
+                                               'name' => $lang_name,
+                                               'code' => $lang_code
+                                               );
+                       }
+               }
+               closedir($dh);
+
+               return $langs;
+       }
+?>
+
+<script language="javascript">
+<!--
+       function change_lang(lang) {
+               location.href = '?lang-override='+lang+'&page=settings';
+       }
+-->
+</script>
+
+<div id="content">
+
+<div class="section"><?= $lang->get('settings') ?></div>
+
+<div class="item">
+        <div class="label"><?= $lang->get('language') ?>: </div>
+        <div class="value">
+               <select name="language" onchange="change_lang(this.value)">
+<?php
+       $langs = get_languages();
+
+       for ($i = 0; $i < sizeof($langs); $i++):
+?>
+                       <option value="<?= $langs[$i]['code'] ?>" <?= ($lang_str == $langs[$i]['code'] ? 'selected="selected"' : '') ?>><?= $langs[$i]['name'] ?></option>
+<?php
+       endfor;
+?>
+               </select>
+       </div>
+        <div class="nl">
+</div>
+
+<div class="section"><?= $lang->get('using-ssh-auth') ?></div>
+
+<?= $lang->get('info-apache-key-copy') ?>
+
+</div>