Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
c1418f 1 <?php
M 2
3 /*
4 Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 --UPDATED 08.2009--
31 Full SOAP support for ISPConfig 3.1.4 b
32 Updated by Arkadiusz Roch & Artur Edelman
33 Copyright (c) Tri-Plex technology
34
35 --UPDATED 08.2013--
36 Migrated into new remote classes system
37 by Marius Cramer <m.cramer@pixcept.de>
38
39 */
40
41 class remoting_server extends remoting {
b1a6a5 42     /**
MC 43      Gets the server configuration
44      @param int session id
45      @param int server id
46      @param string  section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
47      @author Julio Montoya <gugli100@gmail.com> BeezNest 2010
48      */
49
50
c1418f 51     public function server_get_serverid_by_ip($session_id, $ipaddress)
b1a6a5 52     {
MC 53         global $app;
c1418f 54         if(!$this->checkPerm($session_id, 'server_get_serverid_by_ip')) {
b1a6a5 55             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
MC 56             return false;
c1418f 57         }
cc7a82 58         $sql = "SELECT server_id FROM server_ip WHERE ip_address  = ? LIMIT 1";
MC 59         $all = $app->db->queryAllRecords($sql, $ipaddress);
b1a6a5 60         return $all;
c1418f 61     }
b1a6a5 62
bca1af 63     //* Get server ips
MC 64     public function server_ip_get($session_id, $primary_id)
65     {
66         global $app;
67
68         if(!$this->checkPerm($session_id, 'server_ip_get')) {
69             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
70             return false;
71         }
72         $app->uses('remoting_lib');
73         $app->remoting_lib->loadFormDef('../admin/form/server_ip.tform.php');
74         return $app->remoting_lib->getDataRecord($primary_id);
75     }
76
c1418f 77     //* Add a IP address record
M 78     public function server_ip_add($session_id, $client_id, $params)
b1a6a5 79     {
c1418f 80         if(!$this->checkPerm($session_id, 'server_ip_add')) {
M 81             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
82             return false;
83         }
b1a6a5 84         return $this->insertQuery('../admin/form/server_ip.tform.php', $client_id, $params);
c1418f 85     }
b1a6a5 86
c1418f 87     //* Update IP address record
M 88     public function server_ip_update($session_id, $client_id, $ip_id, $params)
b1a6a5 89     {
c1418f 90         if(!$this->checkPerm($session_id, 'server_ip_update')) {
M 91             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
92             return false;
93         }
b1a6a5 94         $affected_rows = $this->updateQuery('../admin/form/server_ip.tform.php', $client_id, $ip_id, $params);
c1418f 95         return $affected_rows;
M 96     }
b1a6a5 97
c1418f 98     //* Delete IP address record
M 99     public function server_ip_delete($session_id, $ip_id)
b1a6a5 100     {
c1418f 101         if(!$this->checkPerm($session_id, 'server_ip_delete')) {
M 102             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
103             return false;
104         }
b1a6a5 105         $affected_rows = $this->deleteQuery('../admin/form/server_ip.tform.php', $ip_id);
c1418f 106         return $affected_rows;
M 107     }
2ebc33 108     
TB 109     /**
110      Gets the server configuration
111      @param int session id
112      @param int server id
113      @param string  section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
114      @author Julio Montoya <gugli100@gmail.com> BeezNest 2010
115      */
116
117
41add6 118     public function server_get($session_id, $server_id = null, $section ='') {
MC 119             global $app;
120             if(!$this->checkPerm($session_id, 'server_get')) {
121                     $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
122                     return false;
123             }
124             if (!empty($session_id)) {
125                     $app->uses('remoting_lib , getconf');
126                     if(!empty($server_id)) {
127                             $section_config =  $app->getconf->get_server_config($server_id, $section);
128                             return $section_config;
129                     } else {
130                             $servers = array();
131                             $sql = "SELECT server_id FROM server WHERE 1";
132                             $all = $app->db->queryAllRecords($sql);
133                             foreach($all as $s) {
134                                     $servers[$s['server_id']] = $app->getconf->get_server_config($s['server_id'], $section);
135                             }
136                             unset($all);
137                             unset($s);
138                             return $servers;
139                     }
140             } else {
141                     return false;
142             }
143     }
144     
145     /**
146         Gets a list of all servers
147         @param int session_id
148         @param int server_name
149         @author Marius Cramer <m.cramer@pixcept.de> 2014
150     */
151     public function server_get_all($session_id)
152     {
2ebc33 153         global $app;
TB 154         if(!$this->checkPerm($session_id, 'server_get')) {
155             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
156             return false;
157         }
41add6 158         if (!empty($session_id)) {
MC 159             $sql = "SELECT server_id, server_name FROM server WHERE 1";
160             $servers = $app->db->queryAllRecords($sql);
161             return $servers;
2ebc33 162         } else {
TB 163             return false;
164         }
165     }
41add6 166         
2ebc33 167     /**
TB 168         Gets the server_id by server_name
169         @param int session_id
170         @param int server_name
171         @author Sascha Bay <info@space2place.de> TheCry 2013
172     */
173     public function server_get_serverid_by_name($session_id, $server_name)
174     {
175         global $app;
176         if(!$this->checkPerm($session_id, 'server_get')) {
177             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
178             return false;
179         }
180         if (!empty($session_id) && !empty($server_name)) {
cc7a82 181             $sql = "SELECT server_id FROM server WHERE server_name  = ? LIMIT 1";
MC 182             $all = $app->db->queryAllRecords($sql, $server_name);
2ebc33 183             return $all;
TB 184         } else {
185             return false;
186         }
187     }
188     
189     /**
190         Gets the functions of a server by server_id
191         @param int session_id
192         @param int server_id
193         @author Sascha Bay <info@space2place.de> TheCry 2013
194     */
195     public function server_get_functions($session_id, $server_id)
196     {
197         global $app;
198         if(!$this->checkPerm($session_id, 'server_get')) {
199             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
200             return false;
201         }
202         if (!empty($session_id) && !empty($server_id)) { 
cc7a82 203             $sql = "SELECT mail_server, web_server, dns_server, file_server, db_server, vserver_server, proxy_server, firewall_server FROM server WHERE server_id  = ? LIMIT 1 ";
MC 204             $all = $app->db->queryAllRecords($sql, $server_id);
2ebc33 205             return $all;
TB 206         } else {
207             return false;
208         }
209     }
b1a6a5 210
c1418f 211 }
M 212
b1a6a5 213 ?>