Logout button in popup window works but user gets no feedback
-
I put the client disconnect after the html is sent.
It might need some php buffer flushing too but should be ok for now.Thank you for tracing.
-
I see that all you did was move the call to disconnect_client() to after the html code. In our experimentation here that does nothing for solving the LOGOUT button issue that is discussed in the post. As stated in my postings the HTML is making it to the web browser. So… that is not the issue. Running the console in Chrome, for example, shows that the LOGOUT HTML code made it to the browser. The problem is that the browser does not render the code until after the socket is closed by the server. The socket is never closed because ipfw shuts down the connection and from then on all IP packets are dropped. The connection is left hanging and the browser just spins away waiting for a response from the server. The only way we have found to solve the problem is have the calls to ipfw happen in another process which executes after index.php exits and the sever closes the socket.
So... your code change is pretty much a NOP.
Let me know if you need further info.
Take care.
--luis
-
Try adding
ob_flush();
Just before the disconnect, maybe even
ob_flush(); sleep(1);
To see if that makes a difference.
-
I will try it but i doubt it will make any difference. As stated previously I am seeing the HTML code in the browser. When you do this with mozilla the "Disconnected…." mesg actually is displayed. But in all browsers the page just sits there with the rotating wait i am busy signal waiting for the server to close the socket.
ob_flush() just flushes the output buffers. It does not close the socket. So... it doesn't help given that all of the HMTL code with the "Disconnect..." message has already made it the browser. As stated numerous times the problem with web browsers based in webkit is that these browsers will not render the HTML code until the socket is closed. The socket is Never closed properly because the calls to ipfw are done synchronously before the index.php exits. Once the ipfw calls are made the socket becomes unresponsive and all traffic between the client and pfsense are dropped. The as far as the browser is concerned the socket is open and it continues to wait for data which never arrives. Hence the busy wait signal in ** ALL *** the browsers tested to date.
The only solution found so far is to execute the ipfw commands asynchronously after index.php has exited. As stated previously in this thread that works perfectly...
--luis
-
Can you try putting a closing php://output
Either with fclose() or stream_close(). -
I assume you mean as in
fclose(STDOUT);
that might work. I will give that a shot and report back to you.
–luis
-
Hi have tried…
EOD;
fclose("php://stdin");
fclose("php://stdout");
fclose("php://stderr");
disconnect_client($_POST['logout_id']);and
EOD;
fclose("STDIN");
fclose("STDOUT");
fclose("STDERR");
disconnect_client($_POST['logout_id']);And neither work…
so far the only that works for me is the solution listed earlier in the post where the pfctl statements are done in another process.
--luis
-
how about in the case we discover logout action before calling exit just do
register_shutdown_function(disconnect_client, $_POST['logout_id']);
That should do as well.
-
I will give it a try… the 64,000 question is... does php execute the function before or after it closes the descriptors. If it executes the function before closing the descriptors then it will not work...
--luis
-
This does not work…
if ($_POST['logout_id']) {
echo << <eod<br><title>Disconnecting…</title>You have been disconnected.
EOD;
register_shutdown_function(disconnect_client,$_POST['logout_id']);
exit;
–-As stated before the only thing that I have been able to make work is this...
--- index.php 2011-02-06 16:24:13.000000000 +0000
+++ index.php.new 2011-02-06 16:16:27.000000000 +0000
@@ -412,29 +412,7 @@
*/
function disconnect_client($sessionid, $logoutReason = "LOGOUT", $term_cause = 1) {- global $g, $config;
- $cplock = lock('captiveportal');
- /* read database */
- $cpdb = captiveportal_read_db();
- $radiusservers = captiveportal_get_radius_servers();
- /* find entry */
- for ($i = 0; $i < count($cpdb); $i++) {
- if ($cpdb[$i][5] == $sessionid) {
- captiveportal_disconnect($cpdb[$i],$radiusservers, $term_cause);
- captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],$logoutReason);
- unset($cpdb[$i]);
- break;
- }
- }
- /* write database */
- captiveportal_write_db($cpdb);
- unlock($cplock);
- mwexec_bg("/usr/local/captiveportal/captiveportal-disconnect.php $sessionid $logoutReason $term_cause");
}
Where /usr/local/www/captiveportal/captiveportal-disconnect.php contains the following
–-
#!/usr/local/bin/php -f
require_once("functions.inc");
global $g, $config;$sessionid = $argv[1];
$logoutReason = $argv[2];
$term_cause = $argv[3];if ( $argc != 4 || $sessionid == "" || logoutReason == "" || $term_cause == "" )
exit;echo "$sessionid $logoutReason $term_cause";
$cplock = lock('captiveportal');
/* read database */
$cpdb = captiveportal_read_db();$radiusservers = captiveportal_get_radius_servers();
/* find entry */
for ($i = 0; $i < count($cpdb); $i++) {
if ($cpdb[$i][5] == $sessionid) {
captiveportal_disconnect($cpdb[$i],$radiusservers, $term_cause);
captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],$logoutReason);
unset($cpdb[$i]);
break;
}
}/* write database */
captiveportal_write_db($cpdb);unlock($cplock);
?>
–-</eod<br>