* Minor code cleanups
authorArt Cancro <ajc@citadel.org>
Mon, 3 Nov 2003 05:32:57 +0000 (05:32 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 3 Nov 2003 05:32:57 +0000 (05:32 +0000)
* ctdl_mesg() now returns ready-to-output HTML to the caller, instead of
  outputting it itself.

ctdlphp/ChangeLog
ctdlphp/ctdlprotocol.php
ctdlphp/login.php
ctdlphp/logout.php
ctdlphp/sessionproxy.php

index 03e0c9552ebbe89057676b1f86724fa36aab0517..017052299fe48c7fe2ff32fc351ee4ff46a2efc6 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 1.11  2003/11/03 05:32:57  ajc
+ * Minor code cleanups
+ * ctdl_mesg() now returns ready-to-output HTML to the caller, instead of
+   outputting it itself.
+
  Revision 1.10  2003/11/02 05:35:11  ajc
  * who.php: added
  * ctdlprotocol.php: worked out a tentative data API using this function.
@@ -45,3 +50,4 @@
 
  Revision 1.1  2003/10/31 03:47:13  ajc
  * Initial CVS import
+
index e197952cdf304a64191ebe850effbf5849d56a8a..45c136e3de8ff1934efbd138c3938ed03a9575a6 100644 (file)
@@ -123,8 +123,12 @@ function ctdl_get_serv_info() {
                $i = 0;
                do {
                        $buf = serv_gets();
+                       if ($i == 1) $_SESSION["serv_nodename"] = $buf;
                        if ($i == 2) $_SESSION["serv_humannode"] = $buf;
+                       if ($i == 3) $_SESSION["serv_fqdn"] = $buf;
                        if ($i == 4) $_SESSION["serv_software"] = $buf;
+                       if ($i == 6) $_SESSION["serv_city"] = $buf;
+                       if ($i == 7) $_SESSION["serv_sysadmin"] = $buf;
                        $i = $i + 1;
                } while (strcasecmp($buf, "000"));
        }
@@ -133,40 +137,30 @@ function ctdl_get_serv_info() {
 
 
 //
-// Temporary function to verify communication with the Citadel server.
-//
-function test_for_echo() {
-       global $clientsocket, $session;
-
-       $command = "ECHO Video vertigo ... test for echo.";
-       serv_puts($command);
-       $response = serv_gets();
-       echo $response, "<BR>";
-       flush();
-}
-
-
-//
-// Display a system banner.
+// Display a system banner.  (Returns completed HTML.)
 // (This is probably temporary because it outputs more or less finalized
 // markup.  For now it's just usable.)
 //
 function ctdl_mesg($msgname) {
        global $clientsocket;
 
+       $msgtext = "<DIV ALIGN=CENTER>\n";
+
        serv_puts("MESG " . $msgname);
        $response = serv_gets();
-       
+
        if (substr($response, 0, 1) == "1") {
-               echo "<DIV ALIGN=CENTER>\n";
                while (strcmp($buf = serv_gets(), "000")) {
-                       echo "<TT>", $buf, "</TT><BR>\n" ;
+                       $msgtext .= "<TT>" . htmlspecialchars($buf)
+                               . "</TT><BR>\n" ;
                }
-               echo "</DIV>\n";
        }
        else {
-               echo "<B><I>", substr($response, 4), "</I></B><BR>\n";
+               $msgtext .= "<B><I>" . substr($response, 4) . "</I></B><BR>\n";
        }
+
+       $msgtext .= "</DIV>\n";
+       return($msgtext);
 }
 
 
index 1a084aae8b9761066387660fba3f78b7b91a0206..cf88c2a4bae50343554dbc0c0386d0dddcd5ca13 100644 (file)
@@ -11,7 +11,7 @@
        include "ctdlheader.php";
        bbs_page_header();
 
-       ctdl_mesg("hello");
+       echo ctdl_mesg("hello");
 ?>
 
        <div align=center>
index 66eb5c8905966bcf0d74b81fc2e32f735e428f55..c338b77c1f0aff306e0371c03bfa974c9eda90d7 100644 (file)
@@ -12,7 +12,7 @@
 
        bbs_page_header();
 
-       ctdl_mesg("goodbye");
+       echo ctdl_mesg("goodbye");
 
        echo "<a href=\"index.php\">Log in again</a><BR>\n" ;
 
index 9f56d18b58b25eb5e4a917c4743070dde9d373b5..986eb2a5219a84a702f9daff22b6214fc162afe9 100755 (executable)
@@ -107,6 +107,9 @@ if (substr($buf, 0, 1) != "2") {
 
 do {
        // Wait for connections, but time out after 15 minutes.
+       // socket_select() is completely b0rken in PHP 4.1, which is why
+       // this program requires PHP 4.3 or newer.
+       //
        if (socket_select($readsock = array($sock),
                        $writesock = NULL,
                        $exceptsock = NULL,