X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=ctdlphp%2Fctdlsession.php;h=c9614c753ef57d2b24ee068d67e2d4eed051f4ca;hb=fa2dd842abb5feedea3e2253255722fcaecc3c6f;hp=996975d7a6d6b2b62d78cf6dd89f39d50d1bd762;hpb=76672070188977e6ceb44388e59d67a8d5779f52;p=citadel.git diff --git a/ctdlphp/ctdlsession.php b/ctdlphp/ctdlsession.php index 996975d7a..c9614c753 100644 --- a/ctdlphp/ctdlsession.php +++ b/ctdlphp/ctdlsession.php @@ -34,24 +34,42 @@ function establish_citadel_session() { // session, and it's found in the /tmp directory. $sockname = "/tmp/" . $session . ".socket" ; - - $clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5); + $errno = 0; + $errstr = ""; + if (is_array(stat($sockname))) + $clientsocket = fsockopen(SOCKET_PREFIX.$sockname, 0, $errno, $errstr, 5); + else + $clientsocket = false; +//// TODO: if we get connection refused... + echo "$socketname - $errno - $errstr"; + if (!$clientsocket) { // It ain't there, dude. Open up the proxy. (C version) //$cmd = "./sessionproxy " . $sockname ; //exec($cmd); // It ain't there, dude. Open up the proxy. (PHP version) + if (CITADEL_DEBUG_PROXY){ + $stdout = '>>/tmp/sessionproxyout.txt '; + } + else{ + $stdout = '>/dev/null '; + } + $cmd = "./sessionproxy.php " . $sockname . - " /dev/null 2>&1 " . + " &1 " . " 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 & " ; exec($cmd); + sleep(1); // Keep attempting connections 10 times per second up to 100 times $attempts = 0; while (!$clientsocket) { usleep(100); - $clientsocket = fsockopen($sockname, 0, $errno, $errstr, 5); + if (is_array(stat($sockname))) + $clientsocket = fsockopen(SOCKET_PREFIX.$sockname, 0, $errno, $errstr, 5); + else + $clientsocket = false; $attempts += 1; if ($attempts > 100) { echo "ERROR: unable to start connection proxy. "; @@ -62,17 +80,23 @@ function establish_citadel_session() { } // At this point we have a good connection to Citadel. - - ctdl_iden(); // Identify client - - if ($_SESSION["username"]) { + $identity=array( + "DevelNr" => '0', + "ClientID" => '8', + "VersionNumber" => '001', + "ClientInfoString" => 'PHP web client|', + "Remote Address" => $_SERVER['REMOTE_ADDR'] ); + + ctdl_iden($identity); // Identify client + ctdl_MessageFormatsPrefered(array("text/html","text/plain")); + if (isset($_SESSION["username"])) { login_existing_user( $_SESSION["username"], $_SESSION["password"] ); } - if ($_SESSION["room"]) { + if (isset($_SESSION["room"])) { ctdl_goto($_SESSION["room"]); } else { @@ -81,7 +105,11 @@ function establish_citadel_session() { } if (!isset($_SESSION["serv_humannode"])) { - ctdl_get_serv_info(); + $server_info = ctdl_get_serv_info(); + // print_r($server_info); + $keys = array_keys($server_info); + foreach ($keys as $key) + $_SESSION[$key] = $server_info[$key]; } // If the user is trying to call up any page other than