1+ <?php
2+ /*
3+ Copyright (c) 2008, Till Brehm, projektfarm Gmbh
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+
31+ /******************************************
32+ * Begin Form configuration
33+ ******************************************/
34+
35+ $ tform_def_file = "form/server_config.tform.php " ;
36+
37+ /******************************************
38+ * End Form configuration
39+ ******************************************/
40+
41+ require_once ('../../lib/config.inc.php ' );
42+ require_once ('../../lib/app.inc.php ' );
43+
44+ //* Check permissions for module
45+ $ app ->auth ->check_module_permissions ('admin ' );
46+
47+ // Loading classes
48+ $ app ->uses ('tpl,tform,tform_actions ' );
49+ $ app ->load ('tform_actions ' );
50+
51+ class page_action extends tform_actions {
52+
53+ function onShowEdit () {
54+ global $ app , $ conf ;
55+
56+ if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) die ('This function needs admin priveliges ' );
57+
58+ if ($ app ->tform ->errorMessage == '' ) {
59+ $ app ->uses ('ini_parser,getconf ' );
60+
61+ $ section = $ this ->active_tab ;
62+ $ server_id = $ this ->id ;
63+
64+ $ this ->dataRecord = $ app ->getconf ->get_server_config ($ server_id ,$ section );
65+ }
66+
67+ $ record = $ app ->tform ->getHTML ($ this ->dataRecord , $ this ->active_tab ,'EDIT ' );
68+
69+ $ record ['id ' ] = $ this ->id ;
70+ $ app ->tpl ->setVar ($ record );
71+ }
72+
73+ function onUpdateSave ($ sql ) {
74+ global $ app ;
75+
76+ if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) die ('This function needs admin priveliges ' );
77+ $ app ->uses ('ini_parser,getconf ' );
78+
79+ $ section = $ app ->tform ->getCurrentTab ();
80+ $ server_id = $ this ->id ;
81+
82+ $ server_config_array = $ app ->getconf ->get_server_config ($ server_id );
83+ $ server_config_array [$ section ] = $ app ->tform ->encode ($ this ->dataRecord ,$ section );
84+ $ server_config_str = $ app ->ini_parser ->get_ini_string ($ server_config_array );
85+
86+ $ sql = "UPDATE server SET config = ' " .$ app ->db ->quote ($ server_config_str )."' WHERE server_id = " .$ server_id ;
87+ $ app ->db ->query ($ sql );
88+ }
89+
90+ }
91+
92+ $ app ->tform_actions = new page_action ;
93+ $ app ->tform_actions ->onLoad ();
94+
95+
96+ ?>
0 commit comments