The code looks like this:
Copy Code code as follows:
<?php
/**
* Update illegal characters, send error information
*
* @author
* @copyright 2009-06-10
*/
Error_reporting (E_error | e_warning | E_parse);
Set_error_handler (' Displayerrorhandler '); self-defining error
Tuning information
echo "Time:". Date ("Y-m-d h:i:s"). " \ n ";
Data configuration
Public function
function Displayerrorhandler ($error, $error _string, $filename, $line, $symbols)
{
$error _no_arr = Array (1=> ' error ', 2=> ' WARNING ', 4=> ' PARSE ', 8=> ' NOTICE ', 16=> ' core_error ', 32=> ') Core_warning ', 64=> ' compile_error ', 128=> ' compile_warning ', 256=> ' user_error ', 512=> ' USER_WARNING ', 1024=> ' User_notice ', 2047=> ' all ', 2048=> ' STRICT ');
$msg = sprintf ("%s:%s at file%s (%s)", $error _no_arr[$error], $error _string, $filename, $line);
if (In_array ($error, Array (1,2,4)) {
Echo $msg; echo "\ n";
Send information
if ($error ==1| | $error ==2) {
Sendbankmsg ($error _string); Send messages
if (Strpos ($error _string, ' Xml_parse (): Bytes: ')!==false) {
Writefiltefile ($error _string);
}
}
}
}
function Hex2bin ($hexdata) {
$bindata = ';
for ($i =0; $i < strlen ($hexdata); $i + + 2) {
$bindata. = Chr (Hexdec (substr ($hexdata, $i, 2));
}
return $bindata;
}
function Writefiltefile ($error _string)
{
if (Strpos ($error _string, ' Xml_parse (): Bytes: ') ===false| | Strpos ($error _string, ' 0x ') ===false) {
Return
}
Write to File
$filename = ' filtetext.php ';
Include ($filename);
$error _string = Str_replace (' Xml_parse (): Bytes: ', ', $error _string);
$error _string = str_replace (' 0x ', ', $error _string);
$error _text = Hex2bin ($error _string);
$FILTETEXTARR [] = $error _text;
$TEMPARR = Array_unique ($FILTETEXTARR);//Remove Redo
$result = Implode ("', '", $TEMPARR);
$result = "<?php\n\ $filtetextArr = Array ('. $result."); \ N?> ";
FileWrite ($filename, $result, ' W ');
}
function Sendbankmsg ($msg)
{
$timestamp = time ();
$params = "msg=". $msg
." &posttime= ". $timestamp;
$length = strlen ($params);
Create a socket connection
$domain = "www.admin.com"; Socket domain Name
$actionPath = "/action/bank/bankmsg.php"; File path
$fp = Fsockopen ($domain, 80);
To construct the header of a POST request
if ($fp) {
$header = "POST". $actionPath. " Http/1.1\r\n ";
$header. = "Host:". $domain. " \ r \ n ";
$header. = "content-type:application/x-www-form-urlencoded\r\n";
$header. = "Content-length:". $length. " \ r \ n ";
$header. = "connection:close\r\n\r\n";
Add a Post string
$header. = $params. " \ r \ n ";
Send the Post data
Fputs ($fp, $header);
while (!feof ($fp)) {
$line = fgets ($fp, 1024); Removing the header of the request package shows only the return data of the page
if ($inheader && ($line = = "\ n" | | $line = = "\ r \ n")) {
Echo $line;
}
}
Fclose ($FP);
}
}
function FileWrite ($fFileName, $fContent, $fTag = ' W ') {
Ignore_user_abort (TRUE);
$fp = fopen ($fFileName, $fTag);
if (Flock ($FP, lock_ex)) {
Fwrite ($fp, $fContent);
Flock ($FP, lock_un);
}
Fclose ($FP);
Ignore_user_abort (FALSE);
Return
}
?>