WordPress.org

Make WordPress Core

Ticket #9235: 9235.diff

File 9235.diff, 1.5 KB (added by Denis-de-Bernardy, 9 years ago)
  • wp-settings.php

     
    102102if ( empty($PHP_SELF) )
    103103        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
    104104
     105// Correct comment's ip address with X-Forwarded-For http header if you are behind a proxy or load balancer.
     106// Via http://wordpress.org/extend/plugins/real-ip/
     107if ( function_exists('filter_var') ) {
     108        if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) )
     109                $_SERVER['REMOTE_ADDR'] = filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE);
     110        elseif ( isset($_SERVER['HTTP_X_REAL_IP']) && filter_var($_SERVER['HTTP_X_REAL_IP'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) )
     111                $_SERVER['REMOTE_ADDR'] = filter_var($_SERVER['HTTP_X_REAL_IP'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE);
     112} else {
     113        if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) )
     114                $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
     115        elseif ( isset($_SERVER['HTTP_X_REAL_IP']) )
     116                $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
     117}
     118
     119
    105120if ( version_compare( '4.3', phpversion(), '>' ) ) {
    106121        die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) );
    107122}
     
    683698// Everything is loaded and initialized.
    684699do_action('init');
    685700
    686 ?>
     701?>
     702 No newline at end of file