SyntaxHighlighter. all (); news & nbsp; | & nbsp; Security & nbsp; | & nbsp; Forum & nbsp; | & nbsp; download & nb
/*
Author: Zhujiang zhu_jiang@263.net
Graduated from Beijing Institute of Technology
Work well, huh, don't say it, it's a place that doesn't make me proud.
The fgetss () function provided by the php4.X system is incomplete. HTML tags cannot be filtered out for analysis.
Some situations are ignored. the following code is a self-made cannon in the development process.
The following code can be used to study the fgetss BUG:
$ Fp = fopen ("index.html", "r ");
While (! Feof ($ fp ))
{
$ Ms = fgetss ($ fp );
Printf ($ ms );
}
Fclose ($ fp );
Free
*/
Function mygets ($ myFile)
{
// While (! Feof ($ myFile ))
//{
$ Myline = fgets ($ myFile, 255 );
$ Big = strlen (strstr ($ myline, "> "));
$ Small = strlen (strstr ($ myline, "<"));
If ($ big> $ small) // This sentence is very important. it is useful if there is a line change in the HTML code.
{// If the first line appears is> instead <时有用
$ Myline = strstr ($ myline, "> ");
$ Myline = substr ($ myline, 1 );
}
$ Len = strlen ($ myline );
$ Startskip = false;
$ Outstring = ""; // important!
For ($ I = 1; $ I <= $ len; $ I ++) // remove all HTML code
{
$ A = substr ($ myline, $ i-1, 1 );
Switch ($)
{
Case "<":
$ Startskip = true;
// $ Myline = substr ($ myline, "> ");
// $ Myline = strstr ($ myline, 1 );
Break;
Case "> ":
// $ Myline = substr ($ myline, 1 );
$ Startskip = false;
Break;
Default:
}
If (! $ Startskip & $! = ">") $ Outstring = $ outstring. $;
}
$ Outstring = str_replace ("", "", $ outstring );
// Of course, if you do not want to add anything starting with "&", this is just a filter.
$ Outstring = str_replace ("", "", $ outstring );
$ Outstring = str_replace ("", "", $ outstring); // double quotation marks contain spaces
$ Outstring = str_replace ("", "", $ outstring );
Return $ outstring;
//}
}?>