]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/sessionproxy.php
* added implementations to the general purpose commands.
[citadel.git] / ctdlphp / sessionproxy.php
index 0ace0b57e037e02f074f9d4ee2475962e135e847..ee919ca99345f70455e1e3ef2d8b4eda611b9354 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php -q
 
 <?php
-
+include "config_ctdlclient.php";
 // $Id$
 //
 // This is the session proxy that binds a unix domain socket to a Citadel
@@ -18,8 +18,9 @@
 // sock_gets() -- reads one line of text from a socket
 // 
 function sock_gets($sock) {
+       socket_clear_error($msgsock);
        $buf = socket_read($sock, 4096, PHP_NORMAL_READ);
-       if ($buf == false) return false;
+       if (socket_last_error($buf)) return false;
 
        if (preg_match("'\n$'s", $buf)) {
                $buf = substr($buf, 0, strpos($buf, "\n"));
@@ -85,8 +86,7 @@ chmod($sockname, 0600);
 
 // We need to get a connection to the Citadel server going now.
 
-$ctdlsock = fsockopen("uncensored.citadel.org", 504, $errno, $errstr, 30);
-//$ctdlsock = fsockopen("/appl/citadel/citadel.socket", 0, $errno, $errstr, 30);
+$ctdlsock = fsockopen(CITADEL_HOSTNAME, CITADEL_TCP_PORTNO, $errno, $errstr, 30);
 if (!$ctdlsock) {
        socket_close ($sock);
        system("/bin/rm -f " . $sockname);
@@ -157,8 +157,9 @@ do {
 
                        // SEND_LISTING mode
                        if (substr($talkback, 0, 1) == "4") do {
+                               socket_clear_error($msgsock);
                                $buf = sock_gets($msgsock);
-                               if (!$buf) {
+                               if (socket_last_error($msgsock)) {
                                        $buf = "000" ;
                                }
                                if (!fwrite($ctdlsock, $buf . "\n")) {