Skip to content

Commit cdaae64

Browse files
author
vogelor
committed
The Interface now supports the first remote-action : do OS-Update
1 parent 9db1454 commit cdaae64

File tree

7 files changed

+153
-0
lines changed

7 files changed

+153
-0
lines changed

interface/web/admin/lib/lang/de.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ $wb['Packages'] = 'Packages';
3737
$wb['Updates'] = 'Updates';
3838
$wb['Merge'] = 'Merge';
3939
$wb['Remote Users'] = 'Remote Benutzer';
40+
$wb['Remote Actions'] = 'Remote Aktionen';
41+
$wb['Do OS-Update'] = 'Betriebssystem Update ausführen';
4042
?>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$wb['select_server_txt'] = 'Server auswählen';
3+
$wb['btn_do_txt'] = 'Aktion ausführen';
4+
$wb['do_osupdate_caption'] = 'Betriebssystem-Update auf entferntem Server ausführen';
5+
$wb['do_osupdate_desc'] = "Diese Aktion wird ein 'aptitude -y upgrade' auf Ihrem ausgewählten Server ausführen.<br><br><strong>DIES GESCHIEHT AUF IHRE EIGENE VERANTWORTUNG!</strong>";
6+
$wb['action_scheduled'] = "Die Aktion wurde zur Ausführung vorgemerkt";
7+
$wb['select_all_server'] = "Alle Server";
8+
?>

interface/web/admin/lib/lang/en.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ $wb['Packages'] = 'Packages';
3939
$wb['Updates'] = 'Updates';
4040
$wb['Merge'] = 'Merge';
4141
$wb['Remote Users'] = 'Remote Users';
42+
$wb['Remote Actions'] = 'Remote Actions';
43+
$wb['Do OS-Update'] = 'Do OS-Update';
4244
?>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
$wb['select_server_txt'] = 'Select Server';
3+
$wb['btn_do_txt'] = 'Execute action';
4+
$wb['do_osupdate_caption'] = 'Do OS-Update at remote server';
5+
$wb['do_osupdate_desc'] = "This Action does a 'aptitude -y upgrade' at your selected Server.<br><br><strong>USE THIS AT YOUR OWN RISK!</strong>";
6+
$wb['action_scheduled'] = "The action is scheduled for execution";
7+
$wb['select_all_server'] = "All server";
8+
?>

interface/web/admin/lib/module.conf.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@
155155
// cleanup
156156
unset($items);
157157

158+
$items[] = array( 'title' => 'Do OS-Update',
159+
'target' => 'content',
160+
'link' => 'admin/remote_action_osupdate.php');
161+
162+
$module['nav'][] = array( 'title' => 'Remote Actions',
163+
'open' => 1,
164+
'items' => $items);
165+
166+
158167
// Getting the admin options from other modules
159168
$modules = explode(',', $_SESSION['s']['user']['modules']);
160169
if(is_array($modules)) {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/*
3+
Copyright (c) 2010, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice,
10+
this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
* Neither the name of ISPConfig nor the names of its contributors
15+
may be used to endorse or promote products derived from this software without
16+
specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
require_once('../../lib/config.inc.php');
31+
require_once('../../lib/app.inc.php');
32+
33+
//* Check permissions for module
34+
$app->auth->check_module_permissions('admin');
35+
36+
//* This is only allowed for administrators
37+
if(!$app->auth->is_admin()) die('only allowed for administrators.');
38+
39+
$app->uses('tpl');
40+
41+
$app->tpl->newTemplate('form.tpl.htm');
42+
$app->tpl->setInclude('content_tpl', 'templates/remote_action_osupdate.htm');
43+
44+
//* load language file
45+
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_remote_action.lng';
46+
include($lng_file);
47+
48+
/*
49+
* We need a list of all Servers
50+
*/
51+
$sysServers = $app->db->queryAllRecords("SELECT server_id, server_name FROM server order by server_name");
52+
$dropDown = "<option value='*'>" . $wb['select_all_server'] . "</option>";
53+
foreach ($sysServers as $server) {
54+
$dropDown .= "<option value='" . $server['server_id'] . "'>" . $server['server_name'] . "</option>";
55+
}
56+
$app->tpl->setVar('server_option', $dropDown);
57+
58+
$msg = '';
59+
60+
/*
61+
* If the user wants to do the action, write this to our db
62+
*/
63+
if (isset($_POST['server_select'])) {
64+
$server = $_POST['server_select'];
65+
$servers = array();
66+
if ($server == '*') {
67+
/* We need ALL Servers */
68+
foreach ($sysServers as $server) {
69+
$servers[] = $server['server_id'];
70+
}
71+
}
72+
else {
73+
/* We need only the selected Server */
74+
$servers[] = $_POST['server_select'];
75+
}
76+
foreach ($servers as $serverId) {
77+
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_status, response) " .
78+
"VALUES (".
79+
(int)$serverId . ", " .
80+
time() . ", " .
81+
"'os_update', " .
82+
"'', " .
83+
"'pending', " .
84+
"''" .
85+
")";
86+
$app->db->query($sql);
87+
}
88+
$msg = $wb['action_scheduled'];
89+
}
90+
91+
$app->tpl->setVar('msg',$msg);
92+
93+
$app->tpl->setVar($wb);
94+
95+
$app->tpl_defaults();
96+
$app->tpl->pparse();
97+
98+
99+
?>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<h2><tmpl_var name="do_osupdate_caption"></h2>
2+
<p><tmpl_var name="do_osupdate_desc"></p>
3+
4+
<div class="panel panel_language_add">
5+
6+
<div class="pnl_formsarea">
7+
<fieldset class="inlineLabels"><legend>{tmpl_var name='do_osupdate_caption'}</legend>
8+
<div class="ctrlHolder">
9+
<label for="server_select">{tmpl_var name='select_server_txt'}</label>
10+
<select name="server_select" id="server" class="selectInput" onchange="document.getElementById('OKMsg').style.visibility = 'hidden'; ">
11+
{tmpl_var name='server_option'}
12+
</select>
13+
</div>
14+
</fieldset>
15+
16+
<tmpl_if name="msg">
17+
<div id="OKMsg"><p><tmpl_var name="msg"></p></div>
18+
</tmpl_if>
19+
20+
<div class="buttonHolder buttons">
21+
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_do_txt'}" onClick="submitForm('pageForm','admin/remote_action_osupdate.php');"><span>{tmpl_var name='btn_do_txt'}</span></button>
22+
</div>
23+
</div>
24+
25+
</div>

0 commit comments

Comments
 (0)