Ejemplo n.º 1
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:
     $iidx = (int) $index;
     // check to make sure index is valid
     if (isset($next[$node]) && count($next[$node]) >= $iidx) {
         $dest = $next[$node][$iidx];
     } else {
         $dest = NULL;
     }
Ejemplo n.º 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);