Edit file File name : EnhancedUtils.php Content :<?php /******************************************************************************* * This file is integral part of the project "Enhanced Studio" for SugarCRM. * * "Enhanced Studio" is a project created by: * Dispage - Patrizio Gelosi * Via A. De Gasperi 91 * P. Potenza Picena (MC) - Italy * * (Hereby referred to as "DISPAGE") * * Copyright (c) 2010-2013 DISPAGE. * * The contents of this file are released under the GNU General Public License * version 3 as published by the Free Software Foundation that can be found on * the "LICENSE.txt" file which is integral part of the SUGARCRM(TM) project. If * the file is not present, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * You may not use the present file except in compliance with the License. * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * Dispage" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by Dispage". * ******************************************************************************/ class EnhancedUtils { public $userFunc = 'htmlentities($c)'; public function recursiveMap ($c) { if (is_array($c)) return array_map(array($this, __FUNCTION__), $c); else return eval('return '.$this->userFunc.';'); } public function secureSerialize ($arr) { $this->userFunc = 'htmlentities($c)'; if ($arr) { foreach ($arr as & $v) { $v = $this->recursiveMap($v); } } return serialize(array_filter($arr)); } public function secureUnserialize ($str) { $this->userFunc = 'html_entity_decode($c)'; $arr = unserialize($str); if ($arr) { foreach ($arr as & $v) { $v = $this->recursiveMap($v); } } return $arr; } public function quotEncode ($arr) { $this->userFunc = 'str_replace(array("\'", \'"\', "\t", "\r", "\n"), array("'", """, "	", " ", " "), $c)'; return $this->recursiveMap($arr); } public function jsonEncode ($arr) { $json = getJSONobj(); $res = $json->encode($arr); return $res; } } ?> Save