global $clientsocket;
fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
+ fflush($clientsocket);
+}
+
+
+//
+// text_to_server() -- sends a block of text to the server. Assumes that
+// the server just sent back a SEND_LISTING response code
+// and is now expecting a 000-terminated series of lines.
+// Set 'convert_to_html' to TRUE to convert the block of
+// text to HTML along the way.
+//
+function text_to_server($thetext, $convert_to_html) {
+
+ // HTML mode
+ if ($convert_to_html) {
+
+ // Strip CR's; we only want the LF's
+ $thetext = trim($thetext, "\r");
+
+ // Replace hard line breaks with <BR>'s
+ $thetext = str_replace("\n", "<BR>\n", $thetext);
+
+ }
+
+ // Either mode ... send it to the server now
+ $this_line = strtok($thetext, "\n");
+ while ($this_line !== FALSE) {
+ $this_line = trim($this_line, "\n\r");
+ if ($this_line == "000") $this_line = "-000" ;
+ serv_puts($this_line);
+ $this_line = strtok("\n");
+ }
+
+ serv_puts("000"); // Tell the server we're done...
+
+ serv_puts("ECHO echo test."); // FIXME
+ echo "Echo test: " . serv_gets() . "<BR>\n" ;
+
}