Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > dca483b59ba61f3fa092de932ddd570e > files > 223

nuface-2.0.14-2mdv2009.1.i586.rpm

<?php
# Copyright(C) 2007 INL
# Written by Victor Stinner <victor.stinner AT inl.fr>
#
# $Id: common.php 17927 2009-02-16 13:16:09Z haypo $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
#  This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

if (version_compare(PHP_VERSION,'5','<'))
{
  print "<h2>";
  print _("You seem to use an outdated version of PHP: PHP 5 or higher is required to run NuFace!");
  print "</h2>";
  exit(0);
}

/* Read current time */
require_once ('nuphp/debug.php');
$nuface_benchmark_start = getmicrotime();

/* Enable compression for browser supporting gzip */
if (array_key_exists('HTTP_ACCEPT_ENCODING', $_SERVER)
    and strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)
{
    ob_start("ob_gzhandler");
}

/* Start session */
require_once ('nuphp/session.php');

require_once ('nuphp/i18n.php');
require_once ('security.php');
require_once ('load_config.php');

/*
 * Load libraries using register_shutdown_function() to make sure that
 * our register_shutdown_function() will be called at the end.
 */
require_once ('nuphp/debug.php');
require_once ('html.php');

$USE_EXIT_NUFACE = true;
function exit_nuface()
{
    global $USE_EXIT_NUFACE;
    if (!$USE_EXIT_NUFACE) {
        return;
    }
    print_console_content();
    echo '</body></html>';
}

function xss_replace_value(&$value)
{
    if (strpos($value, '<') === false and strpos($value, '>') === false)
        return false;

    $value = str_replace('<', '', $value);
    $value = str_replace('>', '', $value);
    return true;
}

function xss_replace()
{
    foreach ($_REQUEST as $key=>$value)
    {
        if (is_array($value)) {
            $fixed = false;
            foreach ($value as $array_key=>$array_value)
            {
                $fixed |= xss_replace_value($value[$array_key]);
            }
        } else {
            $fixed = xss_replace_value($value);
        }
        if (!$fixed) {
            continue;
        }

        $html = sprintf(
                _('HTML characters &lt; and &gt; are forbidden (key "%s")! Remove these characters.'),
                htmlspecialchars($key));
        $_REQUEST[$key] = $value;
        log_error($html);
    }
}

function init_nuface()
{
    global $default_language, $locale_dir;

    /* make sure that exit_nuface() is called at the end */
    if (!array_key_exists('nuface_unittests', $GLOBALS)) {
        register_shutdown_function('exit_nuface');
    }

    /* Initialize internationalization */
    init_i18n($default_language);
    init_gettext('nuface', $locale_dir);

    /* Protect against XSS: Remove "<" and ">" characters */
    xss_replace();
}

init_nuface();

?>