Beispiel #1
0
    WriteCommand($socket, 'COMM', NULL, $content);
    $cmd = ReadCommand($socket);
    socket_close($socket);
} catch (Exception $ex) {
    // Give the daemon some time to collect error output
    usleep(500000);
    try {
        $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($socket === false) {
            throw new Exception("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
        }
        $result = @socket_connect($socket, $WEBCONFIG['address'], $WEBCONFIG['port']);
        if ($result === false) {
            throw new Exception("socket_connect() failed.\nReason: ({$result}) " . socket_strerror(socket_last_error($socket)));
        }
        WriteCommand($socket, 'GETERROR', array('clientid' => $_GET['clientid']));
        $cmd = ReadCommand($socket);
        if ($cmd->found) {
            ReturnError('php_error', $cmd->data);
        } else {
            ReturnError('php_error', 'webfrontend comm: ReadCommand failed');
        }
    } catch (Exception $ex) {
        ReturnError('unspecified_error', $ex->getMessage());
    }
}
if (substr($cmd->data, -16) != '"EXEC_COMPLETE";') {
    ReturnError('php_error', $cmd->data);
} else {
    ReturnResult($cmd->data);
}
Beispiel #2
0
function GetIconv()
{
    $r['can'] = HaveFun("iconv");
    $r['result'] = $r[can] == "支持" ? ReturnResult(1) : ReturnResult(0);
    return $r;
}