From 8065e06cb37b27d0736b74e0e8ab646499a630b7 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Tue, 30 Sep 2008 14:27:48 -0400 Subject: [PATCH] - Added the interface part of the ispconfig pacage manager - updated the debian installation instructions --- interface/web/admin/software_package_list.php | 126 +++++++++ interface/web/admin/software_repo_edit.php | 58 ++++ interface/web/admin/templates/software_update_list.htm | 25 + INSTALL_DEBIAN_4.0.txt | 2 INSTALL_DEBIAN_LENNY.txt | 2 interface/web/admin/templates/software_package_list.htm | 18 + interface/web/admin/lib/lang/en_software_update_list.lng | 7 interface/web/admin/software_update_list.php | 221 +++++++++++++++++ interface/web/admin/templates/software_repo_list.htm | 28 ++ interface/web/tools/lib/menu.d/statistics.menu.php | 21 + install/sql/ispconfig3.sql | 60 ++++ server/mods-available/server_module.inc.php | 11 interface/web/admin/software_repo_list.php | 52 ++++ interface/lib/classes/db_mysql.inc.php | 4 interface/web/admin/lib/module.conf.php | 6 interface/web/admin/software_repo_del.php | 51 +++ interface/web/admin/templates/software_repo_edit.htm | 32 ++ interface/web/admin/lib/lang/en_software_package_list.lng | 7 18 files changed, 722 insertions(+), 9 deletions(-) diff --git a/INSTALL_DEBIAN.txt b/INSTALL_DEBIAN_4.0.txt similarity index 98% rename from INSTALL_DEBIAN.txt rename to INSTALL_DEBIAN_4.0.txt index 120f9c1..ed994d3 100644 --- a/INSTALL_DEBIAN.txt +++ b/INSTALL_DEBIAN_4.0.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: diff --git a/INSTALL_DEBIAN.txt b/INSTALL_DEBIAN_LENNY.txt similarity index 97% copy from INSTALL_DEBIAN.txt copy to INSTALL_DEBIAN_LENNY.txt index 120f9c1..d6131da 100644 --- a/INSTALL_DEBIAN.txt +++ b/INSTALL_DEBIAN_LENNY.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: diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 67cad84..dcf65d9 100644 --- a/install/sql/ispconfig3.sql +++ b/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` +-- + -- -------------------------------------------------------- diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index ca3b38c..8084443 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/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; diff --git a/interface/web/admin/lib/lang/en_software_package_list.lng b/interface/web/admin/lib/lang/en_software_package_list.lng new file mode 100644 index 0000000..03917ca --- /dev/null +++ b/interface/web/admin/lib/lang/en_software_package_list.lng @@ -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'; +?> diff --git a/interface/web/admin/lib/lang/en_software_update_list.lng b/interface/web/admin/lib/lang/en_software_update_list.lng new file mode 100644 index 0000000..3894beb --- /dev/null +++ b/interface/web/admin/lib/lang/en_software_update_list.lng @@ -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'; +?> diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 5b63155..b43fdba 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/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, diff --git a/interface/web/admin/software_package_list.php b/interface/web/admin/software_package_list.php new file mode 100644 index 0000000..2f632a6 --- /dev/null +++ b/interface/web/admin/software_package_list.php @@ -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(); + + +?> \ No newline at end of file diff --git a/interface/web/admin/software_repo_del.php b/interface/web/admin/software_repo_del.php new file mode 100644 index 0000000..8da40c9 --- /dev/null +++ b/interface/web/admin/software_repo_del.php @@ -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(); + +?> \ No newline at end of file diff --git a/interface/web/admin/software_repo_edit.php b/interface/web/admin/software_repo_edit.php new file mode 100644 index 0000000..bd0c875 --- /dev/null +++ b/interface/web/admin/software_repo_edit.php @@ -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(); + +?> \ No newline at end of file diff --git a/interface/web/admin/software_repo_list.php b/interface/web/admin/software_repo_list.php new file mode 100644 index 0000000..0c05490 --- /dev/null +++ b/interface/web/admin/software_repo_list.php @@ -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(); + + +?> \ No newline at end of file diff --git a/interface/web/admin/software_update_list.php b/interface/web/admin/software_update_list.php new file mode 100644 index 0000000..78cbbfe --- /dev/null +++ b/interface/web/admin/software_update_list.php @@ -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(); + + +?> \ No newline at end of file diff --git a/interface/web/admin/templates/software_package_list.htm b/interface/web/admin/templates/software_package_list.htm new file mode 100644 index 0000000..399d972 --- /dev/null +++ b/interface/web/admin/templates/software_package_list.htm @@ -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"> </td> + </tr> +</table> \ No newline at end of file diff --git a/interface/web/admin/templates/software_repo_edit.htm b/interface/web/admin/templates/software_repo_edit.htm new file mode 100644 index 0000000..eb719e9 --- /dev/null +++ b/interface/web/admin/templates/software_repo_edit.htm @@ -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"> </td> + <td class="frmText11"> </td> + </tr> + <tr> + <td> </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> + <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'}"> \ No newline at end of file diff --git a/interface/web/admin/templates/software_repo_list.htm b/interface/web/admin/templates/software_repo_list.htm new file mode 100644 index 0000000..e3aa1d9 --- /dev/null +++ b/interface/web/admin/templates/software_repo_list.htm @@ -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"> </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> \ No newline at end of file diff --git a/interface/web/admin/templates/software_update_list.htm b/interface/web/admin/templates/software_update_list.htm new file mode 100644 index 0000000..34aa779 --- /dev/null +++ b/interface/web/admin/templates/software_update_list.htm @@ -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"> </td> + </tr> +</table> \ No newline at end of file diff --git a/interface/web/tools/lib/menu.d/statistics.menu.php b/interface/web/tools/lib/menu.d/statistics.menu.php new file mode 100644 index 0000000..7c10155 --- /dev/null +++ b/interface/web/tools/lib/menu.d/statistics.menu.php @@ -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); + + + + +?> \ No newline at end of file diff --git a/server/mods-available/server_module.inc.php b/server/mods-available/server_module.inc.php index a9e28dd..a01e4c4 100644 --- a/server/mods-available/server_module.inc.php +++ b/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 -- Gitblit v1.9.1