\n";
// flush();
session_start();
$session = "CtdlSession." . session_id();
// See if there's a Citadel connection proxy open for this session.
// The name of the socket is identical to the name of the
// session, and it's found in the /tmp directory.
$sockname = "/tmp/" . $session . ".socket" ;
// echo "Connecting to ", $sockname, "...
\n";
// flush();
$clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5);
if (!$clientsocket) {
//echo "Socket not present. Firing up a new proxy.
\n";
//flush();
// It ain't there, dude. Open up the proxy. (C version)
//$cmd = "./sessionproxy " . $sockname ;
//exec($cmd);
// It ain't there, dude. Open up the proxy. (PHP version)
$cmd = "./sessionproxy.php " . $sockname .
" /dev/null 2>&1 " .
" 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 & " ;
exec($cmd);
sleep(2);
// Ok, now try again.
// echo "Connecting to ", $sockname, "...
\n";
// flush();
$clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5);
}
if ($clientsocket) {
/*
echo "Connected. Performing echo tests.
\n";
flush();
$cmd = "ECHO test echo string upon connection\n";
fwrite($clientsocket, $cmd);
$response = fgets($clientsocket, 4096);
echo "Response is: ", $response, "
\n";
flush();
$cmd = "ECHO second test for echo\n";
fwrite($clientsocket, $cmd);
$response = fgets($clientsocket, 4096);
echo "Response is: ", $response, "
\n";
flush();
*/
}
else {
echo "ERROR: no Citadel socket!
\n";
flush();
}
}
//
// Clear out both our Citadel session and our PHP session. We're done.
//
function ctdl_end_session() {
global $clientsocket, $session;
// Tell the Citadel server to terminate our connection.
fwrite($clientsocket, "QUIT\n");
fclose($clientsocket);
unset($clientsocket);
// Now clear our PHP session.
unset($session);
session_destroy();
}
?>