1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
* uploadconfig.php
|
5
|
*
|
6
|
* part of pfSense (https://www.pfsense.org)
|
7
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
8
|
* All rights reserved.
|
9
|
*
|
10
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
11
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12
|
* All rights reserved.
|
13
|
*
|
14
|
* Redistribution and use in source and binary forms, with or without
|
15
|
* modification, are permitted provided that the following conditions are met:
|
16
|
*
|
17
|
* 1. Redistributions of source code must retain the above copyright notice,
|
18
|
* this list of conditions and the following disclaimer.
|
19
|
*
|
20
|
* 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
|
*
|
25
|
* 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
|
*
|
30
|
* 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
|
*
|
35
|
* 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
|
*
|
39
|
* 6. Redistributions of any form whatsoever must retain the following
|
40
|
* acknowledgment:
|
41
|
*
|
42
|
* "This product includes software developed by the pfSense Project
|
43
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
44
|
*
|
45
|
* 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
|
*/
|
58
|
|
59
|
##|+PRIV
|
60
|
##|*IDENT=page-hidden-uploadconfiguration
|
61
|
##|*NAME=Hidden: Upload Configuration
|
62
|
##|*DESCR=Allow access to the 'Hidden: Upload Configuration' page.
|
63
|
##|*MATCH=uploadconfig.php*
|
64
|
##|-PRIV
|
65
|
|
66
|
|
67
|
require_once("guiconfig.inc");
|
68
|
|
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
|
echo gettext("ERR Could not save configuration.")."\n";
|
76
|
exit(0);
|
77
|
}
|
78
|
fwrite($fd, $_POST['config']);
|
79
|
fclose($fd);
|
80
|
if (config_install("{$g['tmp_path']}/config.xml") == 0) {
|
81
|
echo gettext("OK")."\n";
|
82
|
system_reboot();
|
83
|
} else {
|
84
|
echo gettext("ERR Could not install configuration.")."\n";
|
85
|
}
|
86
|
} else {
|
87
|
echo gettext("ERR Invalid configuration received.")."\n";
|
88
|
}
|
89
|
|
90
|
exit(0);
|
91
|
?>
|