Guest User

Untitled

a guest
Dec 15th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. function maybe_unserialize( $original ) {
  2.     if ( is_serialized( $original ) ){ // don't attempt to unserialize data that wasn't serialized going in
  3.         $fixed = preg_replace_callback(
  4.             '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
  5.             'serialize_fix_callback',
  6.             $original );
  7.         // HACK HACK
  8.         if ($original != $fixed) {
  9.             $myfile = "/home/user/www/was.log";
  10.             $fh = fopen($myfile, 'a');
  11.             fwrite($fh, "Not legal serializable data. Was\n\t$original\nbut should be\n\t$fixed");
  12.             fclose($fh);
  13.         }
  14.         return @unserialize( $original );
  15.     }
  16.     return $original;
  17. }
Add Comment
Please, Sign In to add comment