From: Wilfried Göesgens Date: Mon, 28 May 2007 22:01:14 +0000 (+0000) Subject: * experiments on user creation... not yet ready, but maybe helpfull to others. X-Git-Tag: v7.86~3351 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b3ce7e70991dcb568968d653a927633641feffc3 * experiments on user creation... not yet ready, but maybe helpfull to others. --- diff --git a/ctdlphp/ctdlelements.php b/ctdlphp/ctdlelements.php index 8834601c4..e165b71eb 100644 --- a/ctdlphp/ctdlelements.php +++ b/ctdlphp/ctdlelements.php @@ -59,6 +59,25 @@ function display_message($msgnum) { echo '
' ; } +function get_message_partlist($msgnum) { + + // Fetch the message from the server + list($ok, $response, $fields) = ctdl_fetch_message($msgnum); + + // Bail out gracefully if the message isn't there. + if (!$ok) { + echo "Error: " . htmlspecialchars($response) . "
" ; + return false; + } + if (isset($fields['part'])) + { + $parts = explode('|', $fields['part']); + return $parts; + + } + return false; +} + ?> diff --git a/ctdlphp/ctdlheader.php b/ctdlphp/ctdlheader.php index 43c0f335b..d097117e0 100644 --- a/ctdlphp/ctdlheader.php +++ b/ctdlphp/ctdlheader.php @@ -81,6 +81,22 @@ LITERAL; 'Enter msg
' . '' . 'Who is online?
' . + '' . + 'My information
' . + '' . + 'Log out' . + '' ; + echo '' ; diff --git a/ctdlphp/ctdlprotocol.php b/ctdlphp/ctdlprotocol.php index bd619598e..677ad5c00 100644 --- a/ctdlphp/ctdlprotocol.php +++ b/ctdlphp/ctdlprotocol.php @@ -20,14 +20,55 @@ function serv_gets($readblock=FALSE) { $buf = fgets($clientsocket, 4096); // Read line $buf = substr($buf, 0, (strlen($buf)-1) ); // strip trailing LF if (CITADEL_DEBUG_CITPROTO == 1) { - if (!$readblock) printf ("
"); + if (!$readblock) printf ("
\n"); printf($buf); - if (!$readblock) printf ("
"); - else printf ("
"); + if (!$readblock) printf ("\n
\n"); + else printf ("
\n"); } return $buf; } +// +// serv_get_n() -- generic function to read a binary blob from the server +// +function serv_get_n($nBytes) { + global $clientsocket; + + if (CITADEL_DEBUG_CITPROTO == 1) { + printf ("
\n"); + printf("reading ".$nBytes." bytes from server\n"); + printf ("
\n"); + } + $i = 0; + $buf = ""; + $nRead = 0; +// while ($nRead < $nBytes) + { + $buf = fread($clientsocket, $nBytes); +// $buf.=fgetc($clientsocket) | die ("fgetc failed"); +// $buf .= serv_gets(TRUE); +// $tbuf = fgets($clientsocket, $nBytes - $nRead); + if (CITADEL_DEBUG_CITPROTO == 1) { + if (!$buf) printf ("
\n"); + printf($buf); + if (!$buf) printf ("
\n"); + else printf ("
\n"); + } +// $buf .= $tbuf; +// $nRead = strlen ($buf); + + } + + //$buf = fread($clientsocket, $nBytes) | die ("fread failed"); // Read line + if (CITADEL_DEBUG_CITPROTO == 1) { + printf ("
\n"); + printf($buf); + printf ("
\n"); + } + print_r($buf); + return $buf; +} + // // serv_puts() -- generic function to write one line of text to the server // @@ -37,13 +78,14 @@ function serv_puts($buf) { fwrite($clientsocket, $buf . "\n", (strlen($buf)+1) ); fflush($clientsocket); if (CITADEL_DEBUG_CITPROTO == 1) - printf ("
".$buf."
"); + printf ("
".$buf."
\n"); } + function read_array() { $nLines = 0; if (CITADEL_DEBUG_CITPROTO == 1) - printf ("
"); + printf ("
\n"); $buf = serv_gets(TRUE); $ret = array(); while (strcasecmp($buf, "000")){ @@ -52,12 +94,37 @@ function read_array() { $nLines++; } if (CITADEL_DEBUG_CITPROTO == 1){ - echo "read ".$nLines." lines from the server."; - printf ("
"); + echo "read ".$nLines." lines from the server.\n"; + printf ("
\n"); } return $ret; } +function read_binary() { + $nLines = 0; + if (CITADEL_DEBUG_CITPROTO == 1) + printf ("
\n"); + $buf = serv_gets(TRUE); + + if (CITADEL_DEBUG_CITPROTO == 1){ + echo "status line from the server\n"; + } + + $statusline = explode(" ", $buf); + + if ($statusline[0] == 600) + { + $buf = serv_get_n($statusline[1]); + + } + + if (CITADEL_DEBUG_CITPROTO == 1){ + echo "read ".$statusline[1]." bytes from the server.\n"; + printf ("
\n"); + } + return array($statusline, $buf); +} + // @@ -310,6 +377,19 @@ function ctdl_get_serv_info() { } +// +// Learn all sorts of interesting things about the Citadel server to +// which we are connected. +/* http://www.citadel.org/doku.php/documentation:appproto:connection#info.get.server.info */ +// +function ctdl_get_registration_info() { + serv_puts("GREG"); + $reply = read_array(); + print_r($reply); +// die ("didn't understand the reply to the INFO command"); + +} + // // Display a system banner. (Returns completed HTML.) @@ -464,12 +544,11 @@ function ctdl_knrooms() { global $clientsocket; serv_puts("LKRA"); - $results = read_array(); - - if (substr($results[0], 0, 1) != "1") { + $response = serv_gets(); + if (substr($response, 0, 1) != "1") { return array(0, NULL); } - array_shift($results); + $results = read_array(); $all_lines = array(); $num_lines = 0; @@ -505,6 +584,46 @@ function ctdl_knrooms() { } +// +// Fetch the list of known floors. +// +/* http://www.citadel.org/doku.php/documentation:appproto:rooms#lflr.list.all.known.floors */ +function ctdl_knfloors() { + global $clientsocket; + + serv_puts("LFLR"); + $response = serv_gets(); + if (substr($response, 0, 1) != "1") { + return array(0, NULL); + } + + $results = read_array(); + $all_lines = array(); + $num_lines = 0; + + foreach ($results as $result){ + $oneline = array(); + $tokens = explode("|",$result); + + $oneline["id"] = $tokens[0]; + $oneline["name"] = $tokens[1]; + $oneline["nref"] = $tokens[2]; + + if (CITADEL_DEBUG_CITPROTO == 1) + { + echo "
";
+			print_r($oneline);
+			echo "
"; + + } + $num_lines = array_push($all_lines, $oneline); + } + + return array($num_lines, $all_lines); + +} + +/* http://www.citadel.org/doku.php/documentation:appproto:rooms#cflr.create.a.new.floor */ // // Fetch the list of messages in one room. @@ -611,4 +730,18 @@ function ctdl_msg4_from_server() { } + +function downoad_attachment($msgnum, $attindex) +{ + $command = "DLAT ".$msgnum."|".$attindex; + serv_puts($command); + $reply = read_binary(); + + print_r($reply); + return $reply; + +} + + + ?> diff --git a/ctdlphp/ctdlsession.php b/ctdlphp/ctdlsession.php index db56974ef..9dbf0ec22 100644 --- a/ctdlphp/ctdlsession.php +++ b/ctdlphp/ctdlsession.php @@ -71,14 +71,14 @@ function establish_citadel_session() { ctdl_iden($identity); // Identify client ctdl_MessageFormatsPrefered(array("text/html","text/plain")); - if ($_SESSION["username"]) { + if (isset($_SESSION["username"])) { login_existing_user( $_SESSION["username"], $_SESSION["password"] ); } - if ($_SESSION["room"]) { + if (isset($_SESSION["room"])) { ctdl_goto($_SESSION["room"]); } else { diff --git a/ctdlphp/do_login.php b/ctdlphp/do_login.php index cc15c791e..97c87d9f8 100644 --- a/ctdlphp/do_login.php +++ b/ctdlphp/do_login.php @@ -32,7 +32,7 @@ if ($retval == FALSE) { else { echo "Logged in. "; echo "Click to continue if your browser does not refresh.
"; - echo "\n"; + echo "\n"; } bbs_page_footer(); diff --git a/ctdlphp/myinfo.php b/ctdlphp/myinfo.php new file mode 100644 index 000000000..a473318f6 --- /dev/null +++ b/ctdlphp/myinfo.php @@ -0,0 +1,58 @@ +
\n" ; + + echo "" . + "" . + "" . + "" . + "" . + "" ; + + ctdl_goto("My Citadel Config"); + list($num_msgs, $response, $msgs) = ctdl_msgs($_REQUEST["mode"], + $_REQUEST["count"] ); + + echo "num_msgs: " . $num_msgs . "
\n" ; + echo "response: " . htmlspecialchars($response) . "
\n" ; + + if ($num_msgs > 0) foreach ($msgs as $msgnum) { + print_r($msgnum); + $result = get_message_partlist($msgnum); + if (is_array($result) && + ($result[4]=="text/vcard")) + { + $vcard = downoad_attachment($msgnum, $result[2]); + + + } + } + +///phpinfo(); +/// list($num_users, $wholist) = +// ctdl_get_registration_info(); +/* + if ($num_users > 0) foreach ($wholist as $x) { + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } +*/ + echo "
UserRoomHost
", htmlspecialchars($x["user"]), "", htmlspecialchars($x["room"]), "", htmlspecialchars($x["host"]), "
\n"; + +?> + +
Sample links
+Page One
+Page Three
+ + diff --git a/ctdlphp/sessionproxy.php b/ctdlphp/sessionproxy.php index 90e7ca3e3..59b84c0f8 100755 --- a/ctdlphp/sessionproxy.php +++ b/ctdlphp/sessionproxy.php @@ -17,6 +17,7 @@ include "config_ctdlclient.php"; // sock_gets() -- reads one line of text from a socket // +$logfd = function sock_gets($sock) { socket_clear_error($msgsock); $buf = socket_read($sock, 4096, PHP_NORMAL_READ); diff --git a/ctdlphp/sitestyle.css b/ctdlphp/sitestyle.css index 027cef121..73c11ef82 100644 --- a/ctdlphp/sitestyle.css +++ b/ctdlphp/sitestyle.css @@ -107,6 +107,37 @@ body>#Menu {width:8em;} text-indent: 0; } +#demolinks { + position:absolute; + top:200px; + left:20px; + width:8em; + padding:0.5em; + background-color:#eee; + border:1px dashed #999; +/* Again, the ugly brilliant hack. */ + voice-family: "\"}\""; + voice-family:inherit; + width:8em; + } +/* Again, "be nice to Opera 5". */ +body>#demolinks {width:8em;} + +/* For convenience */ +.centered { + text-align: center; + margin-left: auto; + margin-right: auto; + } + +.notebox { + background-color:#eee; + border:1px dashed #999; + margin: 15px; + font-size:small; + text-indent: 0; +} + .ctdldbgRead { color:#ff0000; background-color:#eee;