/** * This file is part of the PHP_Unserialize package (http://www.phpguru.org/) * * PHP_Unserialize is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * PHP_Unserialize is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PHP_Unserialize; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * © Copyright 2005 Richard Heyes * http://www.phpguru.org/ */ /** * Unserializes a PHP serialized data type. Currently handles: * o Strings * o Integers * o Doubles * o Arrays * o Booleans * o NULL * o Objects * * alert()s will be thrown if the function is passed something it * can't handle or incorrect data. * * @param string input The serialized PHP data * @return mixed The resulting datatype */ function PHP_Unserialize(input) { var result = PHP_Unserialize_(input); return result[0]; } /** * Function which performs the actual unserializing * * @param string input Input to parse */ function PHP_Unserialize_(input) { var length = 0; switch (input.charAt(0)) { /** * Array */ case 'a': length = PHP_Unserialize_GetLength(input); input = input.substr(String(length).length + 4); var arr = new Array(); var key = null; var value = null; for (var i=0; i