Exemple #1
0
function clean_input_data($str)
{
    if (is_array($str)) {
        $new_array = array();
        foreach ($str as $key => $val) {
            $new_array[clean_input_keys($key)] = clean_input_data($val);
        }
        return $new_array;
    }
    // Standardize newlines
    return preg_replace("/\r\n|\r|\n/", "\n", $str);
}
Exemple #2
0
 function Request()
 {
     if (get_magic_quotes_gpc()) {
         $_REQUEST = stripslashes_deep($_REQUEST);
         $_GET = stripslashes_deep($_GET);
         $_POST = stripslashes_deep($_POST);
         $_COOKIE = stripslashes_deep($_COOKIE);
     }
     foreach (array($_GET, $_POST, $_COOKIE, $_REQUEST) as $global) {
         if (!is_array($global)) {
             global $global;
             ${$global} = NULL;
         } else {
             foreach ($global as $key => $val) {
                 global ${$key};
                 ${$key} = NULL;
                 $global[$key] = clean_input_data($val);
             }
         }
     }
     // Fix for IIS, which doesn't set REQUEST_URI
     if (empty($_SERVER['REQUEST_URI'])) {
         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
         // Does this work under CGI?
         // Append the query string if it exists and isn't null
         if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
             $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
         }
     }
     // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
     if (isset($_SERVER['SCRIPT_FILENAME']) && strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7) {
         $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
     }
     // Fix for Dreamhost and other PHP as CGI hosts
     if (strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) {
         unset($_SERVER['PATH_INFO']);
     }
     // Fix empty PHP_SELF
     $PHP_SELF = $_SERVER['PHP_SELF'];
     if (empty($PHP_SELF)) {
         $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\\?.*)?\$/", '', $_SERVER["REQUEST_URI"]);
     }
     if (isset($_SERVER['HTTP_PC_REMOTE_ADDR'])) {
         $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_PC_REMOTE_ADDR'];
     }
 }