* Added a room list function to the library
authorArt Cancro <ajc@citadel.org>
Wed, 5 Nov 2003 03:29:12 +0000 (03:29 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 5 Nov 2003 03:29:12 +0000 (03:29 +0000)
* Threw together temporary room list and goto pages to demonstrate

ctdlphp/ChangeLog
ctdlphp/ctdlprotocol.php
ctdlphp/do_login.php
ctdlphp/goto.php [new file with mode: 0644]
ctdlphp/listrooms.php [new file with mode: 0644]
ctdlphp/welcome.php

index 4b918281e31f3e3a015d9007e83527bace29f4b3..d90b7c92604651885e962417f25c5cfd275be59d 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 1.13  2003/11/05 03:29:12  ajc
+ * Added a room list function to the library
+ * Threw together temporary room list and goto pages to demonstrate
+
  Revision 1.12  2003/11/04 19:17:16  ajc
  * Added an initial version of the goto command
 
@@ -53,3 +57,4 @@
 
  Revision 1.1  2003/10/31 03:47:13  ajc
  * Initial CVS import
+
index cebf9f45210a99795eeca50fb6bebb40dae5cb12..0463ad5125e8accb647755c79e0ba2b855889936 100644 (file)
@@ -231,4 +231,51 @@ function ctdl_goto($to_where) {
 
 
 
+//
+// Fetch the list of known rooms.
+//
+function ctdl_knrooms() {
+       global $clientsocket;
+
+       serv_puts("LKRA");
+       $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["name"] = $tok;
+
+               $tok = strtok("|");
+               if ($tok) $thisline["flags"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["floor"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["order"] = $tok;
+               
+               $tok = strtok("|");
+               if ($tok) $thisline["flags2"] = $tok;
+
+               $tok = strtok("|");
+               if ($tok) $thisline["access"] = $tok;
+
+               $num_lines = array_push($all_lines, $thisline);
+       }
+
+       return array($num_lines, $all_lines);
+
+}
+
+
+
 ?>
index cc1429dedc506fc8a26ee1280f2d86f2e07c22af..8a9c2e77bc83c591b87aef5e7f62e6d04b9e7a0f 100644 (file)
@@ -12,13 +12,13 @@ include "ctdlheader.php";
 
 bbs_page_header();
 
-if ($_POST["action"] == "Login") {
+if ($_REQUEST["action"] == "Login") {
        list($retval, $msg) =
-               login_existing_user($_POST["user"], $_POST["pass"]);
+               login_existing_user($_REQUEST["user"], $_REQUEST["pass"]);
 }
-else if ($_POST["action"] == "New User") {
+else if ($_REQUEST["action"] == "New User") {
        list($retval, $msg) =
-               create_new_user($_POST["user"], $_POST["pass"]);
+               create_new_user($_REQUEST["user"], $_REQUEST["pass"]);
 }
 else {
        echo "uuuuhhhhhhhhh....<BR>\n" ;
diff --git a/ctdlphp/goto.php b/ctdlphp/goto.php
new file mode 100644 (file)
index 0000000..64d5f96
--- /dev/null
@@ -0,0 +1,15 @@
+<?PHP
+       include "ctdlheader.php";
+       bbs_page_header();
+
+       ctdl_goto($_REQUEST["towhere"]);
+
+       echo "You are now in: ", htmlspecialchars($_SESSION["room"]) , "<BR>\n";
+?>
+
+<a href="welcome.php">Page One</a><BR>
+<a href="page3.php">Page Three</a><BR>
+
+<?PHP
+       bbs_page_footer();
+?>
diff --git a/ctdlphp/listrooms.php b/ctdlphp/listrooms.php
new file mode 100644 (file)
index 0000000..9920c46
--- /dev/null
@@ -0,0 +1,27 @@
+<?PHP
+       include "ctdlheader.php";
+       bbs_page_header();
+?>
+
+<H1>Known rooms</H1>
+
+<UL>
+
+<?PHP
+       list($num_rooms, $roomlist) = ctdl_knrooms();
+
+       if ($num_rooms > 0) foreach ($roomlist as $x) {
+               echo '<LI><A HREF="goto.php?towhere=' .
+                       urlencode($x["name"]) . '">' .
+                       htmlspecialchars($x["name"]) . "</A></LI>\n" ;
+       }
+?>
+
+</UL>
+
+<a href="welcome.php">Page One</a><BR>
+<a href="page3.php">Page Three</a><BR>
+
+<?PHP
+       bbs_page_footer();
+?>
index 19dc7342830e62d1d2cd263a1a8799ef71cc2bd8..db770c4a88e793f1f1022326f6fc8d6ccc2eeca6 100644 (file)
@@ -20,8 +20,9 @@ lorem, mattis et, interdum eu, bibendum sed, tortor. Mauris eu metus. Fusce
 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="listrooms.php">room list</A><BR>
+<a href="page2.php">Page Two</a><BR>
 <a href="page3.php">Page Three</a><BR>
 
 <?PHP