2006-12-02 04:36:16 +00:00
|
|
|
<?php
|
|
|
|
/*
|
2009-11-17 10:46:35 +00:00
|
|
|
* e107 website system
|
|
|
|
*
|
2009-11-18 01:06:08 +00:00
|
|
|
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
2009-11-17 10:46:35 +00:00
|
|
|
* Released under the terms and conditions of the
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
*
|
|
|
|
*/
|
2006-12-02 04:36:16 +00:00
|
|
|
|
|
|
|
if (!defined('e107_INIT')) { exit; }
|
|
|
|
|
|
|
|
/**
|
2013-05-15 16:07:10 -07:00
|
|
|
* @DEPRECATED: Allows Storage of arrays without use of serialize functions
|
2006-12-02 04:36:16 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class ArrayData {
|
|
|
|
|
2013-02-26 19:12:17 -08:00
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
// DO Not translate - debug info only.
|
2013-05-12 20:56:35 -07:00
|
|
|
|
|
|
|
$log = e107::getAdminLog();
|
2013-02-26 19:53:49 -08:00
|
|
|
|
2014-01-10 09:32:14 -08:00
|
|
|
if(E107_DEBUG_LEVEL > 0 || e107::getPref('developer'))
|
2013-02-26 19:53:49 -08:00
|
|
|
{
|
2014-01-10 09:32:14 -08:00
|
|
|
$dep = debug_backtrace(false);
|
|
|
|
|
2013-02-26 19:53:49 -08:00
|
|
|
foreach($dep as $d)
|
|
|
|
{
|
2013-05-12 20:56:35 -07:00
|
|
|
$log->addDebug("Deprecated ArrayStorage Class called by ".str_replace(e_ROOT,"",$d['file'])." on line ".$d['line']);
|
2013-02-26 19:53:49 -08:00
|
|
|
}
|
2013-05-12 20:56:35 -07:00
|
|
|
|
2015-03-08 11:12:42 -07:00
|
|
|
$log->save('DEPRECATED',E_LOG_NOTICE,'',false, LOG_TO_ROLLING);
|
2013-05-12 20:56:35 -07:00
|
|
|
|
2014-01-10 09:32:14 -08:00
|
|
|
e107::getMessage()->addDebug("Please remove references to <b>arraystorage_class.php</b> and use e107::serialize() and e107::unserialize() instead.");
|
2013-02-26 19:53:49 -08:00
|
|
|
}
|
2013-02-26 19:12:17 -08:00
|
|
|
}
|
2006-12-02 04:36:16 +00:00
|
|
|
/**
|
|
|
|
* Return a string containg exported array data.
|
2013-05-12 20:56:35 -07:00
|
|
|
* @DEPRECATED use e107::serialize() instead.
|
2006-12-02 04:36:16 +00:00
|
|
|
* @param array $ArrayData array to be stored
|
|
|
|
* @param bool $AddSlashes default true, add slashes for db storage, else false
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function WriteArray($ArrayData, $AddSlashes = true) {
|
|
|
|
if (!is_array($ArrayData)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$Array = var_export($ArrayData, true);
|
|
|
|
if ($AddSlashes == true) {
|
|
|
|
$Array = addslashes($Array);
|
|
|
|
}
|
|
|
|
return $Array;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array from stored array data.
|
2013-05-12 20:56:35 -07:00
|
|
|
* @DEPRECATED use e107::unserialize() instead.
|
2006-12-02 04:36:16 +00:00
|
|
|
* @param string $ArrayData
|
|
|
|
* @return array stored data
|
|
|
|
*/
|
2014-01-10 09:32:14 -08:00
|
|
|
function ReadArray($ArrayData)
|
|
|
|
{
|
2006-12-02 04:36:16 +00:00
|
|
|
if ($ArrayData == ""){
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-22 13:00:37 +00:00
|
|
|
|
|
|
|
// Saftety mechanism for 0.7 -> 0.8 transition.
|
|
|
|
if(substr($ArrayData,0,2)=='a:' || substr($ArrayData,0,2)=='s:')
|
|
|
|
{
|
|
|
|
$dat = unserialize($ArrayData);
|
|
|
|
$ArrayData = $this->WriteArray($dat,FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
$data = "";
|
|
|
|
$ArrayData = '$data = '.trim($ArrayData).';';
|
|
|
|
@eval($ArrayData);
|
|
|
|
if (!isset($data) || !is_array($data)) {
|
|
|
|
trigger_error("Bad stored array data - <br /><br />".htmlentities($ArrayData), E_USER_ERROR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|