Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > dca483b59ba61f3fa092de932ddd570e > files > 248

nuface-2.0.14-2mdv2009.1.i586.rpm

<?php
# Copyright(C) 2004-2005 INL
# Written by Eric Leblond <regit@inl.fr>
#            Vincent Deffontaines <gryzor@inl.fr>
#	     Jean Gillaux <jean@inl.fr>
#
# $Id: nat_func.php 17927 2009-02-16 13:16:09Z haypo $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
#  This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

function nat_set_order($dndsort, $elts, &$ch_acl)
{
    $aclorder = $dndsort;
    $acls = $elts;
    if (isset($aclorder))
    {
        $tab=array();
        $tab2=array();
        $hacls=array();
        foreach($acls->elts as $eid => $elt){
            $tid=$elt->ID;
            $tab[$eid]=$elt->ID;
            $tab2[$tid]=$elt->cloneobj();
        }
        $acls2=$acls;
        $done = false;
        foreach (explode('|',$aclorder) as $k => $v) {
            $acltmpx=$tab2[$v];
            $oldid = $acltmpx->ID;
            $acltmp=$acltmpx->cloneobj();
            $acltmp->ID=$k+1; //we don't want 0 as ID
            $hacls[$k+1]=$acltmp;
            if($ch_acl==$oldid && !$done){
                $newid = $acltmp->ID;
                $ch_acl = $newid;
                $done = true;
            }
        }
        $newacls=new obj_set($acls->name, $hacls);
        $acls=$newacls;
        return $acls;

    }
}

function displayNAT($nats, $nat_type)
{
	$nat_type = strtolower($nat_type);

	$items = &$nats->ordered_list_tab();
	echo '<h3>'.strtoupper($nat_type).'</h3>';

	if (!isset($items))
	{
		$items=array();
	}

	$class_dec = 'accept';

	if (count($items)) {
		echo '<ul id="sort' . $nat_type .'" class="sortul">';
		foreach ($items as $id=>$desc)
		{
			$item = $nats->get_elt_by_id($id);
			$src_net = $item->srcnet;
			$dst_net=$item->dstnet;
			$proto=$item->proto;
			$sport=$item->sport;
			$dport=$item->dport;
			$icmptype=$item->icmptype;
			$name = $item->name;
			$idp = sprintf("[%03s]",$id);
			$detail_form='<form action="nat.php" method="post" class="acldetail" onsubmit="natHandle()">'.
				'<input type="hidden" name="nat" value="'.$id.'" />'.
				'<input type="hidden" id="dndSort' . ucfirst($nat_type) . '" name="dndSort' . ucfirst($nat_type) . '" value="" />'.
				'<input type="hidden" name="nat_type" value="' . strtoupper($nat_type) . '" />'.
				'<input type="submit" value="'._('Edit').'" class="input1 '.$class_dec.'" title="'.$class_dec.'"/>'.
				'</form>';

			print " <li id=\"$id\"><div class=\"sort\"  id=\"$id\"><div class=enabled><strong>$idp</strong> $desc</div>";
			print"$detail_form</div></li>\n";
		}
		echo '</ul>';
	}
}


function displaySNAT($snats)
{
	displayNAT($snats,"SNAT");
}

function displayDNAT($dnats)
{
    displayNAT($dnats,"DNAT");
}

function displayPNAT($pnats)
{
    displayNAT($pnats,"PNAT");
}

function displayNatReorderButtons() {
        echo '<form onsubmit="natHandle()" action="nat.php" method="post">'."\n";
        echo '<p><input type="hidden" name="dndSortSnat" value="" />'.
                '<input type="hidden" name="dndSortDnat" value="" />'.
                '<input type="hidden" name="dndSortPnat" value="" />'.
                '<input type="submit" class="submit" value="'._('Save the order').'" />'.
                '&nbsp<input class="inspector" type="button" value="'._('Restore initial order').'" onclick="resetOrder(\'sortsnat\'); resetOrder(\'sortdnat\'); resetOrder(\'sortpnat\');"/>'.
             '</p>'.
             '</form>';
}
?>