* login changes
authorArt Cancro <ajc@citadel.org>
Fri, 31 Oct 2003 04:54:20 +0000 (04:54 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 31 Oct 2003 04:54:20 +0000 (04:54 +0000)
ctdlphp/ctdlheader.php
ctdlphp/ctdlprotocol.php
ctdlphp/ctdlsession.php
ctdlphp/index.php [deleted file]
ctdlphp/login.php [new file with mode: 0644]
ctdlphp/sessionproxy.php

index 57e78cbad06b6759f0a0a6d1e455d2b16a2db552..0f56075acf9847f4699bfa7446046279c859d20b 100644 (file)
@@ -9,7 +9,8 @@ function bbs_page_header() {
 
        establish_citadel_session();
 
-       echo <<<CITADEL_HEADER_DATA
+
+       echo <<<LITERAL
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
@@ -27,18 +28,13 @@ function bbs_page_header() {
        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();
 }
 
 
index 4f0b60e62a80c76fd35eb402b435544532f8e2c1..84ab12541616d1011cdd819908101b64bb52ab7c 100644 (file)
@@ -1,22 +1,52 @@
 <?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";
+       }
+}
+
 ?>
index 25427420bafb565c18728b175faccf378ab07aa6..2407a8f76601596867a8da193df0213675938d89 100644 (file)
@@ -79,6 +79,7 @@ function ctdl_end_session() {
 
        // Tell the Citadel server to terminate our connection.
        fwrite($clientsocket, "QUIT\n");
+       $response = fgets($clientsocket, 4096);         // IGnore response
        fclose($clientsocket);
        unset($clientsocket);
 
diff --git a/ctdlphp/index.php b/ctdlphp/index.php
deleted file mode 100644 (file)
index 9127a44..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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();
-?>
-
diff --git a/ctdlphp/login.php b/ctdlphp/login.php
new file mode 100644 (file)
index 0000000..a4da890
--- /dev/null
@@ -0,0 +1,15 @@
+<?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();
+?>
+
index d9977a636a44bfe3cf7521607d2eea8829f93d37..ee4703eb63b8052054d3d3f694e9dc568674ff5c 100755 (executable)
@@ -107,9 +107,26 @@ do {
        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);
 
@@ -118,7 +135,7 @@ do {
 } while (true);
 
 socket_close($sock);
-socket_close($ctdlsock);
+fclose($ctdlsock);
 system("/bin/rm -f " . $sockname);
 exit(0);