Does this fix the JS bug and header bug as well?
authorRoland Häder <roland@mxchange.org>
Tue, 26 Aug 2008 13:19:59 +0000 (13:19 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 26 Aug 2008 13:19:59 +0000 (13:19 +0000)
inc/functions.php
inc/libs/security_functions.php

index c59093bd5004e57c7190a10929cc6e1c0099dc23..56d8a184117263c2e6c825eeaa467b27bc550bcb 100644 (file)
@@ -918,6 +918,12 @@ function LOAD_URL($URL, $addUrlData=true) {
        // Compile out URI codes
        $URL = COMPILE_CODE($URL);
 
        // Compile out URI codes
        $URL = COMPILE_CODE($URL);
 
+       // Get output buffer
+       $OUTPUT = ob_get_contents();
+
+       // Clear it
+       ob_end_clean();
+
        // Add some data to URL if cookies are not accepted
        if (((!defined('__COOKIES')) || (!__COOKIES)) && ($addUrlData)) $URL = ADD_URL_DATA($URL);
 
        // Add some data to URL if cookies are not accepted
        if (((!defined('__COOKIES')) || (!__COOKIES)) && ($addUrlData)) $URL = ADD_URL_DATA($URL);
 
index 190a369e5abebcde7f3e28004fbfb23aba3a7d41..fbd361ed7c18b712d4b13781ab2aad13a0ec895a 100644 (file)
@@ -32,8 +32,7 @@
  ************************************************************************/
 
 // Some security stuff...
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
@@ -42,7 +41,7 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
  * Function to secure input strings
  *
  * @param      $str    The unsecured string
  * Function to secure input strings
  *
  * @param      $str    The unsecured string
- * @return     $str    A (hopefully) secured string against HTML and other things
+ * @return     $str    A (hopefully) secured string against XSS and other bad things
  */
 function secureString ($str) {
        $str = trim(strip_tags($str));
  */
 function secureString ($str) {
        $str = trim(strip_tags($str));
@@ -57,27 +56,27 @@ if (defined('__SECURITY')) return;
 global $FATAL;
 $FATAL = array();
 
 global $FATAL;
 $FATAL = array();
 
-// Runtime quoting is off now...
-set_magic_quotes_runtime(false);
+// Runtime/GPC quoting is off now...
+@set_magic_quotes_runtime(false);
+@ini_set('magic_quotes_gpc', false); // This may not work on some systems
 
 // Check if important arrays are found and define them if missing
 
 // Check if important arrays are found and define them if missing
-if (!isset($_SERVER))
-{
+if (!isset($_SERVER)) {
        global $_SERVER;
        $_SERVER = $GLOBALS['_SERVER'];
 }
        global $_SERVER;
        $_SERVER = $GLOBALS['_SERVER'];
 }
-if (!isset($_GET))
-{
+
+if (!isset($_GET)) {
        global $_GET;
        $_GET = $GLOBALS['_GET'];
 }
        global $_GET;
        $_GET = $GLOBALS['_GET'];
 }
-if (!isset($_POST))
-{
+
+if (!isset($_POST)) {
        global $_POST;
        $_POST = $GLOBALS['_POST'];
 }
        global $_POST;
        $_POST = $GLOBALS['_POST'];
 }
-if (!isset($_COOKIE))
-{
+
+if (!isset($_COOKIE)) {
        global $_COOKIE;
        $_COOKIE = $GLOBALS['_COOKIE'];
 }
        global $_COOKIE;
        $_COOKIE = $GLOBALS['_COOKIE'];
 }
@@ -124,18 +123,13 @@ $URL_CHARS = array(
 
 // Overworked security part:
 if (is_array($_GET)) {
 
 // Overworked security part:
 if (is_array($_GET)) {
-       foreach ($_GET as $seckey=>$secvalue)
-       {
-               if (is_array($secvalue))
-               {
+       foreach ($_GET as $seckey=>$secvalue) {
+               if (is_array($secvalue)) {
                        // Throw arrays away...
                        unset($_GET[$seckey]);
                        // Throw arrays away...
                        unset($_GET[$seckey]);
-               }
-                else
-               {
+               } else {
                        // Only variables are allowed (non-array) but we secure them all!
                        // Only variables are allowed (non-array) but we secure them all!
-                       foreach ($SEC_CHARS['from'] as $key=>$char)
-                       {
+                       foreach ($SEC_CHARS['from'] as $key=>$char) {
                                // Pass all through
                                $_GET[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_GET[$seckey]);
                        }
                                // Pass all through
                                $_GET[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_GET[$seckey]);
                        }
@@ -146,16 +140,12 @@ if (is_array($_GET)) {
        }
 }
 
        }
 }
 
-if (basename($_SERVER['PHP_SELF']) != "install.php")
-{
+if (basename($_SERVER['PHP_SELF']) != "install.php") {
        // And POST data
        // And POST data
-       foreach ($_POST as $seckey=>$secvalue)
-       {
-               if (!is_array($secvalue))
-               {
+       foreach ($_POST as $seckey=>$secvalue) {
+               if (!is_array($secvalue)) {
                        // Only variables are allowed (non-array) to be secured...
                        // Only variables are allowed (non-array) to be secured...
-                       foreach ($SEC_CHARS['from'] as $key=>$char)
-                       {
+                       foreach ($SEC_CHARS['from'] as $key=>$char) {
                                // Pass all through
                                $_POST[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_POST[$seckey]);
                        }
                                // Pass all through
                                $_POST[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_POST[$seckey]);
                        }
@@ -166,18 +156,13 @@ if (basename($_SERVER['PHP_SELF']) != "install.php")
        }
 
        // ... and finally cookies
        }
 
        // ... and finally cookies
-       foreach ($_COOKIE as $seckey=>$secvalue)
-       {
-               if (is_array($secvalue))
-               {
+       foreach ($_COOKIE as $seckey=>$secvalue) {
+               if (is_array($secvalue)) {
                        // Throw arrays away...
                        unset($_COOKIE[$seckey]);
                        // Throw arrays away...
                        unset($_COOKIE[$seckey]);
-               }
-                else
-               {
+               } else {
                        // Only variables are allowed (non-array) but we secure them all!
                        // Only variables are allowed (non-array) but we secure them all!
-                       foreach ($SEC_CHARS['from'] as $key=>$char)
-                       {
+                       foreach ($SEC_CHARS['from'] as $key=>$char) {
                                // Pass all through
                                $_COOKIE[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_COOKIE[$seckey]);
                        }
                                // Pass all through
                                $_COOKIE[$seckey] = str_replace($char  , $SEC_CHARS['to'][$key], $_COOKIE[$seckey]);
                        }
@@ -189,24 +174,17 @@ if (basename($_SERVER['PHP_SELF']) != "install.php")
 }
 
 // Activate caching or transparent compressing when it is not already done
 }
 
 // Activate caching or transparent compressing when it is not already done
-if (!defined('_OB_CACHING'))
-{
-       if (phpversion() >= '4.0.4pl1' && (strstr(getenv('HTTP_USER_AGENT'),'compatible') || (strstr(getenv('HTTP_USER_AGENT'), "Mozilla"))))
-       {
-               if ((extension_loaded('zlib')) && (function_exists('ob_start')))
-               {
+if (!defined('_OB_CACHING')) {
+       if (phpversion() >= '4.0.4pl1' && (strstr(getenv('HTTP_USER_AGENT'),'compatible') || (strstr(getenv('HTTP_USER_AGENT'), "Mozilla")))) {
+               if ((extension_loaded('zlib')) && (function_exists('ob_start'))) {
                        // Start caching
                        define('_OB_CACHING', "on");
                        ob_start();
                        // Start caching
                        define('_OB_CACHING', "on");
                        ob_start();
-               }
-                else
-               {
+               } else {
                        // Extension not loaded or required function is missing
                        define('_OB_CACHING', "404");
                }
                        // Extension not loaded or required function is missing
                        define('_OB_CACHING', "404");
                }
-       }
-        else
-       {
+       } else {
                // Old PHP version
                define('_OB_CACHING', "old");
        }
                // Old PHP version
                define('_OB_CACHING', "old");
        }
@@ -220,8 +198,7 @@ $SELF_DIR  = dirname($_SERVER['PHP_SELF']);
 $SELF_FILE = basename($_SERVER['PHP_SELF']);
 
 // Check for a .php inside the $SELF_DIR...
 $SELF_FILE = basename($_SERVER['PHP_SELF']);
 
 // Check for a .php inside the $SELF_DIR...
-while (ereg(".php", $SELF_DIR))
-{
+while (ereg(".php", $SELF_DIR)) {
        // Correct the dirname
        $SELF_DIR = substr($SELF_DIR, 0, (strpos($SELF_DIR, ".php") + 4));
        // Rewrite filename...
        // Correct the dirname
        $SELF_DIR = substr($SELF_DIR, 0, (strpos($SELF_DIR, ".php") + 4));
        // Rewrite filename...