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
	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) 
55
		if($config['interfaces']['opt' . $i]['descr'] == $pconfig['descr']) 
56
			$input_errors[] = "Sorry, an interface is already named {$pconfig['descr']}.";
57

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

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

    
90
if ($_POST) {
91

    
92
	unset($input_errors);
93
	$pconfig = $_POST;
94

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

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

    
104
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
105

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

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

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

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

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

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

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

    
162
	else
163
		$alias['address'] = $_POST['address'];
164

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

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

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

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

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

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

    
270
		touch($d_aliasesdirty_path);
271

    
272
		write_config();
273
		filter_configure();
274

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

    
288
include("head.inc");
289

    
290
$jscriptstr = <<<EOD
291

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

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

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

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

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

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

    
359
EOD;
360

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

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

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

    
382
$jscriptstr .= <<<EOD
383

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

    
431
EOD;
432

    
433
?>
434

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

    
441
<script type="text/javascript" src="row_helper.js">
442
</script>
443

    
444
<input type='hidden' name='address_type' value='textbox' />
445
<input type='hidden' name='address_subnet_type' value='select' />
446

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

    
452
	rowname[1] = "address_subnet";
453
	rowtype[1] = "select";
454
	rowsize[1] = "1";
455

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

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

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

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

    
568
        } // end foreach
569
      ?>
570
        </tbody>
571
        <tfoot>
572

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

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

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

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