Project

General

Profile

« Previous | Next » 

Revision 5a1eebc7

Added by Scott Ullrich over 18 years ago

Backport the alias rowhelper description feature

View differences:

etc/inc/util.inc
232 232
		return true;
233 233
}
234 234

  
235
/* returns true if $portrange is a valid TCP/UDP portrange ("<port>:<port>") */
236
function is_portrange($portrange) {
237
        $ports = explode(":", $portrange);
238

  
239
        if(count($ports) == 2 && is_port($ports[0]) && is_port($ports[1]))
240
                return true;
241
        else
242
                return false;
243
}
244

  
235 245
/* returns true if $val is a valid shaper bandwidth value */
236 246
function is_valid_shaperbw($val) {
237 247
	return (preg_match("/^[0-9]+(Kb|Mb|Gb|%)$/", $val));
......
553 563
    }
554 564
}
555 565

  
556
?>
566
?>
usr/local/www/firewall_aliases_edit.php
31 31
	POSSIBILITY OF SUCH DAMAGE.
32 32
*/
33 33

  
34
$pgtitle = "Firewall: Aliases: Edit";
35

  
34 36
require("guiconfig.inc");
35 37

  
36 38
if (!is_array($config['aliases']['alias']))
......
59 61
			$pconfig['type'] = "host";
60 62
		else
61 63
			$pconfig['type'] = "port";
62
			
63
	$pconfig['descr'] = $a_aliases[$id]['descr'];
64

  
65
	$pconfig['descr'] = html_entity_decode($a_aliases[$id]['descr']);
66

  
67
	/* Explode out details for entry details */
68
	$address_details = explode('||', $a_aliases[$id]['detail']);
69
	if (is_array($address_details))
70
			$address_detail = $address_details[0];
71
	else
72
		$address_detail = $address_details;
73

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

  
66 91
if ($_POST) {
......
89 114
		$input_errors[] = "Reserved word used for alias name.";
90 115
	} else {
91 116
		if (is_validaliasname($_POST['name']) == false)
92
			$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9.";
117
			$input_errors[] = "The alias name may only consist of the characters a-z, A-Z, 0-9, -, _.";
93 118
	}
94 119
	if ($_POST['type'] == "host")
95 120
		if (!is_ipaddr($_POST['address'])) {
......
103 128
			$input_errors[] = "A valid subnet bit count must be specified.";
104 129
		}
105 130
	}
131

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

  
106 137
	if ($_POST['type'] == "port")
107
		if (!is_port($_POST['address']))
108
			$input_errors[] = "The port must be an integer between 1 and 65535.";
138
		if (! is_port($_POST['address']) && ! is_portrange($_POST['address']))
139
			$input_errors[] = "Please specify a valid port or portrange.";
109 140

  
110 141
	/* check for name conflicts */
111 142
	foreach ($a_aliases as $alias) {
......
117 148
			break;
118 149
		}
119 150
	}
120
	
151

  
121 152
	/* check for name interface description conflicts */
122 153
	foreach($config['interfaces'] as $interface) {
123 154
		if($interface['descr'] == $_POST['name']) {
124
			$input_errors[] = gettext("An interface description with this name already exists.");
125
			break;	
155
			$input_errors[] = "An interface description with this name already exists.";
156
			break;
126 157
		}
127
	}	
158
	}
128 159

  
129 160
	if (!$input_errors) {
130 161
		$alias = array();
......
136 167
			$alias['address'] = $_POST['address'];
137 168

  
138 169
		$address = $alias['address'];
170
		$final_address_detail = htmlentities($_POST['detail'], ENT_QUOTES, 'UTF-8');
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 .= "||";
139 178
		$isfirst = 0;
140
		for($x=0; $x<99; $x++) {
141
			$comd = "\$subnet = \$_POST['address" . $x . "'];";
142
			eval($comd);
143
			$comd = "\$subnet_address = \$_POST['address_subnet" . $x . "'];";
144
			eval($comd);
145
			if($subnet <> "") {
146
				$address .= " ";
147
				$address .= $subnet;
148
				if($subnet_address <> "") $address .= "/" . $subnet_address;
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; $x<99; $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<99; $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 = htmlentities( \$_POST['detail" . $x . "'], ENT_QUOTES, 'UTF-8' );";
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
				}
149 260
			}
150 261
		}
151 262

  
152
		$alias['address'] = $address;
153
		$alias['descr'] = $_POST['descr'];
263
		if($dont_update <> true) {
154 264

  
155
		if (isset($id) && $a_aliases[$id])
156
			$a_aliases[$id] = $alias;
157
		else
158
			$a_aliases[] = $alias;
265
			$alias['address'] = $address;
266
			$alias['descr'] = htmlentities($_POST['descr'], ENT_QUOTES, 'UTF-8');
267
			$alias['type'] = $_POST['type'];
268
			$alias['detail'] = $final_address_details;
159 269

  
160
		touch($d_aliasesdirty_path);
270
			if (isset($id) && $a_aliases[$id])
271
				$a_aliases[$id] = $alias;
272
			else
273
				$a_aliases[] = $alias;
161 274

  
162
		write_config();
275
			touch($d_aliasesdirty_path);
163 276

  
164
		filter_configure();
277
			write_config();
278
			filter_configure();
165 279

  
166
		header("Location: firewall_aliases.php");
167
		exit;
280
			header("Location: firewall_aliases.php");
281
			exit;
282
		}
168 283
	}
169 284
}
170 285

  
171 286
$pgtitle = "System: Firewall: Aliases: Edit";
172 287
include("head.inc");
173 288

  
174
?>
289
$jscriptstr = <<<EOD
175 290

  
176
<script language="JavaScript">
177
<!--
291
<script type="text/javascript">
178 292
function typesel_change() {
179 293
	switch (document.iform.type.selectedIndex) {
180 294
		case 0:	/* host */
181 295
			var cmd;
296

  
297
			document.iform.address_subnet.disabled = 1;
182 298
			document.iform.address_subnet.value = "";
183 299
			document.iform.address_subnet.selected = 0;
184
			document.iform.address_subnet.disabled = 1;
185
			newrows = totalrows+100;
186
			for(i=1; i<newrows; i++) {
187
				var working_with = 'address_subnet' + i;
188
				var item = document.getElementById(working_with);
189
				if(item) {
190
					comd = 'document.iform.' + working_with + '.value = "";';
191
					eval(comd);
192
					comd = 'document.iform.' + working_with + '.disabled = 1;';
193
					eval(comd);
194
				}
300
			newrows = totalrows+1;
301
			for(i=2; i<newrows; i++) {
302
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
303
				eval(comd);
304
				comd = 'document.iform.address_subnet' + i + '.value = "";';
305
				eval(comd);
195 306
			}
196 307
			break;
197 308
		case 1:	/* network */
198 309
			var cmd;
310

  
199 311
			document.iform.address_subnet.disabled = 0;
200
			newrows = totalrows+100;
312
			newrows = totalrows+1;
201 313
			for(i=2; i<newrows; i++) {
202
				var item = document.getElementById('address_subnet' + i);
203
				if(item) {
204
					comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
205
					eval(comd);
206
				}
314
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
315
				eval(comd);
207 316
			}
208 317
			break;
209 318
		case 2:	/* port */
210 319
			var cmd;
320

  
211 321
			document.iform.address_subnet.disabled = 1;
212 322
			document.iform.address_subnet.value = "";
213
			newrows = totalrows+100;
323
			newrows = totalrows+1;
214 324
			for(i=2; i<newrows; i++) {
215
				var item = document.getElementById('address_subnet' + i);
216
				if(item) {
217
					comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
218
					eval(comd);
219
					comd = 'document.iform.address_subnet' + i + '.value = "32";';
220
					eval(comd);
221
				}
325
				comd = 'document.iform.address_subnet' + i + '.disabled = 1;';
326
				eval(comd);
327
				comd = 'document.iform.address_subnet' + i + '.value = "32";';
328
				eval(comd);
329
			}
330
			break;
331
		case 3:	/* url */
332
			var cmd;
333
			document.iform.address_subnet.disabled = 0;
334
			newrows = totalrows+1;
335
			for(i=2; i<newrows; i++) {
336
				comd = 'document.iform.address_subnet' + i + '.disabled = 0;';
337
				eval(comd);
222 338
			}
223 339
			break;
224 340
	}
225 341
}
226 342

  
343
EOD;
344

  
345
$network_str = gettext("Network");
346
$networks_str = gettext("Network(s)");
347
$cidr_str = gettext("CIDR");
348
$description_str = gettext("Description");
349
$hosts_str = gettext("Host(s)");
350
$ip_str = gettext("IP");
351
$ports_str = gettext("Port(s)");
352
$port_str = gettext("Port");
353
$url_str = gettext("URL");
354
$update_freq_str = gettext("Update Freq.");
355

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

  
361
$jscriptstr .= <<<EOD
362

  
227 363
function update_box_type() {
228 364
	var indexNum = document.forms[0].type.selectedIndex;
229 365
	var selected = document.forms[0].type.options[indexNum].text;
230
	if(selected == 'Network(s)') {
231
		document.getElementById ("addressnetworkport").firstChild.data = "Network(s)";
366
	if(selected == '{$networks_str}') {
367
		document.getElementById ("addressnetworkport").firstChild.data = "{$networks_str}";
232 368
		document.getElementById ("address_subnet").visible = true;
233 369
		document.getElementById ("address_subnet").disabled = false;
234
	} else if(selected == 'Host(s)') {
235
		document.getElementById ("addressnetworkport").firstChild.data = "Host(s)";
370
		document.getElementById ("onecolumn").firstChild.data = "{$network_str}";
371
		document.getElementById ("twocolumn").firstChild.data = "{$cidr_str}";
372
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
373
		document.getElementById ("itemhelp").firstChild.data = "{$networks_help}";
374
	} else if(selected == '{$hosts_str}') {
375
		document.getElementById ("addressnetworkport").firstChild.data = "{$hosts_str}";
236 376
		document.getElementById ("address_subnet").visible = false;
237 377
		document.getElementById ("address_subnet").disabled = true;
238
	} else if(selected == 'Port(s)') {
239
		document.getElementById ("addressnetworkport").firstChild.data = "Port(s)";
378
		document.getElementById ("onecolumn").firstChild.data = "{$ip_str}";
379
		document.getElementById ("twocolumn").firstChild.data = "";
380
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
381
		document.getElementById ("itemhelp").firstChild.data = "{$hosts_help}";
382
	} else if(selected == '{$ports_str}') {
383
		document.getElementById ("addressnetworkport").firstChild.data = "{$ports_str}";
240 384
		document.getElementById ("address_subnet").visible = false;
241 385
		document.getElementById ("address_subnet").disabled = true;
386
		document.getElementById ("onecolumn").firstChild.data = "{$port_str}";
387
		document.getElementById ("twocolumn").firstChild.data = "";
388
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
389
		document.getElementById ("itemhelp").firstChild.data = "{$ports_help}";
390
	} else if(selected == '{$url_str}') {
391
		document.getElementById ("addressnetworkport").firstChild.data = "{$url_str}";
392
		document.getElementById ("address_subnet").visible = true;
393
		document.getElementById ("address_subnet").disabled = false;
394
		document.getElementById ("onecolumn").firstChild.data = "{$url_str}";
395
		document.getElementById ("twocolumn").firstChild.data = "{$update_freq_str}";
396
		document.getElementById ("threecolumn").firstChild.data = "{$description_str}";
397
		document.getElementById ("itemhelp").firstChild.data = "{$url_help}";
242 398
	}
243 399
}
244

  
245
-->
246 400
</script>
247 401

  
248
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
249
<?php include("fbegin.inc"); ?>
402
EOD
250 403

  
251
<script type="text/javascript" language="javascript" src="row_helper.js">
252
</script>
404
?>
253 405

  
254
<input type='hidden' name='address_type' value='textbox'></input>
255
<input type='hidden' name='address_subnet_type' value='select'></input>
406
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
407
<?php
408
	include("fbegin.inc");
409
	echo $jscriptstr;
410
?>
411

  
412
<script type="text/javascript" src="row_helper.js">
413
</script>
256 414

  
257
<script type="text/javascript" language='javascript'>
258
<!--
415
<input type='hidden' name='address_type' value='textbox' />
416
<input type='hidden' name='address_subnet_type' value='select' />
259 417

  
260
rowname[0] = "address";
261
rowtype[0] = "textbox";
418
<script type="text/javascript">
419
	rowname[0] = "address";
420
	rowtype[0] = "textbox";
421
	rowsize[0] = "30";
262 422

  
263
rowname[1] = "address_subnet";
264
rowtype[1] = "select";
423
	rowname[1] = "address_subnet";
424
	rowtype[1] = "select";
425
	rowsize[1] = "1";
265 426

  
266
rowname[2] = "address_subnet";
267
rowtype[2] = "select";
268
-->
427
	rowname[2] = "detail";
428
	rowtype[2] = "textbox";
429
	rowsize[2] = "61";
269 430
</script>
270 431

  
271 432
<p class="pgtitle"><?=$pgtitle?></p>
433

  
272 434
<?php if ($input_errors) print_input_errors($input_errors); ?>
273
            <form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
274
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
435
<div id="inputerrors"></div>
436

  
437
<form action="firewall_aliases_edit.php" method="post" name="iform" id="iform">
438
<table width="100%" border="0" cellpadding="6" cellspacing="0">
275 439
<?php if(is_alias_inuse($pconfig['name']) == true): ?>
276
                <tr>
277
                  <td valign="top" class="vncellreq">Name</td>
278
                  <td class="vtable"> <input name="name" type="hidden" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>">
440
  <tr>
441
    <td valign="top" class="vncellreq">Name</td>
442
    <td class="vtable"> <input name="name" type="hidden" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
279 443
		  <?php echo $pconfig['name']; ?>
280
                    <p><span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span></td>
281
                </tr>
444
      <p>
445
        <span class="vexpl">NOTE: This alias is in use so the name may not be modified!</span>
446
      </p>
447
    </td>
448
  </tr>
282 449
<?php else: ?>
283
                <tr>
284
                  <td valign="top" class="vncellreq">Name</td>
285
                  <td class="vtable"> <input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>">
286
                    <br> <span class="vexpl">The name of the alias may only consist
287
                    of the characters a-z, A-Z and 0-9.</span></td>
288
                </tr>
450
  <tr>
451
    <td valign="top" class="vncellreq">Name</td>
452
    <td class="vtable">
453
      <input name="name" type="text" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>" />
454
      <br />
455
      <span class="vexpl">
456
        The name of the alias may only consist of the characters a-z, A-Z and 0-9.
457
      </span>
458
    </td>
459
  </tr>
289 460
<?php endif; ?>
290
                <tr>
291
                  <td width="22%" valign="top" class="vncell">Description</td>
292
                  <td width="78%" class="vtable"> <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
293
                    <br> <span class="vexpl">You may enter a description here
294
                    for your reference (not parsed).</span></td>
295
                </tr>
296
                <tr>
297
                  <td valign="top" class="vncellreq">Type</td>
298
                  <td class="vtable">
299
                    <select name="type" class="formfld" id="type" onChange="update_box_type(); typesel_change();">
300
                      <option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
301
                      <option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
302
		      <option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
303
                    </select>
304
                  </td>
305
                </tr>
306
                <tr>
307
                  <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport" name="addressnetworkport">Host(s)</div></td>
308
                  <td width="78%" class="vtable">
309

  
310

  
311
		    <table name="maintable" id="maintable">
312
		      <tbody>
461
  <tr>
462
    <td width="22%" valign="top" class="vncell">Description</td>
463
    <td width="78%" class="vtable">
464
      <input name="descr" type="text"  id="descr" size="40" value="<?=$pconfig['descr'];?>" />
465
      <br />
466
      <span class="vexpl">
467
        You may enter a description here for your reference (not parsed).
468
      </span>
469
    </td>
470
  </tr>
471
  <tr>
472
    <td valign="top" class="vncellreq">Type</td>
473
    <td class="vtable">
474
      <select name="type" class="formselect" id="type" onchange="update_box_type(); typesel_change();">
475
        <option value="host" <?php if ($pconfig['type'] == "host") echo "selected"; ?>>Host(s)</option>
476
        <option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>>Network(s)</option>
477
        <option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>>Port(s)</option>
478
      </select>
479
    </td>
480
  </tr>
481
  <tr>
482
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Host(s)</div></td>
483
    <td width="78%" class="vtable">
484
      <table id="maintable">
485
        <tbody>
486
          <tr>
487
            <td colspan="4">
488
      		    <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>
489
            </td>
490
          </tr>
491
          <tr>
492
            <td><div id="onecolumn">Network</div></td>
493
            <td><div id="twocolumn">CIDR</div></td>
494
           <td><div id="threecolumn">Description</div></td>
495
          </tr>
313 496

  
314 497
			<?php
315 498
			$counter = 0;
316 499
			$address = $a_aliases[$id]['address'];
317 500
			$item = explode(" ", $address);
501
			$item3 = explode("||", $a_aliases[$id]['detail']);
318 502
			foreach($item as $ww) {
319 503
				$address = $item[$counter];
320 504
				$address_subnet = "";
......
325 509
						$address_subnet = $item2[1];
326 510
					}
327 511
				}
512
				$item4 = $item3[$counter];
328 513
				if($counter > 0) $tracker = $counter + 1;
329 514
			?>
330
			<tr><td> <input name="address<?php echo $tracker; ?>" type="text" class="formfld" id="address<?php echo $tracker; ?>" size="20" value="<?=htmlspecialchars($address);?>"></td><td>
331
			<select name="address_subnet<?php echo $tracker; ?>" class="formfld" id="address_subnet<?php echo $tracker; ?>">
332
			  <option></option>
333
			  <?php for ($i = 32; $i >= 1; $i--): ?>
334
			  <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
335
			  <?php endfor; ?>
336
			</select>
337
			  <?php
338
				if($counter > 0)
339
					echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\">";
340
			  ?>
341

  
342
			</td></tr>
343
			<?php $counter++; } ?>
344

  
345
		     </tbody>
346
		    </table>
347
			<a onClick="javascript:addRowTo('maintable'); typesel_change(); return false;" href="#"><img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add another entry"></a>
348
		    </td>
349
                </tr>
350
                <tr>
351
                  <td width="22%" valign="top">&nbsp;</td>
352
                  <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()">
353
                    <?php if (isset($id) && $a_aliases[$id]): ?>
354
                    <input name="id" type="hidden" value="<?=$id;?>">
355
                    <?php endif; ?>
356
                  </td>
357
                </tr>
358
              </table>
515
          <tr>
516
            <td>
517
              <input name="address<?php echo $tracker; ?>" type="text"  id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
518
            </td>
519
            <td>
520
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
521
			          <option></option>
522
			          <?php for ($i = 32; $i >= 1; $i--): ?>
523
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
524
			          <?php endfor; ?>
525
			        </select>
526
			      </td>
527
            <td>
528
              <input name="detail<?php echo $tracker; ?>" type="text"  id="detail<?php echo $tracker; ?>" size="50" value="<?=$item4;?>" />
529
            </td>
530
            <td>
531
    			  <?php
532
    				if($counter > 0)
533
    					echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
534
    			  ?>
535
			      </td>
536
          </tr>
537
			<?php
538
        $counter++;
539

  
540
        } // end foreach
541
      ?>
542
        </tbody>
543
        <tfoot>
544

  
545
        </tfoot>
546
		  </table>
547
			<a onclick="javascript:addRowTo('maintable'); typesel_change(); return false;" href="#">
548
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
549
      </a>
550
		</td>
551
  </tr>
552
  <tr>
553
    <td width="22%" valign="top">&nbsp;</td>
554
    <td width="78%">
555
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
556
      <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
557
      <?php if (isset($id) && $a_aliases[$id]): ?>
558
      <input name="id" type="hidden" value="<?=$id;?>" />
559
      <?php endif; ?>
560
    </td>
561
  </tr>
562
</table>
359 563
</form>
360
<script language="JavaScript">
361
<!--
362
field_counter_js = 2;
363
rows = 1;
364
totalrows = <?php echo $counter; ?>;
365
loaded = <?php echo $counter; ?>;
366
typesel_change();
367
update_box_type();
368

  
369
//-->
564

  
565
<script type="text/javascript">
566
	field_counter_js = 3;
567
	rows = 1;
568
	totalrows = <?php echo $counter; ?>;
569
	loaded = <?php echo $counter; ?>;
570
	typesel_change();
571
	update_box_type();
370 572
</script>
573

  
371 574
<?php include("fend.inc"); ?>
372 575
</body>
373 576
</html>
577

  
578
<?php
579
function process_alias_tgz($temp_filename) {
580
	mwexec("/bin/mv {$temp_filename}/aliases {$temp_filename}/aliases.tgz");
581
	mwexec("/usr/bin/tar xzf {$temp_filename}/aliases.tgz -C {$temp_filename}/aliases/");
582
	unlink("{$temp_filename}/aliases.tgz");
583
	$files_to_process = return_dir_as_array("{$temp_filename}/");
584
	/* foreach through all extracted files and build up aliases file */
585
	$fd = fopen("{$temp_filename}/aliases", "a");
586
	foreach($files_to_process as $f2p) {
587
		$file_contents = file_get_contents($f2p);
588
		fwrite($fd, $file_contents);
589
		unlink($f2p);
590
	}
591
	fclose($fd);
592
}
593
?>
usr/local/www/row_helper.js
2 2
var rowname = new Array(99);
3 3
var rowtype = new Array(99);
4 4
var newrow  = new Array(99);
5
var rowsize = new Array(99);
5 6

  
6 7
for (i = 0; i < 99; i++) {
7 8
	rowname[i] = '';
8 9
	rowtype[i] = '';
9
	 newrow[i] = '';
10
	newrow[i] = '';
11
	rowsize[i] = '25';
10 12
}
11 13

  
12 14
var field_counter_js = 0;
......
24 26
	for (i = 0; i < field_counter_js; i++) {
25 27
		td = d.createElement("td");
26 28
		if(rowtype[i] == 'textbox') {
27
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input id='" + rowname[i] + totalrows + "' name='" + rowname[i] + totalrows + "'></input> ";
29
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'></input> ";
28 30
		} else if(rowtype[i] == 'select') {
29
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select id='" + rowname[i] + totalrows + "' name='" + rowname[i] + totalrows + "'><option value=\"\" selected></option><option value=\"32\" selected>32</option><option value=\"31\" >31</option><option value=\"30\" >30</option><option value=\"29\" >29</option><option value=\"28\" >28</option><option value=\"27\" >27</option><option value=\"26\" >26</option><option value=\"25\" >25</option><option value=\"24\" >24</option><option value=\"23\" >23</option><option value=\"22\" >22</option><option value=\"21\" >21</option><option value=\"20\" >20</option><option value=\"19\" >19</option><option value=\"18\" >18</option><option value=\"17\" >17</option><option value=\"16\" >16</option><option value=\"15\" >15</option><option value=\"14\" >14</option><option value=\"13\" >13</option><option value=\"12\" >12</option><option value=\"11\" >11</option><option value=\"10\" >10</option><option value=\"9\" >9</option><option value=\"8\" >8</option><option value=\"7\" >7</option><option value=\"6\" >6</option><option value=\"5\" >5</option><option value=\"4\" >4</option><option value=\"3\" >3</option><option value=\"2\" >2</option><option value=\"1\" >1</option></select> ";
31
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'><option value=\"32\" selected>32</option><option value=\"31\" >31</option><option value=\"30\" >30</option><option value=\"29\" >29</option><option value=\"28\" >28</option><option value=\"27\" >27</option><option value=\"26\" >26</option><option value=\"25\" >25</option><option value=\"24\" >24</option><option value=\"23\" >23</option><option value=\"22\" >22</option><option value=\"21\" >21</option><option value=\"20\" >20</option><option value=\"19\" >19</option><option value=\"18\" >18</option><option value=\"17\" >17</option><option value=\"16\" >16</option><option value=\"15\" >15</option><option value=\"14\" >14</option><option value=\"13\" >13</option><option value=\"12\" >12</option><option value=\"11\" >11</option><option value=\"10\" >10</option><option value=\"9\" >9</option><option value=\"8\" >8</option><option value=\"7\" >7</option><option value=\"6\" >6</option><option value=\"5\" >5</option><option value=\"4\" >4</option><option value=\"3\" >3</option><option value=\"2\" >2</option><option value=\"1\" >1</option></select> ";
30 32
		} else {
31
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input id='" + rowname[i] + totalrows + "' type='checkbox' name='" + rowname[i] + totalrows + "'></input> ";
33
			td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input type='checkbox' name='" + rowname[i] + totalrows + "'></input> ";
32 34
		}
33 35
		tr.appendChild(td);
34 36
	}
......
50 52
	cel = el.getElementsByTagName("td").item(0);
51 53
	el.parentNode.removeChild(el);
52 54
    }
53
    totalrows--;
54 55
}
55 56

  
56 57
function find_unique_field_name(field_name) {

Also available in: Unified diff