コード例 #1
0
function process_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    global $argv;
    $list = parse_opt($argv);
    $exitchar = $sgbl->__var_exit_char;
    $res = new Remote();
    $res->exception = null;
    $res->ddata = "hello";
    $res->message = "hello";
    $total = file_get_contents($list['temp-input-file']);
    @lunlink($list['temp-input-file']);
    $string = explode("\n", $total);
    if (csb($total, "__file::")) {
        ob_end_clean();
        file_server(null, $total);
    } else {
        $reply = process_server_input($total);
        //fprint(unserialize(base64_decode($reply)));
        ob_end_clean();
        print "{$reply}\n{$exitchar}\n";
        flush();
    }
    exit;
}
コード例 #2
0
ファイル: remotelib.php プロジェクト: soar-team/kloxo
function process_single_command($mchildsock, $processfunc)
{
    global $gbl, $sgbl, $login, $ghtml;
    $exitchar = $sgbl->__var_exit_char;
    $total = null;
    while (true) {
        $input = fgets($mchildsock, 10);
        if ($input == null) {
            //fclose($mchildsock);
            break;
        }
        //dprintr($input . "\n");
        $total .= $input;
        if (csa($total, $exitchar)) {
            if (csa($total, "__file::")) {
                $ret = file_server($mchildsock, $total);
            } else {
                if (csa($total, "__master::")) {
                    $out = process_in_master($total);
                    fwrite($mchildsock, $out);
                    fwrite($mchildsock, "\n");
                    fwrite($mchildsock, $exitchar);
                    fwrite($mchildsock, "\n");
                    $ret = true;
                } else {
                    $out = $processfunc($total);
                    fwrite($mchildsock, $out);
                    fwrite($mchildsock, "\n");
                    fwrite($mchildsock, $exitchar);
                    fwrite($mchildsock, "\n");
                    $ret = true;
                }
            }
            // dummy read but only if there was something written to the socket.
            if ($ret) {
                stream_set_timeout($mchildsock, 15);
                fgets($mchildsock, 200);
            }
            //fclose($mchildsock);
            break;
        }
    }
}