Project

General

Profile

Download (16.8 KB) Statistics
| Branch: | Tag: | Revision:
1 50d49018 Colin Smith
<?php
2
/*
3 81d8a9ad Colin Smith
	$Id$
4 dc1cd85d Scott Ullrich
5 50d49018 Colin Smith
        xmlrpc.php
6 d1a6552b Scott Ullrich
        Copyright (C) 2009, 2010 Scott Ullrich
7 50d49018 Colin Smith
        Copyright (C) 2005 Colin Smith
8
        All rights reserved.
9
10
        Redistribution and use in source and binary forms, with or without
11
        modification, are permitted provided that the following conditions are met:
12
13
        1. Redistributions of source code must retain the above copyright notice,
14
           this list of conditions and the following disclaimer.
15
16
        2. Redistributions in binary form must reproduce the above copyright
17
           notice, this list of conditions and the following disclaimer in the
18
           documentation and/or other materials provided with the distribution.
19
20
        THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
        INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
        AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
        AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
        OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
        SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 0e19e0e4 Scott Ullrich
        POSSIBILITY OF SUCH DAMAGE.
30 50d49018 Colin Smith
*/
31
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-xmlrpclibrary
34
##|*NAME=XMLRPC Library page
35
##|*DESCR=Allow access to the 'XMLRPC Library' page.
36
##|*MATCH=xmlrpc.php*
37
##|-PRIV
38
39 0674f163 sullrich
require("config.inc");
40
require("functions.inc");
41
require("filter.inc");
42
require("shaper.inc");
43
require("xmlrpc_server.inc");
44
require("xmlrpc.inc");
45
require("array_intersect_key.inc");
46 50d49018 Colin Smith
47 ff664954 Scott Ullrich
/* grab sync to ip if enabled */
48 f97a5b04 Darren Embry
if ($config['hasync']) {
49
	$synchronizetoip = $hasync['synchronizetoip'];
50 ff664954 Scott Ullrich
}
51
52
if($synchronizetoip) {
53
	if($synchronizetoip == $_SERVER['REMOTE_ADDR']) {
54 de63649b Rafael Lucas
		log_error(gettext("Disallowing CARP sync loop."));
55 ff664954 Scott Ullrich
		die;	
56
	}
57
}
58
59 8da3de34 Colin Smith
$xmlrpc_g = array(
60 137f46d8 Ermal
	"return" => array(
61
		"true" => new XML_RPC_Response(new XML_RPC_Value(true, $XML_RPC_Boolean)),
62
		"false" => new XML_RPC_Response(new XML_RPC_Value(false, $XML_RPC_Boolean)),
63
		"authfail" => new XML_RPC_Response(new XML_RPC_Value(gettext("Authentication failed"), $XML_RPC_String))
64
	)
65
);
66 8da3de34 Colin Smith
67
/*
68
 *   pfSense XMLRPC errors
69
 *   $XML_RPC_erruser + 1 = Auth failure
70
 */
71
$XML_RPC_erruser = 200;
72
73
/* EXPOSED FUNCTIONS */
74 de63649b Rafael Lucas
$exec_php_doc = gettext("XMLRPC wrapper for eval(). This method must be called with two parameters: a string containing the local system\'s password followed by the PHP code to evaluate.");
75 c3638879 Scott Ullrich
$exec_php_sig = array(
76 137f46d8 Ermal
	array(
77
		$XML_RPC_Boolean, // First signature element is return value.
78
		$XML_RPC_String, // password
79
		$XML_RPC_String, // shell code to exec
80
	)
81
);
82 c3638879 Scott Ullrich
83 3dd2a278 Scott Ullrich
function xmlrpc_authfail() {
84
	log_auth("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']}");
85
}
86
87 c3638879 Scott Ullrich
function exec_php_xmlrpc($raw_params) {
88
	global $config, $xmlrpc_g;
89 137f46d8 Ermal
90 c3638879 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
91 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
92
		xmlrpc_authfail();
93 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
94 3dd2a278 Scott Ullrich
	}
95 c3638879 Scott Ullrich
	$exec_php = $params[0];
96
	eval($exec_php);
97 2c0dd581 Scott Ullrich
	if($toreturn) {
98
		$response = XML_RPC_encode($toreturn);
99
		return new XML_RPC_Response($response);
100
	} else
101
		return $xmlrpc_g['return']['true'];
102 c3638879 Scott Ullrich
}
103
104
/*****************************/
105 de63649b Rafael Lucas
$exec_shell_doc = gettext("XMLRPC wrapper for mwexec(). This method must be called with two parameters: a string containing the local system\'s password followed by an shell command to execute.");
106 c3638879 Scott Ullrich
$exec_shell_sig = array(
107 137f46d8 Ermal
	array(
108
		$XML_RPC_Boolean, // First signature element is return value.
109
		$XML_RPC_String, // password
110
		$XML_RPC_String, // shell code to exec
111
	)
112
);
113 c3638879 Scott Ullrich
114
function exec_shell_xmlrpc($raw_params) {
115
	global $config, $xmlrpc_g;
116 137f46d8 Ermal
117 c3638879 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
118 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
119
		xmlrpc_authfail();
120 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
121 3dd2a278 Scott Ullrich
	}
122 c3638879 Scott Ullrich
	$shell_cmd = $params[0];
123
	mwexec($shell_cmd);
124 137f46d8 Ermal
125 c3638879 Scott Ullrich
	return $xmlrpc_g['return']['true'];
126
}
127
128
/*****************************/
129 de63649b Rafael Lucas
$backup_config_section_doc = gettext("XMLRPC wrapper for backup_config_section. This method must be called with two parameters: a string containing the local system\'s password followed by an array containing the keys to be backed up.");
130 8da3de34 Colin Smith
$backup_config_section_sig = array(
131 137f46d8 Ermal
	array(
132
		$XML_RPC_Struct, // First signature element is return value.
133
		$XML_RPC_String,
134
		$XML_RPC_Array
135
	)
136
);
137 21dc3a7d Colin Smith
138 57e6d4c9 Colin Smith
function backup_config_section_xmlrpc($raw_params) {
139 03d89831 Scott Ullrich
	global $config, $xmlrpc_g;
140 137f46d8 Ermal
141 8da3de34 Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
142 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
143
		xmlrpc_authfail();
144 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
145 3dd2a278 Scott Ullrich
	}
146 03d89831 Scott Ullrich
	$val = array_intersect_key($config, array_flip($params[0]));
147 137f46d8 Ermal
148 8da3de34 Colin Smith
	return new XML_RPC_Response(XML_RPC_encode($val));
149 50d49018 Colin Smith
}
150
151 8da3de34 Colin Smith
/*****************************/
152 de63649b Rafael Lucas
$restore_config_section_doc = gettext("XMLRPC wrapper for restore_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
153 8da3de34 Colin Smith
$restore_config_section_sig = array(
154 137f46d8 Ermal
	array(
155
		$XML_RPC_Boolean,
156
		$XML_RPC_String,
157
		$XML_RPC_Struct
158
	)
159
);
160 21dc3a7d Colin Smith
161 57e6d4c9 Colin Smith
function restore_config_section_xmlrpc($raw_params) {
162 03d89831 Scott Ullrich
	global $config, $xmlrpc_g;
163 137f46d8 Ermal
164 57e6d4c9 Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
165 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
166
		xmlrpc_authfail();
167 19b5c3e7 Ermal
		return $xmlrpc_g['return']['authfail'];
168 3dd2a278 Scott Ullrich
	}
169 1b99e1e5 jim-p
170
	// Some sections should just be copied and not merged or we end
171
	//   up unable to sync the deletion of the last item in a section
172
	$sync_full = array('ipsec', 'aliases', 'wol', 'load_balancer', 'openvpn', 'cert', 'ca', 'crl', 'schedules');
173
	$sync_full_done = array();
174
	foreach ($sync_full as $syncfull) {
175
		if (isset($params[0][$syncfull])) {
176
			$config[$syncfull] = $params[0][$syncfull];
177
			unset($params[0][$syncfull]);
178
			$sync_full_done[] = $syncfull;
179
		}
180
	}
181
182 a8200dbf Ermal
	$vipbackup = array();
183 51611440 Ermal
	$oldvips = array();
184 4d775dd0 Ermal
	if (isset($params[0]['virtualip'])) {
185 7b47bd4c Ermal
		if (is_array($config['virtualip']['vip'])) {
186 51611440 Ermal
			foreach ($config['virtualip']['vip'] as $vipindex => $vip) {
187
				if ($vip['mode'] == "carp")
188 7b47bd4c Ermal
					$oldvips["{$vip['interface']}_vip{$vip['vhid']}"] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}";
189
				else if ($vip['mode'] == "ipalias" && strstr($vip['interface'], "_vip"))
190 2708a5cf Ermal
					$oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}";
191 7b47bd4c Ermal
				else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !strstr($vip['interface'], "_vip"))
192 51611440 Ermal
					$vipbackup[] = $vip;
193
			}
194 19b5c3e7 Ermal
		}
195
	}
196 f51d4f98 Ermal
197 b019222a pierrepomes
        // For vip section, first keep items sent from the master
198 aa6699fb jim-p
	$config = array_merge_recursive_unique($config, $params[0]);
199 51611440 Ermal
200 f51d4f98 Ermal
        /* Then add ipalias and proxyarp types already defined on the backup */
201
	if (is_array($vipbackup) && !empty($vipbackup)) {
202 51611440 Ermal
		if (!is_array($config['virtualip']))
203
			$config['virtualip'] = array();
204 f51d4f98 Ermal
		if (!is_array($config['virtualip']['vip']))
205
			$config['virtualip']['vip'] = array();
206
		foreach ($vipbackup as $vip)
207 51611440 Ermal
			array_unshift($config['virtualip']['vip'], $vip);
208 a8200dbf Ermal
	}
209 51611440 Ermal
210
	/* Log what happened */
211 1b99e1e5 jim-p
	$mergedkeys = implode(",", array_merge(array_keys($params[0]), $sync_full_done));
212 3a3fb8ea Erik Fonnesbeck
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
213 51611440 Ermal
214
	/* 
215
	 * The real work on handling the vips specially
216
	 * This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps
217
	 */
218 63f81fbd Ermal
	if (isset($params[0]['virtualip']) && is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) {
219 51611440 Ermal
		$carp_setuped = false;
220 f51d4f98 Ermal
		$anyproxyarp = false;
221 51611440 Ermal
		foreach ($config['virtualip']['vip'] as $vip) {
222 7b47bd4c Ermal
			if ($vip['mode'] == "carp" && isset($oldvips["{$vip['interface']}_vip{$vip['vhid']}"])) {
223
				if ($oldvips["{$vip['interface']}_vip{$vip['vhid']}"] == "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}") {
224 2708a5cf Ermal
					if (does_vip_exist($vip)) {
225 7b47bd4c Ermal
						unset($oldvips["{$vip['interface']}_vip{$vip['vhid']}"]);
226 d1e03822 Ermal
						continue; // Skip reconfiguring this vips since nothing has changed.
227 19ed1624 Ermal
					}
228 92ca32cc Ermal
				}
229 7b47bd4c Ermal
				unset($oldvips["{$vip['interface']}_vip{$vip['vhid']}"]);
230
			} else if ($vip['mode'] == "ipalias" && strstr($vip['interface'], "_vip") && isset($oldvips[$vip['subnet']])) {
231 2708a5cf Ermal
				if ($oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}") {
232
					if (does_vip_exist($vip)) {
233
						unset($oldvips[$vip['subnet']]);
234
						continue; // Skip reconfiguring this vips since nothing has changed.
235
					}
236
				}
237
				unset($oldvips[$vip['subnet']]);
238 51611440 Ermal
			}
239
240
			switch ($vip['mode']) {
241
			case "proxyarp":
242
				$anyproxyarp = true;
243
				break;
244
			case "ipalias":
245
				interface_ipalias_configure(&$vip);
246
				break;
247
			case "carp":
248
				if ($carp_setuped == false)
249
                                        $carp_setuped = true;
250
				interface_carp_configure($vip);
251
				break;
252
			case "carpdev-dhcp":
253
				interface_carpdev_configure($vip);
254
				break;
255
			}
256
		}
257
		/* Cleanup remaining old carps */
258
		foreach ($oldvips as $oldvipif => $oldvippar) {
259 7b47bd4c Ermal
			if (!is_ipaddr($oldvipif) && does_interface_exist($oldvipif))
260
					pfSense_interface_destroy($oldvipif);
261 51611440 Ermal
		}
262
		if ($carp_setuped == true)
263
			interfaces_carp_setup();
264
		if ($anyproxyarp == true)
265
			interface_proxyarp_configure();
266
	}
267 137f46d8 Ermal
268 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
269 50d49018 Colin Smith
}
270
271 82ae5cfc Scott Ullrich
/*****************************/
272 de63649b Rafael Lucas
$merge_config_section_doc = gettext("XMLRPC wrapper for merging package sections. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
273 82ae5cfc Scott Ullrich
$merge_config_section_sig = array(
274 137f46d8 Ermal
	array(
275
		$XML_RPC_Boolean,
276
		$XML_RPC_String,
277
		$XML_RPC_Struct
278
	)
279
);
280 82ae5cfc Scott Ullrich
281
function merge_installedpackages_section_xmlrpc($raw_params) {
282
	global $config, $xmlrpc_g;
283 137f46d8 Ermal
284 82ae5cfc Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
285 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
286
		xmlrpc_authfail();
287 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
288 3dd2a278 Scott Ullrich
	}
289 82ae5cfc Scott Ullrich
	$config['installedpackages'] = array_merge($config['installedpackages'], $params[0]);
290
	$mergedkeys = implode(",", array_keys($params[0]));
291 3a3fb8ea Erik Fonnesbeck
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
292 137f46d8 Ermal
293 82ae5cfc Scott Ullrich
	return $xmlrpc_g['return']['true'];
294
}
295
296 8da3de34 Colin Smith
/*****************************/
297 de63649b Rafael Lucas
$merge_config_section_doc = gettext("XMLRPC wrapper for merge_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
298 dc1cd85d Scott Ullrich
$merge_config_section_sig = array(
299 137f46d8 Ermal
	array(
300
		$XML_RPC_Boolean,
301
		$XML_RPC_String,
302
		$XML_RPC_Struct
303
	)
304
);
305 dc1cd85d Scott Ullrich
306
function merge_config_section_xmlrpc($raw_params) {
307
	global $config, $xmlrpc_g;
308 db748384 Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
309 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
310
		xmlrpc_authfail();
311 db748384 Scott Ullrich
		return $xmlrpc_g['return']['authfail'];
312 3dd2a278 Scott Ullrich
	}
313 f9d7c5b3 Scott Ullrich
	$config_new = array_overlay($config, $params[0]);
314 db748384 Scott Ullrich
	$config = $config_new;
315
	$mergedkeys = implode(",", array_keys($params[0]));
316
	write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."), $mergedkeys));
317
	return $xmlrpc_g['return']['true'];
318 dc1cd85d Scott Ullrich
}
319
320
/*****************************/
321 de63649b Rafael Lucas
$filter_configure_doc = gettext("Basic XMLRPC wrapper for filter_configure. This method must be called with one paramater: a string containing the local system\'s password. This function returns true upon completion.");
322 8da3de34 Colin Smith
$filter_configure_sig = array(
323 137f46d8 Ermal
	array(
324
		$XML_RPC_Boolean,
325
		$XML_RPC_String
326
	)
327
);
328 07a7b08f Colin Smith
329
function filter_configure_xmlrpc($raw_params) {
330 8da3de34 Colin Smith
	global $xmlrpc_g;
331 137f46d8 Ermal
332 07a7b08f Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
333 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
334
		xmlrpc_authfail();
335 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
336 3dd2a278 Scott Ullrich
	}
337 07a7b08f Colin Smith
	filter_configure();
338 e700437b Scott Ullrich
	system_routing_configure();
339 41e6d4bd Seth Mos
	setup_gateways_monitor();
340 651c32e2 Bill Marquette
	relayd_configure();
341 c3fef0c9 jim-p
	require_once("openvpn.inc");
342
	openvpn_resync_all();
343
	services_dhcpd_configure();
344 62c4d0fb jim-p
	services_dnsmasq_configure();
345 0ce72662 jim-p
	local_sync_accounts();
346 137f46d8 Ermal
347 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
348 07a7b08f Colin Smith
}
349
350 8da3de34 Colin Smith
/*****************************/
351 de63649b Rafael Lucas
$carp_configure_doc = gettext("Basic XMLRPC wrapper for configuring CARP interfaces.");
352 efe7562e Scott Ullrich
$carp_configure_sig = array(
353 137f46d8 Ermal
	array(
354
		$XML_RPC_Boolean,
355
		$XML_RPC_String
356
	)
357
);
358 efe7562e Scott Ullrich
359
function interfaces_carp_configure_xmlrpc($raw_params) {
360
	global $xmlrpc_g;
361 137f46d8 Ermal
362 efe7562e Scott Ullrich
	$params = xmlrpc_params_to_php($raw_params);
363 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
364
		xmlrpc_authfail();
365 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
366 3dd2a278 Scott Ullrich
	}
367 efe7562e Scott Ullrich
	interfaces_vips_configure();
368 137f46d8 Ermal
369 efe7562e Scott Ullrich
	return $xmlrpc_g['return']['true'];
370
}
371
372
/*****************************/
373 de63649b Rafael Lucas
$check_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
374 137f46d8 Ermal
375 8da3de34 Colin Smith
$check_firmware_version_sig = array(
376 137f46d8 Ermal
	array(
377
		$XML_RPC_String,
378
		$XML_RPC_String
379
	)
380
);
381 44488c3c Colin Smith
382
function check_firmware_version_xmlrpc($raw_params) {
383 b4d19b46 Bill Marquette
	global $xmlrpc_g, $XML_RPC_String;
384 137f46d8 Ermal
385 b4d19b46 Bill Marquette
	$params = xmlrpc_params_to_php($raw_params);
386 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
387
		xmlrpc_authfail();
388 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
389 3dd2a278 Scott Ullrich
	}
390 8da3de34 Colin Smith
	return new XML_RPC_Response(new XML_RPC_Value(check_firmware_version(false), $XML_RPC_String));
391 44488c3c Colin Smith
}
392
393 e501de37 Ermal
/*****************************/
394 0567899d Ermal
$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
395
396
$pfsense_firmware_version_sig = array (
397
        array (
398
                $XML_RPC_Struct,
399
                $XML_RPC_String
400
        )
401
);
402 e501de37 Ermal
403
function pfsense_firmware_version_xmlrpc($raw_params) {
404 0567899d Ermal
        global $xmlrpc_g;
405 e501de37 Ermal
406
        $params = xmlrpc_params_to_php($raw_params);
407 3dd2a278 Scott Ullrich
        if(!xmlrpc_auth($params)) {
408
			xmlrpc_authfail();
409
			return $xmlrpc_g['return']['authfail'];
410
		}
411 0567899d Ermal
        return new XML_RPC_Response(XML_RPC_encode(host_firmware_version()));
412 e501de37 Ermal
}
413
414 8da3de34 Colin Smith
/*****************************/
415 de63649b Rafael Lucas
$reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot.");
416 1cdca133 Colin Smith
$reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String));
417 bd0fe65b Colin Smith
function reboot_xmlrpc($raw_params) {
418 8da3de34 Colin Smith
	global $xmlrpc_g;
419 137f46d8 Ermal
420 bd0fe65b Colin Smith
	$params = xmlrpc_params_to_php($raw_params);
421 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
422
		xmlrpc_authfail();
423 137f46d8 Ermal
		return $xmlrpc_g['return']['authfail'];
424 3dd2a278 Scott Ullrich
	}
425 53cf5533 Colin Smith
	mwexec_bg("/etc/rc.reboot");
426 137f46d8 Ermal
427 8da3de34 Colin Smith
	return $xmlrpc_g['return']['true'];
428 bd0fe65b Colin Smith
}
429
430 8da3de34 Colin Smith
/*****************************/
431
$get_notices_sig = array(
432 137f46d8 Ermal
	array(
433
		$XML_RPC_Array,
434
		$XML_RPC_String
435
	),
436
	array(
437
		$XML_RPC_Array
438
	)
439
);
440 8da3de34 Colin Smith
441 d9064267 Colin Smith
function get_notices_xmlrpc($raw_params) {
442 8da3de34 Colin Smith
	global $g, $xmlrpc_g;
443 137f46d8 Ermal
444 b4d19b46 Bill Marquette
	$params = xmlrpc_params_to_php($raw_params);
445 3dd2a278 Scott Ullrich
	if(!xmlrpc_auth($params)) {
446
		xmlrpc_authfail();
447
		return $xmlrpc_g['return']['authfail'];
448
	}
449 0674f163 sullrich
	require("notices.inc");
450 8da3de34 Colin Smith
	if(!$params) {
451 d9064267 Colin Smith
		$toreturn = get_notices();
452
	} else {
453 8da3de34 Colin Smith
		$toreturn = get_notices($params);
454 d9064267 Colin Smith
	}
455
	$response = new XML_RPC_Response(XML_RPC_encode($toreturn));
456 137f46d8 Ermal
457 d9064267 Colin Smith
	return $response;
458
}
459
460 67d78c87 Ermal
$xmlrpclockkey = lock('xmlrpc', LOCK_EX);
461
462 8da3de34 Colin Smith
/*****************************/
463 21dc3a7d Colin Smith
$server = new XML_RPC_Server(
464
        array(
465 137f46d8 Ermal
		'pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc',
466 0567899d Ermal
			'signature' => $exec_shell_sig,
467
			'docstring' => $exec_shell_doc),
468 137f46d8 Ermal
		'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc',
469 0567899d Ermal
			'signature' => $exec_php_sig,
470
			'docstring' => $exec_php_doc),	
471 137f46d8 Ermal
		'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc',
472 0567899d Ermal
			'signature' => $filter_configure_sig,
473
			'docstring' => $filter_configure_doc),
474 137f46d8 Ermal
		'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc',
475 0567899d Ermal
			'docstring' => $carp_configure_sig),
476 137f46d8 Ermal
		'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc',
477 0567899d Ermal
			'signature' => $backup_config_section_sig,
478
			'docstring' => $backup_config_section_doc),
479 137f46d8 Ermal
		'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc',
480 0567899d Ermal
			'signature' => $restore_config_section_sig,
481
			'docstring' => $restore_config_section_doc),
482 137f46d8 Ermal
		'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
483 0567899d Ermal
			'signature' => $merge_config_section_sig,
484
			'docstring' => $merge_config_section_doc),
485 137f46d8 Ermal
		'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
486 0567899d Ermal
			'signature' => $merge_config_section_sig,
487
			'docstring' => $merge_config_section_doc),							
488 137f46d8 Ermal
		'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
489 0567899d Ermal
			'signature' => $check_firmware_version_sig,
490
			'docstring' => $check_firmware_version_doc),
491 e501de37 Ermal
		'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc',
492 0567899d Ermal
			'signature' => $pfsense_firmware_version_sig,
493
			'docstring' => $host_firmware_version_doc),
494 137f46d8 Ermal
		'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
495 0567899d Ermal
			'signature' => $reboot_sig,
496
			'docstring' => $reboot_doc),
497 137f46d8 Ermal
		'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc',
498 0567899d Ermal
			'signature' => $get_notices_sig)
499 50d49018 Colin Smith
        )
500
);
501 b298dd06 Scott Ullrich
502 67d78c87 Ermal
unlock($xmlrpclockkey);
503
504 f9d7c5b3 Scott Ullrich
    function array_overlay($a1,$a2)
505
    {
506
        foreach($a1 as $k => $v) {
507
            if(!array_key_exists($k,$a2)) continue;
508
            if(is_array($v) && is_array($a2[$k])){
509
                $a1[$k] = array_overlay($v,$a2[$k]);
510
            }else{
511
                $a1[$k] = $a2[$k];
512 0b581a8a Scott Ullrich
            }
513
        }
514 f9d7c5b3 Scott Ullrich
        return $a1;
515 0b581a8a Scott Ullrich
    }
516
517 de63649b Rafael Lucas
?>