array('{', '}', '/', '.', "'", '$', '(', ')', '{--', '--}', '{?', '?}', '%', ';', '[', ']', ':', '--'), // ... and we will replace to. 'to' => array( '{OPEN_ANCHOR2}', '{CLOSE_ANCHOR2}', '{SLASH}', '{DOT}', '{QUOT}', '{DOLLAR}', '{OPEN_ANCHOR}', '{CLOSE_ANCHOR}', '{OPEN_TEMPLATE}', '{CLOSE_TEMPLATE}', '{OPEN_CONFIG}', '{CLOSE_CONFIG}', '{PER}', '{SEMI}', '{OPEN_INDEX}', '{CLOSE_INDEX}', '{DBL_DOT}', '{COMMENT}' ), ); // Characters allowed in URLs // // Note: Do not replace 'to' with 'from' and vise-versa! When you do this all booked URLs will be // rejected because of the {SLASH}, {DOT} and all below listed items inside the URL. $GLOBALS['url_chars'] = array( // Search for these secured characters 'to' => array('{SLASH}', '{DOT}', '{PER}', '{DBL_DOT}', '{COMMENT}'), // Replace with these characters 'from' => array('/', '.', '%', ':', '--') ); // Overworked security part: if (is_array($_GET)) { foreach ($_GET as $seckey => $secvalue) { if (is_array($secvalue)) { // Throw arrays away... unset($_GET[$seckey]); } else { // Only variables are allowed (non-array) but we secure them all! foreach ($GLOBALS['security_chars']['from'] as $key => $char) { // Pass all through $_GET[$seckey] = str_replace($char , $GLOBALS['security_chars']['to'][$key], $_GET[$seckey]); } // END - foreach // Strip all other out $_GET[$seckey] = secureString($_GET[$seckey]); } } // END - foreach } // END - if // Activate caching or transparent compressing when it is not already done 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 $GLOBALS['php_caching'] = 'on'; ob_start(); } else { // Extension not loaded or required function is missing $GLOBALS['php_caching'] = '404'; } } else { // Old PHP version $GLOBALS['php_caching'] = 'old'; } // At last secure the $_SERVER['PHP_SELF'] element $_SERVER['PHP_SELF'] = secureString($_SERVER['PHP_SELF']); // Split it up into path and filename $phpSelfDirectory = dirname($_SERVER['PHP_SELF']); $phpSelfFile = basename($_SERVER['PHP_SELF']); // Check for a .php inside the $phpSelfDirectory... while (ereg('.php', $phpSelfDirectory)) { // Correct the dirname $phpSelfDirectory = substr($phpSelfDirectory, 0, (strpos($phpSelfDirectory, '.php') + 4)); // Rewrite filename... $phpSelfFile = basename($phpSelfDirectory); // ... and dirname $phpSelfDirectory = dirname($phpSelfDirectory); } // END - while // Put both together again and let's pray it is secured now... $_SERVER['PHP_SELF'] = $phpSelfDirectory . '/' . $phpSelfFile; // Remove uneccessary variables unset($phpSelfDirectory); unset($phpSelfFile); // Security system loaded... define('__SECURITY', 1); // [EOF] ?>