Project

General

Profile

Download (21 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
	/* optional if list */
55
	$iflist = get_configured_interface_with_descr(true, true);
56
	foreach ($iflist as $if => $ifdesc)
57
		if($ifdesc == $pconfig['descr']) 
58
			$input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}.";
59

    
60
	$addresses = explode(' ', $pconfig['address']);
61
	$address = explode("/", $addresses[0]);
62
	if ($address[1])
63
		$addresssubnettest = true;
64
	else
65
		$addresssubnettest = false;	
66
	
67
	if ($addresssubnettest)
68
		$pconfig['type'] = "network";
69
	else
70
		if (is_ipaddr($address[0]))
71
			$pconfig['type'] = "host";
72
		else
73
			$pconfig['type'] = "port";
74

    
75
	if($a_aliases[$id]['aliasurl'] <> "") {
76
		$pconfig['type'] = "url";
77
		if(is_array($a_aliases[$id]['aliasurl'])) {
78
			$isfirst = 0;
79
			$pconfig['address'] = "";
80
			foreach($a_aliases[$id]['aliasurl'] as $aa) {
81
				if($isfirst == 1)
82
					$pconfig['address'] .= " ";
83
				$isfirst = 1;
84
				$pconfig['address'] .= $aa;
85
			}
86
		} else {
87
			$pconfig['address'] = $a_aliases[$id]['aliasurl'];
88
		}
89
	}
90
}
91

    
92
if ($_POST) {
93

    
94
	unset($input_errors);
95
	$pconfig = $_POST;
96

    
97
	/* input validation */
98
	$reqdfields = explode(" ", "name address");
99
	$reqdfieldsn = explode(",", "Name,Address");
100

    
101
	if ($_POST['type'] == "network") {
102
		$reqdfields[] = "address_subnet";
103
		$reqdfieldsn[] = "Subnet bit count";
104
	}
105

    
106
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
107

    
108
	if(strtolower($_POST['name']) == "lan")
109
		$input_errors[] = "Aliases may not be named LAN.";
110
	if(strtolower($_POST['name']) == "wan")
111
		$input_errors[] = "Aliases may not be named WAN.";
112
	if(strtolower($_POST['name']) == "pptp")
113
		$input_errors[] = gettext("Aliases may not be named PPTP.");
114

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

    
131
	if ($_POST['type'] == "url") {
132
		if(stristr($_POST['address'], "http") == false)
133
			$input_errors[] = "You must provide a valid URL to the resource.";
134
	}
135

    
136
	if ($_POST['type'] == "port")
137
		if (! is_port($_POST['address']) && ! is_portrange($_POST['address']))
138
			$input_errors[] = "Please specify a valid port or portrange.";
139

    
140
	/* check for name conflicts */
141
	foreach ($a_aliases as $alias) {
142
		if (isset($id) && ($a_aliases[$id]) && ($a_aliases[$id] === $alias))
143
			continue;
144

    
145
		if ($alias['name'] == $_POST['name']) {
146
			$input_errors[] = "An alias with this name already exists.";
147
			break;
148
		}
149
	}
150

    
151
	/* check for name interface description conflicts */
152
	foreach($config['interfaces'] as $interface) {
153
		if($interface['descr'] == $_POST['name']) {
154
			$input_errors[] = "An interface description with this name already exists.";
155
			break;
156
		}
157
	}
158
	
159
	$alias = array();
160
	$alias['name'] = $_POST['name'];
161
	if ($_POST['type'] == "network")
162
		$alias['address'] = $_POST['address'] . "/" . $_POST['address_subnet'];
163

    
164
	else
165
		$alias['address'] = $_POST['address'];
166

    
167
	$address = $alias['address'];
168
	$final_address_detail  =  mb_convert_encoding($_POST['detail'],"HTML-ENTITIES","auto");  
169
  		if($final_address_detail <> "") {
170
	       	$final_address_details .= $final_address_detail;
171
	} else {
172
		$final_address_details .= "Entry added" . " ";
173
   			$final_address_details .= date('r');
174
		}
175
    	$final_address_details .= "||";
176
	$isfirst = 0;
177

    
178
	if($_POST['type'] == "url") {
179
		$address = "";
180
		$isfirst = 0;
181
		$address_count = 2;
182

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

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

    
261
	if (!$input_errors) {
262
		$alias['address'] = $address;
263
		$alias['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
264
		$alias['type'] = $_POST['type'];
265
		$alias['detail'] = $final_address_details;
266

    
267
		if (isset($id) && $a_aliases[$id])
268
			$a_aliases[$id] = $alias;
269
		else
270
			$a_aliases[] = $alias;
271

    
272
		touch($d_aliasesdirty_path);
273

    
274
		write_config();
275
		filter_configure();
276

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

    
290
include("head.inc");
291

    
292
$jscriptstr = <<<EOD
293

    
294
<script type="text/javascript">
295
function typesel_change() {
296
	switch (document.iform.type.selectedIndex) {
297
		case 0:	/* host */
298
			var cmd;
299

    
300
			document.iform.address_subnet.disabled = 1;
301
			document.iform.address_subnet.value = "";
302
			document.iform.address_subnet.selected = 0;
303
			newrows = totalrows+1;
304
			for(i=2; i<newrows; i++) {
305
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
306
				eval(comd);
307
				comd = 'document.iform.address_subnet' + i + '.value = "";';
308
				eval(comd);
309
			}
310
			break;
311
		case 1:	/* network */
312
			var cmd;
313

    
314
			document.iform.address_subnet.disabled = 0;
315
			newrows = totalrows+1;
316
			for(i=2; i<newrows; i++) {
317
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
318
				eval(comd);
319
			}
320
			break;
321
		case 2:	/* port */
322
			var cmd;
323

    
324
			document.iform.address_subnet.disabled = 1;
325
			document.iform.address_subnet.value = "";
326
			newrows = totalrows+1;
327
			for(i=2; i<newrows; i++) {
328
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
329
				eval(comd);
330
				comd = 'document.iform.address_subnet' + i + '.value = "32";';
331
				eval(comd);
332
			}
333
			break;
334
		case 3:	/* OpenVPN Users */
335
			var cmd;
336

    
337
			document.iform.address_subnet.disabled = 1;
338
			document.iform.address_subnet.value = "";
339
			document.iform.address_subnet.selected = 0;
340
			newrows = totalrows+1;
341
			for(i=2; i<newrows; i++) {
342
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
343
				eval(comd);
344
				comd = 'document.iform.address_subnet' + i + '.value = "";';
345
				eval(comd);
346
			}
347
			break;
348

    
349
		case 4:	/* url */
350
			var cmd;
351
			document.iform.address_subnet.disabled = 0;
352
			newrows = totalrows+1;
353
			for(i=2; i<newrows; i++) {
354
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
355
				eval(comd);
356
			}
357
			break;
358
	}
359
}
360

    
361
EOD;
362

    
363
$network_str = gettext("Network");
364
$networks_str = gettext("Network(s)");
365
$cidr_str = gettext("CIDR");
366
$description_str = gettext("Description");
367
$hosts_str = gettext("Host(s)");
368
$ip_str = gettext("IP");
369
$ports_str = gettext("Port(s)");
370
$port_str = gettext("Port");
371
$url_str = gettext("URL");
372
$update_freq_str = gettext("Update Freq.");
373

    
374
$networks_help = gettext("Networks can be expressed like 10.0.0.0 format.  Select the CIDR (network mask) that pertains to each entry.");
375
$hosts_help = gettext("Enter as many hosts as you would like.  Hosts should be expressed in their ip address format.");
376
$ports_help = gettext("Enter as many ports as you wish.  Port ranges can be expressed by seperating with a colon.");
377
$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.");
378

    
379
$openvpn_str = gettext("Username");
380
$openvpn_user_str = gettext("OpenVPN Users");
381
$openvpn_help = gettext("Enter as many usernames as you wish.");
382
$openvpn_freq = gettext("");
383

    
384
$jscriptstr .= <<<EOD
385

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

    
433
EOD;
434

    
435
?>
436

    
437
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
438
<?php
439
	include("fbegin.inc");
440
	echo $jscriptstr;
441
?>
442

    
443
<script type="text/javascript" src="row_helper.js">
444
</script>
445

    
446
<input type='hidden' name='address_type' value='textbox' />
447
<input type='hidden' name='address_subnet_type' value='select' />
448

    
449
<script type="text/javascript">
450
	rowname[0] = "address";
451
	rowtype[0] = "textbox";
452
	rowsize[0] = "30";
453

    
454
	rowname[1] = "address_subnet";
455
	rowtype[1] = "select";
456
	rowsize[1] = "1";
457

    
458
	rowname[2] = "detail";
459
	rowtype[2] = "textbox";
460
	rowsize[2] = "61";
461
</script>
462

    
463
<?php if ($input_errors) print_input_errors($input_errors); ?>
464
<div id="inputerrors"></div>
465

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

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

    
570
        } // end foreach
571
      ?>
572
        </tbody>
573
        <tfoot>
574

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

    
595
<script type="text/javascript">
596
	field_counter_js = 3;
597
	rows = 1;
598
	totalrows = <?php echo $counter; ?>;
599
	loaded = <?php echo $counter; ?>;
600
	typesel_change();
601
	update_box_type();
602
</script>
603

    
604
<?php include("fend.inc"); ?>
605
</body>
606
</html>
607

    
608
<?php
609
function process_alias_tgz($temp_filename) {
610
	mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
611
	mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
612
	unlink("{$temp_filename}/aliases.tgz");
613
	$files_to_process = return_dir_as_array("{$temp_filename}/");
614
	/* foreach through all extracted files and build up aliases file */
615
	$fd = fopen("{$temp_filename}/aliases", "a");
616
	foreach($files_to_process as $f2p) {
617
		$file_contents = file_get_contents($f2p);
618
		fwrite($fd, $file_contents);
619
		unlink($f2p);
620
	}
621
	fclose($fd);
622
}
623
?>
(41-41/200)