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+ ?>
0 commit comments