Project

General

Profile

Download (3.29 KB) Statistics
| Branch: | Tag: | Revision:
1 c0914318 Scott Ullrich
#!/usr/local/bin/php
2
<?php
3
/*
4 aaec5634 Renato Botelho
 * uploadconfig.php
5 191cb31d Stephen Beaver
 *
6 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
7 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
8 aaec5634 Renato Botelho
 * All rights reserved.
9 191cb31d Stephen Beaver
 *
10 aaec5634 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
11
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
 * All rights reserved.
13 191cb31d Stephen Beaver
 *
14 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
15
 * modification, are permitted provided that the following conditions are met:
16 191cb31d Stephen Beaver
 *
17 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
18
 *    this list of conditions and the following disclaimer.
19 191cb31d Stephen Beaver
 *
20 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
21
 *    notice, this list of conditions and the following disclaimer in
22
 *    the documentation and/or other materials provided with the
23
 *    distribution.
24 191cb31d Stephen Beaver
 *
25 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
26
 *    must display the following acknowledgment:
27
 *    "This product includes software developed by the pfSense Project
28
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
29 191cb31d Stephen Beaver
 *
30 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
31
 *    endorse or promote products derived from this software without
32
 *    prior written permission. For written permission, please contact
33
 *    coreteam@pfsense.org.
34 191cb31d Stephen Beaver
 *
35 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
36
 *    nor may "pfSense" appear in their names without prior written
37
 *    permission of the Electric Sheep Fencing, LLC.
38 191cb31d Stephen Beaver
 *
39 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
40
 *    acknowledgment:
41 191cb31d Stephen Beaver
 *
42 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
43
 * for use in the pfSense software distribution (http://www.pfsense.org/).
44 191cb31d Stephen Beaver
 *
45 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
46
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
48
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
49
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
51
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56
 * OF THE POSSIBILITY OF SUCH DAMAGE.
57 191cb31d Stephen Beaver
 */
58 c0914318 Scott Ullrich
59 6b07c15a Matthew Grooms
##|+PRIV
60
##|*IDENT=page-hidden-uploadconfiguration
61 5230f468 jim-p
##|*NAME=Hidden: Upload Configuration
62 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Hidden: Upload Configuration' page.
63
##|*MATCH=uploadconfig.php*
64
##|-PRIV
65
66
67 aceaf18c Phil Davis
require_once("guiconfig.inc");
68 c0914318 Scott Ullrich
69
header("Content-Type: text/plain");
70
71
/* get config.xml in POST variable "config" */
72
if ($_POST['config']) {
73
	$fd = @fopen("{$g['tmp_path']}/config.xml", "w");
74
	if (!$fd) {
75 a697d396 Rafael Lucas
		echo gettext("ERR Could not save configuration.")."\n";
76 c0914318 Scott Ullrich
		exit(0);
77
	}
78
	fwrite($fd, $_POST['config']);
79
	fclose($fd);
80
	if (config_install("{$g['tmp_path']}/config.xml") == 0) {
81 65634b7e Carlos Eduardo Ramos
		echo gettext("OK")."\n";
82 c0914318 Scott Ullrich
		system_reboot();
83
	} else {
84 a697d396 Rafael Lucas
		echo gettext("ERR Could not install configuration.")."\n";
85 c0914318 Scott Ullrich
	}
86
} else {
87 a697d396 Rafael Lucas
	echo gettext("ERR Invalid configuration received.")."\n";
88 c0914318 Scott Ullrich
}
89
90
exit(0);
91
?>