Beispiel #1
0
switch ($node) {
    case 'updip':
        $tmp = str_split($index, 3);
        // strip leading zeros in each array element
        foreach ($tmp as &$val) {
            $val = ltrim($val, '0');
        }
        $ip = implode('.', $tmp);
        if (ValidIpAddress($ip)) {
            $fh->ipaddr = $ip;
        }
        $dest = 'update';
        break;
    case 'updpt':
        $p = ltrim($index, '0');
        if (ValidPort($p)) {
            $fh->port = $p;
        }
        $dest = 'update';
        break;
    case 'updtw':
        $d = ltrim($index, '0');
        if (ValidDuration($d)) {
            $fh->duration = $d;
        }
        $dest = 'update';
        break;
    case 'back':
        $dest = 'mainmenu';
        break;
    default:
Beispiel #2
0
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
<?php 
if ($name) {
    $tmp = explode($field_delim, $txt, 5);
    $command = strtoupper(ltrim($tmp[0], ' '));
    $ipaddr = $tmp[1];
    $port = $tmp[2];
    $duration = $tmp[3];
    if (count($tmp) == 5) {
        $confirm = strtoupper($tmp[4]);
    }
    // sanity check arguments before use
    if (ValidCommand($command) && ValidIpAddress($ipaddr) && ValidPort($port) && ValidDuration($duration)) {
        switch ($command) {
            case 'O':
                $output = shell_exec("sudo /usr/local/bin/iptables_wrapper_script.sh -a {$ipaddr} {$port} {$duration} ");
                $msg = "open {$ipaddr}:{$port} for {$duration} minutes";
                LogAction($mylogsrc, $mylogdst, "{$name} requested to " . $msg);
                break;
            case 'C':
                $output = shell_exec("sudo /usr/local/bin/iptables_wrapper_script.sh -d {$ipaddr} {$port} 0 ");
                $msg = "close {$ipaddr}:{$port}";
                LogAction($mylogsrc, $mylogdst, "{$name} requested to " . $msg);
                break;
            case 'M':
                $output = shell_exec("sudo /usr/local/bin/iptables_wrapper_script.sh -m {$ipaddr} 0 60 ");
                $msg = "allow access to the mpd stream and control port";
                LogAction($mylogsrc, $mylogdst, "{$name} requested to " . $msg);