tbrehm
2008-09-30 8065e06cb37b27d0736b74e0e8ab646499a630b7
- Added the interface part of the ispconfig pacage manager
- updated the debian installation instructions
1 files copied
4 files modified
1 files renamed
12 files added
731 ■■■■■ changed files
INSTALL_DEBIAN_4.0.txt 2 ●●● patch | view | raw | blame | history
INSTALL_DEBIAN_LENNY.txt 2 ●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 60 ●●●●● patch | view | raw | blame | history
interface/lib/classes/db_mysql.inc.php 4 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_software_package_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_software_update_list.lng 7 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/module.conf.php 6 ●●●●● patch | view | raw | blame | history
interface/web/admin/software_package_list.php 126 ●●●●● patch | view | raw | blame | history
interface/web/admin/software_repo_del.php 51 ●●●●● patch | view | raw | blame | history
interface/web/admin/software_repo_edit.php 58 ●●●●● patch | view | raw | blame | history
interface/web/admin/software_repo_list.php 52 ●●●●● patch | view | raw | blame | history
interface/web/admin/software_update_list.php 221 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_package_list.htm 18 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_repo_edit.htm 32 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_repo_list.htm 28 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_update_list.htm 25 ●●●●● patch | view | raw | blame | history
interface/web/tools/lib/menu.d/statistics.menu.php 21 ●●●●● patch | view | raw | blame | history
server/mods-available/server_module.inc.php 11 ●●●●● patch | view | raw | blame | history
INSTALL_DEBIAN_4.0.txt
File was renamed from INSTALL_DEBIAN.txt
@@ -40,7 +40,7 @@
3) Install apache, PHP5 and phpmyadmin (1 line!):
apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli
apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli libapache2-mod-fcgid
Then run the following to enable the Apache modules:
INSTALL_DEBIAN_LENNY.txt
copy from INSTALL_DEBIAN.txt copy to INSTALL_DEBIAN_LENNY.txt
File was copied from INSTALL_DEBIAN.txt
@@ -40,7 +40,7 @@
3) Install apache, PHP5 and phpmyadmin (1 line!):
apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli
apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap phpmyadmin php5-cli libapache2-mod-fcgid apache2-suexec
Then run the following to enable the Apache modules:
install/sql/ispconfig3.sql
@@ -609,6 +609,27 @@
-- --------------------------------------------------------
-- 
-- Tabellenstruktur für Tabelle `software_package`
--
CREATE TABLE `software_package` (
  `package_id` int(11) NOT NULL auto_increment,
  `software_repo_id` int(11) NOT NULL,
  `package_name` varchar(100) NOT NULL,
  `package_title` varchar(255) NOT NULL,
  `package_description` text,
  `package_version` varchar(255) default NULL,
  PRIMARY KEY  (`package_id`),
  UNIQUE KEY `package_name` (`package_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `software_package`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `software_repo`
-- 
@@ -625,7 +646,13 @@
  `repo_password` varchar(30) default NULL,
  `active` varchar(255) NOT NULL default 'y',
  PRIMARY KEY  (`software_repo_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `software_repo`
--
INSERT INTO `software_repo` (`software_repo_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `repo_name`, `repo_url`, `repo_username`, `repo_password`, `active`) VALUES (1, 1, 1, 'riud', 'riud', '', 'ISPConfig Addons', 'http://repo.ispconfig.org/addons/', '', '', 'n');
-- --------------------------------------------------------
@@ -636,18 +663,43 @@
CREATE TABLE `software_update` (
  `software_update_id` int(11) NOT NULL auto_increment,
  `software_repo_id` int(11) NOT NULL,
  `package_name` varchar(255) NOT NULL,
  `update_url` varchar(255) NOT NULL,
  `update_md5` varchar(255) NOT NULL,
  `install` char(1) NOT NULL,
  `depenencies` varchar(255) NOT NULL,
  `update_dependencies` varchar(255) NOT NULL,
  `update_title` varchar(255) NOT NULL,
  `v1` tinyint(4) NOT NULL default '0',
  `v2` tinyint(4) NOT NULL default '0',
  `v3` tinyint(4) NOT NULL default '0',
  `v4` tinyint(4) NOT NULL default '0',
  `type` enum('full','update') NOT NULL default 'full',
  PRIMARY KEY  (`software_update_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
-- 
-- Daten für Tabelle `software_update`
-- 
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `software_update_inst`
--
CREATE TABLE `software_update_inst` (
  `software_update_inst_id` int(10) unsigned NOT NULL auto_increment,
  `software_update_id` int(11) NOT NULL default '0',
  `package_name` varchar(255) NOT NULL,
  `server_id` int(11) NOT NULL,
  `status` enum('none','installing','installed','deleting') NOT NULL default 'none',
  PRIMARY KEY  (`software_update_inst_id`),
  UNIQUE KEY `software_update_id` (`software_update_id`,`package_name`,`server_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `software_update_inst`
--
-- --------------------------------------------------------
interface/lib/classes/db_mysql.inc.php
@@ -250,10 +250,10 @@
            }
        } elseif(is_array($record_new)) {
            foreach($record_new as $key => $val) {
                if(isset($record_new[$key]) && $record_old[$key] != $val) {
                if(isset($record_new[$key]) && @$record_old[$key] != $val) {
                    // Record has changed
                    $diffrec_full['new'][$key] = $val;
                    $diffrec_full['old'][$key] = $record_old[$key];
                    $diffrec_full['old'][$key] = @$record_old[$key];
                    $diff_num++;
                } else {
                    $diffrec_full['new'][$key] = $val;
interface/web/admin/lib/lang/en_software_package_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb['list_head_txt'] = 'Software packages';
$wb['installed_txt'] = 'Status';
$wb['package_title_txt'] = 'Package';
$wb['package_description_txt'] = 'Description';
$wb['action_txt'] = 'Action';
?>
interface/web/admin/lib/lang/en_software_update_list.lng
New file
@@ -0,0 +1,7 @@
<?php
$wb['list_head_txt'] = 'Software updates';
$wb['installed_txt'] = 'Action';
$wb['update_title_txt'] = 'Update';
$wb['version_txt'] = 'Version';
$wb['action_txt'] = 'Action';
?>
interface/web/admin/lib/module.conf.php
@@ -90,7 +90,13 @@
                  'target'     => 'content',
                  'link'    => 'admin/software_repo_list.php');
$items[] = array( 'title'     => 'Packages',
                  'target'     => 'content',
                  'link'    => 'admin/software_package_list.php');
$items[] = array( 'title'     => 'Updates',
                  'target'     => 'content',
                  'link'    => 'admin/software_update_list.php');
$module['nav'][] = array(    'title'    => 'Software',
                            'open'     => 1,
interface/web/admin/software_package_list.php
New file
@@ -0,0 +1,126 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('admin');
//* This is only allowed for administrators
if(!$app->auth->is_admin()) die('only allowed for administrators.');
//* Get the latest packages from the repositorys and insert them in the local database
$packages_added = 0;
$repos = $app->db->queryAllRecords("SELECT software_repo_id, repo_url, repo_username, repo_password FROM software_repo WHERE active = 'y'");
if(is_array($repos)) {
    foreach($repos as $repo) {
        $client = new SoapClient(null, array('location' => $repo['repo_url'],
                                              'uri'      => $repo['repo_url']));
        $packages = $client->get_packages($repo['repo_username'], $repo['repo_password']);
        if(is_array($packages)) {
            foreach($packages as $p) {
                $package_name = $app->db->quote($p['name']);
                $tmp = $app->db->queryOneRecord("SELECT package_id FROM software_package WHERE package_name = '$package_name'");
                if(empty($tmp['package_id'])) {
                    $package_title = $app->db->quote($p['title']);
                    $package_description = $app->db->quote($p['description']);
                    $software_repo_id = intval($repo['software_repo_id']);
                    $sql = "INSERT INTO software_package (software_repo_id, package_name, package_title, package_description) VALUES ($software_repo_id, '$package_name', '$package_title', '$package_description')";
                    $app->db->query($sql);
                    $packages_added++;
                }
            }
        }
    }
}
//* Install packages, if GET Request
if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) {
    $package_name = $app->db->quote($_GET['package']);
    $server_id = intval($_GET['server_id']);
    $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = '$package_name' ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1";
    $tmp = $app->db->queryOneRecord($sql);
    $software_update_id = $tmp['software_update_id'];
    $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installing')";
    $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id');
}
// Show the list in the interface
// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl','templates/software_package_list.htm');
$servers = $app->db->queryAllRecords('SELECT server_id, server_name FROM server ORDER BY server_name');
$packages = $app->db->queryAllRecords('SELECT * FROM software_package');
if(is_array($packages)) {
    foreach($packages as $key => $p) {
        $installed_txt = '';
        foreach($servers as $s) {
            $inst = $app->db->queryOneRecord("SELECT * FROM software_update, software_update_inst WHERE software_update_inst.software_update_id = software_update.software_update_id AND software_update_inst.package_name = '".addslashes($p["package_name"])."' AND server_id = '".$s["server_id"]."'");
            $version = $inst['v1'].'.'.$inst['v2'].'.'.$inst['v3'].'.'.$inst['v4'];
            if($inst['status'] == 'installed') {
                $installed_txt .= $s['server_name'].": Installed version $version<br />";
            } elseif ($inst['status'] == 'installing') {
                $installed_txt .= $s['server_name'].": Installation in progress<br />";
            } elseif ($inst['status'] == 'deleting') {
                $installed_txt .= $s['server_name'].": Deletion in progress<br />";
            } else {
                $installed_txt .= $s['server_name'].": <a href=\"#\" onClick=\"loadContent('admin/software_package_list.php?action=install&package=".$p["package_name"]."&server_id=".$s["server_id"]."');\">Install now</a><br />";
            }
        }
        $packages[$key]['installed'] = $installed_txt;
    }
}
$app->tpl->setLoop('records',$packages);
include_once('lib/lang/en_software_package_list.lng');
$app->tpl->setVar($wb);
$app->tpl_defaults();
$app->tpl->pparse();
?>
interface/web/admin/software_repo_del.php
New file
@@ -0,0 +1,51 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/software_repo.list.php";
$tform_def_file = "form/software_repo.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('admin');
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
interface/web/admin/software_repo_edit.php
New file
@@ -0,0 +1,58 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/software_repo.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('admin');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onLoad();
?>
interface/web/admin/software_repo_list.php
New file
@@ -0,0 +1,52 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/software_repo.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('admin');
$app->uses('listform_actions');
$app->listform_actions->onLoad();
?>
interface/web/admin/software_update_list.php
New file
@@ -0,0 +1,221 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('admin');
//* This is only allowed for administrators
if(!$app->auth->is_admin()) die('only allowed for administrators.');
//* Get the latest updates from the repositorys and insert them in the local database
$updates_added = 0;
$repos = $app->db->queryAllRecords("SELECT software_repo_id, repo_url, repo_username, repo_password FROM software_repo WHERE active = 'y'");
if(is_array($repos)) {
    foreach($repos as $repo) {
        /*
        SELECT software_package.package_name, v1, v2, v3, v4
        FROM software_package
        LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name )
        LEFT JOIN software_update_inst ON ( software_update.software_update_id = software_update_inst.software_update_id )
        GROUP BY package_name
        ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC
        */
        $client = new SoapClient(null, array('location' => $repo['repo_url'],
                                              'uri'      => $repo['repo_url']));
        $packages = $app->db->queryAllRecords("SELECT software_package.package_name, v1, v2, v3, v4 FROM software_package LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name ) GROUP BY package_name ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC");
        if(is_array($packages)) {
            foreach($packages as $p) {
                $version = $p['v1'].'.'.$p['v2'].'.'.$p['v3'].'.'.$p['v4'];
                $updates = $client->get_updates($p['package_name'], $version,$repo['repo_username'], $repo['repo_password']);
                if(is_array($updates)) {
                    foreach($updates as $u) {
                        $version_array = explode('.',$u['version']);
                        $v1 = intval($version_array[0]);
                        $v2 = intval($version_array[1]);
                        $v3 = intval($version_array[2]);
                        $v4 = intval($version_array[3]);
                        $package_name = $app->db->quote($u['package_name']);
                        $software_repo_id = intval($repo['software_repo_id']);
                        $update_url = $app->db->quote($u['url']);
                        $update_md5 = $app->db->quote($u['md5']);
                        $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):'';
                        $update_title = $app->db->quote($u['title']);
                        $type = $app->db->quote($u['type']);
                        // Check that we do not have this update in the database yet
                        $sql = "SELECT * FROM software_update WHERE package_name = '$package_name' and v1 = '$v1' and v2 = '$v2' and v3 = '$v3' and v4 = '$v4'";
                        $tmp = $app->db->queryOneRecord($sql);
                        if(!isset($tmp['software_update_id'])) {
                            // Insert the update in the datbase
                            $sql = "INSERT INTO software_update (software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type)
                            VALUES ($software_repo_id, '$package_name', '$update_url', '$update_md5', '$update_dependencies', '$update_title', '$v1', '$v2', '$v3', '$v4', '$type')";
                            //die($sql);
                            $app->db->query($sql);
                        }
                    }
                }
            }
        }
    }
}
//* Install packages, if GET Request
if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) {
    $package_name = $app->db->quote($_GET['package']);
    $server_id = intval($_GET['server_id']);
    $software_update_id = intval($_GET['id']);
    $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installing')";
    $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id');
}
// Show the list in the interface
// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl','templates/software_update_list.htm');
/*
SELECT software_package.package_name, software_package.package_title, software_update.update_title, v1, v2, v3, v4, software_update_inst.status
        FROM software_package
        LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name )
        LEFT JOIN software_update_inst ON ( software_update.software_update_id = software_update_inst.software_update_id )
GROUP BY software_update.software_update_id
        ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC
*/
if(isset($_POST["server_id"]) && $_POST["server_id"] > 0) {
    $server_id = intval($_POST["server_id"]);
} else {
    $server_id = 1;
}
$servers = $app->db->queryAllRecords('SELECT server_id, server_name FROM server ORDER BY server_name');
foreach($servers as $key => $server) {
    if($server['server_id'] == $server_id) {
        $servers[$key]['selected'] = 'selected';
    } else {
        $servers[$key]['selected'] = '';
    }
}
$app->tpl->setLoop('servers',$servers);
$sql = "SELECT v1, v2, v3, v4, software_update.update_title, software_update.software_update_id, software_update.package_name, v1, v2, v3, v4, software_update_inst.status
        FROM software_update LEFT JOIN software_update_inst ON ( software_update.software_update_id = software_update_inst.software_update_id )
        WHERE server_id = $server_id
        GROUP BY software_update.package_name
        ORDER BY software_update.package_name ASC, v1 DESC , v2 DESC , v3 DESC , v4 DESC";
$installed_packages = $app->db->queryAllRecords($sql);
$records_out = array();
if(is_array($installed_packages)) {
    foreach($installed_packages as $ip) {
        // Get version number of the latest installed version
        $sql = "SELECT v1, v2, v3, v4 FROM software_update, software_update_inst WHERE software_update.software_update_id = software_update_inst.software_update_id AND server_id = 1 ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1";
        $lu = $app->db->queryOneRecord($sql);
        // Get all installable updates
        $sql = "SELECT * FROM software_update WHERE v1 >= $lu[v1] AND v2 >= $lu[v2] AND v3 >= $lu[v3] AND v4 >= $lu[v4] AND package_name = '$ip[package_name]' ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC";
        $updates = $app->db->queryAllRecords($sql);
        //die($sql);
        if(is_array($updates)) {
            // Delete the last record as it is already installed
            unset($updates[count($updates)-1]);
            foreach($updates as $key => $u) {
                $version = $u['v1'].'.'.$u['v2'].'.'.$u['v3'].'.'.$u['v4'];
                $installed_txt = "<a href=\"#\" onClick=\"loadContent('admin/software_update_list.php?action=install&package=".$u["package_name"]."&id=".$u["software_update_id"]."&server_id=".$server_id."');\">Install Update</a><br />";
                $records_out[] = array('version' => $version, 'update_title' => $u["update_title"], 'installed' => $installed_txt);
            }
        }
    }
}
/*
$updates = $app->db->queryAllRecords('SELECT software_update.update_title, software_update.software_update_id, software_update.package_name, v1, v2, v3, v4, software_update_inst.status
        FROM software_update LEFT JOIN software_update_inst ON ( software_update.software_update_id = software_update_inst.software_update_id )
        WHERE server_id = '.$server_id.'
        GROUP BY software_update.package_name
        ORDER BY software_update.package_name ASC, v1 DESC , v2 DESC , v3 DESC , v4 DESC');
if(is_array($updates)) {
    foreach($updates as $key => $u) {
        $installed_txt = '';
        $version = $u['v1'].'.'.$u['v2'].'.'.$u['v3'].'.'.$u['v4'];
        $updates[$key]['version'] = $version;
        if($u['status'] == 'installed' || $u['status'] == 'installing' || $u['status'] == 'deleting') {
            $installed_txt .= "Installed version $version<br />";
        } else {
            $installed_txt .= "<a href=\"#\" onClick=\"loadContent('admin/software_update_list.php?action=install&package=".$u["package_name"]."&id=".$u["software_update_id"]."&server_id=".$server_id."');\">Install now</a><br />";
        }
        $updates[$key]['installed'] = $installed_txt;
    }
}
*/
$app->tpl->setLoop('records',$records_out);
include_once('lib/lang/en_software_update_list.lng');
$app->tpl->setVar($wb);
$app->tpl_defaults();
$app->tpl->pparse();
?>
interface/web/admin/templates/software_package_list.htm
New file
@@ -0,0 +1,18 @@
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td class="tblHead"><tmpl_var name="installed_txt"></td>
    <td class="tblHead"><tmpl_var name="package_title_txt"></td>
    <td class="tblHead"><tmpl_var name="package_description_txt"></td>
  </tr>
  <tmpl_loop name="records">
  <tr bgcolor="{tmpl_var name="bgcolor"}">
      <td class="frmText11">{tmpl_var name="installed"}</td>
    <td class="frmText11">{tmpl_var name="package_title"}</td>
    <td class="frmText11">{tmpl_var name="package_description"}</td>
  </tr>
  </tmpl_loop>
  <tr>
      <td colspan="3" height="40" align="center" class="tblFooter">&nbsp;</td>
  </tr>
</table>
interface/web/admin/templates/software_repo_edit.htm
New file
@@ -0,0 +1,32 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td class="frmText11">{tmpl_var name='repo_name_txt'}:</td>
    <td class="frmText11"><input name="repo_name" type="text" class="text" value="{tmpl_var name='repo_name'}" size="40" maxlength="40"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='repo_url_txt'}:</td>
    <td class="frmText11"><input name="repo_url" type="text" class="text" value="{tmpl_var name='repo_url'}" size="40" maxlength="40"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='repo_username_txt'}:</td>
    <td class="frmText11"><input name="repo_username" type="text" class="text" value="{tmpl_var name='repo_username'}" size="30" maxlength="30"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='repo_password_txt'}:</td>
    <td class="frmText11"><input name="repo_password" type="password" class="text" value="{tmpl_var name='repo_password'}" size="30" maxlength="30"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='active_txt'}:</td>
    <td class="frmText11">{tmpl_var name='active'}</td>
  </tr>  <tr>
    <td class="frmText11">&nbsp;</td>
    <td class="frmText11">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/software_repo_edit.php');"><div class="buttonEnding"></div>&nbsp;
      <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/software_repo_list.php');"><div class="buttonEnding"></div>
    </td>
  </tr>
</table>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/admin/templates/software_repo_list.htm
New file
@@ -0,0 +1,28 @@
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<input type="button" value="{tmpl_var name="add_new_record_txt"}" class="button" onClick="loadContent('admin/software_repo_edit.php');" /><div class="buttonEnding"></div><br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
  <tr>
    <td class="tblHead"><tmpl_var name="active_txt"></td>
    <td class="tblHead"><tmpl_var name="repo_name_txt"></td>
    <td class="tblHead"><tmpl_var name="repo_url_txt"></td>
    <td class="tblHead">&nbsp;</td>
  </tr>
  <tr>
    <td class="frmText11"><select name="search_active" onChange="submitForm('pageForm','admin/software_repo_list.php');">{tmpl_var name='search_active'}</select></td>
    <td class="frmText11"><input type="text" name="search_repo_name" value="{tmpl_var name='search_repo_name'}" class="text" /></td>
    <td class="frmText11"><input type="text" name="search_repo_url" value="{tmpl_var name='search_repo_url'}" class="text" /></td>
    <td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','admin/software_repo_list.php');"><div class="buttonEnding"></div></td>
  </tr>
  <tmpl_loop name="records">
  <tr bgcolor="{tmpl_var name="bgcolor"}">
    <td class="frmText11"><a href="#" onClick="loadContent('admin/software_repo_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="active"}</a></td>
    <td class="frmText11"><a href="#" onClick="loadContent('admin/software_repo_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="repo_name"}</a></td>
    <td class="frmText11"><a href="#" onClick="loadContent('admin/software_repo_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="repo_url"}</a></td>
    <td class="frmText11" align="right"><a href="javascript: del_record('admin/software_repo_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');" class="frmText11"><img src="themes/{tmpl_var name='theme'}/icons/list_icon_delete.png" alt="{tmpl_var name='delete_txt'}" border="0" /></a></td>
  </tr>
  </tmpl_loop>
  <tr>
      <td colspan="4" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
  </tr>
</table>
interface/web/admin/templates/software_update_list.htm
New file
@@ -0,0 +1,25 @@
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<select name="server_id" id="server_id" onChange="submitForm('pageForm','admin/software_update_list.php')">
<tmpl_loop name="servers">
  <option value="{tmpl_var name='server_id'}" {tmpl_var name='selected'}>{tmpl_var name='server_name'}</option>
</tmpl_loop>
</select>
<br /><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td class="tblHead"><tmpl_var name="installed_txt"></td>
    <td class="tblHead"><tmpl_var name="update_title_txt"></td>
    <td class="tblHead"><tmpl_var name="version_txt"></td>
  </tr>
  <tmpl_loop name="records">
  <tr bgcolor="{tmpl_var name="bgcolor"}">
      <td class="frmText11">{tmpl_var name="installed"}</td>
    <td class="frmText11">{tmpl_var name="update_title"}</td>
    <td class="frmText11">{tmpl_var name="version"}</td>
  </tr>
  </tmpl_loop>
  <tr>
      <td colspan="3" height="40" align="center" class="tblFooter">&nbsp;</td>
  </tr>
</table>
interface/web/tools/lib/menu.d/statistics.menu.php
New file
@@ -0,0 +1,21 @@
<?php
$items = array();
$items[] = array( 'title'     => 'Other page',
                  'target'     => 'content',
                  'link'    => 'http://www.google.de');
$items[] = array( 'title'     => 'Mailqueue',
                  'target'     => 'content',
                  'link'    => 'tools/mailqueue.php');
$module['nav'][] = array(    'title'    => 'System Info',
                            'open'     => 1,
                            'items'    => $items);
?>
server/mods-available/server_module.inc.php
@@ -40,7 +40,10 @@
                                    'server_ip_delete',
                                    'firewall_insert',
                                    'firewall_update',
                                    'firewall_delete');
                                    'firewall_delete',
                                    'software_update_inst_insert',
                                    'software_update_inst_update',
                                    'software_update_inst_delete');
    
    /*
         This function is called when the module is loaded
@@ -69,6 +72,7 @@
        $app->modules->registerTableHook('server','server_module','process');
        $app->modules->registerTableHook('server_ip','server_module','process');
        $app->modules->registerTableHook('firewall','server_module','process');
        $app->modules->registerTableHook('software_update_inst','server_module','process');
        
        // Register service
        //$app->services->registerService('httpd','web_module','restartHttpd');
@@ -99,6 +103,11 @@
                if($action == 'u') $app->plugins->raiseEvent('firewall_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('firewall_delete',$data);
            break;
            case 'software_update_inst':
                if($action == 'i') $app->plugins->raiseEvent('software_update_inst_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('software_update_inst_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('software_update_inst_delete',$data);
            break;
        } // end switch
    } // end function