Example #1
0
/**
 * Recursively fixes silly \r\n stuff that some browsers send.
 * Also adds a generic entry for fiends ending in _x or _y to better deal
 * with image inputs.
/**/
function &fix_crlfxy(&$array)
{
    foreach ($array as $key => $val) {
        if (is_array($val)) {
            fix_crlfxy($array[$key]);
        } elseif (is_string($val)) {
            $array[$key] = str_replace("\r\n", "\n", $val);
            // Process any imagemap submissions to make sure we also get the name itself
            if ($key != ($new_key = preg_replace('/_[xy]$/', '', $key))) {
                if (!array_key_exists($new_key, $array)) {
                    $array[$new_key] = true;
                }
            }
        }
    }
    return $array;
}
Example #2
0
// to cleanly reference things like the /js directory from subpaths.
define('root', str_replace('//', '/', dirname($_SERVER['SCRIPT_NAME']) . '/'));
// Several sections of this program require the current hostname
define('hostname', empty($_SERVER['hostname']) ? trim(`hostname`) : $_SERVER['hostname']);
// Load the generic utilities so we have access to stuff like DEBUG()
require_once 'includes/utils.php';
// Load the error trapping and display routines
require_once 'includes/errors.php';
require_once 'includes/errordisplay.php';
// Make sure we're running a new enough version of php
if (substr(phpversion(), 0, 3) < 4.3) {
    trigger_error('You must be running at least php 4.3 to use this program.', FATAL);
}
// Clean up input data
fix_crlfxy($_GET);
fix_crlfxy($_POST);
if (get_magic_quotes_gpc()) {
    fix_magic_quotes($_COOKIE);
    fix_magic_quotes($_ENV);
    fix_magic_quotes($_GET);
    fix_magic_quotes($_POST);
    fix_magic_quotes($_REQUEST);
    fix_magic_quotes($_SERVER);
}
// No MySQL libraries installed in PHP
if (!function_exists('mysql_connect')) {
    $Error = "Please install the MySQL libraries for PHP.\n" . 'The package is usually called something like php-mysql.';
    require_once 'templates/_error.php';
    exit;
}
// No database connection info defined?