From 3aece284ede198abf2fb13b643198d9d97b4ecef Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 23 Nov 2003 21:05:34 +0000 Subject: [PATCH] * improved but still wrong --- ctdlphp/ctdlprotocol.php | 26 ++++++++++++++++++++++++++ ctdlphp/postmsg.php | 7 +------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ctdlphp/ctdlprotocol.php b/ctdlphp/ctdlprotocol.php index ff23a05b6..a104d03bb 100644 --- a/ctdlphp/ctdlprotocol.php +++ b/ctdlphp/ctdlprotocol.php @@ -31,6 +31,32 @@ function serv_puts($buf) { } +// +// 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) { + + + $this_line = strtok($thetext, "\n"); + + while ($this_line) { + $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("ECHO echo test."); // FIXME + echo "Echo test: " . serv_gets() . "
\n" ; + +} + + // // Identify ourselves to the Citadel server (do this once after connection) diff --git a/ctdlphp/postmsg.php b/ctdlphp/postmsg.php index 70111a754..778d269d3 100644 --- a/ctdlphp/postmsg.php +++ b/ctdlphp/postmsg.php @@ -10,12 +10,7 @@ echo htmlspecialchars(substr($response, 3)) . '
' ; } else { - echo 'Sending: ' . $_REQUEST["msgtext"] . '
' ; - flush(); - serv_puts($_REQUEST["msgtext"]); - echo 'Sending: 000
' ; - flush(); - serv_puts("000"); + text_to_server($_REQUEST["msgtext"], TRUE); } echo "Message has been posted.
\n" ; -- 2.30.2