From 3a8c3971da12623aeb86c67c34fe0b962d672ad9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Jan 2007 16:07:38 +0000 Subject: - use var_export instead of our format_array function [Bug #6748] - fix dumb error in column naming [Bug #6750] - Make sure to catch some special conditions for cpf translation as well as correctly removing/adding default values on language installation/removing [Bug #6752] git-svn-id: file:///svn/phpbb/trunk@6839 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acm/acm_file.php | 48 +++++++---------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'phpBB/includes/acm/acm_file.php') diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index b6af055399..ecc4db8a89 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -71,12 +71,11 @@ class acm } global $phpEx; - $file = "vars = " . $this->format_array($this->vars) . ";\n\n\$this->var_expires = " . $this->format_array($this->var_expires) . "\n?>"; if ($fp = @fopen($this->cache_dir . 'data_global.' . $phpEx, 'wb')) { @flock($fp, LOCK_EX); - fwrite($fp, $file); + fwrite($fp, "vars = " . var_export($this->vars, true) . ";\n\n\$this->var_expires = " . var_export($this->var_expires, true) . "\n?>"); @flock($fp, LOCK_UN); fclose($fp); } @@ -151,7 +150,7 @@ class acm return false; } - include($this->cache_dir . 'data' . $var_name . ".$phpEx"); + include($this->cache_dir . "data{$var_name}.$phpEx"); return (isset($data)) ? $data : false; } else @@ -169,10 +168,10 @@ class acm { global $phpEx; - if ($fp = @fopen($this->cache_dir . 'data' . $var_name . ".$phpEx", 'wb')) + if ($fp = @fopen($this->cache_dir . "data{$var_name}.$phpEx", 'wb')) { @flock($fp, LOCK_EX); - fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$data = unserialize('" . str_replace("'", "\\'", str_replace('\\', '\\\\', serialize($var))) . "');\n?>"); + fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$data = " . var_export($var, true) . ";\n?>"); @flock($fp, LOCK_UN); fclose($fp); } @@ -290,37 +289,6 @@ class acm } } - /** - * Format an array to be stored on filesystem - */ - function format_array($array, $tab = '') - { - $tab .= "\t"; - - $lines = array(); - foreach ($array as $k => $v) - { - if (is_array($v)) - { - $lines[] = "\n{$tab}'$k' => " . $this->format_array($v, $tab); - } - else if (is_int($v)) - { - $lines[] = "\n{$tab}'$k' => $v"; - } - else if (is_bool($v)) - { - $lines[] = "\n{$tab}'$k' => " . (($v) ? 'true' : 'false'); - } - else - { - $lines[] = "\n{$tab}'$k' => '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $v)) . "'"; - } - } - - return 'array(' . implode(',', $lines) . ')'; - } - /** * Load cached sql query */ @@ -368,7 +336,6 @@ class acm { @flock($fp, LOCK_EX); - $lines = array(); $query_id = sizeof($this->sql_rowset); $this->sql_rowset[$query_id] = array(); $this->sql_row_pointer[$query_id] = 0; @@ -376,12 +343,13 @@ class acm while ($row = $db->sql_fetchrow($query_result)) { $this->sql_rowset[$query_id][] = $row; - - $lines[] = "unserialize('" . str_replace("'", "\\'", str_replace('\\', '\\\\', serialize($row))) . "')"; } $db->sql_freeresult($query_result); - fwrite($fp, " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n\n\$this->sql_rowset[\$query_id] = array(" . implode(',', $lines) . ') ?>'); + $file = " " . (time() + $ttl) . ") ? true : false;\nif (\$expired) { return; }\n"; + + fwrite($fp, $file . "\n\$this->sql_rowset[\$query_id] = " . var_export($this->sql_rowset[$query_id], true) . ";\n?>"); @flock($fp, LOCK_UN); fclose($fp); -- cgit v1.2.1