Project

General

Profile

Download (10.6 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / system_firmware_settings.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	system_firmware_settings.php
5
       	part of pfSense
6
		Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
7
        Copyright (C) 2005 Colin Smith
8

    
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
/*
31
	pfSense_BUILDER_BINARIES:	/usr/bin/fetch
32
	pfSense_MODULE:	firmware
33
*/
34

    
35
##|+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
require("guiconfig.inc");
43

    
44
if ($_POST) {
45
	if (!$input_errors) {
46
		if($_POST['alturlenable'] == "yes") {
47
			$config['system']['firmware']['alturl']['enable'] = true;
48
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
49
		} else {
50
			unset($config['system']['firmware']['alturl']['enable']);
51
			unset($config['system']['firmware']['alturl']['firmwareurl']);
52
			unset($config['system']['firmware']['alturl']);
53
			unset($config['system']['firmware']);
54
		}
55
		if($_POST['allowinvalidsig'] == "yes")
56
			$config['system']['firmware']['allowinvalidsig'] = true;
57
		else
58
			unset($config['system']['firmware']['allowinvalidsig']);
59

    
60
		if($_POST['disablecheck'] == "yes")
61
			$config['system']['firmware']['disablecheck'] = true;
62
		else
63
			unset($config['system']['firmware']['disablecheck']);
64

    
65
		if($_POST['synconupgrade'] == "yes")
66
			$config['system']['gitsync']['synconupgrade'] = true;
67
		else
68
			unset($config['system']['gitsync']['synconupgrade']);
69
		$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
70
		$config['system']['gitsync']['branch'] = $_POST['branch'];
71

    
72
		write_config();
73
	}
74
}
75

    
76
$curcfg = $config['system']['firmware'];
77
$gitcfg = $config['system']['gitsync'];
78

    
79
$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
80
$closehead = false;
81
include("head.inc");
82

    
83
exec("/usr/bin/fetch -q -o {$g['tmp_path']}/manifest \"{$g['update_manifest']}\"");
84
if(file_exists("{$g['tmp_path']}/manifest")) {
85
	$preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest"));
86
}
87

    
88
?>
89
<script type="text/javascript">
90
//<![CDATA[
91

    
92

    
93
function enable_altfirmwareurl(enable_over) {  	 
94
	if (document.iform.alturlenable.checked || enable_over) { 	 
95
		document.iform.firmwareurl.disabled = 0; 	 
96
	} else { 	 
97
		document.iform.firmwareurl.disabled = 1;
98
		document.iform.firmwareurl.value = '';
99
	} 	 
100
}
101

    
102
//]]>
103
</script>
104
</head>
105

    
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107
<?php include("fbegin.inc");?>
108
<?php if ($input_errors) print_input_errors($input_errors); ?>
109

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