Project

General

Profile

Download (19.9 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 = "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'] == "host")
121
		if (!is_ipaddr($_POST['address'])) {
122
			$input_errors[] = "A valid address must be specified.";
123
		}
124
	if ($_POST['type'] == "network") {
125
		if (!is_ipaddr($_POST['address'])) {
126
			$input_errors[] = "A valid address must be specified.";
127
		}
128
		if (!is_numeric($_POST['address_subnet'])) {
129
			$input_errors[] = "A valid subnet bit count must be specified.";
130
		}
131
	}
132

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

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

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

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

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

    
166
	else
167
		$alias['address'] = $_POST['address'];
168

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

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

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

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

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

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

    
274
		touch($d_aliasesdirty_path);
275

    
276
		write_config();
277
		filter_configure();
278

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

    
292
include("head.inc");
293

    
294
$jscriptstr = <<<EOD
295

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

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

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

    
326
			document.iform.address_subnet.disabled = 1;
327
			document.iform.address_subnet.value = "";
328
			newrows = totalrows+1;
329
			for(i=2; i<newrows; i++) {
330
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
331
				eval(comd);
332
				comd = 'document.iform.address_subnet' + i + '.value = "32";';
333
				eval(comd);
334
			}
335
			break;
336
		case 3:	/* url */
337
			var cmd;
338
			document.iform.address_subnet.disabled = 0;
339
			newrows = totalrows+1;
340
			for(i=2; i<newrows; i++) {
341
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
342
				eval(comd);
343
			}
344
			break;
345
	}
346
}
347

    
348
EOD;
349

    
350
$network_str = gettext("Network");
351
$networks_str = gettext("Network(s)");
352
$cidr_str = gettext("CIDR");
353
$description_str = gettext("Description");
354
$hosts_str = gettext("Host(s)");
355
$ip_str = gettext("IP");
356
$ports_str = gettext("Port(s)");
357
$port_str = gettext("Port");
358
$url_str = gettext("URL");
359
$update_freq_str = gettext("Update Freq.");
360

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

    
366
$jscriptstr .= <<<EOD
367

    
368
function update_box_type() {
369
	var indexNum = document.forms[0].type.selectedIndex;
370
	var selected = document.forms[0].type.options[indexNum].text;
371
	if(selected == '{$networks_str}') {
372
		document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
373
		document.getElementById ("address_subnet").visible = true;
374
		document.getElementById ("address_subnet").disabled = false;
375
		document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
376
		document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
377
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
378
		document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
379
	} else if(selected == '{$hosts_str}') {
380
		document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
381
		document.getElementById ("address_subnet").visible = false;
382
		document.getElementById ("address_subnet").disabled = true;
383
		document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
384
		document.getElementById ("twocolumn").firstChild.data = "";
385
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
386
		document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
387
	} else if(selected == '{$ports_str}') {
388
		document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
389
		document.getElementById ("address_subnet").visible = false;
390
		document.getElementById ("address_subnet").disabled = true;
391
		document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
392
		document.getElementById ("twocolumn").firstChild.data = "";
393
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
394
		document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
395
	} else if(selected == '{$url_str}') {
396
		document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
397
		document.getElementById ("address_subnet").visible = true;
398
		document.getElementById ("address_subnet").disabled = false;
399
		document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
400
		document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
401
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
402
		document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
403
	}
404
}
405
</script>
406

    
407
EOD;
408

    
409
?>
410

    
411
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
412
<?php
413
	include("fbegin.inc");
414
	echo $jscriptstr;
415
?>
416

    
417
<script type="text/javascript" src="row_helper.js">
418
</script>
419

    
420
<input type='hidden' name='address_type' value='textbox' />
421
<input type='hidden' name='address_subnet_type' value='select' />
422

    
423
<script type="text/javascript">
424
	rowname[0] = "address";
425
	rowtype[0] = "textbox";
426
	rowsize[0] = "30";
427

    
428
	rowname[1] = "address_subnet";
429
	rowtype[1] = "select";
430
	rowsize[1] = "1";
431

    
432
	rowname[2] = "detail";
433
	rowtype[2] = "textbox";
434
	rowsize[2] = "61";
435
</script>
436

    
437
<p class="pgtitle"><?=$pgtitle?></p>
438

    
439
<?php if ($input_errors) print_input_errors($input_errors); ?>
440
<div id="inputerrors"></div>
441

    
442
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
443
<table width="100%" border="0" cellpadding="6" cellspacing="0">
444
<?php if(is_alias_inuse($pconfig['name']) == true): ?>
445
  <tr>
446
    <td valign="top" class="vncellreq">Name</td>
447
    <td class="vtable"> <input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
448
		  <?php echo $pconfig['name']; ?>
449
      <p>
450
        <span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span>
451
      </p>
452
    </td>
453
  </tr>
454
<?php else: ?>
455
  <tr>
456
    <td valign="top" class="vncellreq">Name</td>
457
    <td class="vtable">
458
      <input name="name" type="text" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
459
      <br />
460
      <span class="vexpl">
461
        The name of the alias may only consist of the characters a-z, A-Z and 0-9.
462
      </span>
463
    </td>
464
  </tr>
465
<?php endif; ?>
466
  <tr>
467
    <td width="22%" valign="top" class="vncell">Description</td>
468
    <td width="78%" class="vtable">
469
      <input name="descr" type="text"  id="descr" size="40" value="<?=$pconfig['descr'];?>" />
470
      <br />
471
      <span class="vexpl">
472
        You may enter a description here for your reference (not parsed).
473
      </span>
474
    </td>
475
  </tr>
476
  <tr>
477
    <td valign="top" class="vncellreq">Type</td>
478
    <td class="vtable">
479
      <select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
480
        <option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
481
        <option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
482
        <option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
483
      </select>
484
    </td>
485
  </tr>
486
  <tr>
487
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
488
    <td width="78%" class="vtable">
489
      <table id="maintable">
490
        <tbody>
491
          <tr>
492
            <td colspan="4">
493
      		    <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>
494
            </td>
495
          </tr>
496
          <tr>
497
            <td><div id="onecolumn">Network</div></td>
498
            <td><div id="twocolumn">CIDR</div></td>
499
           <td><div id="threecolumn">Description</div></td>
500
          </tr>
501

    
502
			<?php
503
			$counter = 0;
504
			$address = $pconfig['address'];
505
			$item = explode(" ", $address);
506
			$item3 = explode("||", $pconfig['detail']);
507
			foreach($item as $ww) {
508
				$address = $item[$counter];
509
				$address_subnet = "";
510
				$item2 = explode("/", $address);
511
				foreach($item2 as $current) {
512
					if($item2[1] <> "") {
513
						$address = $item2[0];
514
						$address_subnet = $item2[1];
515
					}
516
				}
517
				$item4 = $item3[$counter];
518
				if($counter > 0) $tracker = $counter + 1;
519
			?>
520
          <tr>
521
            <td>
522
              <input name="address<?php echo $tracker; ?>" type="text"  id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
523
            </td>
524
            <td>
525
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
526
			          <option></option>
527
			          <?php for ($i = 32; $i >= 1; $i--): ?>
528
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
529
			          <?php endfor; ?>
530
			        </select>
531
			      </td>
532
            <td>
533
              <input name="detail<?php echo $tracker; ?>" type="text"  id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
534
            </td>
535
            <td>
536
    			  <?php
537
    				if($counter > 0)
538
    					echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
539
    			  ?>
540
			      </td>
541
          </tr>
542
			<?php
543
        $counter++;
544

    
545
        } // end foreach
546
      ?>
547
        </tbody>
548
        <tfoot>
549

    
550
        </tfoot>
551
		  </table>
552
			<a onclick="javascript:addRowTo('maintable'); typesel_change(); return false;" href="#">
553
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
554
      </a>
555
		</td>
556
  </tr>
557
  <tr>
558
    <td width="22%" valign="top">&nbsp;</td>
559
    <td width="78%">
560
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
561
      <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
562
      <?php if (isset($id) && $a_aliases[$id]): ?>
563
      <input name="id" type="hidden" value="<?=$id;?>" />
564
      <?php endif; ?>
565
    </td>
566
  </tr>
567
</table>
568
</form>
569

    
570
<script type="text/javascript">
571
	field_counter_js = 3;
572
	rows = 1;
573
	totalrows = <?php echo $counter; ?>;
574
	loaded = <?php echo $counter; ?>;
575
	typesel_change();
576
	update_box_type();
577
</script>
578

    
579
<?php include("fend.inc"); ?>
580
</body>
581
</html>
582

    
583
<?php
584
function process_alias_tgz($temp_filename) {
585
	mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
586
	mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
587
	unlink("{$temp_filename}/aliases.tgz");
588
	$files_to_process = return_dir_as_array("{$temp_filename}/");
589
	/* foreach through all extracted files and build up aliases file */
590
	$fd = fopen("{$temp_filename}/aliases", "a");
591
	foreach($files_to_process as $f2p) {
592
		$file_contents = file_get_contents($f2p);
593
		fwrite($fd, $file_contents);
594
		unlink($f2p);
595
	}
596
	fclose($fd);
597
}
598
?>
(40-40/173)