]> code.citadel.org Git - citadel.git/blobdiff - ctdlphp/ctdlprotocol.php
* Removed stray \n
[citadel.git] / ctdlphp / ctdlprotocol.php
index a104d03bbbaea174efe626da4d3d6e8723baf1d2..49aa4e47e3787f53dc178b82e2469595e27a092f 100644 (file)
@@ -40,17 +40,28 @@ function serv_puts($buf) {
 //
 function text_to_server($thetext, $convert_to_html) {
 
+       // HTML mode
+       if ($convert_to_html) {
 
-       $this_line = strtok($thetext, "\n");
+               // 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);
+
+       }
 
-       while ($this_line) {
+       // 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");
+       serv_puts("000");       // Tell the server we're done...
+
        serv_puts("ECHO echo test.");           // FIXME
        echo "Echo test: " . serv_gets() . "<BR>\n" ;