Thứ Hai, 25 tháng 11, 2019

PHP string Serialize Corrector SOLVED

Reason: many string Serialize NOT right format
Solution: check and correction  string. Check many times on internet
Source : from internet. Not remember exactly. So thanks for all

 /*Serialize Corrector*/
 function serialize_corrector($serialized_string){       
        if ( @unserialize($serialized_string) !== true &&  preg_match('/^[aOs]:/', $serialized_string) ) {
             $serialized_string = preg_replace_callback( '/s\:(\d+)\:\"(.*?)\";/s',    function($matches){return 's:'.strlen($matches[2]).':"'.$matches[2].'";'; },   $serialized_string );
        }
        return $serialized_string;
    }

0 nhận xét:

Đăng nhận xét