establish_citadel_session();
- echo <<<CITADEL_HEADER_DATA
+
+ echo <<<LITERAL
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
link="#0000FF"
vlink="#990066"
alink="#DD0000"
->
-
-Citadel test PHP thing.<BR>
-CITADEL_HEADER_DATA;
-
-echo "Your session ID is ", $session, "<BR>\n";
-echo "Dude, we're in ", `pwd`, "<BR>";
-echo "<A HREF=\"logout.php\">Log out</A><HR>";
-flush();
-test_for_echo();
+LITERAL;
+ echo "Your session ID is ", $session, "<BR>\n";
+ echo "<A HREF=\"logout.php\">Log out</A><HR>";
+ // flush();
+ // test_for_echo();
}
<?PHP
+function serv_gets() {
+ global $clientsocket;
+
+ $buf = fgets($clientsocket, 4096); // Read line
+ $buf = substr($buf, 0, (strlen($buf)-1) ); // strip trailing LF
+ return $buf;
+}
+
+function serv_puts($buf) {
+ global $clientsocket;
+
+ fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) );
+}
+
+
+
function test_for_echo() {
global $clientsocket, $session;
- $command = "ECHO Video vertigo ... test for echo.\n";
+ $command = "ECHO Video vertigo ... test for echo.";
- echo "Trying echo ... session name is ", $session, "<BR>\n";
- flush();
- echo "Writing...<BR>\n";
- flush();
- // fwrite($clientsocket, $command, strlen($command));
- fwrite($clientsocket, $command);
- echo "Reading...<BR>\n";
- flush();
- $response = fgets($clientsocket, 4096);
+ serv_puts($command);
+ $response = serv_gets();
echo $response, "<BR>";
flush();
}
+function ctdl_mesg($msgname) {
+ global $clientsocket;
+
+ serv_puts("MESG " . $msgname);
+ $response = serv_gets();
+
+ if (substr($response, 0, 1) == "1") {
+ echo "<DIV ALIGN=CENTER>\n";
+ do {
+ $buf = serv_gets();
+ if ($buf != "000") {
+ echo "<TT>", $buf, "</TT><BR>\n" ;
+ }
+ } while ($buf != "000");
+ echo "</DIV>\n";
+ }
+ else {
+ echo "<B><I>", substr($response, 4), "</I></B><BR>\n";
+ }
+}
+
?>
// Tell the Citadel server to terminate our connection.
fwrite($clientsocket, "QUIT\n");
+ $response = fgets($clientsocket, 4096); // IGnore response
fclose($clientsocket);
unset($clientsocket);
+++ /dev/null
-<?PHP
- include "ctdlheader.php";
-
- bbs_page_header();
-?>
-
-
-<h1>Page One</h1>
-
-<P>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis consectetuer
-varius ipsum. Cras neque tortor, congue in, faucibus id, ornare vitae, est.
-Vivamus erat. Cras vel erat vitae pede convallis porttitor. Vestibulum
-dictum, arcu in tempus vulputate, leo lorem commodo purus, ut fringilla
-augue urna eget mi. Donec laoreet condimentum est. Vestibulum bibendum.
-Curabitur faucibus, risus vitae porta commodo, felis eros fringilla nibh,
-quis varius lectus ante ac pede. Maecenas eu leo. Phasellus orci. Suspendisse
-elementum ultricies quam. Nulla facilisi. Fusce vel purus at nunc ultrices
-tempor. Nullam laoreet massa ut wisi.</p>
-
-<a href="page2.php">Page Two</a><BR>
-<a href="page3.php">Page Three</a><BR>
-
-<?PHP
- bbs_page_footer();
-?>
-
--- /dev/null
+<?PHP
+ include "ctdlheader.php";
+
+ bbs_page_header();
+
+ ctdl_mesg("hello");
+?>
+
+<a href="page2.php">Page Two</a><BR>
+<a href="page3.php">Page Three</a><BR>
+
+<?PHP
+ bbs_page_footer();
+?>
+
if ($msgsock >= 0) do {
$buf = sock_gets($msgsock);
if ($buf !== false) {
- fwrite($ctdlsock, $buf . "\n", (strlen($buf)+1) );
+ if (!fwrite($ctdlsock, $buf . "\n")) {
+ fclose($ctdlsock);
+ socket_close($sock);
+ system("/bin/rm -f " . $sockname);
+ exit(8);
+ }
$talkback = fgets($ctdlsock, 4096);
+ if (!$talkback) {
+ fclose($ctdlsock);
+ socket_close($sock);
+ system("/bin/rm -f " . $sockname);
+ exit(9);
+ }
socket_write($msgsock, $talkback, strlen($talkback));
+
+ if (substr($talkback, 0, 1) == "1") do {
+ $buf = fgets($ctdlsock, 4096);
+ socket_write($msgsock, $buf, strlen($buf));
+ } while ($buf != "000\n");
+
}
} while($buf !== false);
} while (true);
socket_close($sock);
-socket_close($ctdlsock);
+fclose($ctdlsock);
system("/bin/rm -f " . $sockname);
exit(0);