Till Brehm
2015-06-03 5af0cfd99a13fda9afad3380b0c50a3428acd299
commit | author | age
cdaae6 1 <?php
V 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
7fe908 30 require_once '../../lib/config.inc.php';
MC 31 require_once '../../lib/app.inc.php';
cdaae6 32
V 33 //* Check permissions for module
34 $app->auth->check_module_permissions('admin');
9edea9 35 $app->auth->check_security_permissions('admin_allow_osupdate');
cdaae6 36
V 37 //* This is only allowed for administrators
38 if(!$app->auth->is_admin()) die('only allowed for administrators.');
39
40 $app->uses('tpl');
41
42 $app->tpl->newTemplate('form.tpl.htm');
43 $app->tpl->setInclude('content_tpl', 'templates/remote_action_osupdate.htm');
44
45 //* load language file
46 $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_remote_action.lng';
7fe908 47 include $lng_file;
cdaae6 48
V 49 /*
50  * We need a list of all Servers
51  */
52 $sysServers = $app->db->queryAllRecords("SELECT server_id, server_name FROM server order by server_name");
53 $dropDown = "<option value='*'>" . $wb['select_all_server'] . "</option>";
54 foreach ($sysServers as $server) {
55     $dropDown .= "<option value='" . $server['server_id'] . "'>" . $server['server_name'] . "</option>";
56 }
57 $app->tpl->setVar('server_option', $dropDown);
58
59 $msg = '';
60
61 /*
62  * If the user wants to do the action, write this to our db
63 */
64 if (isset($_POST['server_select'])) {
5af0cf 65     
TB 66     //* CSRF Check
67     $app->auth->csrf_token_check();
68     
cdaae6 69     $server = $_POST['server_select'];
V 70     $servers = array();
71     if ($server == '*') {
72         /* We need ALL Servers */
73         foreach ($sysServers as $server) {
74             $servers[] = $server['server_id'];
75         }
76     }
77     else {
78         /* We need only the selected Server */
79         $servers[] = $_POST['server_select'];
80     }
81     foreach ($servers as $serverId) {
82d6e5 82         $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
7fe908 83             "VALUES (".
604c0c 84             $app->functions->intval($serverId) . ", " .
7fe908 85             time() . ", " .
MC 86             "'os_update', " .
87             "'', " .
88             "'pending', " .
89             "''" .
90             ")";
cdaae6 91         $app->db->query($sql);
V 92     }
93     $msg = $wb['action_scheduled'];
94 }
95
7fe908 96 $app->tpl->setVar('msg', $msg);
cdaae6 97
5af0cf 98 //* SET csrf token
TB 99 $csrf_token = $app->auth->csrf_token_get('osupdate');
100 $app->tpl->setVar('_csrf_id',$csrf_token['csrf_id']);
101 $app->tpl->setVar('_csrf_key',$csrf_token['csrf_key']);
102
cdaae6 103 $app->tpl->setVar($wb);
V 104
105 $app->tpl_defaults();
106 $app->tpl->pparse();
107
108
7fe908 109 ?>