Project

General

Profile

Download (9.31 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
	$preset_urls_split = split("\n", file_get_contents("/tmp/manifest"));
80
}
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 8395f51e Carlos Eduardo Ramos
	$tab_array[0] = array(gettext("Manual Update"), false, "system_firmware.php");
111
	$tab_array[1] = array(gettext("Auto Update"), false, "system_firmware_check.php");
112
	$tab_array[2] = array(gettext("Updater Settings"), true, "system_firmware_settings.php");
113 4820d297 Scott Ullrich
	display_top_tabs($tab_array);
114
?>
115 0b2e3c64 Colin Smith
		</td>
116
	</tr>
117 e12d98ea Bill Marquette
	<tr><td><div id=mainarea>
118
	      <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
119 0b2e3c64 Colin Smith
	<tr>
120 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></td>
121 0b2e3c64 Colin Smith
	</tr>
122 563f5b51 Scott Ullrich
<?php if(is_array($preset_urls_split)): ?>
123
	<tr>
124 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td>
125 563f5b51 Scott Ullrich
		<td class="vtable">
126 5d5f69a2 Scott Ullrich
			<select name='preseturls' id='preseturls' onChange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; new Effect.Highlight(this.parentNode, { startcolor: '#ffff99', endcolor: '#fffffff' });">
127 563f5b51 Scott Ullrich
					<option></option>
128
				<?php 
129
					foreach($preset_urls_split as $pus) {
130
						$pus_text = split("\t", $pus);
131 2dc44e89 Scott Ullrich
						if($pus_text[0])
132
							echo "<option value='{$pus_text[1]}'>{$pus_text[0]}</option>";
133 563f5b51 Scott Ullrich
					}
134
				?>
135
			</select>
136
		</td>
137
	</tr>
138
<?php endif; ?>
139 0b2e3c64 Colin Smith
	<tr>
140 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td>
141 9471afe1 Colin Smith
		<td class="vtable">
142 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>
143 9471afe1 Colin Smith
			<table>
144 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>
145 9471afe1 Colin Smith
			</table>
146 359f32dc Scott Ullrich
			<span class="vexpl">
147 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."); ?>
148 359f32dc Scott Ullrich
				<p/>
149 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']); ?>
150 359f32dc Scott Ullrich
				</span>
151
				</td>
152 9471afe1 Colin Smith
	</tr>
153 a0116247 Ermal
	<tr>
154
		<td colspan="2" class="list" height="12">&nbsp;</td>
155
	</tr>
156
	<tr>
157 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></td>
158 a0116247 Ermal
	</tr>
159
	<tr>
160 3395ba20 jim-p
		<td width="22%" valign="top" class="vncell"><?=gettext("Unsigned images"); ?></td>
161 a0116247 Ermal
		<td width="78%" class="vtable">
162
			<input name="allowinvalidsig" type="checkbox" id="allowinvalidsig" value="yes" <?php if (isset($curcfg['allowinvalidsig'])) echo "checked"; ?> />
163
			<br />
164 3395ba20 jim-p
			<?=gettext("Allow auto-update firmware images with a missing or invalid digital signature to be used."); ?>
165 a0116247 Ermal
		</td>
166
	</tr>
167 2d539f40 Erik Fonnesbeck
<?php if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): ?>
168 f0ce6758 Erik Fonnesbeck
	<tr>
169
		<td colspan="2" class="list" height="12">&nbsp;</td>
170
	</tr>
171
	<tr>
172
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td>
173
	</tr>
174
	<tr>
175
		<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
176
		<td width="78%" class="vtable">
177
			<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked"; ?> />
178
			<br />
179
			<?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
180
		</td>
181
	</tr>
182 b5efd82a Erik Fonnesbeck
<?php
183
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
184
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str);
185
		if(is_array($output_str) && !empty($output_str[0]))
186
			$lastrepositoryurl = $output_str[0];
187
		unset($output_str);
188
	}
189
?>
190 f0ce6758 Erik Fonnesbeck
	<tr>
191
		<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
192
		<td width="78%" class="vtable">
193
			<input name="repositoryurl" type="input" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>">
194 b5efd82a Erik Fonnesbeck
<?php if($lastrepositoryurl): ?>
195
			<br />
196
			<?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?>
197
			<br />
198
			<?=gettext("This will be used if the field is left blank."); ?>
199
<?php endif; ?>
200 f0ce6758 Erik Fonnesbeck
		</td>
201
	</tr>
202 b5efd82a Erik Fonnesbeck
<?php
203
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
204
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str);
205
		if(is_array($output_str)) {
206
			foreach($output_str as $output_line) {
207
				if(strstr($output_line, '* ')) {
208
					$lastbranch = substr($output_line, 2);
209
					break;
210
				}
211
			}
212
		}
213
		unset($output_str);
214
	}
215
?>
216 f0ce6758 Erik Fonnesbeck
	<tr>
217
		<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
218
		<td width="78%" class="vtable">
219
			<input name="branch" type="input" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>">
220 b5efd82a Erik Fonnesbeck
<?php if($lastbranch): ?>
221
			<br />
222
			<?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?>
223
<?php else: ?>
224
			<br />
225
			<?=gettext("Usually the branch name is master"); ?>
226
<?php endif; ?>
227 f0ce6758 Erik Fonnesbeck
			<br />
228 b5efd82a Erik Fonnesbeck
			<?=gettext("Note: Sync will not be performed if a branch is not specified."); ?>
229 f0ce6758 Erik Fonnesbeck
		</td>
230
	</tr>
231
<?php endif; ?>
232 9471afe1 Colin Smith
	<script>enable_altfirmwareurl();</script>
233 0b2e3c64 Colin Smith
                <tr>
234
                  <td width="22%" valign="top">&nbsp;</td>
235
                  <td width="78%">
236 8395f51e Carlos Eduardo Ramos
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
237 0b2e3c64 Colin Smith
                  </td>
238
                </tr>
239 e12d98ea Bill Marquette
              </table></div></td></tr></table>
240 0b2e3c64 Colin Smith
</form>
241
<?php include("fend.inc"); ?>
242
</body>
243
</html>