1<?php
2/* Configure session cache */
3session_cache_limiter('nocache');
4session_start();
5
6header('Content-type: text/plain; charset=UTF-8');
7
8include_once "gda-utils.php";
9include_once "gda-config.php";
10
11if (! try_include ("MDB2.php") && ! try_include ("PEAR".DIRECTORY_SEPARATOR."MDB2.php")) {
12	$reply = new SimpleXMLElement("<reply></reply>");
13	$node = $reply->addChild ("status", "ERROR");
14	$node->addAttribute ("error", "The PEAR MDB2 extension is required");
15	echo gda_add_hash ($init_shared, $reply->asXml());
16	session_destroy ();
17	exit (1);
18}
19
20if (! extension_loaded ("SimpleXML")) {
21	$reply = new SimpleXMLElement("<reply></reply>");
22	$node = $reply->addChild ("status", "ERROR");
23	$node->addAttribute ("error", "The SimpleXML extension is required");
24	echo gda_add_hash ($init_shared, $reply->asXml());
25	session_destroy ();
26	exit (1);
27}
28
29$cmdfile = get_command_filename (session_id ());
30$replyfile = get_reply_filename (session_id ());
31
32umask(0);
33$mode = 0600;
34posix_mkfifo ($cmdfile, $mode);
35posix_mkfifo ($replyfile, $mode);
36
37if (!file_exists ($cmdfile) ||
38    !file_exists ($replyfile)) {
39	$reply = new SimpleXMLElement("<reply></reply>");
40	$node = $reply->addChild ("status", "ERROR");
41	$node->addAttribute ("error", "Can't create named pipes");
42	echo gda_add_hash ($init_shared, $reply->asXml());
43
44	@unlink ($cmdfile);
45	@unlink ($replyfile);
46	session_destroy ();
47	exit (1);
48}
49
50/* all setup */
51$reply = new SimpleXMLElement("<reply></reply>");
52$reply->addChild ('session', htmlspecialchars(SID));
53$reply->addChild ("status", "OK");
54echo gda_add_hash ($init_shared, $reply->asXml());
55flush ();
56ob_flush ();
57?>
58