Project

General

Profile

Download (9.41 KB) Statistics
| Branch: | Tag: | Revision:
1 0b2e3c64 Colin Smith
<?php
2
/* $Id$ */
3
/*
4 2094568a Colin Smith
	system_firmware_settings.php
5 1cecfbf7 Scott Ullrich
       	part of pfSense
6
		Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
7 2094568a Colin Smith
        Copyright (C) 2005 Colin Smith
8 0b2e3c64 Colin Smith
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30 1d333258 Scott Ullrich
/*
31
	pfSense_BUILDER_BINARIES:	/usr/bin/fetch
32
	pfSense_MODULE:	firmware
33
*/
34 0b2e3c64 Colin Smith
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-system-firmware-settings
37
##|*NAME=System: Firmware: Settings page
38
##|*DESCR=Allow access to the 'System: Firmware: Settings' page.
39
##|*MATCH=system_firmware_settings.php*
40
##|-PRIV
41
42 0b2e3c64 Colin Smith
require("guiconfig.inc");
43
44
if ($_POST) {
45 9471afe1 Colin Smith
	if (!$input_errors) {
46
		if($_POST['alturlenable'] == "yes") {
47 da55e467 Scott Ullrich
			$config['system']['firmware']['alturl']['enable'] = true;
48 9471afe1 Colin Smith
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
49
		} else {
50
			unset($config['system']['firmware']['alturl']['enable']);
51 da55e467 Scott Ullrich
			unset($config['system']['firmware']['alturl']['firmwareurl']);
52 52629104 Scott Ullrich
			unset($config['system']['firmware']['alturl']);
53
			unset($config['system']['firmware']);			
54 9471afe1 Colin Smith
		}
55 a0116247 Ermal
		if($_POST['allowinvalidsig'] == "yes")
56
                        $config['system']['firmware']['allowinvalidsig'] = true;
57
                else
58
                        unset($config['system']['firmware']['allowinvalidsig']);
59
60 f0ce6758 Erik Fonnesbeck
		if($_POST['synconupgrade'] == "yes")
61
			$config['system']['gitsync']['synconupgrade'] = true;
62
		else
63
			unset($config['system']['gitsync']['synconupgrade']);
64
		$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
65
		$config['system']['gitsync']['branch'] = $_POST['branch'];
66
67 9471afe1 Colin Smith
		write_config();
68
	}
69 0b2e3c64 Colin Smith
}
70
71
$curcfg = $config['system']['firmware'];
72 f0ce6758 Erik Fonnesbeck
$gitcfg = $config['system']['gitsync'];
73 0b2e3c64 Colin Smith
74 8395f51e Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
75 52380979 Scott Ullrich
include("head.inc");
76
77 1d333258 Scott Ullrich
exec("/usr/bin/fetch -q -o /tmp/manifest \"{$g['update_manifest']}\"");
78 563f5b51 Scott Ullrich
if(file_exists("/tmp/manifest")) {
79 cfbfd941 smos
	$preset_urls_split = explode("\n", file_get_contents("/tmp/manifest"));
80 563f5b51 Scott Ullrich
}
81 52380979 Scott Ullrich
82 563f5b51 Scott Ullrich
?>
83 0b2e3c64 Colin Smith
<script language="JavaScript">
84
<!--
85
86
87 9471afe1 Colin Smith
function enable_altfirmwareurl(enable_over) {  	 
88
	if (document.iform.alturlenable.checked || enable_over) { 	 
89
		document.iform.firmwareurl.disabled = 0; 	 
90
	} else { 	 
91 53075520 Scott Ullrich
		document.iform.firmwareurl.disabled = 1;
92 5d5f69a2 Scott Ullrich
		document.iform.firmwareurl.value = '';
93 9471afe1 Colin Smith
	} 	 
94
}
95
96 0b2e3c64 Colin Smith
// -->
97
</script>
98
99
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
100 b30cacb2 Bill Marquette
<?php include("fbegin.inc");?>
101 9471afe1 Colin Smith
<?php if ($input_errors) print_input_errors($input_errors); ?>
102 fd3e7e5d Scott Ullrich
103 0b2e3c64 Colin Smith
<form action="system_firmware_settings.php" method="post" name="iform" id="iform">
104
            <?php if ($savemsg) print_info_box($savemsg); ?>
105 c03d45a2 Colin Smith
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
106 0b2e3c64 Colin Smith
	<tr>
107
		<td>
108 4820d297 Scott Ullrich
<?php
109
	$tab_array = array();
110 3ff39566 Scott Ullrich
	$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
111
	$tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php");
112
	$tab_array[] = array(gettext("Updater Settings"), true, "system_firmware_settings.php");
113
	if($g['hidedownloadbackup'] == false)
114
		$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
115 4820d297 Scott Ullrich
	display_top_tabs($tab_array);
116
?>
117 0b2e3c64 Colin Smith
		</td>
118
	</tr>
119 e12d98ea Bill Marquette
	<tr><td><div id=mainarea>
120
	      <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
121 0b2e3c64 Colin Smith
	<tr>
122 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></td>
123 0b2e3c64 Colin Smith
	</tr>
124 563f5b51 Scott Ullrich
<?php if(is_array($preset_urls_split)): ?>
125
	<tr>
126 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td>
127 563f5b51 Scott Ullrich
		<td class="vtable">
128 030e4b31 Vinicius Coque
			<select name='preseturls' id='preseturls' onChange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; jQuery('#preseturls').parent().effect('highlight');">
129 563f5b51 Scott Ullrich
					<option></option>
130
				<?php 
131
					foreach($preset_urls_split as $pus) {
132 cfbfd941 smos
						$pus_text = explode("\t", $pus);
133 2dc44e89 Scott Ullrich
						if($pus_text[0])
134
							echo "<option value='{$pus_text[1]}'>{$pus_text[0]}</option>";
135 563f5b51 Scott Ullrich
					}
136
				?>
137
			</select>
138
		</td>
139
	</tr>
140
<?php endif; ?>
141 0b2e3c64 Colin Smith
	<tr>
142 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td>
143 9471afe1 Colin Smith
		<td class="vtable">
144 22a11a58 Larry Gilbert
			<input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onClick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked"; ?>> <?=gettext("Use a URL server for firmware upgrades other than") . " " . $g['product_website']; ?><br>
145 9471afe1 Colin Smith
			<table>
146 ea53e38f Renato Botelho
			<tr><td><?=gettext("Base URL:"); ?></td><td><input name="firmwareurl" type="input" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['']; ?>"></td></tr>
147 9471afe1 Colin Smith
			</table>
148 359f32dc Scott Ullrich
			<span class="vexpl">
149 259159e0 Renato Botelho
				<?=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."); ?>
150 359f32dc Scott Ullrich
				<p/>
151 3b7f0f53 Erik Fonnesbeck
				<b><?=gettext("NOTE:"); ?></b> <?php printf(gettext("When a custom URL is enabled, the system will not verify the digital signature from %s."), $g['product_website']); ?>
152 359f32dc Scott Ullrich
				</span>
153
				</td>
154 9471afe1 Colin Smith
	</tr>
155 a0116247 Ermal
	<tr>
156
		<td colspan="2" class="list" height="12">&nbsp;</td>
157
	</tr>
158
	<tr>
159 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></td>
160 a0116247 Ermal
	</tr>
161
	<tr>
162 3395ba20 jim-p
		<td width="22%" valign="top" class="vncell"><?=gettext("Unsigned images"); ?></td>
163 a0116247 Ermal
		<td width="78%" class="vtable">
164
			<input name="allowinvalidsig" type="checkbox" id="allowinvalidsig" value="yes" <?php if (isset($curcfg['allowinvalidsig'])) echo "checked"; ?> />
165
			<br />
166 3395ba20 jim-p
			<?=gettext("Allow auto-update firmware images with a missing or invalid digital signature to be used."); ?>
167 a0116247 Ermal
		</td>
168
	</tr>
169 2d539f40 Erik Fonnesbeck
<?php if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): ?>
170 f0ce6758 Erik Fonnesbeck
	<tr>
171
		<td colspan="2" class="list" height="12">&nbsp;</td>
172
	</tr>
173
	<tr>
174
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td>
175
	</tr>
176
	<tr>
177
		<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
178
		<td width="78%" class="vtable">
179
			<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked"; ?> />
180
			<br />
181
			<?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
182
		</td>
183
	</tr>
184 b5efd82a Erik Fonnesbeck
<?php
185
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
186
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str);
187
		if(is_array($output_str) && !empty($output_str[0]))
188
			$lastrepositoryurl = $output_str[0];
189
		unset($output_str);
190
	}
191
?>
192 f0ce6758 Erik Fonnesbeck
	<tr>
193
		<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
194
		<td width="78%" class="vtable">
195
			<input name="repositoryurl" type="input" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>">
196 b5efd82a Erik Fonnesbeck
<?php if($lastrepositoryurl): ?>
197
			<br />
198
			<?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?>
199
			<br />
200
			<?=gettext("This will be used if the field is left blank."); ?>
201
<?php endif; ?>
202 f0ce6758 Erik Fonnesbeck
		</td>
203
	</tr>
204 b5efd82a Erik Fonnesbeck
<?php
205
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
206
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str);
207
		if(is_array($output_str)) {
208
			foreach($output_str as $output_line) {
209
				if(strstr($output_line, '* ')) {
210
					$lastbranch = substr($output_line, 2);
211
					break;
212
				}
213
			}
214
		}
215
		unset($output_str);
216
	}
217
?>
218 f0ce6758 Erik Fonnesbeck
	<tr>
219
		<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
220
		<td width="78%" class="vtable">
221
			<input name="branch" type="input" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>">
222 b5efd82a Erik Fonnesbeck
<?php if($lastbranch): ?>
223
			<br />
224
			<?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?>
225
<?php else: ?>
226
			<br />
227
			<?=gettext("Usually the branch name is master"); ?>
228
<?php endif; ?>
229 f0ce6758 Erik Fonnesbeck
			<br />
230 b5efd82a Erik Fonnesbeck
			<?=gettext("Note: Sync will not be performed if a branch is not specified."); ?>
231 f0ce6758 Erik Fonnesbeck
		</td>
232
	</tr>
233
<?php endif; ?>
234 9471afe1 Colin Smith
	<script>enable_altfirmwareurl();</script>
235 0b2e3c64 Colin Smith
                <tr>
236
                  <td width="22%" valign="top">&nbsp;</td>
237
                  <td width="78%">
238 8395f51e Carlos Eduardo Ramos
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
239 0b2e3c64 Colin Smith
                  </td>
240
                </tr>
241 e12d98ea Bill Marquette
              </table></div></td></tr></table>
242 0b2e3c64 Colin Smith
</form>
243
<?php include("fend.inc"); ?>
244
</body>
245
</html>