webservers_exceeded() and check_webservers() functions added to change behaviour...
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 22 May 2011 15:52:35 +0000 (17:52 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 22 May 2011 15:52:35 +0000 (17:52 +0200)
web/Obj/brisk.phh
web/briskin5/index_rd.php
web/index_rd.php

index 8663ca2..67854cf 100644 (file)
@@ -284,6 +284,39 @@ Copyright 2006-2009 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nasta
 <br><b>version '.$G_brisk_version.'</b><br><br>
 Copyright 2006-2009 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>');
 
+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(   "&quot;" );
 
@@ -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");
 
index 0e273a1..75081a7 100644 (file)
@@ -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
index 6c8c5db..2283ec5 100644 (file)
@@ -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