Commit 16022187 authored by Ad Schellevis's avatar Ad Schellevis
parent 109da1b2
......@@ -495,39 +495,6 @@ include("head.inc");
echo $input;
break;
case "password":
$size = ($pkga['size'] ? " size='{$pkga['size']}' " : "");
$input = "<input " . $size . " id='" . $pkga['fieldname'] . "' type='password' name='" . $pkga['fieldname'] . "' class='formfld pwd' value=\"" . htmlspecialchars($value) . "\" />\n";
$input .= "<br />" . fixup_string($description) . "\n";
echo $input;
break;
case "info":
$input = fixup_string($description) . "\n";
echo $input;
break;
case "select":
$fieldname = $pkga['fieldname'];
if (isset($pkga['multiple'])) {
$multiple = 'multiple="multiple"';
$items = explode(',', $value);
$fieldname .= "[]";
} else {
$multiple = '';
$items = array($value);
}
$size = ($pkga['size'] ? " size='{$pkga['size']}' " : "");
$onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : '');
$input = "<select id='" . $pkga['fieldname'] . "' $multiple $size $onchange name=\"$fieldname\">\n";
foreach ($pkga['options']['option'] as $opt) {
$selected = (in_array($opt['value'], $items) ? 'selected="selected"' : '');
$input .= "\t<option value=\"{$opt['value']}\" {$selected}>{$opt['name']}</option>\n";
}
$input .= "</select>\n<br />\n" . fixup_string($description) . "\n";
echo $input;
break;
case "select_source":
$fieldname = $pkga['fieldname'];
if (isset($pkga['multiple'])) {
......@@ -561,17 +528,6 @@ include("head.inc");
echo $input;
break;
case "vpn_selection" :
$input = "<select id='{$pkga['fieldname']}' name='{$vpn['name']}'>\n";
foreach ($config['ipsec']['phase1'] as $vpn) {
$input .= "\t<option value=\"{$vpn['descr']}\">{$vpn['descr']}</option>\n";
}
$input .= "</select>\n";
$input .= "<br />" . fixup_string($description) . "\n";
echo $input;
break;
case "checkbox":
$checkboxchecked =($value == "on" ? " checked=\"checked\"" : "");
$onchange = (isset($pkga['onchange']) ? "onchange=\"{$pkga['onchange']}\"" : '');
......@@ -582,224 +538,6 @@ include("head.inc");
echo $input;
break;
case "textarea":
if($pkga['rows'])
$rows = " rows='{$pkga['rows']}' ";
if($pkga['cols'])
$cols = " cols='{$pkga['cols']}' ";
if (($pkga['encoding'] == 'base64') && !$get_from_post && !empty($value))
$value = base64_decode($value);
$wrap =($pkga['wrap'] == "off" ? 'wrap="off" style="white-space:nowrap;"' : '');
$input = "<textarea {$rows} {$cols} name='{$pkga['fieldname']}'{$wrap}>{$value}</textarea>\n";
$input .= "<br />" . fixup_string($description) . "\n";
echo $input;
break;
case "aliases":
// Use xml tag <typealiases> to filter type aliases
$size = ($pkga['size'] ? "size=\"{$pkga['size']}\"" : '');
$fieldname = $pkga['fieldname'];
$a_aliases = &$config['aliases']['alias'];
$addrisfirst = 0;
$aliasesaddr = "";
$value = "value='{$value}'";
if(isset($a_aliases)) {
if(!empty($pkga['typealiases'])) {
foreach($a_aliases as $alias)
if($alias['type'] == $pkga['typealiases']) {
if($addrisfirst == 1) $aliasesaddr .= ",";
$aliasesaddr .= "'" . $alias['name'] . "'";
$addrisfirst = 1;
}
} else {
foreach($a_aliases as $alias) {
if($addrisfirst == 1) $aliasesaddr .= ",";
$aliasesaddr .= "'" . $alias['name'] . "'";
$addrisfirst = 1;
}
}
}
$input = "<input name='{$fieldname}' type='text' class='formfldalias' id='{$fieldname}' {$size} {$value} />\n<br />";
$input .= fixup_string($description) . "\n";
$script = "<script type='text/javascript'>\n";
$script .= "//<![CDATA[\n";
$script .= "var aliasarray = new Array({$aliasesaddr})\n";
$script .= "var oTextbox1 = new AutoSuggestControl(document.getElementById('{$fieldname}'), new StateSuggestions(aliasarray))\n";
$script .= "//]]>\n";
$script .= "</script>";
echo $input;
echo $script;
break;
case "interfaces_selection":
$ips=array();
$interface_regex=(isset($pkga['hideinterfaceregex']) ? $pkga['hideinterfaceregex'] : "nointerfacestohide");
if (is_array($config['interfaces']))
foreach ($config['interfaces'] as $iface_key=>$iface_value){
if (isset($iface_value['enable']) && ! preg_match("/$interface_regex/",$iface_key)){
$iface_description=($iface_value['descr'] !="" ? strtoupper($iface_value['descr']) : strtoupper($iface_key));
if (isset($pkga['showips']))
$iface_description .= " address";
$ips[]=array('ip'=> $iface_key, 'description'=> $iface_description);
}
}
if (is_array($config['virtualip']) && isset($pkga['showvirtualips']))
foreach ($config['virtualip']['vip'] as $vip){
if (! preg_match("/$interface_regex/",$vip['interface']))
$vip_description=($vip['descr'] !="" ? " ({$vip['descr']}) " : " ");
switch ($vip['mode']){
case "ipalias":
case "carp":
$ips[]=array( 'ip'=> $vip['subnet'],'description' => "{$vip['subnet']} $vip_description");
break;
case "proxyarp":
if ($vip['type']=="network"){
$start = ip2long32(gen_subnet($vip['subnet'], $vip['subnet_bits']));
$end = ip2long32(gen_subnet_max($vip['subnet'], $vip['subnet_bits']));
$len = $end - $start;
for ($i = 0; $i <= $len; $i++)
$ips[]= array('ip'=>long2ip32($start+$i),'description'=> long2ip32($start+$i)." from {$vip['subnet']}/{$vip['subnet_bits']} {$vip_description}");
}
else{
$ips[]= array('ip'=>$vip['subnet'],'description'=> "{$vip['subnet']} $vip_description");
}
break;
}
}
sort($ips);
if (isset($pkga['showlistenall']))
array_unshift($ips,array('ip'=> 'All', 'description'=> 'Listen on All interfaces/ip addresses '));
if (! preg_match("/$interface_regex/","loopback")){
$iface_description=(isset($pkga['showips']) ? "127.0.0.1 (loopback)" : "loopback");
array_push($ips,array('ip'=> 'lo0', 'description'=> $iface_description));
}
#show interfaces array on gui
$size = ($pkga['size'] ? "size=\"{$pkga['size']}\"" : '');
$multiple = '';
$fieldname = $pkga['fieldname'];
if (isset($pkga['multiple'])) {
$fieldname .= '[]';
$multiple = 'multiple="multiple"';
}
$input = "<select id='{$pkga['fieldname']}' name=\"{$fieldname}\" {$size} {$multiple}>\n";
if(is_array($value))
$values = $value;
else
$values = explode(',', $value);
foreach($ips as $iface){
$selected = (in_array($iface['ip'], $values) ? 'selected="selected"' : '');
$input .= "<option value=\"{$iface['ip']}\" {$selected}>{$iface['description']}</option>\n";
}
$input .= "</select>\n<br />" . fixup_string($description) . "\n";
echo $input;
break;
case "radio":
$input = "<input type='radio' id='{$pkga['fieldname']}' name='{$pkga['fieldname']}' value='{$value}' />";
echo $input;
break;
case "button":
$input = "<input type='submit' id='{$pkga['fieldname']}' name='{$pkga['fieldname']}' class='formbtn' value='{$pkga['fieldname']}' />\n";
if(isset($pkga['placeonbottom']))
$pkg_buttons .= $input;
else
echo $input ."\n<br />" . fixup_string($description) . "\n";
break;
case "rowhelper":
#$rowhelpername=($fields['fieldname'] ? $fields['fieldname'] : "row");
$rowhelpername="row";
?>
<script type="text/javascript">
//<![CDATA[
<?php
$rowcounter = 0;
$fieldcounter = 0;
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
echo "rowname[{$fieldcounter}] = \"{$rowhelper['fieldname']}\";\n";
echo "rowtype[{$fieldcounter}] = \"{$rowhelper['type']}\";\n";
echo "rowsize[{$fieldcounter}] = \"{$rowhelper['size']}\";\n";
$fieldcounter++;
}
?>
//]]>
</script>
<table id="maintable" summary="main table">
<tr id='<?="tr_{$pkga['fieldname']}";?>'>
<?php
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
echo "<td ".domTT_title($rowhelper['description'])."><b>" . fixup_string($rowhelper['fielddescr']) . "</b></td>\n";
}
$rowcounter = 0;
$trc = 0;
//Use assigned $a_pkg or create an empty array to enter loop
if(isset($a_pkg[$id][$rowhelpername]))
$saved_rows=$a_pkg[$id][$rowhelpername];
else
$saved_rows[]=array();
foreach($saved_rows as $row) {
echo "</tr>\n<tr class=\"sortable\" id=\"id_{$rowcounter}\">\n";
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
unset($value);
if($rowhelper['value'] <> "") $value = $rowhelper['value'];
$fieldname = $rowhelper['fieldname'];
// if user is editing a record, load in the data.
if (isset($id) && $a_pkg[$id]) {
$value = $row[$fieldname];
}
$options = "";
$type = $rowhelper['type'];
$description = $rowhelper['description'];
$fieldname = $rowhelper['fieldname'];
if($type == "option")
$options = &$rowhelper['options']['option'];
if($rowhelper['size'])
$size = $rowhelper['size'];
else if ($pkga['size'])
$size = $pkga['size'];
else
$size = "8";
display_row($rowcounter, $value, $fieldname, $type, $rowhelper, $size);
$text = "";
$trc++;
}
$rowcounter++;
echo "<td>";
#echo "<a onclick=\"removeRow(this); return false;\" href=\"#\"><img border=\"0\" src=\"./themes/".$g['theme']."/images/icons/icon_x.gif\" alt=\"remove\" /></a>";
echo "<a class='delete' href=\"#\"><img border='0' src='./themes/{$g['theme']}/images/icons/icon_x.gif' alt='delete' /></a>";
echo "</td>\n";
}
?>
</tr>
<tbody></tbody>
</table>
<!-- <br /><a onclick="javascript:addRowTo('maintable'); return false;" href="#"><img border="0" src="./themes/<?#= $g['theme']; ?>/images/icons/icon_plus.gif" alt="add" /></a>-->
<br /><a class="add" href="#"><img border="0" src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="add" /></a>
<br /><?php if($description != "") echo $description; ?>
<script type="text/javascript">
//<![CDATA[
field_counter_js = <?= $fieldcounter ?>;
rows = <?= $rowcounter ?>;
totalrows = <?php echo $rowcounter; ?>;
loaded = <?php echo $rowcounter; ?>;
//typesel_change();
//]]>
</script>
<?php
break;
}
#check typehint value
if(isset($pkga['typehint']))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment