Пример #1
0
    $reply = new SimpleXMLElement("<reply></reply>");
    $node = $reply->addChild("status", "ERROR");
    $node->addAttribute("error", "The PEAR MDB2 extension is required");
    echo gda_add_hash($init_shared, $reply->asXml());
    session_destroy();
    exit(1);
}
if (!extension_loaded("SimpleXML")) {
    $reply = new SimpleXMLElement("<reply></reply>");
    $node = $reply->addChild("status", "ERROR");
    $node->addAttribute("error", "The SimpleXML extension is required");
    echo gda_add_hash($init_shared, $reply->asXml());
    session_destroy();
    exit(1);
}
$cmdfile = get_command_filename(session_id());
$replyfile = get_reply_filename(session_id());
umask(0);
$mode = 0600;
posix_mkfifo($cmdfile, $mode);
posix_mkfifo($replyfile, $mode);
if (!file_exists($cmdfile) || !file_exists($replyfile)) {
    $reply = new SimpleXMLElement("<reply></reply>");
    $node = $reply->addChild("status", "ERROR");
    $node->addAttribute("error", "Can't create named pipes");
    echo gda_add_hash($init_shared, $reply->asXml());
    @unlink($cmdfile);
    @unlink($replyfile);
    session_destroy();
    exit(1);
}
Пример #2
0
include_once "gda-config.php";
/*
 * REM: no session is started in this script because sessions would serialize the
 * execution of the gda-front.php and gda-worker.php scripts. Only the session ID, transmitted
 * in the URL is used here.
 */
header('Content-type: text/plain; charset=UTF-8');
$datafile = null;
try {
    global $datafile;
    $text = $GLOBALS["HTTP_RAW_POST_DATA"];
    if ($text == "") {
        throw new Exception("Empty command");
    }
    /* Send command */
    $cmdfile = get_command_filename($_GET['PHPSESSID']);
    if (!file_exists($cmdfile)) {
        throw new Exception("Bad setup {$cmdfile}");
    }
    $datafile = tempnam(session_save_path(), "GDACommand");
    //echo "DATAFILE [$datafile]\n"; flush (); ob_flush();
    if (file_put_contents($datafile, $text) == false) {
        throw new Exception("Can't create command file " . $cmdfile);
    }
    if (isset($log)) {
        $log->lwrite("COMMAND: [{$text}]");
    }
    $file = fopen($cmdfile, "w");
    if (fwrite($file, $datafile) == false) {
        // block until there is a reader
        throw new Exception("Can't send command");