* who.php: added
authorArt Cancro <ajc@citadel.org>
Sun, 2 Nov 2003 05:35:11 +0000 (05:35 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 2 Nov 2003 05:35:11 +0000 (05:35 +0000)
* ctdlprotocol.php: worked out a tentative data API using this function.

ctdlphp/ChangeLog
ctdlphp/ctdlprotocol.php
ctdlphp/do_login.php
ctdlphp/login.php
ctdlphp/page2.php
ctdlphp/welcome.php
ctdlphp/who.php [new file with mode: 0644]

index 7e0a956b410fb5a516fb3db4173edba21da2e449..03e0c9552ebbe89057676b1f86724fa36aab0517 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 1.10  2003/11/02 05:35:11  ajc
+ * who.php: added
+ * ctdlprotocol.php: worked out a tentative data API using this function.
+
  Revision 1.9  2003/11/02 04:26:11  ajc
  * Cleaned up the pages in preparation for handing it off to the extremely
    talented developers and webmasters who will soon be working on it.
@@ -41,4 +45,3 @@
 
  Revision 1.1  2003/10/31 03:47:13  ajc
  * Initial CVS import
-
index 2fd38d4f3a16dae766565b65b1bfd3af10d1f0d8..32d0030450e1504604ed78e55d5a955c94ae3927 100644 (file)
@@ -145,12 +145,9 @@ function ctdl_mesg($msgname) {
        
        if (substr($response, 0, 1) == "1") {
                echo "<DIV ALIGN=CENTER>\n";
-               do {
-                       $buf = serv_gets();
-                       if (strcasecmp($buf, "000")) {
-                               echo "<TT>", $buf, "</TT><BR>\n" ;
-                       }
-               } while (strcasecmp($buf, "000"));
+               while (strcmp($buf = serv_gets(), "000")) {
+                       echo "<TT>", $buf, "</TT><BR>\n" ;
+               }
                echo "</DIV>\n";
        }
        else {
@@ -159,4 +156,50 @@ function ctdl_mesg($msgname) {
 }
 
 
+//
+// Fetch the list of users currently logged in.
+//
+function ctdl_rwho() {
+       global $clientsocket;
+
+       serv_puts("RWHO");
+       $response = serv_gets();
+
+       if (substr($response, 0, 1) != "1") {
+               return array(0, NULL);
+       }
+       
+       $all_lines = array();
+       $num_lines = 0;
+
+       while (strcmp($buf = serv_gets(), "000")) {
+
+               $thisline = array();
+
+               $tok = strtok($buf, "|");
+               if ($tok) $thisline["session"] = $tok;
+
+               $tok = strtok("|");
+               if ($tok) $thisline["user"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["room"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["host"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["client"] = $tok;
+
+               // IGnore the rest of the fields for now.
+
+               $num_lines = array_push($all_lines, $thisline);
+       }
+
+       return array($num_lines, $all_lines);
+
+}
+
+
+
 ?>
index 6e09432934095ad1422758143ebff2d8902b6ecc..cc1429dedc506fc8a26ee1280f2d86f2e07c22af 100644 (file)
@@ -31,7 +31,8 @@ if ($retval == FALSE) {
        echo "<a href=\"logout.php\">Log out</A><BR>\n" ;
 }
 else {
-       echo "<A HREF=\"welcome.php\">Logged in.  Click to continue.</a><BR>";
+       echo "<A HREF=\"welcome.php\">Logged in.  ";
+       echo "Click to continue if your browser does not refresh.</a><BR>";
        echo "<meta http-equiv=\"refresh\" content=\"0;url=welcome.php\">\n";
 }
 
index 00f25254e4cb6f3609cdc15da2dfbf747a82c4d6..1a084aae8b9761066387660fba3f78b7b91a0206 100644 (file)
@@ -19,7 +19,7 @@
 
        <table border="0" cellspacing="5" cellpadding="5" BGCOLOR="#EEEEEE">
                <tr><td>User name:</td>
-               <td><input type="text" name="name" maxlength="25"></td></tr>
+               <td><input type="text" name="user" maxlength="25"></td></tr>
                <tr><td>Password:</td>
                <td><input type="password" name="pass" maxlength="20"></td></tr>
 
@@ -36,4 +36,3 @@
 <?PHP
        bbs_page_footer();
 ?>
-
index 3c93e09391ad8fc53f1dfa6ec806eabee85005af..7d690b5158f85b53e88d343678d2cc6e1ba46158 100644 (file)
@@ -24,6 +24,7 @@ faucibus sit amet, magna. In pretium lacus eget mi.</p>
 
 <a href="welcome.php">Page One</a><BR>
 <a href="page3.php">Page Three</a><BR>
+<a href="who.php">Who is online?</a><BR>
 
 <?PHP
        bbs_page_footer();
index 149273349dc5b72f3c0b0f08aea9cbfe3f7aafb7..e1a49cafd554bc14b990ff73f1f53fa8a5fb9973 100644 (file)
@@ -20,6 +20,7 @@ tellus tortor, vehicula at, iaculis vitae, adipiscing quis, sapien. Lorem
 ipsum dolor sit amet, consectetuer adipiscing elit.</p>
 
 <a href="page2.php">Page Two</a><BR>
+<a href="who.php">Who is online?</a><BR>
 <a href="page3.php">Page Three</a><BR>
 
 <?PHP
diff --git a/ctdlphp/who.php b/ctdlphp/who.php
new file mode 100644 (file)
index 0000000..d1f7836
--- /dev/null
@@ -0,0 +1,32 @@
+<?PHP
+       include "ctdlheader.php";
+       bbs_page_header();
+
+
+       echo "<TABLE border=1>";
+       echo "<TR>";
+       echo "<TD><B>User</B></TD>";
+       echo "<TD><B>Room</B></TD>";
+       echo "<TD><B>Host</B></TD>";
+       echo "</TR>";
+
+       list($num_users, $wholist) = ctdl_rwho();
+
+       if ($num_users > 0) foreach ($wholist as $x) {
+               echo "<TR>";
+               echo "<TD>", htmlspecialchars($x["user"]), "</TD>";
+               echo "<TD>", htmlspecialchars($x["room"]), "</TD>";
+               echo "<TD>", htmlspecialchars($x["host"]), "</TD>";
+               echo "</TR>\n";
+       }
+
+       echo "</TABLE>\n";
+
+?>
+
+<a href="welcome.php">Page One</a><BR>
+<a href="page3.php">Page Three</a><BR>
+
+<?PHP
+       bbs_page_footer();
+?>