From 737366a9ee1d0a66622d51598f7d639c9edeb8b8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 14 Nov 2003 17:09:04 +0000 Subject: [PATCH] * Added a basic read loop ... currently only fetches message numbers --- ctdlphp/ChangeLog | 4 +++- ctdlphp/ctdlprotocol.php | 24 ++++++++++++++++++++++++ ctdlphp/goto.php | 2 ++ ctdlphp/readmsgs.php | 23 +++++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 ctdlphp/readmsgs.php diff --git a/ctdlphp/ChangeLog b/ctdlphp/ChangeLog index 4f638b7d2..636b2861c 100644 --- a/ctdlphp/ChangeLog +++ b/ctdlphp/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 1.16 2003/11/14 17:09:04 ajc + * Added a basic read loop ... currently only fetches message numbers + Revision 1.15 2003/11/09 17:53:47 ajc * Moved all of the session-management code from ctdlheader.php to ctdlsession.php, leaving only a single function call. This will @@ -66,4 +69,3 @@ Revision 1.1 2003/10/31 03:47:13 ajc * Initial CVS import - diff --git a/ctdlphp/ctdlprotocol.php b/ctdlphp/ctdlprotocol.php index 8ed50b9f0..7341f2d19 100644 --- a/ctdlphp/ctdlprotocol.php +++ b/ctdlphp/ctdlprotocol.php @@ -305,5 +305,29 @@ function ctdl_knrooms() { } +// +// Fetch the list of messages in this room. +// Returns: count, response, message array +// +function ctdl_msgs($mode, $count) { + global $clientsocket; + + serv_puts("MSGS " . $mode . "|" . $count); + $response = serv_gets(); + + if (substr($response, 0, 1) != "1") { + return array(0, substr($response, 4), NULL); + } + + $msgs = array(); + $num_msgs = 0; + + while (strcmp($buf = serv_gets(), "000")) { + $num_msgs = array_push($msgs, $buf); + } + + return array($num_msgs, substr($response, 4), $msgs); +} + ?> diff --git a/ctdlphp/goto.php b/ctdlphp/goto.php index 64d5f96d8..61f2bd5fa 100644 --- a/ctdlphp/goto.php +++ b/ctdlphp/goto.php @@ -7,6 +7,8 @@ echo "You are now in: ", htmlspecialchars($_SESSION["room"]) , "
\n"; ?> +Read new messages
+Read all messages
Page One
Page Three
diff --git a/ctdlphp/readmsgs.php b/ctdlphp/readmsgs.php new file mode 100644 index 000000000..2c81dd41a --- /dev/null +++ b/ctdlphp/readmsgs.php @@ -0,0 +1,23 @@ +\n" ; + echo "response: " . htmlspecialchars($response) . "
\n" ; + + if ($num_msgs > 0) foreach ($msgs as $msgnum) { + echo $msgnum . ", " ; + } + +?> + +
+Page One
+Page Three
+ + -- 2.30.2