Projet

Général

Profil

Télécharger (38,4 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / installer / installer.php @ b9cf74c3

1
<?php
2
/*
3
	installer.php (pfSense webInstaller)
4
	part of pfSense (https://www.pfsense.org/)
5
	Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
$nocsrf = true;
31

    
32
require("globals.inc");
33
require("guiconfig.inc");
34

    
35
define('PC_SYSINSTALL', '/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh');
36

    
37
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
38
	header("Location: /");
39
	exit;
40
}
41

    
42
// Main switch dispatcher
43
switch ($_REQUEST['state']) {
44
	case "update_installer_status":
45
		update_installer_status();
46
		exit;
47
	case "custominstall":
48
		installer_custom();
49
		exit;
50
	case "begin_install":
51
		installing_gui();
52
		begin_install();
53
		exit;
54
	case "verify_before_install":
55
		verify_before_install();
56
		exit;
57
	case "easy_install_ufs":
58
		easy_install("UFS+S");
59
		exit;
60
	case "easy_install_ufs":
61
		easy_install("ZFS");
62
		exit;
63

    
64
	default:
65
		installer_main();	
66
}
67

    
68
function easy_install($fstype = "UFS+S") {
69
	// Calculate swap and disk sizes
70
	$disks = installer_find_all_disks();
71
	$memory = get_memory();
72
	$swap_size = $memory[0] * 2;
73
	$first_disk = trim(installer_find_first_disk());
74
	$disk_info = pcsysinstall_get_disk_info($first_disk);
75
	$size = $disk_info['size'];
76
	$first_disk_size = $size - $swap_size;
77
	$disk_setup = array();
78
	$tmp_array = array();
79
	// Build the disk layout for /
80
	$tmp_array['disk'] = $first_disk;
81
	$tmp_array['size'] = $first_disk_size;
82
	$tmp_array['mountpoint'] = "/";
83
	$tmp_array['fstype'] = $fstype;
84
	$disk_setup[] = $tmp_array;
85
	unset($tmp_array);
86
	$tmp_array = array();
87
	// Build the disk layout for SWAP
88
	$tmp_array['disk'] = $first_disk;
89
	$tmp_array['size'] = $swap_size;
90
	$tmp_array['mountpoint'] = "none";
91
	$tmp_array['fstype'] = "SWAP";
92
	$disk_setup[] = $tmp_array;
93
	unset($tmp_array);
94
	$bootmanager = "bsd";
95
	file_put_contents("/tmp/webInstaller_disk_layout.txt", serialize($disk_setup));
96
	file_put_contents("/tmp/webInstaller_disk_bootmanager.txt", serialize($bootmanager));
97
	header("Location: installer.php?state=verify_before_install");
98
	exit;
99
}
100

    
101
function write_out_pc_sysinstaller_config($disks, $bootmanager = "bsd") {
102
	$diskareas = "";
103
	$fd = fopen("/usr/sbin/pc-sysinstall/examples/pfSense-install.cfg", "w");
104
	if(!$fd) 
105
		return true;
106
	if($bootmanager == "") 
107
	 	$bootmanager = "none";
108
	// Yes, -1.  We ++ early in loop.
109
	$numdisks = -1;
110
	$lastdisk = "";
111
	$diskdefs = "";
112
	// Run through the disks and create the conf areas for pc-sysinstaller
113
	foreach($disks as $disksa) {
114
		$fstype = $disksa['fstype'];
115
		$size = $disksa['size'];
116
		$mountpoint = $disksa['mountpoint'];
117
		$disk = $disksa['disk'];
118
		if($disk <> $lastdisk) {
119
			$lastdisk = $disk;
120
			$numdisks++;
121
			$diskdefs .= "# disk {$disk}\n";
122
			$diskdefs .= "disk{$numdisks}={$disk}\n";
123
			$diskdefs .= "partition=all\n";
124
			$diskdefs .= "bootManager={$bootmanager}\n";
125
			$diskdefs .= "commitDiskPart\n\n";
126
		}
127
		$diskareas .= "disk{$numdisks}-part={$fstype} {$size} {$mountpoint} \n";
128
		if($encpass)
129
			$diskareas .= "encpass={$encpass}\n";
130
	}
131
	
132
	$config = <<<EOF
133
# Sample configuration file for an installation using pc-sysinstall
134
# This file was automatically generated by installer.php
135
 
136
installMode=fresh
137
installInteractive=yes
138
installType=FreeBSD
139
installMedium=LiveCD
140

    
141
# Set the disk parameters
142
{$diskdefs}
143

    
144
# Setup the disk label
145
# All sizes are expressed in MB
146
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
147
# Size 0 means use the rest of the slice size
148
# Alternatively, you can append .eli to any of
149
# the above filesystem types to encrypt that disk.
150
# If you with to use a passphrase with this 
151
# encrypted partition, on the next line 
152
# the flag "encpass=" should be entered:
153
# encpass=mypass
154
# disk0-part=UFS 500 /boot
155
# disk0-part=UFS.eli 500 /
156
# disk0-part=UFS.eli 500 /usr
157
{$diskareas}
158

    
159
# Do it now!
160
commitDiskLabel
161

    
162
# Set if we are installing via optical, USB, or FTP
163
installType=FreeBSD
164

    
165
packageType=cpdup
166

    
167
# Optional Components
168
cpdupPaths=boot,COPYRIGHT,bin,conf,conf.default,dev,etc,home,kernels,libexec,lib,root,sbin,usr,var
169

    
170
# runExtCommand=chmod a+rx /usr/local/bin/after_installation_routines.sh ; cd / ; /usr/local/bin/after_installation_routines.sh
171
EOF;
172
	fwrite($fd, $config);
173
	fclose($fd);
174
	return;
175
}
176

    
177
function start_installation() {
178
	global $g, $fstype, $savemsg;
179
	if(file_exists("/tmp/install_complete"))
180
		return;
181
	$ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
182
	if($ps_running)	
183
		return;
184
	$fd = fopen("/tmp/installer.sh", "w");
185
	if(!$fd) {
186
		die(gettext("Could not open /tmp/installer.sh for writing"));
187
		exit;
188
	}
189
	fwrite($fd, "/bin/rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
190
	fwrite($fd, "/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh -c /usr/sbin/pc-sysinstall/examples/pfSense-install.cfg \n");
191
	fwrite($fd, "/bin/chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
192
	fwrite($fd, "cd / && /usr/local/bin/after_installation_routines.sh\n");
193
	fwrite($fd, "/bin/mkdir /mnt/tmp\n");
194
	fwrite($fd, "/usr/bin/touch /tmp/install_complete\n");
195
	fclose($fd);
196
	exec("/bin/chmod a+rx /tmp/installer.sh");
197
	mwexec_bg("/bin/sh /tmp/installer.sh");
198
}
199

    
200
function installer_find_first_disk() {
201
	global $g, $fstype, $savemsg;
202
	$disk = `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list | head -n1 | cut -d':' -f1`;
203
	return trim($disk);
204
}
205

    
206
function pcsysinstall_get_disk_info($diskname) {
207
	global $g, $fstype, $savemsg;
208
	$disk = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
209
	$disks_array = array();
210
	foreach($disk as $d) {
211
		$disks_info = explode(":", $d);
212
		$tmp_array = array();
213
		if($disks_info[0] == $diskname) {
214
			$disk_info = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
215
			$disk_info_split = explode("=", $disk_info);
216
			foreach($disk_info as $di) { 
217
				$di_s = explode("=", $di);
218
				if($di_s[0])
219
					$tmp_array[$di_s[0]] = $di_s[1];
220
			}
221
			$tmp_array['size']--;
222
			$tmp_array['disk'] = trim($disks_info[0]);
223
			$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
224
			return $tmp_array;
225
		}
226
	}
227
}
228

    
229
// Return an array with all disks information.
230
function installer_find_all_disks() {
231
	global $g, $fstype, $savemsg;
232
	$disk = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
233
	$disks_array = array();
234
	foreach($disk as $d) {
235
		if(!$d) 
236
			continue;
237
		$disks_info = explode(":", $d);
238
		$tmp_array = array();
239
		$disk_info = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
240
		foreach($disk_info as $di) { 
241
			$di_s = explode("=", $di);
242
			if($di_s[0])
243
				$tmp_array[$di_s[0]] = $di_s[1];
244
		}
245
		$tmp_array['size']--;
246
		$tmp_array['disk'] = trim($disks_info[0]);
247
		$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
248
		$disks_array[] = $tmp_array;
249
	}
250
	return $disks_array;
251
}
252

    
253
function update_installer_status() {
254
	global $g, $fstype, $savemsg;
255
	// Ensure status files exist
256
	if(!file_exists("/tmp/installer_installer_running"))
257
		touch("/tmp/installer_installer_running");
258
	$status = `cat /tmp/.pc-sysinstall/pc-sysinstall.log`;
259
	$status = str_replace("\n", "\\n", $status);
260
	$status = str_replace("\n", "\\r", $status);
261
	$status = str_replace("'", "\\'", $status);
262
	echo "document.forms[0].installeroutput.value='$status';\n";
263
	echo "document.forms[0].installeroutput.scrollTop = document.forms[0].installeroutput.scrollHeight;\n";	
264
	// Find out installer progress
265
	$progress = "5";
266
	if(strstr($status, "Running: dd")) 
267
		$progress = "6";
268
	if(strstr($status, "Running: gpart create -s GPT")) 
269
		$progress = "7";
270
	if(strstr($status, "Running: gpart bootcode")) 
271
		$progress = "7";
272
	if(strstr($status, "Running: newfs -U")) 
273
		$progress = "8";
274
	if(strstr($status, "Running: sync")) 
275
		$progress = "9";
276
	if(strstr($status, "/boot /mnt/boot")) 
277
		$progress = "10";
278
	if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
279
		$progress = "11";
280
	if(strstr($status, "/bin /mnt/bin"))
281
		$progress = "12";
282
	if(strstr($status, "/conf /mnt/conf"))
283
		$progress = "15";
284
	if(strstr($status, "/conf.default /mnt/conf.default"))
285
		$progress = "20";
286
	if(strstr($status, "/dev /mnt/dev"))
287
		$progress = "25";
288
	if(strstr($status, "/etc /mnt/etc"))
289
		$progress = "30";
290
	if(strstr($status, "/home /mnt/home"))
291
		$progress = "35";
292
	if(strstr($status, "/kernels /mnt/kernels"))
293
		$progress = "40";
294
	if(strstr($status, "/libexec /mnt/libexec"))
295
		$progress = "50";
296
	if(strstr($status, "/lib /mnt/lib"))
297
		$progress = "60";
298
	if(strstr($status, "/root /mnt/root"))
299
		$progress = "70";
300
	if(strstr($status, "/sbin /mnt/sbin"))
301
		$progress = "75";
302
	if(strstr($status, "/sys /mnt/sys"))
303
		$progress = "80";
304
	if(strstr($status, "/usr /mnt/usr"))
305
		$progress = "95";
306
	if(strstr($status, "/usr /mnt/usr"))
307
		$progress = "90";
308
	if(strstr($status, "/var /mnt/var"))
309
		$progress = "95";
310
	if(strstr($status, "cap_mkdb /etc/login.conf"))
311
		$progress = "96";
312
	if(strstr($status, "Setting hostname"))
313
		$progress = "97";
314
	if(strstr($status, "umount -f /mnt"))
315
		$progress = "98";
316
	if(strstr($status, "umount -f /mnt"))
317
		$progress = "99";
318
	if(strstr($status, "Installation finished"))
319
		$progress = "100";
320
	// Check for error and bail if we see one.
321
	if(stristr($status, "error")) {
322
		$error = true;
323
		echo "\$('#installerrunning').html('<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"2\"><b>An error occurred.  Aborting installation.  <a href=\"/installer\">Back</a> to webInstaller'); ";
324
		echo "\$('#progressbar').css('width','100%');\n";
325
		unlink_if_exists("/tmp/install_complete");
326
		return;
327
	}
328
	$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
329
	if($installer_running <> "running") {
330
		$ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
331
		if($ps_running)	{
332
			$running = "\$('#installerrunning').html('<table><tr><td valign=\"middle\"><img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"></td><td valign=\"middle\">&nbsp;<font size=\"2\"><b>Installer running ({$progress}% completed)...</td></tr></table>'); ";
333
			if($running_old <> $running) {
334
				echo $running;
335
				file_put_contents("/tmp/installer_installer_running", "$running");			
336
			}
337
		}
338
	}
339
	if($progress) 
340
		echo "\$('#progressbar').css('width','{$progress}%');\n";
341
	if(file_exists("/tmp/install_complete")) {
342
		echo "\$('#installerrunning').html('<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"+1\">Installation completed.  Please <a href=\"/reboot.php\">reboot</a> to continue');\n";
343
		echo "\$('#pbdiv').fadeOut();\n";
344
		unlink_if_exists("/tmp/installer.sh");
345
		file_put_contents("/tmp/installer_installer_running", "finished");
346
	}
347
}
348

    
349
function update_installer_status_win($status) {
350
	global $g, $fstype, $savemsg;
351
	echo "<script type=\"text/javascript\">\n";
352
	echo "	\$('#installeroutput').val('" . str_replace(htmlentities($status), "\n", "") . "');\n";
353
	echo "</script>\n";
354
}
355

    
356
function begin_install() {
357
	global $g, $savemsg;
358
	if(file_exists("/tmp/install_complete"))
359
		return;
360
	unlink_if_exists("/tmp/install_complete");
361
	update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
362
	start_installation();
363
}
364

    
365
function head_html() {
366
	global $g, $fstype, $savemsg;
367
	echo <<<EOF
368
<html>
369
	<head>
370
		<style type='text/css'>
371
			hr {
372
				border: 0;
373
				color: #000000;
374
				background-color: #000000;
375
				height: 1px;
376
				width: 100%;
377
				text-align: left;
378
			}
379
			a:link { 
380
				color: #000000;
381
				text-decoration:underline;
382
				font-size:14;
383
			}
384
			a:visited { 
385
				color: #000000;
386
				text-decoration:underline;
387
				font-size:14;
388
			}
389
			a:hover { 
390
				color: #FFFF00;
391
				text-decoration: none;
392
				font-size:14;
393
			}
394
			a:active { 
395
				color: #FFFF00;
396
				text-decoration:underline;
397
				font-size:14;
398
			}
399
		</style>
400
	</head>
401
EOF;
402

    
403
}
404

    
405
function body_html() {
406
	global $g, $fstype, $savemsg;
407
	$pgtitle = array("{$g['product_name']}", gettext("Installer"));
408
	include("head.inc");
409
	echo <<<EOF
410
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
411
	<script type="text/javascript" src="/javascript/jquery-1.11.1.min.js"></script>
412
	<script type="text/javascript" src="/javascript/jquery-migrate-1.2.1.min.js"></script>
413
	<script type="text/javascript" src="/javascript/jquery/jquery-ui-1.11.1.min.js"></script>
414
	<script type="text/javascript">
415
		function getinstallerprogress() {
416
			url = '/installer/installer.php';
417
			pars = 'state=update_installer_status';
418
			callajax(url, pars, installcallback);
419
		}
420
		function callajax(url, pars, activitycallback) {
421
			jQuery.ajax(
422
				url,
423
				{
424
					type: 'post',
425
					data: pars,
426
					complete: activitycallback
427
				});
428
		}
429
		function installcallback(transport) {
430
			setTimeout('getinstallerprogress()', 2000);
431
			eval(transport.responseText);
432
		}
433
	</script>
434
EOF;
435

    
436
	if($one_two)
437
		echo "<p class=\"pgtitle\">{$pgtitle}</font></p>";
438

    
439
	if ($savemsg) print_info_box($savemsg); 
440
}
441

    
442
function end_html() {
443
	global $g, $fstype, $savemsg;
444
	echo "</form>";
445
	echo "</body>";
446
	echo "</html>";
447
}
448

    
449
function template() {
450
	global $g, $fstype, $savemsg;
451
	head_html();
452
	body_html();
453
	echo <<<EOF
454
	<div id="mainlevel">
455
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
456
	 		<tr>
457
	    		<td>
458
					<div id="mainarea">
459
						<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
460
							<tr>
461
	     						<td class="tabcont" >
462
	      							<form action="installer.php" method="post">
463
									<div id="pfsensetemplate">
464

    
465

    
466
									</div>
467
	     						</td>
468
							</tr>
469
						</table>
470
					</div>
471
				</td>
472
			</tr>
473
		</table>
474
	</div>
475
EOF;
476
	end_html();
477
}
478

    
479
function verify_before_install() {
480
	global $g, $fstype, $savemsg;
481
	$encrypted_root = false;
482
	$non_encrypted_boot = false;
483
	$non_encrypted_notice = false;
484
	head_html();
485
	body_html();
486
	page_table_start($g['product_name'] . " installer - Verify final installation settings");
487
	// If we are visiting this step from anything but the row editor / custom install
488
	// then load the on disk layout contents if they are available.
489
	if(!$_REQUEST['fstype0'] && file_exists("/tmp/webInstaller_disk_layout.txt")) {
490
		$disks = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
491
		$bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
492
		$restored_layout_from_file = true;
493
		$restored_layout_txt = "The previous disk layout was restored from disk";
494
	} else {
495
		$disks = array();
496
	}
497
	if(!$bootmanager) 
498
		$bootmanager = $_REQUEST['bootmanager'];
499
	echo "\n<!--" . print_r($_REQUEST, true) . " -->\n";
500
	$disk = pcsysinstall_get_disk_info(htmlspecialchars($_REQUEST['disk']));
501
	$disksize = format_bytes($disk['size'] * 1048576);
502
	// Loop through posted items and create an array
503
	for($x=0; $x<99; $x++) { // XXX: Make this more optimal
504
		if(!$_REQUEST['fstype' . $x])
505
			continue;
506
		$tmparray = array();
507
		if($_REQUEST['fstype' . $x] <> "SWAP") {
508
			$tmparray['mountpoint'] = $_REQUEST['mountpoint' . $x];
509
			// Check for encrypted slice /
510
			if(stristr($_REQUEST['fstype' . $x], ".eli")) {
511
				if($tmparray['mountpoint'] == "/") 
512
					$encrypted_root = true;
513
			}
514
			// Check if we have a non-encrypted /boot
515
			if($tmparray['mountpoint'] == "/boot") 	{
516
				if(!stristr($_REQUEST['fstype' . $x], ".eli"))
517
					$non_encrypted_boot = true;
518
			}
519
			if($tmparray['mountpoint'] == "/conf") {	
520
				$tmparray['mountpoint'] = "/conf{$x}";
521
				$error_txt[] = "/conf is not an allowed mount point and has been renamed to /conf{$x}.";
522
			}
523
		} else  {
524
			$tmparray['mountpoint'] = "none";
525
		}
526
		// If we have an encrypted /root and lack a non encrypted /boot, throw an error/warning
527
		if($encrypted_root && !$non_encrypted_boot && !$non_encrypted_notice) {
528
			$error_txt[] = "A non-encrypted /boot slice is required when encrypting the / slice";
529
			$non_encrypted_notice = true;
530
		}
531
		$tmparray['disk'] = $_REQUEST['disk' . $x];
532
		$tmparray['fstype'] = $_REQUEST['fstype' . $x];
533
		$tmparray['size'] = $_REQUEST['size' . $x];
534
		$tmparray['encpass'] = $_REQUEST['encpass' . $x];
535
		$disks[] = $tmparray;
536
	}
537
	echo "\n<!-- " . print_r($disks, true) . " --> \n";
538
	$bootmanagerupper = strtoupper($bootmanager);
539
	echo <<<EOFAMBAC
540
	<form method="post" action="installer.php">
541
	<input type="hidden" name="fstype" value="{$fstype_echo}">
542
	<input type="hidden" name="disk" value="{$disk_echo}">
543
	<input type="hidden" name="state" value="begin_install">
544
	<input type="hidden" name="swapsize" value="{$swapsize}">
545
	<input type="hidden" name="encpass" value="{$encpass}">
546
	<input type="hidden" name="bootmanager" value="{$bootmanager}">
547
	<div id="mainlevel">
548
		<table width="800" border="0" cellpadding="0" cellspacing="0">
549
	 		<tr>
550
	    		<td>
551
					<div id="mainarea">
552
						<table width="100%" border="0" cellpadding="0" cellspacing="0">
553
							<tr>
554
	     						<td >
555
									<div>
556
										<center>
557
											<div id="pfsensetemplate">
558
												<table width='100%'>
559
EOFAMBAC;
560
												// If errors are found, throw the big red box.
561
												if ($error_txt) {
562
													echo "<tr><td colspan=\"5\">&nbsp;</td>";
563
													echo "<tr><td colspan=\"5\">";
564
													print_input_errors($error_txt);
565
													echo "</td></tr>";
566
												} else 
567
													echo "<tr><td>&nbsp;</td></tr>";
568

    
569
	echo <<<EOFAMBACBAF
570

    
571
												<tr><td colspan='5' align="center"><b>Boot manager: {$bootmanagerupper}</td></tr>
572
												<tr><td>&nbsp;</td></tr>
573
												<tr>
574
													<td align='left'>
575
														<b>Mount point</b>
576
													</td>
577
													<td align='left'>
578
														<b>Filesysytem type</b>
579
													</td>
580
													<td align='left'>
581
														<b>Disk</b>
582
													</td>
583
													<td align='left'>
584
														<b>Size</b>
585
													</td>
586
													<td align='left'>
587
														<b>Encryption password</b>
588
													</td>
589
												</tr>
590
												<tr><td colspan='5'><hr></td></tr>
591

    
592
EOFAMBACBAF;
593

    
594
													foreach($disks as $disk) {
595
														$desc = pcsysinstall_get_disk_info($disk['disk']);
596
														echo "<tr>";
597
														echo "<td>&nbsp;&nbsp;&nbsp;{$disk['mountpoint']}</td>";
598
														echo "<td>{$disk['fstype']}</td>";
599
														echo "<td>{$disk['disk']} {$desc['desc']}</td>";
600
														echo "<td>{$disk['size']}</td>";
601
														echo "<td>{$disk['encpass']}</td>";
602
														echo "</tr>";
603
													}
604

    
605
echo <<<EOFAMB
606
												<tr><td colspan="5"><hr></td></tr>
607
												</table>
608
											</div>
609
										</center>
610
									</div>
611
	     						</td>
612
							</tr>
613
						</table>
614
					</div>
615
					<center>
616
						<p/>
617
						<input type="button" value="Cancel" onClick="javascript:document.location='installer.php?state=custominstall';"> &nbsp;&nbsp;
618
EOFAMB;
619
						if(!$error_txt) 
620
						echo "<input type=\"submit\" value=\"Begin installation\"> <br />&nbsp;";
621
echo <<<EOFAMBASDF
622

    
623
					</center>
624
				</td>
625
			</tr>
626
		</table>
627
	</div>
628
EOFAMBASDF;
629

    
630

    
631
	page_table_end();
632
	end_html();
633
	write_out_pc_sysinstaller_config($disks, $bootmanager);
634
	// Serialize layout to disk so it can be read in later.
635
	file_put_contents("/tmp/webInstaller_disk_layout.txt", serialize($disks));
636
	file_put_contents("/tmp/webInstaller_disk_bootmanager.txt", serialize($bootmanager));
637
}
638

    
639
function installing_gui() {
640
	global $g, $fstype, $savemsg;
641
	head_html();
642
	body_html();
643
	echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
644
	page_table_start();
645
	echo <<<EOF
646
	<center>
647
		<table width="100%">
648
		<tr><td>
649
			<div id="mainlevel">
650
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
651
			 		<tr>
652
			    		<td>
653
							<div id="mainarea">
654
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
655
									<tr>
656
			     						<td>
657
											<div id="pfsenseinstaller" width="100%">
658
												<div id='installerrunning' width='100%' style="padding:8px; border:1px dashed #000000">
659
													<table>
660
														<tr>
661
															<td valign="middle">
662
																<img src="/themes/{$g['theme']}/images/misc/loader.gif">
663
															</td>
664
															<td valign="middle">
665
																&nbsp;<font size="2"><b>Starting Installer...  Please wait...
666
															</td>
667
														</tr>
668
													</table>
669
												</div>
670
												<div id='pbdiv'>
671
													<br />
672
													<center>
673
													<table id='pbtable' height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
674
														<tr>
675
															<td background="/themes/{$g['theme']}/images/misc/bar_left.gif" height='15' width='5'>
676
															</td>
677
															<td>
678
																<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
679
																	<td background="/themes/{$g['theme']}/images/misc/bar_gray.gif" valign="top" align="left">
680
																		<img src='/themes/{$g['theme']}/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
681
																	</td>
682
																</table>
683
															</td>
684
															<td background="/themes/{$g['theme']}/images/misc/bar_right.gif" height='15' width='5'>
685
															</td>
686
														</tr>
687
													</table>
688
													<br />
689
												</div>
690
												<textarea name='installeroutput' id='installeroutput' rows="31" cols="90">
691
												</textarea>
692
											</div>
693
			     						</td>
694
									</tr>
695
								</table>
696
							</div>
697
						</td>
698
					</tr>
699
				</table>
700
			</div>
701
		</td></tr>
702
		</table>
703
	</center>
704
	<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script>
705

    
706
EOF;
707
	page_table_end();
708
	end_html();
709
}
710

    
711
function page_table_start($pgtitle = "") {
712
	global $g, $fstype, $savemsg;
713
	if($pgtitle == "") 
714
		$pgtitle = "{$g['product_name']} installer";
715
	echo <<<EOF
716
	<center>
717
		<img border="0" src="/themes/{$g['theme']}/images/logo.gif"></a><br />
718
		<table cellpadding="6" cellspacing="0" width="550" style="border:1px solid #000000">
719
		<tr height="10" bgcolor="#990000">
720
			<td style="border-bottom:1px solid #000000">
721
				<font color='white'>
722
					<b>
723
						{$pgtitle}
724
					</b>
725
				</font>
726
			</td>
727
		</tr>
728
		<tr>
729
			<td>
730

    
731
EOF;
732

    
733
}
734

    
735
function page_table_end() {
736
	global $g, $fstype, $savemsg;
737
	echo <<<EOF
738
			</td>
739
		</tr>
740
		</table>
741
	</center>
742

    
743
EOF;
744
	
745
}
746

    
747
function installer_custom() {
748
	global $g, $fstype, $savemsg;
749
	global $select_txt, $custom_disks;
750
	if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) 
751
		unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
752
	$disks = installer_find_all_disks();
753
	// Pass size of disks down to javascript.
754
	$disk_sizes_js_txt = "var disk_sizes = new Array();\n";
755
	foreach($disks as $disk) 
756
		$disk_sizes_js_txt .= "disk_sizes['{$disk['disk']}'] = '{$disk['size']}';\n";
757
	head_html();
758
	body_html();
759
	page_table_start($g['product_name'] . " installer - Customize disk(s) layout");
760
	echo <<<EOF
761
		<script type="text/javascript">
762
			Array.prototype.in_array = function(p_val) {
763
				for(var i = 0, l = this.length; i < l; i++) {
764
					if(this[i] == p_val) {
765
						return true;
766
					}
767
				}
768
				return false;
769
			}
770
			function row_helper_dynamic_custom() {
771
				var totalsize = 0;
772
				{$disk_sizes_js_txt}
773
				// Run through all rows and process data
774
				for(var x = 0; x<99; x++) { //optimize me better
775
					if(\$('#fstype' + x).length) {
776
						if(\$('#size' + x).val() == '')
777
							\$('#size' + x).val(disk_sizes[\$('disk' + x).value]);
778
						var fstype = \$('#fstype' + x).val();
779
						if(fstype.substring(fstype.length - 4) == ".eli") {
780
							\$('#encpass' + x).prop('disabled',false);
781
							if(!encryption_warning_shown) {
782
								alert('NOTE: If you define a disk encryption password you will need to enter it on *EVERY* bootup!');
783
								encryption_warning_shown = true;
784
							}
785
						} else { 
786
							\$('#encpass' + x).prop('disabled',true);
787
						}
788
					}
789
					// Calculate size allocations
790
					if(\$('#size' + x).length) {
791
						if(parseInt($('#size' + x).val()) > 0)
792
							totalsize += parseInt($('#size' + x).val());
793
					}
794
				}
795
				// If the totalsize element exists, set it and disable
796
				if(\$('#totalsize').length) {
797
					if(\$('#totalsize').val() != totalsize) {
798
						// When size allocation changes, draw attention.
799
 						jQuery('#totalsize').effect('highlight');
800
						\$('#totalsize').val(totalsize);
801
					}
802
					\$('#totalsize').prop('disabled',true);
803
				}
804
				if(\$('#disktotals').length) {
805
					var disks_seen = new Array();
806
					var tmp_sizedisks = 0;
807
					var disksseen = 0;
808
					for(var xx = 0; xx<99; xx++) {
809
						if(\$('#disk' + xx).length) {
810
							if(!disks_seen.in_array(\$('#disk' + xx).val())) {
811
								tmp_sizedisks += parseInt(disk_sizes[\$('#disk' + xx).val()]);
812
								disks_seen[disksseen] = \$('#disk' + xx).val();
813
								disksseen++;
814
							}
815
						}
816
					\$('#disktotals').val(tmp_sizedisks);
817
					\$('#disktotals').prop('disabled',true);
818
					\$('#disktotals').css('color','#000000');
819
					var remaining = parseInt(\$('#disktotals').val()) - parseInt(\$('#totalsize').val());
820
						if(remaining == 0) {
821
							if(\$('#totalsize').length)
822
								\$('#totalsize').css({
823
									'background':'#00FF00',
824
									'color':'#000000'
825
								});
826
						} else {
827
							if(\$('#totalsize').length)
828
								\$('#totalsize').css({
829
									'background':'#FFFFFF',
830
									'color':'#000000'
831
								});
832
						}
833
						if(parseInt(\$('#totalsize').val()) > parseInt(\$('#disktotals').val())) {
834
							if(\$('#totalsize'))
835
								\$('#totalsize').css({
836
									'background':'#FF0000',
837
									'color':'#000000'
838
								});							
839
						}
840
						if(\$('#availalloc').length) {
841
							\$('#availalloc').prop('disabled',true);
842
							\$('#availalloc').val(remaining);
843
								\$('#availalloc').css({
844
									'background':'#FFFFFF',
845
									'color':'#000000'
846
								});							
847
						}
848
					}
849
				}
850
			}
851
		</script>
852
		<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
853
		<script type="text/javascript">
854
			// Setup rowhelper data types
855
			rowname[0] = "mountpoint";
856
			rowtype[0] = "textbox";
857
			rowsize[0] = "8";
858
			rowname[1] = "fstype";
859
			rowtype[1] = "select";
860
			rowsize[1] = "1";
861
			rowname[2] = "disk";
862
			rowtype[2] = "select";
863
			rowsize[2] = "1";
864
			rowname[3] = "size";
865
			rowtype[3] = "textbox";
866
			rowsize[3] = "8";
867
			rowname[4] = "encpass";
868
			rowtype[4] = "textbox";
869
			rowsize[4] = "8";
870
			field_counter_js = 5;
871
			rows = 1;
872
			totalrows = 1;
873
			loaded = 1;
874
			rowhelper_onChange = 	" onChange='javascript:row_helper_dynamic_custom()' ";
875
			rowhelper_onDelete = 	"row_helper_dynamic_custom(); ";
876
			rowhelper_onAdd = 		"row_helper_dynamic_custom();";
877
		</script>
878
		<form action="installer.php" method="post">
879
			<input type="hidden" name="state" value="verify_before_install">
880
			<div id="mainlevel">
881
				<center>
882
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
883
			 		<tr>
884
			    		<td>
885
							<center>
886
							<div id="mainarea">
887
								<center>
888
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
889
									<tr>
890
			     						<td>
891
											<div id="pfsenseinstaller">
892
												<center>
893
												<div id='loadingdiv'>
894
													<table>
895
														<tr>
896
															<td valign="center">
897
																<img src="/themes/{$g['theme']}/images/misc/loader.gif">
898
															</td>
899
															<td valign="center">
900
														 		&nbsp;Probing disks, please wait...
901
															</td>
902
														</tr>
903
													</table>
904
												</div>
905
EOF;
906
	ob_flush();
907
	// Read bootmanager setting from disk if found
908
	if(file_exists("/tmp/webInstaller_disk_bootmanager.txt"))
909
		$bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
910
	if($bootmanager == "none") 
911
		$noneselected = " SELECTED";
912
	if($bootmanager == "bsd") 
913
		$bsdeselected = " SELECTED";
914
	if(!$disks)  {
915
		$custom_txt = gettext("ERROR: Could not find any suitable disks for installation.");
916
	} else {
917
		// Prepare disk selection dropdown
918
		$custom_txt = <<<EOF
919
												<center>
920
												<table>
921
												<tr>
922
													<td align='right'>
923
														Boot manager:
924
													</td>
925
													<td>
926
														<select name='bootmanager'>
927
															<option value='none' $noneselected>
928
																None
929
															</option>
930
															<option value='bsd' $bsdeselected>
931
																BSD
932
															</option>
933
														</select>
934
													</td>
935
												</tr>
936
												</table>
937
												<hr>
938
												<table id='maintable'><tbody>
939
												<tr>
940
													<td align="middle">
941
														<b>Mount</b>
942
													</td>
943
													<td align='middle'>
944
														<b>Filesysytem</b>
945
													</td>
946
													<td align="middle">
947
														<b>Disk</b>
948
													</td>
949
													<td align="middle">
950
														<b>Size</b>
951
													</td>
952
													<td align="middle">
953
														<b>Encryption password</b>
954
													</td>
955
													<td>
956
														&nbsp;
957
													</td>
958
												</tr>
959
												<tr>
960

    
961
EOF;
962

    
963
		// Calculate swap disk sizes
964
		$memory = get_memory();
965
		$swap_size = $memory[0] * 2;
966
		$first_disk = trim(installer_find_first_disk());
967
		$disk_info = pcsysinstall_get_disk_info($first_disk);
968
		$size = $disk_info['size'];
969
		$first_disk_size = $size - $swap_size;
970

    
971
		// Debugging
972
		echo "\n\n<!-- $first_disk - " . print_r($disk_info, true) . " - $size  - $first_disk_size -->\n\n";
973

    
974
		// Check to see if a on disk layout exists
975
		if(file_exists("/tmp/webInstaller_disk_layout.txt")) {
976
			$disks_restored = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
977
			$restored_layout_from_file = true;
978
			$restored_layout_txt = "<br />* The previous disk layout was restored from a previous session";
979
		}
980

    
981
		// If we restored disk layout(s) from a file then build the rows
982
		if($restored_layout_from_file == true) {
983
			$diskcounter = 0;
984
			foreach($disks_restored as $dr) {
985
				$custom_txt .= return_rowhelper_row("$diskcounter", $dr['mountpoint'], $dr['fstype'], $dr['disk'], $dr['size'], $dr['encpass']);
986
				$diskcounter++;
987
			}
988
		} else {		
989
			// Construct the default rows that outline the disks configuration.
990
			$custom_txt .= return_rowhelper_row("0", "/", "UFS+S", $first_disk, "{$first_disk_size}", "");
991
			$custom_txt .= return_rowhelper_row("1", "none", "SWAP", $first_disk, "$swap_size", "");
992
		}
993

    
994
		// tfoot and tbody are used by rowhelper
995
		$custom_txt .= "</tr>";
996
		$custom_txt .= "<tfoot></tfoot></tbody>";
997
		// Total allocation box
998
		$custom_txt .= "<tr><td></td><td></td><td align='right'>Total allocated:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='totalsize' name='totalsize'></td>";
999
		// Add row button
1000
		$custom_txt .= "</td><td>&nbsp;</td><td>";
1001
		$custom_txt .= "<div id=\"addrowbutton\">";
1002
		$custom_txt .= "<a onclick=\"javascript:addRowTo('maintable', 'formfldalias'); return false;\" href=\"#\">";
1003
		$custom_txt .= "<img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" alt=\"\" title=\"add another entry\" /></a>";
1004
		$custom_txt .= "</div>";
1005
		$custom_txt .= "</td></tr>";	
1006
		// Disk capacity box
1007
		$custom_txt .= "<tr><td></td><td></td><td align='right'>Disk(s) capacity total:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='disktotals' name='disktotals'></td></tr>";
1008
		// Remaining allocation box
1009
		$custom_txt .= "<tr><td></td><td></td><td align='right'>Available space for allocation:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='availalloc' name='availalloc'></td></tr>";
1010
		$custom_txt .= "</table>";
1011
		$custom_txt .= "<script type=\"text/javascript\">row_helper_dynamic_custom();</script>";
1012
	}
1013
	echo <<<EOF
1014

    
1015
												<tr>
1016
													<td colspan='4'>
1017
													<script type="text/javascript">
1018
														\$('#loadingdiv').css('visibility','hidden');
1019
													</script>
1020
													<div id='contentdiv' style="display:none;">
1021
														<p/>
1022
														{$custom_txt}<p/>
1023
														<hr><p/>
1024
														<input type="button" value="Cancel" onClick="javascript:document.location='/installer/installer.php';"> &nbsp;&nbsp
1025
														<input type="submit" value="Next">
1026
													</div>
1027
													<script type="text/javascript">
1028
														var encryption_warning_shown = false;
1029
														\$('#contentdiv').fadeIn();
1030
														row_helper_dynamic_custom();
1031
													</script>
1032
												</center>
1033
												</td></tr>
1034
												</table>
1035
											</div>
1036
			     						</td>
1037
									</tr>
1038
								</table>
1039
								</center>
1040
								<span class="vexpl">
1041
									<span class="red">
1042
										<strong>
1043
											NOTES:
1044
										</strong>
1045
									</span>
1046
									<br />* Sizes are in megabytes.
1047
									<br />* Mount points named /conf are not allowed.  Use /cf if you want to make a configuration slice/mount.
1048
									{$restored_layout_txt}
1049
								</span>
1050
								</strong>
1051
							</div>
1052
						</td>
1053
					</tr>
1054
				</table>
1055
			</div>
1056
			</center>
1057
			<script type="text/javascript">
1058
			<!--
1059
				newrow[1] = "{$select_txt}";
1060
				newrow[2] = "{$custom_disks}";
1061
			-->
1062
			</script>
1063
			
1064

    
1065
EOF;
1066
	page_table_end();
1067
	end_html();
1068
}
1069

    
1070
function installer_main() {
1071
	global $g, $fstype, $savemsg;
1072
	if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) 
1073
		unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
1074
	head_html();
1075
	body_html();
1076
	$disk = installer_find_first_disk();
1077
	// Only enable ZFS if this exists.  The install will fail otherwise.
1078
	if(file_exists("/boot/gptzfsboot")) 
1079
		$zfs_enabled = "<tr bgcolor=\"#9A9A9A\"><td align=\"center\"><a href=\"installer.php?state=easy_install_zfs\">Easy installation of {$g['product_name']} using the ZFS filesystem on disk {$disk}</a></td></tr>";
1080
	page_table_start();
1081
	echo <<<EOF
1082
		<form action="installer.php" method="post" state="step1_post">
1083
			<div id="mainlevel">
1084
				<center>
1085
				<b><font face="arial" size="+2">Welcome to the {$g['product_name']} webInstaller!</b></font><p/>
1086
				<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
1087
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
1088
			 		<tr>
1089
			    		<td>
1090
							<center>
1091
							<div id="mainarea">
1092
								<br />
1093
								<center>
1094
								Please select an installer option to begin:
1095
								<p/>
1096
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
1097
									<tr>
1098
			     						<td>
1099
											<div id="pfsenseinstaller">
1100
												<center>
1101
EOF;
1102
	if(!$disk) {
1103
		echo gettext("ERROR: Could not find any suitable disks for installation.");
1104
		echo "</div></td></tr></table></div></table></div>";
1105
		end_html();
1106
		exit;
1107
	}
1108
	echo <<<EOF
1109

    
1110
													<table cellspacing="5" cellpadding="5" style="border: 1px dashed;">
1111
														<tr bgcolor="#CECECE"><td align="center">
1112
															<a href="installer.php?state=easy_install_ufs">Easy installation of {$g['product_name']} using the UFS filesystem on disk {$disk}</a>
1113
														</td></tr>
1114
													 	{$zfs_enabled}
1115
														<tr bgcolor="#AAAAAA"><td align="center">
1116
															<a href="installer.php?state=custominstall">Custom installation of {$g['product_name']}</a>
1117
														</td></tr>
1118
														<tr bgcolor="#CECECE"><td align="center">
1119
															<a href='/'>Cancel and return to Dashboard</a>
1120
														</td></tr>
1121
													</table>
1122
												</center>
1123
											</div>
1124
			     						</td>
1125
									</tr>
1126
								</table>
1127
							</div>
1128
						</td>
1129
					</tr>
1130
				</table>
1131
			</div>
1132
EOF;
1133
	page_table_end();
1134
	end_html();
1135
}
1136

    
1137
function return_rowhelper_row($rownum, $mountpoint, $fstype, $disk, $size, $encpass) {
1138
		global $g, $select_txt, $custom_disks, $savemsg;
1139
		$release = php_uname("r");
1140
		$release = trim($release[0]);
1141

    
1142
		// Mount point
1143
		$disks = installer_find_all_disks();
1144
		$custom_txt .= "<tr>";
1145
		$custom_txt .=  "<td><input size='8' id='mountpoint{$rownum}' name='mountpoint{$rownum}' value='{$mountpoint}'></td>";
1146

    
1147
		// Filesystem type array
1148
		$types = array(
1149
			'UFS' => 'UFS',
1150
			'UFS+S' => 'UFS + Softupdates',
1151
			'UFS.eli' => 'Encrypted UFS',
1152
			'UFS+S.eli' => 'Encrypted UFS + Softupdates',
1153
			'SWAP' => 'SWAP'
1154
		);
1155

    
1156
		// UFS + Journaling was introduced in 9.0
1157
		if($release == "9") {
1158
			$types['UFS+J'] = "UFS + Journaling";
1159
			$types['UFS+J.eli'] = "Encrypted UFS + Journaling";
1160
		}
1161
		
1162
		// Add ZFS Boot loader if it exists
1163
		if(file_exists("/boot/gptzfsboot")) {
1164
			$types['ZFS'] = "Zetabyte Filesystem";
1165
			$types['ZFS.eli'] = "Encrypted Zetabyte Filesystem";
1166
		}
1167

    
1168
		// fstype form field
1169
		$custom_txt .=  "<td><select onChange='javascript:row_helper_dynamic_custom()' id='fstype{$rownum}' name='fstype{$rownum}'>";
1170
		$select_txt = "";
1171
		foreach($types as $type => $desc) {
1172
			if($type == $fstype)
1173
				$SELECTED="SELECTED";
1174
			else 
1175
				$SELECTED="";
1176
			$select_txt .= "<option value='$type' $SELECTED>$desc</option>";
1177
		}
1178
		$custom_txt .= "{$select_txt}</select>\n";
1179
		$custom_txt .= "</td>";
1180
		
1181
		// Disk selection form field
1182
		$custom_txt .= "<td><select id='disk{$rownum}' name='disk{$rownum}'>\n";
1183
		$custom_disks = "";
1184
		foreach($disks as $dsk) {
1185
			$disksize_bytes = format_bytes($dsk['size'] * 1048576);
1186
			$disksize = $dsk['size'];
1187
			if($disk == $dsk['disk'])
1188
				$SELECTED="SELECTED";
1189
			else 
1190
				$SELECTED="";
1191
			$custom_disks .= "<option value='{$dsk['disk']}' $SELECTED>{$dsk['disk']} - {$dsk['desc']} - {$disksize}MB ({$disksize_bytes})</option>";
1192
		}
1193
		$custom_txt .= "{$custom_disks}</select></td>\n";
1194

    
1195
		// Slice size
1196
		$custom_txt .= "<td><input onChange='javascript:row_helper_dynamic_custom();' name='size{$rownum}' id='size{$rownum}' size='8' type='text' value='{$size}'></td>";
1197

    
1198
		// Encryption password
1199
		$custom_txt .= "<td>";
1200
		$custom_txt .= "<input id='encpass{$rownum}' name='encpass{$rownum}' size='8' value='{$encpass}'>";
1201
		$custom_txt .= "</td>";
1202
	
1203
		// Add Rowhelper + button
1204
		if($rownum > 0) 
1205
			$custom_txt .= "<td><a onclick=\"removeRow(this); return false;\" href=\"#\"><img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" alt=\"\" title=\"remove this entry\"/></a></td>";
1206

    
1207
		$custom_txt .= "</tr>";	
1208
		return $custom_txt;
1209
}
1210

    
1211
?>
(2-2/2)