* Added a basic read loop ... currently only fetches message numbers
authorArt Cancro <ajc@citadel.org>
Fri, 14 Nov 2003 17:09:04 +0000 (17:09 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 14 Nov 2003 17:09:04 +0000 (17:09 +0000)
ctdlphp/ChangeLog
ctdlphp/ctdlprotocol.php
ctdlphp/goto.php
ctdlphp/readmsgs.php [new file with mode: 0644]

index 4f638b7d2a6203c35e245aac1beefd9b41b7b354..636b2861c385a40b326401fa891d3183bf534460 100644 (file)
@@ -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
-
index 8ed50b9f0095e0dfbfa076392c621ed336b82657..7341f2d1965804894d4fa2c71ee406d5749d10b2 100644 (file)
@@ -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);
+}
+
 
 ?>
index 64d5f96d8bc2fcd3caf193b4fb50d43f7a057afd..61f2bd5fae0acb0a64d263571206e7383669ca08 100644 (file)
@@ -7,6 +7,8 @@
        echo "You are now in: ", htmlspecialchars($_SESSION["room"]) , "<BR>\n";
 ?>
 
+<a href="readmsgs.php?mode=new&count=0">Read new messages</a><BR>
+<a href="readmsgs.php?mode=all&count=0">Read all messages</a><BR>
 <a href="welcome.php">Page One</a><BR>
 <a href="page3.php">Page Three</a><BR>
 
diff --git a/ctdlphp/readmsgs.php b/ctdlphp/readmsgs.php
new file mode 100644 (file)
index 0000000..2c81dd4
--- /dev/null
@@ -0,0 +1,23 @@
+<?PHP
+       include "ctdlheader.php";
+       bbs_page_header();
+
+       list($num_msgs, $response, $msgs) = ctdl_msgs($_REQUEST["mode"],
+                                                       $_REQUEST["count"] );
+
+       echo "num_msgs: " . $num_msgs . "<BR>\n" ;
+       echo "response: " . htmlspecialchars($response) . "<BR>\n" ;
+
+        if ($num_msgs > 0) foreach ($msgs as $msgnum) {
+               echo $msgnum . ", " ;
+       }
+
+?>
+
+<BR>
+<a href="welcome.php">Page One</a><BR>
+<a href="page3.php">Page Three</a><BR>
+
+<?PHP
+       bbs_page_footer();
+?>