r1921 + fix addition of NATv4 rule
authorDenis Ovsienko <infrastation@yandex.ru>
Fri, 9 May 2008 20:11:23 +0000 (20:11 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Fri, 9 May 2008 20:11:23 +0000 (20:11 +0000)
inc/functions.php
inc/ophandlers.php

index 8b4d0d5a2f55b76e85d3b93a31e3d07c0acf5a94..16e83ba342f2c231f06377bfb91f8f52d5f98a6a 100644 (file)
@@ -1058,11 +1058,24 @@ function newPortForwarding($object_id, $localip, $localport, $remoteip, $remotep
        if ( ($remoteport <= 0) or ($remoteport >= 65536) )
                return "$remoteport: invaild port";
 
-        $query =
-                "insert into PortForwarding set object_id='$object_id', localip=INET_ATON('$localip'), remoteip=INET_ATON('$remoteip'), localport='$localport', remoteport='$remoteport', proto='$proto', description='$description'";
-        $result = $dbxlink->exec ($query);
-
-       return '';
+       $result = useInsertBlade
+       (
+               'PortForwarding',
+               array
+               (
+                       'object_id' => $object_id,
+                       'localip' => "INET_ATON('${localip}')",
+                       'remoteip' => "INET_ATON('$remoteip')",
+                       'localport' => $localport,
+                       'remoteport' => $remoteport,
+                       'proto' => "'${proto}'",
+                       'description' => "'${description}'",
+               )
+       );
+       if ($result)
+               return '';
+       else
+               return __FUNCTION__ . ': Failed to insert the rule.';
 }
 
 function deletePortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto)
index 61357ba447b39680b50d9d3028fe76d601b0edea..bc1c29e5d7c65dbfb8bd1fc9a409b936ad966e2b 100644 (file)
@@ -89,22 +89,25 @@ function addPortForwarding ()
        assertIPv4Arg ('localip', __FUNCTION__);
        assertIPv4Arg ('remoteip', __FUNCTION__);
        assertUIntArg ('localport', __FUNCTION__);
-       assertUIntArg ('proto', __FUNCTION__);
+       assertStringArg ('proto', __FUNCTION__);
        assertStringArg ('description', __FUNCTION__, TRUE);
        $object_id = $_REQUEST['object_id'];
-       $localip = $_REQUEST['localip'];
-       $remoteip = $_REQUEST['remoteip'];
-       $localport = $_REQUEST['localport'];
        $remoteport = $_REQUEST['remoteport'];
-       $proto = $_REQUEST['proto'];
-       $description = $_REQUEST['description'];
        if (empty ($remoteport))
                $remoteport = $localport;
 
        $retpage="${root}?page=${pageno}&tab=${tabno}&object_id=$object_id";
 
-
-       $error=newPortForwarding($object_id, $localip, $localport, $remoteip, $remoteport, $proto, $description);
+       $error = newPortForwarding
+       (
+               $object_id,
+               $_REQUEST['localip'],
+               $_REQUEST['localport'],
+               $_REQUEST['remoteip'],
+               $remoteport,
+               $_REQUEST['proto'],
+               $_REQUEST['description']
+       );
 
        if ($error == '')
                return "${retpage}&message=".urlencode('Port forwarding successfully added.');