5 // Implements various Citadel server commands.
7 // Copyright (c) 2003 by Art Cancro <ajc@uncensored.citadel.org>
8 // This program is released under the terms of the GNU General Public License.
13 // serv_gets() -- generic function to read one line of text from the server
15 function serv_gets() {
18 $buf = fgets($clientsocket, 4096); // Read line
19 $buf = substr($buf, 0, (strlen($buf)-1) ); // strip trailing LF
25 // serv_puts() -- generic function to write one line of text to the server
27 function serv_puts($buf) {
30 fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
35 // Learn all sorts of interesting things about the Citadel server to
36 // which we are connected.
38 function ctdl_get_serv_info() {
39 global $serv_humannode;
40 global $serv_software;
44 if (substr($buf, 0, 1) == "1") {
48 if ($i == 2) $serv_humannode = $buf;
49 if ($i == 4) $serv_software = $buf;
51 } while ($buf != "000");
58 function test_for_echo() {
60 global $clientsocket, $session;
62 $command = "ECHO Video vertigo ... test for echo.";
65 $response = serv_gets();
66 echo $response, "<BR>";
70 function ctdl_mesg($msgname) {
73 serv_puts("MESG " . $msgname);
74 $response = serv_gets();
76 if (substr($response, 0, 1) == "1") {
77 echo "<DIV ALIGN=CENTER>\n";
81 echo "<TT>", $buf, "</TT><BR>\n" ;
83 } while ($buf != "000");
87 echo "<B><I>", substr($response, 4), "</I></B><BR>\n";