Project

General

Profile

Download (10.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_firmware_settings.php
5
	part of pfSense
6
	Copyright (C) 2005 Colin Smith
7
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
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
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/usr/bin/fetch
33
	pfSense_MODULE:	firmware
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-system-firmware-settings
38
##|*NAME=System: Firmware: Settings page
39
##|*DESCR=Allow access to the 'System: Firmware: Settings' page.
40
##|*MATCH=system_firmware_settings.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if ($_POST) {
46
	unset($input_errors);
47

    
48
	/* input validation */
49
	if(($_POST['alturlenable'] == "yes") && (empty($_POST['firmwareurl']))) {
50
		$input_errors[] = gettext("A Firmware Auto Update Base URL must be specified when \"Use an unofficial server for firmware upgrades\" is enabled.");
51
	}
52

    
53
	if (!$input_errors) {
54
		if($_POST['alturlenable'] == "yes") {
55
			$config['system']['firmware']['alturl']['enable'] = true;
56
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
57
		} else {
58
			unset($config['system']['firmware']['alturl']['enable']);
59
			unset($config['system']['firmware']['alturl']['firmwareurl']);
60
			unset($config['system']['firmware']['alturl']);
61
			unset($config['system']['firmware']);
62
		}
63
		if($_POST['allowinvalidsig'] == "yes")
64
			$config['system']['firmware']['allowinvalidsig'] = true;
65
		else
66
			unset($config['system']['firmware']['allowinvalidsig']);
67

    
68
		if($_POST['disablecheck'] == "yes")
69
			$config['system']['firmware']['disablecheck'] = true;
70
		else
71
			unset($config['system']['firmware']['disablecheck']);
72

    
73
		if($_POST['synconupgrade'] == "yes")
74
			$config['system']['gitsync']['synconupgrade'] = true;
75
		else
76
			unset($config['system']['gitsync']['synconupgrade']);
77
		$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
78
		$config['system']['gitsync']['branch'] = $_POST['branch'];
79

    
80
		write_config();
81
	}
82
}
83

    
84
$curcfg = $config['system']['firmware'];
85
$gitcfg = $config['system']['gitsync'];
86

    
87
$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
88
$closehead = false;
89
include("head.inc");
90

    
91
exec("/usr/bin/fetch -q -o {$g['tmp_path']}/manifest \"{$g['update_manifest']}\"");
92
if(file_exists("{$g['tmp_path']}/manifest")) {
93
	$preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest"));
94
}
95

    
96
?>
97
<script type="text/javascript">
98
//<![CDATA[
99

    
100

    
101
function enable_altfirmwareurl(enable_over) {  	 
102
	if (document.iform.alturlenable.checked || enable_over) { 	 
103
		document.iform.firmwareurl.disabled = 0; 	 
104
	} else { 	 
105
		document.iform.firmwareurl.disabled = 1;
106
		document.iform.firmwareurl.value = '';
107
	} 	 
108
}
109

    
110
//]]>
111
</script>
112
</head>
113

    
114
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
115
<?php include("fbegin.inc");?>
116
<?php if ($input_errors) print_input_errors($input_errors); ?>
117

    
118
<form action="system_firmware_settings.php" method="post" name="iform" id="iform">
119
            <?php if ($savemsg) print_info_box($savemsg); ?>
120
              <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware settings">
121
	<tr>
122
		<td>
123
<?php
124
	$tab_array = array();
125
	$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
126
	$tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php");
127
	$tab_array[] = array(gettext("Updater Settings"), true, "system_firmware_settings.php");
128
	if($g['hidedownloadbackup'] == false)
129
		$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
130
	display_top_tabs($tab_array);
131
?>
132
		</td>
133
	</tr>
134
	<tr><td><div id="mainarea">
135
	      <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
136
	<tr>
137
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></td>
138
	</tr>
139
<?php if(is_array($preset_urls_split)): ?>
140
	<tr>
141
		<td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td>
142
		<td class="vtable">
143
			<select name='preseturls' id='preseturls' onchange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; jQuery('#preseturls').parent().effect('highlight');">
144
					<option></option>
145
				<?php 
146
					foreach($preset_urls_split as $pus) {
147
						$pus_text = explode("\t", $pus);
148
						if (empty($pus_text[0]))
149
							continue;
150
						if (stristr($pus_text[0], php_uname("m")) !== false) {
151
							$style = " style=\"font-weight: bold\"";
152
							$yourarch = " (Current architecture)";
153
						} else {
154
							$style = "";
155
							$yourarch = "";
156
						}
157
						echo "<option value='{$pus_text[1]}'{$style}>{$pus_text[0]}{$yourarch}</option>";
158
					}
159
				?>
160
			</select>
161
		<br /><br /><?php echo sprintf(gettext("Entries denoted by \"Current architecture\" match the architecture of your current installation, such as %s. Changing architectures during an upgrade is not recommended, and may require a manual reboot after the update completes."), php_uname("m")); ?>
162
		</td>
163
	</tr>
164
<?php endif; ?>
165
	<tr>
166
		<td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td>
167
		<td class="vtable">
168
			<input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onclick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked=\"checked\""; ?> /> <?=gettext("Use an unofficial server for firmware upgrades") ?><br />
169
			<table summary="alternative Base URL">
170
			<tr><td><?=gettext("Base URL:"); ?></td><td><input name="firmwareurl" type="text" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['']; ?>" /></td></tr>
171
			</table>
172
			<span class="vexpl">
173
				<?=gettext("This is where"); ?> <?php echo $g['product_name'] ?> <?=gettext("will check for newer firmware versions when the"); ?> <a href="system_firmware_check.php"><?=gettext("System: Firmware: Auto Update"); ?></a> <?=gettext("page is viewed."); ?>
174
				<br />
175
				<b><?=gettext("NOTE:"); ?></b> <?php printf(gettext("When a custom URL is configured, the system will not verify the image has an official digital signature")); ?>
176
				</span>
177
				</td>
178
	</tr>
179
	<tr>
180
		<td colspan="2" class="list" height="12">&nbsp;</td>
181
	</tr>
182
	<tr>
183
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></td>
184
	</tr>
185
	<tr>
186
		<td width="22%" valign="top" class="vncell"><?=gettext("Unsigned images"); ?></td>
187
		<td width="78%" class="vtable">
188
			<input name="allowinvalidsig" type="checkbox" id="allowinvalidsig" value="yes" <?php if (isset($curcfg['allowinvalidsig'])) echo "checked=\"checked\""; ?> />
189
			<br />
190
			<?=gettext("Allow auto-update firmware images with a missing or invalid digital signature to be used."); ?>
191
		</td>
192
	</tr>
193
	<tr>
194
		<td width="22%" valign="top" class="vncell"><?=gettext("Dashboard check"); ?></td>
195
		<td width="78%" class="vtable">
196
			<input name="disablecheck" type="checkbox" id="disablecheck" value="yes" <?php if (isset($curcfg['disablecheck'])) echo "checked=\"checked\""; ?> />
197
			<br />
198
			<?=gettext("Disable the automatic dashboard auto-update check."); ?>
199
		</td>
200
	</tr>
201
<?php if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): ?>
202
	<tr>
203
		<td colspan="2" class="list" height="12">&nbsp;</td>
204
	</tr>
205
	<tr>
206
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td>
207
	</tr>
208
	<tr>
209
		<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
210
		<td width="78%" class="vtable">
211
			<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked=\"checked\""; ?> />
212
			<br />
213
			<?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
214
		</td>
215
	</tr>
216
<?php
217
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
218
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str);
219
		if(is_array($output_str) && !empty($output_str[0]))
220
			$lastrepositoryurl = $output_str[0];
221
		unset($output_str);
222
	}
223
?>
224
	<tr>
225
		<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
226
		<td width="78%" class="vtable">
227
			<input name="repositoryurl" type="text" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>" />
228
<?php if($lastrepositoryurl): ?>
229
			<br />
230
			<?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?>
231
			<br />
232
			<?=gettext("This will be used if the field is left blank."); ?>
233
<?php endif; ?>
234
		</td>
235
	</tr>
236
<?php
237
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
238
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str);
239
		if(is_array($output_str)) {
240
			foreach($output_str as $output_line) {
241
				if(strstr($output_line, '* ')) {
242
					$lastbranch = substr($output_line, 2);
243
					break;
244
				}
245
			}
246
		}
247
		unset($output_str);
248
	}
249
?>
250
	<tr>
251
		<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
252
		<td width="78%" class="vtable">
253
			<input name="branch" type="text" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>" />
254
<?php if($lastbranch): ?>
255
			<br />
256
			<?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?>
257
<?php else: ?>
258
			<br />
259
			<?=gettext("Usually the branch name is master"); ?>
260
<?php endif; ?>
261
			<br />
262
			<?=gettext("Note: Sync will not be performed if a branch is not specified."); ?>
263
		</td>
264
	</tr>
265
<?php endif; ?>
266
	<tr><td><script type="text/javascript">
267
	//<![CDATA[
268
	enable_altfirmwareurl();
269
	//]]>
270
	</script></td></tr>
271
                <tr>
272
                  <td width="22%" valign="top">&nbsp;</td>
273
                  <td width="78%">
274
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
275
                  </td>
276
                </tr>
277
              </table></div></td></tr></table>
278
</form>
279
<?php include("fend.inc"); ?>
280
</body>
281
</html>
(219-219/256)