* Implemented SEND_LISTING mode in the session proxy
authorArt Cancro <ajc@citadel.org>
Sun, 23 Nov 2003 04:39:30 +0000 (04:39 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 23 Nov 2003 04:39:30 +0000 (04:39 +0000)
* Put together a simple 'enter message' loop (doesn't work properly yet)
* Threw in a temporary menu

ctdlphp/ctdlheader.php
ctdlphp/ctdlprotocol.php
ctdlphp/display_enter.php [new file with mode: 0644]
ctdlphp/postmsg.php [new file with mode: 0644]
ctdlphp/sessionproxy.php
ctdlphp/who.php

index 94f14417d70d2ddac477b6aa62abff795f039762..3eaa8a855192604a5980b63868f3599686ebdf54 100644 (file)
@@ -62,7 +62,24 @@ LITERAL;
        echo '<TD>' . $_SESSION["username"] . '</TD>' ;
        echo '<TD>' . $_SESSION["room"] . '</TD>' ;
        echo '<TD ALIGN=RIGHT><A HREF="logout.php">Log out</A></TD>' ;
-       echo '</TR></TABLE><HR>';
+       echo '</TR></TABLE><BR>';
+
+       // Temporary menu
+       if ($_SESSION["logged_in"]) {
+               echo    '<a href="listrooms.php">' .
+                       'room list</A> ' .
+                       '<a href="readmsgs.php?mode=all&count=0">' .
+                       'Read all messages</a> ' .
+                       '<a href="readmsgs.php?mode=new&count=0">' .
+                       'Read new messages</a> ' .
+                       '<a href="display_enter.php">' .
+                       'Enter a message</a> ' .
+                       '<a href="who.php">' .
+                       'Who is online?</a> ' .
+                       '<A HREF="logout.php">' .
+                       'Log out</A><HR>' ;
+       }
+
 }
 
 
index 7770364112ffe252bf9ff5c583a8be43e992a79e..ff23a05b61b3df2e5553c7d117d323ebc60a45e3 100644 (file)
@@ -27,6 +27,7 @@ function serv_puts($buf) {
        global $clientsocket;
        
        fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
+       fflush($clientsocket);
 }
 
 
diff --git a/ctdlphp/display_enter.php b/ctdlphp/display_enter.php
new file mode 100644 (file)
index 0000000..56a9874
--- /dev/null
@@ -0,0 +1,27 @@
+<?PHP
+
+       include "ctdlheader.php";
+       bbs_page_header();
+
+       serv_puts("ENT0 ");
+       $response = serv_gets();
+
+       if (substr($response, 0, 1) != '2') {
+               echo htmlspecialchars(substr($response, 3)) . '<br>' ;
+       }
+       else {
+               echo    '<center>' .
+                       '<form ENCTYPE="multipart/form-data" ' .
+                       'METHOD="POST" ACTION="postmsg.php" NAME="postmsg">' .
+                       '<input TYPE="submit" NAME="sc" VALUE="Save message">'.
+                       '<input TYPE="submit" NAME="sc" VALUE="Cancel">' .
+                       '<br>' .
+                       '<textarea NAME="msgtext" wrap=soft' .
+                       ' ROWS=25 COLS=80 WIDTH=80></textarea><br> '.
+                       '</form>' .
+                       '</center> '
+               ;
+       }
+
+       bbs_page_footer();
+?>
diff --git a/ctdlphp/postmsg.php b/ctdlphp/postmsg.php
new file mode 100644 (file)
index 0000000..70111a7
--- /dev/null
@@ -0,0 +1,24 @@
+<?PHP
+
+       include "ctdlheader.php";
+       bbs_page_header();
+
+       serv_puts("ENT0 1");
+       $response = serv_gets();
+
+       if (substr($response, 0, 1) != '4') {
+               echo htmlspecialchars(substr($response, 3)) . '<br>' ;
+       }
+       else {
+               echo 'Sending: ' . $_REQUEST["msgtext"] . '<BR>' ;
+               flush();
+               serv_puts($_REQUEST["msgtext"]);
+               echo 'Sending: 000<BR>' ;
+               flush();
+               serv_puts("000");
+       }
+
+       echo "Message has been posted.<BR>\n" ;
+
+       bbs_page_footer();
+?>
index ba4a502bc597046bb6f27dce21db2219e72e637f..0ace0b57e037e02f074f9d4ee2475962e135e847 100755 (executable)
@@ -143,6 +143,7 @@ do {
                        }
                        socket_write($msgsock, $talkback, strlen($talkback));
 
+                       // LISTING_FOLLOWS mode
                        if (substr($talkback, 0, 1) == "1") do {
                                $buf = fgets($ctdlsock, 4096);
                                if (!$buf) {
@@ -154,6 +155,20 @@ do {
                                }
                        } while ($buf != "000\n");
 
+                       // SEND_LISTING mode
+                       if (substr($talkback, 0, 1) == "4") do {
+                               $buf = sock_gets($msgsock);
+                               if (!$buf) {
+                                       $buf = "000" ;
+                               }
+                               if (!fwrite($ctdlsock, $buf . "\n")) {
+                                       fclose($ctdlsock);
+                                       socket_close($sock);
+                                       system("/bin/rm -f " . $sockname);
+                                       exit(11);
+                               }
+                       } while ($buf != "000");
+
                }
        } while($buf !== false);
 
index 92d7ccb8dd5332f3d5d7d756eda9ca58d03d4c8f..8f0bf9f3de85ebbcffb004dd72c2bf7f5ebd8690 100644 (file)
@@ -3,15 +3,15 @@
        include "ctdlheader.php";
        bbs_page_header();
 
-       echo "This is an example of the use of ctdl_rwho() to display the " ;
-       echo "list of users currently logged in.<BR><BR>\n" ;
-
-       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>";
+       echo    "This is an example of the use of ctdl_rwho() to display " .
+               "the list of users currently logged in.<BR><BR>\n" ;
+
+       echo    "<TABLE border=1>" .
+               "<TR>" .
+               "<TD><B>User</B></TD>" .
+               "<TD><B>Room</B></TD>" .
+               "<TD><B>Host</B></TD>" .
+               "</TR>" ;
 
        list($num_users, $wholist) = ctdl_rwho();