Ejemplo n.º 1
0
    $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);
}
/* all setup */
Ejemplo n.º 2
0
 //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");
 }
 fclose($file);
 /* wait for reply, and destroy the reading file */
 $text = "";
 $replyfile = get_reply_filename($_GET['PHPSESSID']);
 if (!file_exists($replyfile)) {
     throw new Exception("Bad setup");
 }
 $file = fopen($replyfile, "r");
 $datafile = fread($file, 8192);
 fclose($file);
 //echo "DATAFILE [$datafile]\n"; flush (); ob_flush();
 if (filesize($datafile) == 0) {
     throw new Exception("No reply");
 }
 $file = fopen($datafile, 'rb');
 fpassthru($file);
 if (isset($log)) {
     $tmp = file_get_contents($datafile);
     $log->lwrite("RESPONSE: [{$tmp}]");