]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/ctdlprotocol.php
* Moved all of the session-management code from ctdlheader.php to
[citadel.git] / ctdlphp / ctdlprotocol.php
index e197952cdf304a64191ebe850effbf5849d56a8a..a15686f3529ed4b6718579e610ea10a8620e4c20 100644 (file)
@@ -108,6 +108,7 @@ function create_new_user($user, $pass) {
 //
 function become_logged_in($server_parms) {
        $_SESSION["logged_in"] = 1;
+       ctdl_goto("_BASEROOM_");
 }
 
 
@@ -123,8 +124,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 +138,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);
 }
 
 
@@ -215,5 +210,79 @@ function ctdl_rwho() {
 }
 
 
+//
+// Goto a room.
+//
+function ctdl_goto($to_where) {
+       
+       serv_puts("GOTO " . $to_where);
+       $response = serv_gets();
+
+       if (substr($response, 0, 1) == "2") {
+               $_SESSION["room"] = strtok(substr($response, 4), "|");
+               return array(TRUE, substr($response, 0, 3));
+       }
+
+       else {
+               return array(FALSE, substr($response, 0, 3));
+       }
+
+}
+
+
+
+//
+// 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;
+
+               if ($thisline["access"] & 8) {
+                       $thisline["hasnewmsgs"] = TRUE;
+               }
+               else {
+                       $thisline["hasnewmsgs"] = FALSE;
+               }
+
+               $num_lines = array_push($all_lines, $thisline);
+       }
+
+       return array($num_lines, $all_lines);
+
+}
+
+
 
 ?>