Skip to content

Instantly share code, notes, and snippets.

@VSeryoga
Created October 21, 2019 05:48
Show Gist options
  • Save VSeryoga/1d3307d2ae843807addd0e8f68384889 to your computer and use it in GitHub Desktop.
Save VSeryoga/1d3307d2ae843807addd0e8f68384889 to your computer and use it in GitHub Desktop.
Восстановление serialize
<?
function serialize_corrector($serialized_string){
// at first, check if "fixing" is really needed at all. After that, security checkup.
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;
}
unserialize( serialize_corrector( $serialized_string ) ) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment