1<?php 2/* 3 * e107 website system 4 * 5 * Copyright (C) 2008-2009 e107 Inc (e107.org) 6 * Released under the terms and conditions of the 7 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) 8 * 9 */ 10 11if (!defined('e107_INIT')) { exit; } 12 13/** 14* @DEPRECATED: Allows Storage of arrays without use of serialize functions 15* 16*/ 17class ArrayData { 18 19 20 function __construct() 21 { 22 // DO Not translate - debug info only. 23 24 $log = e107::getAdminLog(); 25 26 if(E107_DEBUG_LEVEL > 0 || e107::getPref('developer')) 27 { 28 $dep = debug_backtrace(false); 29 30 foreach($dep as $d) 31 { 32 $log->addDebug("Deprecated ArrayStorage Class called by ".str_replace(e_ROOT,"",$d['file'])." on line ".$d['line']); 33 } 34 35 $log->save('DEPRECATED',E_LOG_NOTICE,'',false, LOG_TO_ROLLING); 36 37 e107::getMessage()->addDebug("Please remove references to <b>arraystorage_class.php</b> and use e107::serialize() and e107::unserialize() instead."); 38 } 39 } 40 /** 41 * Return a string containg exported array data. 42 * @DEPRECATED use e107::serialize() instead. 43 * @param array $ArrayData array to be stored 44 * @param bool $AddSlashes default true, add slashes for db storage, else false 45 * @return string 46 */ 47 function WriteArray($ArrayData, $AddSlashes = true) { 48 if (!is_array($ArrayData)) { 49 return false; 50 } 51 $Array = var_export($ArrayData, true); 52 if ($AddSlashes == true) { 53 $Array = addslashes($Array); 54 } 55 return $Array; 56 } 57 58 /** 59 * Returns an array from stored array data. 60 * @DEPRECATED use e107::unserialize() instead. 61 * @param string $ArrayData 62 * @return bool|array stored data 63 */ 64 function ReadArray($ArrayData) 65 { 66 if ($ArrayData == ""){ 67 return false; 68 } 69 70 // Saftety mechanism for 0.7 -> 0.8 transition. 71 if(substr($ArrayData,0,2)=='a:' || substr($ArrayData,0,2)=='s:') 72 { 73 $dat = unserialize($ArrayData); 74 $ArrayData = $this->WriteArray($dat,FALSE); 75 } 76 77 78 $data = ""; 79 $ArrayData = '$data = '.trim($ArrayData).';'; 80 @eval($ArrayData); 81 if (!isset($data) || !is_array($data)) 82 { 83 trigger_error("Bad stored array data - <br /><br />".htmlentities($ArrayData), E_USER_ERROR); 84 // return false; 85 } 86 return $data; 87 } 88} 89 90