Project

General

Profile

Download (20.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_aliases_edit.php
5
	Copyright (C) 2004 Scott Ullrich
6
	All rights reserved.
7

    
8
	originially part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

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

    
34
$pgtitle = array("Firewall","Aliases","Edit");
35

    
36
require("guiconfig.inc");
37

    
38
if (!is_array($config['aliases']['alias']))
39
	$config['aliases']['alias'] = array();
40

    
41
aliases_sort();
42
$a_aliases = &$config['aliases']['alias'];
43

    
44
$id = $_GET['id'];
45
if (isset($_POST['id']))
46
	$id = $_POST['id'];
47

    
48
if (isset($id) && $a_aliases[$id]) {
49
	$pconfig['name'] = $a_aliases[$id]['name'];
50
	$pconfig['detail'] = $a_aliases[$id]['detail'];
51
	$pconfig['address'] = $a_aliases[$id]['address'];
52
	$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
53
	
54
	$addresses = explode(' ', $pconfig['address']);
55
	$address = explode("/", $addresses[0]);
56
	if ($address[1])
57
		$addresssubnettest = true;
58
	else
59
		$addresssubnettest = false;	
60
	
61
	if ($addresssubnettest)
62
		$pconfig['type'] = "network";
63
	else
64
		if (is_ipaddr($address[0]))
65
			$pconfig['type'] = "host";
66
		else
67
			$pconfig['type'] = "port";
68

    
69
	if($a_aliases[$id]['aliasurl'] <> "") {
70
		$pconfig['type'] = "url";
71
		if(is_array($a_aliases[$id]['aliasurl'])) {
72
			$isfirst = 0;
73
			$pconfig['address'] = "";
74
			foreach($a_aliases[$id]['aliasurl'] as $aa) {
75
				if($isfirst == 1)
76
					$pconfig['address'] .= " ";
77
				$isfirst = 1;
78
				$pconfig['address'] .= $aa;
79
			}
80
		} else {
81
			$pconfig['address'] = $a_aliases[$id]['aliasurl'];
82
		}
83
	}
84
}
85

    
86
if ($_POST) {
87

    
88
	unset($input_errors);
89
	$pconfig = $_POST;
90

    
91
	/* input validation */
92
	$reqdfields = explode(" ", "name address");
93
	$reqdfieldsn = explode(",", "Name,Address");
94

    
95
	if ($_POST['type'] == "network") {
96
		$reqdfields[] = "address_subnet";
97
		$reqdfieldsn[] = "Subnet bit count";
98
	}
99

    
100
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
101

    
102
	if(strtolower($_POST['name']) == "lan")
103
		$input_errors[] = "Aliases may not be named LAN.";
104
	if(strtolower($_POST['name']) == "wan")
105
		$input_errors[] = "Aliases may not be named WAN.";
106
	if(strtolower($_POST['name']) == "pptp")
107
		$input_errors[] = gettext("Aliases may not be named PPTP.");
108

    
109
	$x = is_validaliasname($_POST['name']);
110
	if (!isset($x)) {
111
		$input_errors[] = "Reserved word used for alias name.";
112
	} else {
113
		if (is_validaliasname($_POST['name']) == false)
114
			$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, _.";
115
	}
116
	if ($_POST['type'] == "network") {
117
		if (!is_ipaddr($_POST['address'])) {
118
			$input_errors[] = "A valid address must be specified.";
119
		}
120
		if (!is_numeric($_POST['address_subnet'])) {
121
			$input_errors[] = "A valid subnet bit count must be specified.";
122
		}
123
	}
124

    
125
	if ($_POST['type'] == "url") {
126
		if(stristr($_POST['address'], "http") == false)
127
			$input_errors[] = "You must provide a valid URL to the resource.";
128
	}
129

    
130
	if ($_POST['type'] == "port")
131
		if (! is_port($_POST['address']) && ! is_portrange($_POST['address']))
132
			$input_errors[] = "Please specify a valid port or portrange.";
133

    
134
	/* check for name conflicts */
135
	foreach ($a_aliases as $alias) {
136
		if (isset($id) && ($a_aliases[$id]) && ($a_aliases[$id] === $alias))
137
			continue;
138

    
139
		if ($alias['name'] == $_POST['name']) {
140
			$input_errors[] = "An alias with this name already exists.";
141
			break;
142
		}
143
	}
144

    
145
	/* check for name interface description conflicts */
146
	foreach($config['interfaces'] as $interface) {
147
		if($interface['descr'] == $_POST['name']) {
148
			$input_errors[] = "An interface description with this name already exists.";
149
			break;
150
		}
151
	}
152
	
153
	$alias = array();
154
	$alias['name'] = $_POST['name'];
155
	if ($_POST['type'] == "network")
156
		$alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet'];
157

    
158
	else
159
		$alias['address'] = $_POST['address'];
160

    
161
	$address = $alias['address'];
162
	$final_address_detail  =  mb_convert_encoding($_POST['detail'],"HTML-ENTITIES","auto");  
163
  		if($final_address_detail <> "") {
164
	       	$final_address_details .= $final_address_detail;
165
	} else {
166
		$final_address_details .= "Entry added" . " ";
167
   			$final_address_details .= date('r');
168
		}
169
    	$final_address_details .= "||";
170
	$isfirst = 0;
171

    
172
	if($_POST['type'] == "url") {
173
		$address = "";
174
		$isfirst = 0;
175
		$address_count = 2;
176

    
177
		/* item is a url type */
178
		if($_POST['address'])
179
			$_POST['address0'] = $_POST['address'];
180
		for($x=0; $x<299; $x++) {
181
			if($_POST['address' . $x]) {
182
				/* fetch down and add in */
183
				$isfirst = 0;
184
				$temp_filename = tempnam("/tmp/", "alias_import");
185
				unlink($temp_filename);
186
				$fda = fopen("/tmp/tmpfetch","w");
187
				fwrite($fda, "/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
188
				fclose($fda);
189
				mwexec("mkdir -p {$temp_filename}");
190
				mwexec("/usr/bin/fetch -q -o \"{$temp_filename}/aliases\" \"" . $_POST['address' . $x] . "\"");
191
				/* if the item is tar gzipped then extract */
192
				if(stristr($_POST['address' . $x], ".tgz"))
193
					process_alias_tgz($temp_filename);
194
				if(file_exists("{$temp_filename}/aliases")) {
195
					$file_contents = file_get_contents("{$temp_filename}/aliases");
196
					$file_contents = str_replace("#", "\n#", $file_contents);
197
					$file_contents_split = split("\n", $file_contents);
198
					foreach($file_contents_split as $fc) {
199
						$tmp = trim($fc);
200
						if(stristr($fc, "#")) {
201
							$tmp_split = split("#", $tmp);
202
							$tmp = trim($tmp_split[0]);
203
						}
204
						if(trim($tmp) <> "") {
205
							if($isfirst == 1)
206
								$address .= " ";
207
							$address .= $tmp;
208
							$isfirst = 1;
209
						}
210
					}
211
					if($isfirst == 0) {
212
						/* nothing was found */
213
						$input_errors[] = "You must provide a valid URL. Could not fetch usable data.";
214
						$dont_update = true;
215
						break;
216
					}
217
					$alias['aliasurl'][] = $_POST['address' . $x];
218
					mwexec("/bin/rm -rf {$temp_filename}");
219
				} else {
220
					$input_errors[] = "You must provide a valid URL.";
221
					$dont_update = true;
222
					break;
223
				}
224
			}
225
		}
226
	} else {
227
		/* item is a normal alias type */
228
		for($x=0; $x<299; $x++) {
229
			$comd = "\$subnet = \$_POST['address" . $x . "'];";
230
			eval($comd);
231
			$comd = "\$subnet_address = \$_POST['address_subnet" . $x . "'];";
232
			eval($comd);
233
			if($subnet <> "") {
234
				$address .= " ";
235
				$address .= $subnet;
236
				if($subnet_address <> "") $address .= "/" . $subnet_address;
237

    
238
				/* Compress in details to a single key, data separated by pipes.
239
				   Pulling details here lets us only pull in details for valid
240
				   address entries, saving us from having to track which ones to
241
				   process later. */
242
	       $comd = "\$final_address_detail = mb_convert_encoding(\$_POST['detail" . $x . "'],'HTML-ENTITIES','auto');";
243
	       eval($comd);
244
	       if($final_address_detail <> "") {
245
	       $final_address_details .= $final_address_detail;
246
	       } else {
247
		       $final_address_details .= "Entry added" . " ";
248
		       $final_address_details .= date('r');
249
	       }
250
	       $final_address_details .= "||";
251
			}
252
		}
253
	}
254

    
255
	if (!$input_errors) {
256
		$alias['address'] = $address;
257
		$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
258
		$alias['type'] = $_POST['type'];
259
		$alias['detail'] = $final_address_details;
260

    
261
		if (isset($id) && $a_aliases[$id])
262
			$a_aliases[$id] = $alias;
263
		else
264
			$a_aliases[] = $alias;
265

    
266
		touch($d_aliasesdirty_path);
267

    
268
		write_config();
269
		filter_configure();
270

    
271
		header("Location: firewall_aliases.php");
272
		exit;		
273
	}
274
	//we received input errors, copy data to prevent retype
275
	else
276
	{
277
		$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
278
		$pconfig['address'] = $address;
279
		$pconfig['type'] = $_POST['type'];
280
		$pconfig['detail'] = $final_address_details;
281
	}
282
}
283

    
284
include("head.inc");
285

    
286
$jscriptstr = <<<EOD
287

    
288
<script type="text/javascript">
289
function typesel_change() {
290
	switch (document.iform.type.selectedIndex) {
291
		case 0:	/* host */
292
			var cmd;
293

    
294
			document.iform.address_subnet.disabled = 1;
295
			document.iform.address_subnet.value = "";
296
			document.iform.address_subnet.selected = 0;
297
			newrows = totalrows+1;
298
			for(i=2; i<newrows; i++) {
299
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
300
				eval(comd);
301
				comd = 'document.iform.address_subnet' + i + '.value = "";';
302
				eval(comd);
303
			}
304
			break;
305
		case 1:	/* network */
306
			var cmd;
307

    
308
			document.iform.address_subnet.disabled = 0;
309
			newrows = totalrows+1;
310
			for(i=2; i<newrows; i++) {
311
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
312
				eval(comd);
313
			}
314
			break;
315
		case 2:	/* port */
316
			var cmd;
317

    
318
			document.iform.address_subnet.disabled = 1;
319
			document.iform.address_subnet.value = "";
320
			newrows = totalrows+1;
321
			for(i=2; i<newrows; i++) {
322
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
323
				eval(comd);
324
				comd = 'document.iform.address_subnet' + i + '.value = "32";';
325
				eval(comd);
326
			}
327
			break;
328
		case 3:	/* OpenVPN Users */
329
			var cmd;
330

    
331
			document.iform.address_subnet.disabled = 1;
332
			document.iform.address_subnet.value = "";
333
			document.iform.address_subnet.selected = 0;
334
			newrows = totalrows+1;
335
			for(i=2; i<newrows; i++) {
336
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
337
				eval(comd);
338
				comd = 'document.iform.address_subnet' + i + '.value = "";';
339
				eval(comd);
340
			}
341
			break;
342

    
343
		case 4:	/* url */
344
			var cmd;
345
			document.iform.address_subnet.disabled = 0;
346
			newrows = totalrows+1;
347
			for(i=2; i<newrows; i++) {
348
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
349
				eval(comd);
350
			}
351
			break;
352
	}
353
}
354

    
355
EOD;
356

    
357
$network_str = gettext("Network");
358
$networks_str = gettext("Network(s)");
359
$cidr_str = gettext("CIDR");
360
$description_str = gettext("Description");
361
$hosts_str = gettext("Host(s)");
362
$ip_str = gettext("IP");
363
$ports_str = gettext("Port(s)");
364
$port_str = gettext("Port");
365
$url_str = gettext("URL");
366
$update_freq_str = gettext("Update Freq.");
367

    
368
$networks_help = gettext("Networks can be expressed like 10.0.0.0 format.  Select the CIDR (network mask) that pertains to each entry.");
369
$hosts_help = gettext("Enter as many hosts as you would like.  Hosts should be expressed in their ip address format.");
370
$ports_help = gettext("Enter as many ports as you wish.  Port ranges can be expressed by seperating with a colon.");
371
$url_help = gettext("Enter as many urls as you wish.  Also set the time that you would like the url refreshed in days.  After saving {$g['product_name']} will download the URL and import the items into the alias.");
372

    
373
$openvpn_str = gettext("Username");
374
$openvpn_user_str = gettext("OpenVPN Users");
375
$openvpn_help = gettext("Enter as many usernames as you wish.");
376
$openvpn_freq = gettext("");
377

    
378
$jscriptstr .= <<<EOD
379

    
380
function update_box_type() {
381
	var indexNum = document.forms[0].type.selectedIndex;
382
	var selected = document.forms[0].type.options[indexNum].text;
383
	if(selected == '{$networks_str}') {
384
		document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
385
		document.getElementById ("address_subnet").visible = true;
386
		document.getElementById ("address_subnet").disabled = false;
387
		document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
388
		document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
389
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
390
		document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
391
	} else if(selected == '{$hosts_str}') {
392
		document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
393
		document.getElementById ("address_subnet").visible = false;
394
		document.getElementById ("address_subnet").disabled = true;
395
		document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
396
		document.getElementById ("twocolumn").firstChild.data = "";
397
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
398
		document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
399
	} else if(selected == '{$ports_str}') {
400
		document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
401
		document.getElementById ("address_subnet").visible = false;
402
		document.getElementById ("address_subnet").disabled = true;
403
		document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
404
		document.getElementById ("twocolumn").firstChild.data = "";
405
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
406
		document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
407
	} else if(selected == '{$url_str}') {
408
		document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
409
		document.getElementById ("address_subnet").visible = true;
410
		document.getElementById ("address_subnet").disabled = false;
411
		document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
412
		document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
413
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
414
		document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
415
	} else if(selected == '{$openvpn_user_str}') {
416
		document.getElementById ("addressnetworkport").firstChild.data = "{$openvpn_user_str}";
417
		document.getElementById ("address_subnet").visible = false;
418
		document.getElementById ("address_subnet").disabled = false;
419
		document.getElementById ("onecolumn").firstChild.data = "{$openvpn_str}";
420
		document.getElementById ("twocolumn").firstChild.data = "{$openvpn_freq}";
421
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
422
		document.getElementById ("itemhelp").firstChild.data = "{$openvpn_help}";
423
	}
424
}
425
</script>
426

    
427
EOD;
428

    
429
?>
430

    
431
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
432
<?php
433
	include("fbegin.inc");
434
	echo $jscriptstr;
435
?>
436

    
437
<script type="text/javascript" src="row_helper.js">
438
</script>
439

    
440
<input type='hidden' name='address_type' value='textbox' />
441
<input type='hidden' name='address_subnet_type' value='select' />
442

    
443
<script type="text/javascript">
444
	rowname[0] = "address";
445
	rowtype[0] = "textbox";
446
	rowsize[0] = "30";
447

    
448
	rowname[1] = "address_subnet";
449
	rowtype[1] = "select";
450
	rowsize[1] = "1";
451

    
452
	rowname[2] = "detail";
453
	rowtype[2] = "textbox";
454
	rowsize[2] = "61";
455
</script>
456

    
457
<?php if ($input_errors) print_input_errors($input_errors); ?>
458
<div id="inputerrors"></div>
459

    
460
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
461
<table width="100%" border="0" cellpadding="6" cellspacing="0">
462
<?php if(is_alias_inuse($pconfig['name']) == true): ?>
463
  <tr>
464
    <td valign="top" class="vncellreq">Name</td>
465
    <td class="vtable"> <input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
466
		  <?php echo $pconfig['name']; ?>
467
      <p>
468
        <span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span>
469
      </p>
470
    </td>
471
  </tr>
472
<?php else: ?>
473
  <tr>
474
    <td valign="top" class="vncellreq">Name</td>
475
    <td class="vtable">
476
      <input name="name" type="text" id="name" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
477
      <br />
478
      <span class="vexpl">
479
        The name of the alias may only consist of the characters a-z, A-Z and 0-9.
480
      </span>
481
    </td>
482
  </tr>
483
<?php endif; ?>
484
  <tr>
485
    <td width="22%" valign="top" class="vncell">Description</td>
486
    <td width="78%" class="vtable">
487
      <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
488
      <br />
489
      <span class="vexpl">
490
        You may enter a description here for your reference (not parsed).
491
      </span>
492
    </td>
493
  </tr>
494
  <tr>
495
    <td valign="top" class="vncellreq">Type</td>
496
    <td class="vtable">
497
      <select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
498
        <option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
499
        <option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
500
        <option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
501
        <option value="openvpn" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>OpenVPN Users</option>
502
      </select>
503
    </td>
504
  </tr>
505
  <tr>
506
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
507
    <td width="78%" class="vtable">
508
      <table id="maintable">
509
        <tbody>
510
          <tr>
511
            <td colspan="4">
512
      		    <div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">Item information</div>
513
            </td>
514
          </tr>
515
          <tr>
516
            <td><div id="onecolumn">Network</div></td>
517
            <td><div id="twocolumn">CIDR</div></td>
518
           <td><div id="threecolumn">Description</div></td>
519
          </tr>
520

    
521
			<?php
522
			$counter = 0;
523
			$address = $pconfig['address'];
524
			$item = explode(" ", $address);
525
			$item3 = explode("||", $pconfig['detail']);
526
			foreach($item as $ww) {
527
				$address = $item[$counter];
528
				$address_subnet = "";
529
				$item2 = explode("/", $address);
530
				foreach($item2 as $current) {
531
					if($item2[1] <> "") {
532
						$address = $item2[0];
533
						$address_subnet = $item2[1];
534
					}
535
				}
536
				$item4 = $item3[$counter];
537
				if($counter > 0) $tracker = $counter + 1;
538
			?>
539
          <tr>
540
            <td>
541
              <input name="address<?php echo $tracker; ?>" type="text" class="formfld unknown" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
542
            </td>
543
            <td>
544
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
545
			          <option></option>
546
			          <?php for ($i = 32; $i >= 1; $i--): ?>
547
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
548
			          <?php endfor; ?>
549
			        </select>
550
			      </td>
551
            <td>
552
              <input name="detail<?php echo $tracker; ?>" type="text" class="formfld unknown" id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
553
            </td>
554
            <td>
555
    			  <?php
556
    				if($counter > 0)
557
    					echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
558
    			  ?>
559
			      </td>
560
          </tr>
561
			<?php
562
        $counter++;
563

    
564
        } // end foreach
565
      ?>
566
        </tbody>
567
        <tfoot>
568

    
569
        </tfoot>
570
		  </table>
571
			<a onclick="javascript:addRowTo('maintable'); typesel_change(); return false;" href="#">
572
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
573
      </a>
574
		</td>
575
  </tr>
576
  <tr>
577
    <td width="22%" valign="top">&nbsp;</td>
578
    <td width="78%">
579
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
580
      <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
581
      <?php if (isset($id) && $a_aliases[$id]): ?>
582
      <input name="id" type="hidden" value="<?=$id;?>" />
583
      <?php endif; ?>
584
    </td>
585
  </tr>
586
</table>
587
</form>
588

    
589
<script type="text/javascript">
590
	field_counter_js = 3;
591
	rows = 1;
592
	totalrows = <?php echo $counter; ?>;
593
	loaded = <?php echo $counter; ?>;
594
	typesel_change();
595
	update_box_type();
596
</script>
597

    
598
<?php include("fend.inc"); ?>
599
</body>
600
</html>
601

    
602
<?php
603
function process_alias_tgz($temp_filename) {
604
	mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
605
	mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
606
	unlink("{$temp_filename}/aliases.tgz");
607
	$files_to_process = return_dir_as_array("{$temp_filename}/");
608
	/* foreach through all extracted files and build up aliases file */
609
	$fd = fopen("{$temp_filename}/aliases", "a");
610
	foreach($files_to_process as $f2p) {
611
		$file_contents = file_get_contents($f2p);
612
		fwrite($fd, $file_contents);
613
		unlink($f2p);
614
	}
615
	fclose($fd);
616
}
617
?>
(40-40/193)