Dream of weaving verification Code does not show resolution

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Once in a dream system for two times, suddenly found uploaded to the server, the verification code can not be displayed.

Went to the internet to find a lot of information, almost all is said permissions and the GD library problem.

However, after trying these methods, the verification code still cannot be displayed.

Later thought of doing a website before encountered a UTF-8 code BOM problem. So went to the Internet to find a section of code, removed the entire Web site file BOM. After the removal of the verification code is really shown.

Try to analyze the reason, probably because the BOM produces a blank line output. Causes the validation code to generate an error, so it cannot be displayed.

Bulk removal of the BOM method: The following code saved as a php file, accessed through the browser.

<?php
Remove the Utf-8 BOMs
by magicbug at gmail dot com

if (Isset ($_get[' dir ')) {//file directory to be removed, no arguments for file current directory.
$basedir =$_get[' dir '];
}else{
$basedir = '. ';
}

$auto = 1;

Checkdir ($basedir);

Function Checkdir ($basedir) {
if ($dh = Opendir ($basedir)) {
   while ($file = Readdir ($DH))!== FAL SE) {
    if ($file!= '. ' && $file!= '. ') {
     if (!is_dir ($basedir.) /". $file)) {
      echo filename: $basedir/
$file". Checkbom ("$basedir/$file"). " <br> ";
    }else{
      $dirname = $basedir. /”.
$file;
      Checkdir ($dirname);
    }
   }
  }
Closedir ($DH);
}
}

function Checkbom ($filename) {
Global $auto;
$contents = file_get_contents ($filename);
$charset [1] = substr ($contents, 0, 1);
$charset [2] = substr ($contents, 1, 1);
$charset [3] = substr ($contents, 2, 1);
if (Ord ($charset [1]) = = 239 && ord ($charset [2]) = = 187 &&
Ord ($charset [3]) = = 191) {
if ($auto = = 1) {
$rest = substr ($contents, 3);
Rewrite ($filename, $rest);
Return ("<font Color=red>bom found,
Automatically removed.</font> ");
else {
Return ("<font Color=red>bom found.
</font> ");
}
}
else return ("BOM not Found.");
}

function rewrite ($filename, $data) {
$filenum = fopen ($filename, "w");
Flock ($filenum, LOCK_EX);
Fwrite ($filenum, $data);
Fclose ($filenum);
}
?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.