From 04de0e58bd8e0d0de4e317d79611dfdb71180d22 Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Sun, 22 May 2011 17:52:35 +0200 Subject: [PATCH] webservers_exceeded() and check_webservers() functions added to change behaviour of page_streaming --- web/Obj/brisk.phh | 34 ++++++++++++++++++++++++++++++++++ web/briskin5/index_rd.php | 2 +- web/index_rd.php | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 8663ca2..67854cf 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -284,6 +284,39 @@ Copyright 2006-2009 Matteo Nasta
version '.$G_brisk_version.'

Copyright 2006-2009
Matteo Nastasi (aka mop)

'); +function webservers_exceeded() +{ + return(file_exists(PROXY_PATH."/webservers_exceded.flag")); +} + +function check_webservers() +{ + GLOBAL $G_webserver_max; + + $ct = 0; + + $dh = opendir('/proc'); + while (($file = readdir($dh)) !== false) { + if (preg_match('/[0-9]+/', $file)) { + $cmdline = explode("\0", file_get_contents('/proc/'.$file.'/cmdline')); + // echo "xxx".$cmdline[0].$n; + if (strstr('/usr/sbin/apache2', $cmdline[0]) != FALSE) { + // echo "yyy".$cmdline[0].$n; + $ct++; + } + } + } + closedir($dh); + + if ($ct >= $G_webserver_max) { + touch(PROXY_PATH."/webservers_exceded.flag"); + } + else { + unlink(PROXY_PATH."/webservers_exceded.flag"); + } + return ($ct); +} + $escinp_from = array( "\"" ); $escinp_to = array( """ ); @@ -1084,6 +1117,7 @@ class Room { return ($ismod); } + check_webservers(); // FIXME BRISK4: include for each kind of table require_once("${G_base}briskin5/Obj/briskin5.phh"); diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 0e273a1..75081a7 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -328,7 +328,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su step */ -$is_page_streaming = (stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); +$is_page_streaming = (webservers_exceeded() || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past diff --git a/web/index_rd.php b/web/index_rd.php index 6c8c5db..2283ec5 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -380,7 +380,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su step */ -$is_page_streaming = (stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); +$is_page_streaming = (webservers_exceeded() || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past -- 2.17.1