$Log$
+ Revision 1.5 2003/11/01 23:29:04 ajc
+ * Allow the session proxy to time out after 15 minutes.
+ * This program now requires PHP v4.3.0 or newer due to bugs in the socket
+ functions of PHP 4.1. ctdlheader.php now enforces this.
+
Revision 1.4 2003/11/01 06:12:20 ajc
* Got login/logout working. Still need to redirect unloggedin sessions to
a login page.
Revision 1.1 2003/10/31 03:47:13 ajc
* Initial CVS import
+
+
include "ctdlprotocol.php";
function bbs_page_header() {
-
global $session;
+ if(strcmp('4.3.0', phpversion()) > 0) {
+ die("This program requires PHP 4.3.0 or newer.");
+ }
+
establish_citadel_session();
echo <<<LITERAL
system("/bin/rm -f " . $sockname);
$sock = socket_create(AF_UNIX, SOCK_STREAM, 0);
-if ($sock < 0) {
+if (!$sock) {
echo "socket_create() failed: ", socket_strerror($sock), "\n";
system("/bin/rm -f " . $sockname);
exit(2);
}
$ret = socket_bind($sock, $sockname);
-if ($ret < 0) {
+if (!$ret) {
echo "socket_bind() failed: ", socket_strerror($ret), "\n";
system("/bin/rm -f " . $sockname);
exit(3);
}
$ret = socket_listen($sock, 5);
-if ($ret < 0) {
+if (!$ret) {
echo "socket_listen() failed: ", socket_strerror($ret), "\n";
system("/bin/rm -f " . $sockname);
exit(4);
}
do {
+ // Wait for connections, but time out after 15 minutes.
+ if (socket_select($readsock = array($sock),
+ $writesock = NULL,
+ $exceptsock = NULL,
+ 900, 0
+ ) == 0) {
+ // Timing out.
+ socket_close ($sock);
+ system("/bin/rm -f " . $sockname);
+ exit(8);
+ }
+
+ // Ok, there's a valid connection coming in. Accept it.
$msgsock = socket_accept($sock);
if ($msgsock >= 0) do {
$buf = sock_gets($msgsock);
fclose($ctdlsock);
socket_close($sock);
system("/bin/rm -f " . $sockname);
- exit(8);
+ exit(9);
}
$talkback = fgets($ctdlsock, 4096);
if (!$talkback) {
fclose($ctdlsock);
socket_close($sock);
system("/bin/rm -f " . $sockname);
- exit(9);
+ exit(10);
}
socket_write($msgsock, $talkback, strlen($talkback));