示例#1
0
    }
    if (isset($array['sport']) && $array['sport']) {
        $rule->additional .= ' --sport ' . $array['sport'];
    }
    $rule->target = isset($array['target']) ? $array['target'] : '';
    return $rule;
}
if (isset($_GET['reload'])) {
    session_start();
    unset($_SESSION[Iptables::$sessionCacheKey]);
    header('Location: index.php');
}
if (isset($_GET['export'])) {
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="iptables-export.conf"');
    echo $iptables->export();
    exit;
}
if (isset($_GET['import'])) {
    if (!isset($_FILES['file']) || $_FILES['file']['error'] == UPLOAD_ERR_NO_FILE) {
        $flashes['danger'][] = 'No file selected';
    } else {
        $content = file_get_contents($_FILES['file']['tmp_name']);
        $output = $iptables->import($content);
        if ($output) {
            $flashes['danger'][] = $output;
        } else {
            $flashes['success'][] = 'File successfully imported';
        }
        header('Location: index.php');
    }