* Stabilized the session proxy
[citadel.git] / ctdlphp / ctdlprotocol.php
1 <?PHP
2
3 function serv_gets() {
4         global $clientsocket;
5
6         $buf = fgets($clientsocket, 4096);              // Read line
7         $buf = substr($buf, 0, (strlen($buf)-1) );      // strip trailing LF
8         return $buf;
9 }
10
11 function serv_puts($buf) {
12         global $clientsocket;
13         
14         fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
15 }
16
17
18
19 function test_for_echo() {
20
21         global $clientsocket, $session;
22
23         $command = "ECHO Video vertigo ... test for echo.";
24
25         serv_puts($command);
26         $response = serv_gets();
27         echo $response, "<BR>";
28         flush();
29 }
30
31 function ctdl_mesg($msgname) {
32         global $clientsocket;
33
34         serv_puts("MESG " . $msgname);
35         $response = serv_gets();
36         
37         if (substr($response, 0, 1) == "1") {
38                 echo "<DIV ALIGN=CENTER>\n";
39                 do {
40                         $buf = serv_gets();
41                         if ($buf != "000") {
42                                 echo "<TT>", $buf, "</TT><BR>\n" ;
43                         }
44                 } while ($buf != "000");
45                 echo "</DIV>\n";
46         }
47         else {
48                 echo "<B><I>", substr($response, 4), "</I></B><BR>\n";
49         }
50 }
51
52 ?>