0

I have an old script that I did not write. I am a beginner PHP coder, so if anyone can help me with this issue. The script works fine in PHP 5.2, but error in 5.4 I am getting this error:

"The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol."

this is just part of the functions.php script, but I think this is the function areas giving me the html header error. If I need to post the entire functions.php script, please tell me.

function standardheader($title,$normalpage=true,$idlang=0) {

    global $CURUSER, $SITENAME, $STYLEPATH, $USERLANG,$time_start, $gzip, $GZIP_ENABLED,$err_msg_install;

    $time_start = get_microtime();

    // default settings for blocks/menu
    if (!isset($GLOBALS["charset"]))
       $GLOBALS["charset"] = "iso-8859-1";

    // controll if client can handle gzip
    if ($GZIP_ENABLED)
        {
         if (stristr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip") && extension_loaded('zlib') && ini_get("zlib.output_compression") == 0)
             {
             if (ini_get('output_handler')!='ob_gzhandler')
                 {
                 ob_start("ob_gzhandler");
                 $gzip='enabled';
                 }
             else
                 {
                 ob_start();
                 $gzip='enabled';
                 }
         }
         else
             {
             ob_start();
             $gzip='disabled';
             }
    }
    else
        $gzip='disabled';

    header("Content-Type: text/html; charset=".$GLOBALS["charset"]);

    if ($title == "")
        $title = unesc($SITENAME);
    else
        $title = unesc($SITENAME) . " - " . htmlspecialchars($title);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title><?php echo $title; ?></title>
<?php
// get user's style
$resheet=mysql_query("SELECT * FROM style where id=".$CURUSER["style"]."");
if (!$resheet)
   {

   $STYLEPATH="./style/base";
   $style="./style/base/torrent.css";
   }
else
    {
        $resstyle=mysql_fetch_array($resheet);
        $STYLEPATH=$resstyle["style_url"];
        $style=$resstyle["style_url"]."/torrent.css";
    }
print("<link rel=\"stylesheet\" href=$style type=\"text/css\" />");
?>
</head>
<body>
<?php

// getting user language
if ($idlang==0)
   $reslang=mysql_query("SELECT * FROM language WHERE id=".$CURUSER["language"]);
else
   $reslang=mysql_query("SELECT * FROM language WHERE id=$idlang");

if (!$reslang)
   {
   $USERLANG="language/english.php";
   }
else
    {
        $rlang=mysql_fetch_array($reslang);
        $USERLANG="".$rlang["language_url"];
    }

clearstatcache();

if (!file_exists($USERLANG))
    {
    err_msg("Error!","Missing Language!");
    print_version();
    print("</body>\n</html>\n");
    die;
}

require_once($USERLANG);

if (!file_exists($style))
    {
    err_msg("Error!","Missing Style!");
    print_version();
    print("</body>\n</html>\n");
    die;
}


if ($normalpage)
   require_once($STYLEPATH."/header.php");

echo $err_msg_install;


}

function err_msg($heading="Error!",$string)
{
 // just in case not found the language
 if (!defined("BACK"))
      define("BACK","Back");

 print("<div align=\"center\"><br /><table border=\"0\" width=\"500\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
 print("<td bgcolor=\"#FFFFFF\" align=\"center\" style=\"border-style: dotted; border-width: 1px\" bordercolor=\"#CC0000\">\n");
 print("<font color=\"#CC0000\"><b>$heading</b><br />$string<br /></font></td>\n");
 print("</tr></table></div><br />\n");
 print("<center><a href=javascript:history.go(-1)>".BACK."</a></center>");
}
hakre
  • 193,403
  • 52
  • 435
  • 836

1 Answers1

0

I got it working by removing the gzip, its not great, but it works

function standardheader($title,$normalpage=true,$idlang=0) {

global $CURUSER, $SITENAME, $STYLEPATH, $USERLANG, $time_start, $gzip, $GZIP_ENABLED, $err_msg_install;

$time_start = get_microtime();

// default settings for blocks/menu
if (!isset($GLOBALS["charset"]))
   $GLOBALS["charset"] = "utf-8";

// controll if client can handle gzip
    $gzip='disabled';

header("Content-Type: text/html; charset=".$GLOBALS["charset"]);

if ($title == "")
    $title = unesc($SITENAME);
else
    $title = unesc($SITENAME) . " - " . htmlsafechars($title);
?>
B3n0n
  • 1
  • http://ge.tt/7YKRGFL1/v/0 its runing here, cloned from https://github.com/Yupy/BtiTracker-1.4.9 all I changed was that part – B3n0n Feb 25 '14 at 00:20
  • ok, but that now just show only the header and footer. So some progress, but the body of the site is missing. – user3348228 Feb 25 '14 at 01:01
  • I got it working, but its a lot to change, allmost every sql instruction, give me a call – B3n0n Feb 25 '14 at 16:11
  • B3nOn, how can I reach you? I have some questions about a project I would like you to join. – user3348228 Feb 27 '14 at 23:19