Skip to content

Commit ff58a5f

Browse files
author
Marius Cramer
committed
Added remoting function to list all servers
1 parent f753744 commit ff58a5f

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

interface/lib/classes/remoting.inc.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,54 @@ public function logout($session_id)
136136
@param int session id
137137
@param int server id
138138
@param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
139-
@author Julio Montoya <gugli100@gmail.com> BeezNest 2010
139+
@author Julio Montoya <gugli100@gmail.com> BeezNest 2010, extended by M. Cramer <m.cramer@pixcept.de> 2014
140140
*/
141141

142142

143-
public function server_get($session_id, $server_id, $section ='') {
143+
public function server_get($session_id, $server_id = null, $section ='') {
144144
global $app;
145145
if(!$this->checkPerm($session_id, 'server_get')) {
146146
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
147147
return false;
148148
}
149-
if (!empty($session_id) && !empty($server_id)) {
150-
$app->uses('remoting_lib , getconf');
151-
$section_config = $app->getconf->get_server_config($server_id, $section);
152-
return $section_config;
149+
if (!empty($session_id)) {
150+
if(!empty($server_id)) {
151+
$app->uses('remoting_lib , getconf');
152+
$section_config = $app->getconf->get_server_config($server_id, $section);
153+
return $section_config;
154+
} else {
155+
$servers = array();
156+
$sql = "SELECT server_id FROM server WHERE 1";
157+
$all = $app->db->queryAllRecords($sql);
158+
foreach($all as $s) {
159+
$servers[$s['server_id']] = $app->getconf->get_server_config($s['server_id'], $section);
160+
}
161+
unset($all);
162+
unset($s);
163+
return $servers;
164+
}
165+
} else {
166+
return false;
167+
}
168+
}
169+
170+
/**
171+
Gets a list of all servers
172+
@param int session_id
173+
@param int server_name
174+
@author Marius Cramer <m.cramer@pixcept.de> 2014
175+
*/
176+
public function server_get_all($session_id)
177+
{
178+
global $app;
179+
if(!$this->checkPerm($session_id, 'server_get')) {
180+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
181+
return false;
182+
}
183+
if (!empty($session_id)) {
184+
$sql = "SELECT server_id, server_name FROM server WHERE 1";
185+
$servers = $app->db->queryAllRecords($sql);
186+
return $servers;
153187
} else {
154188
return false;
155189
}

0 commit comments

Comments
 (0)