//
-// Identify this client, and the hostname where the user is, to Citadel.
+// Identify ourselves to the Citadel server (do this once after connection)
//
function ctdl_iden() {
global $clientsocket;
+ // Identify client and hostname
serv_puts("IDEN 0|8|001|PHP web client|" . $_SERVER['REMOTE_ADDR'] );
$buf = serv_gets();
+
+ // Also express our message format preferences
+ serv_puts("MSGP text/html|text/plain");
+ $buf = serv_gets();
}
}
+//
+// Fetch the list of messages in this room.
+// Returns: count, response, message array
+//
+function ctdl_msgs($mode, $count) {
+ global $clientsocket;
+
+ serv_puts("MSGS " . $mode . "|" . $count);
+ $response = serv_gets();
+
+ if (substr($response, 0, 1) != "1") {
+ return array(0, substr($response, 4), NULL);
+ }
+
+ $msgs = array();
+ $num_msgs = 0;
+
+ while (strcmp($buf = serv_gets(), "000")) {
+ $num_msgs = array_push($msgs, $buf);
+ }
+
+ return array($num_msgs, substr($response, 4), $msgs);
+}
+
?>