Example #1
0
<?php

require_once __DIR__ . '/lib/SSH.php';
require_once __DIR__ . '/lib/Iptables.php';
$ssh = new SSH('192.168.20.127');
$ssh->setUsername('root');
$ssh->setPassword('root');
$iptables = new Iptables($ssh);
$iptables->setOnFly(FALSE);
$flashes = array();
$editDialogDisplayed = FALSE;
$editDialogAction = './index.php';
function buildQueryFromRule(\stdClass $rule, $table, $chain)
{
    $rule = clone $rule;
    $parameters = array();
    $parameters['protocol'] = $rule->protocol;
    $parameters['in'] = $rule->in;
    $parameters['out'] = $rule->out;
    $parameters['source'] = $rule->source;
    $parameters['destination'] = $rule->destination;
    $parameters['target'] = $rule->target;
    if (preg_match('~--(d|s)port ([0-9:]+)~i', $rule->additional, $matches)) {
        $parameters[$matches[1] . 'port'] = $matches[2];
        $rule->additional = str_replace($matches[0], '', $rule->additional);
    }
    $parameters['additional'] = trim($rule->additional);
    $parameters['table'] = $table;
    $parameters['chain'] = $chain;
    return http_build_query($parameters);
}