]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/ctdlprotocol.php
* login changes
[citadel.git] / ctdlphp / ctdlprotocol.php
index 4f0b60e62a80c76fd35eb402b435544532f8e2c1..84ab12541616d1011cdd819908101b64bb52ab7c 100644 (file)
@@ -1,22 +1,52 @@
 <?PHP
 
+function serv_gets() {
+       global $clientsocket;
+
+       $buf = fgets($clientsocket, 4096);              // Read line
+       $buf = substr($buf, 0, (strlen($buf)-1) );      // strip trailing LF
+       return $buf;
+}
+
+function serv_puts($buf) {
+       global $clientsocket;
+       
+       fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
+}
+
+
+
 function test_for_echo() {
 
        global $clientsocket, $session;
 
-       $command = "ECHO Video vertigo ... test for echo.\n";
+       $command = "ECHO Video vertigo ... test for echo.";
 
-       echo "Trying echo ... session name is ", $session, "<BR>\n";
-       flush();
-       echo "Writing...<BR>\n";
-       flush();
-       // fwrite($clientsocket, $command, strlen($command));
-       fwrite($clientsocket, $command);
-       echo "Reading...<BR>\n";
-       flush();
-       $response = fgets($clientsocket, 4096);
+       serv_puts($command);
+       $response = serv_gets();
        echo $response, "<BR>";
        flush();
 }
 
+function ctdl_mesg($msgname) {
+       global $clientsocket;
+
+       serv_puts("MESG " . $msgname);
+       $response = serv_gets();
+       
+       if (substr($response, 0, 1) == "1") {
+               echo "<DIV ALIGN=CENTER>\n";
+               do {
+                       $buf = serv_gets();
+                       if ($buf != "000") {
+                               echo "<TT>", $buf, "</TT><BR>\n" ;
+                       }
+               } while ($buf != "000");
+               echo "</DIV>\n";
+       }
+       else {
+               echo "<B><I>", substr($response, 4), "</I></B><BR>\n";
+       }
+}
+
 ?>