From 81fd2500ea1cc8d28ab06ad0d290c353a33e7bfa Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Thu, 2 Aug 2012 01:33:27 +0200 Subject: [PATCH] Check if the strings array is actually a valid array before attempting to use it. --- class.templater.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/class.templater.php b/class.templater.php index 0af52e6..e7c8a20 100644 --- a/class.templater.php +++ b/class.templater.php @@ -77,10 +77,17 @@ class Templater { if(!is_null($this->tpl)) { - foreach($strings as $key => $str) + if(is_array($strings)) { - $this->tpl_rendered = str_replace("<%!{$key}>", $str, $this->tpl_rendered); - $this->tpl_rendered = str_replace("{%!{$key}}", $str, $this->tpl_rendered); + foreach($strings as $key => $str) + { + $this->tpl_rendered = str_replace("<%!{$key}>", $str, $this->tpl_rendered); + $this->tpl_rendered = str_replace("{%!{$key}}", $str, $this->tpl_rendered); + } + } + else + { + Throw new Exception("No valid array of localized strings specified."); } } else