Hello i get this error: Warning: Cannot use a scalar value as an array in /www/oox/class.smarttemplate.php on line 306 This is my code <?php /** * SmartTemplate Class * * 'Compiles' HTML-Templates to PHP Code * * * Usage Example I: * * $page = new SmartTemplate( "templates" ); * $page->assign( 'TITLE', 'TemplateDemo - Userlist' ); * $page->assign( 'user', DB_read_all( 'select * from ris_user' ) ); * $page->set_filenames(array('body' => 'templatefile.html')); * $page->output('body'); * * * @author Philipp v. Criegern philipp@criegern.com * @author Manuel 'EndelWar' Dalla Lana endelwar@aregar.it * @version 1.2.1 03.07.2006 * * CVS ID: $Id: class.smarttemplate.php,v 1.7 2006/07/02 22:17:15 endelwar Exp $ */ /* +-------------------------------------------------------------------------- | Mega File Hosting Script v1.5 | ======================================== | by Stephen Yabziz | (c) 2005-2006 YABSoft Services | http://www.yabsoft.com | ======================================== | Web: http://www.yabsoft.com | Email: ywyhnchina@163.com +-------------------------------------------------------------------------- | | > This class has been modified by Stephen Yabziz for YABSoft product | > The 'SmartTemplate' class is released under LGPL 2.1, which grant to you the right to use this library in proprietary software. | > And this modifed 'SmartTemplate' class is also released under LGPL 2.1! | > Last updated: 20th May 2008 +-------------------------------------------------------------------------- */ class SmartTemplate { /** * Whether to store compiled php code or not (for debug purpose) * * @access public */ var $reuse_code = true; /** * Whether to use php code or php including * Especially added for YABSoft product! * * @access public */ var $use_php = true; /** * Whether to use strict mode to parse the block name * the option need to be turned off to be compatiable with phpBB2 or phpBB3 engine * Especially added for YABSoft product! * * @access private */ var $strict_mode = false; /** * Directory where all templates are stored * * @access public */ var $template_dir = 'skin/default/'; /** * Directory where php script which all templates need are stored * * @access public */ var $templatephp_dir = 'skin/default/'; /** * Directory where extensions script which all templates need are stored * * @access public */ var $templateext_dir = 'skin/default/extensions/'; /** * Where to store compiled templates * * @access public */ var $temp_dir = 'skin/default/cache/'; /** * Temporary folder for output cache storage * * @access public */ var $cache_dir = 'skin/default/cache/'; /** * Default Output Cache Lifetime in Seconds * * @access public */ var $cache_lifetime = 600; /** * Temporary file for output cache storage * * @access private */ var $cache_filename; /** * The last template filename to be parsed * * @access private */ var $tpl_file; /** * The template filenames to be parsed * * @access private */ var $tpl_files; /** * The last compiled template filename * * @access private */ var $cpl_file; /** * Template content array * * @access private */ var $data = array(); /** * Parser Class * * @access private */ var $parser; /** * Debugger Class * * @access private */ var $debugger; /** * SmartTemplate Constructor * * @access public * @param string $template_filename Template Filename */ function SmartTemplate ( $template_dir = '' ) { if(is_dir($template_dir)) { $this->template_dir = $template_dir; } elseif(!is_dir($template_dir)&&is_dir('../admin')) { exit( 'SmartTemplate Error[Line:'.__LINE__.']: Intiniatiting SmartTemplate: Invalid template dir specified for '.$template_dir); } if (strlen($this->template_dir) && substr($this->template_dir, -1) != '/') { $this->template_dir .= '/'; } $this->templatephp_dir = $this->template_dir; $this->templateext_dir = $this->template_dir.'extensions/'; $this->temp_dir = $this->template_dir.'cache/'; $this->cache_dir = $this->template_dir.'cache/'; } /* Set (or reset) Properties (variables) * * Usage Example: * $page->set('reuse_code', true); * * @access public * @param string $name Parameter Name * @param mixed $value Parameter Value * NOTE: will not work with arrays, there are no arrays to set/reset */ function set ( $name, $value = '' ) { if ( isset($this->$name) ) { $this->$name = $value; } else { exit( 'SmartTemplate Error[Line:'.__LINE__.']: Attempt to set a non-existant class property: ' . $name); } } // DEPRECATED METHODS // Methods used in older parser versions, soon will be removed function set_templatefile ($handle, $template_filename) { $this->tpl_files[$handle] = $template_filename; } function add_value ($name, $value ) { $this->assign($name, $value); } function add_array ($name, $value ) { $this->append($name, $value); } /** * Assign Template Content * * Usage Example: * $page->assign( 'TITLE', 'My Document Title' ); * $page->assign( 'userlist', array( * array( 'ID' => 123, 'NAME' => 'John Doe' ), * array( 'ID' => 124, 'NAME' => 'Jack Doe' ), * ); * * @access public * @param string $name Parameter Name * @param mixed $value Parameter Value * @desc Assign Template Content */ function assign ( $name, $value = '' ) { if (is_array($name)) { foreach ($name as $k => $v) { $this->data[$k] = $v; } } else { $this->data[$name] = $value; } } /** * Get the value of assigned var * * @public */ function get_var ( $name ) { return $this->data[$name]; } /** * Template function compatiable with phpbb2 template engine * * @public */ function assign_var ( $name, $value = '' ) { $this->assign($name, $value); } /** * Template function compatiable with phpbb2 template engine * * @public */ function assign_vars ( $name, $value = '' ) { $this->assign($name, $value); } /** * Assign Template Block Content * * @access public * @param string $name Parameter Name * @param mixed $value Parameter Value * @desc Assign Template Block Content */ function assign_block_vars ( $name, $value = '' ) { if (strpos($name, '.') !== false) { $blocks = explode('.', $name); $blockcount = sizeof($blocks) - 1; $ref_obj = & $this->data; for ($i = 0; $i < $blockcount; $i++) { $block_name = $blocks[$i]; // if this block is not created yet if(!isset($ref_obj[$block_name])) { $ref_obj[$block_name] = array(); $ref_obj = & $ref_obj[$block_name]; } // if the block has already existed, pass to the last items else { $ref_obj = & $ref_obj[$block_name]; $ref_obj = & $ref_obj[sizeof($ref_obj) - 1]; } } // append the value to the current block! $ref_obj[$blocks[$blockcount]][] = $value; } else { $this->data[$name][sizeof($this->data[$name])] = $value; } } /** * Template function compatiable with phpbb2 template engine * * @public */ function assign_var_from_handle($tpl_var = '', $handle, $return_content = false, $include_once = false) { $contents = $this->result($handle, $include_once); if ($return_content) { return $contents; } $this->assign_var($tpl_var, $contents); return true; } /** * Template function compatiable with phpbb2 template engine * * @public */ function set_filenames($filename_array) { if (!is_array($filename_array)) { return false; } foreach ($filename_array as $handle => $filename) { if (empty($filename)) { exit( 'SmartTemplate Error[Line:'.__LINE__.']: template->set_filenames: Empty filename specified for '.$handle); } $this->tpl_files[$handle] = $filename; } return true; } /** * Template function compatiable with phpbb2 template engine * * @public */ function pparse($handle='index', $include_once = true) { $this->output($handle, $include_once); } /** * Template function compatiable with phpbb2 template engine * * @public */ function email_pparse($handle,$from='',$to='') { global $LANG,$user; $email = new Email($this->template_dir); $email->template = & $this; $email->admin_email =$user->setting['adminemail']; # sending emails via SMTP? if($user->setting[use_smtp]) { $email->handler->IsSMTP(); $email->handler->SMTPAuth = true; $email->handler->Host = $user->setting[smtp_host]; $email->handler->Username = $user->setting[smtp_user]; $email->handler->Password = $user->setting[smtp_pass]; $email->SMTPDebug = 1; } $email->to($to); $email->from($from); $email->send($handle); return true; } /** * Include a seperate template * * @private */ function _tpl_include($filename, $include = false) { $handle = preg_replace('/[:\/.\\\\]/', '_', $filename); $this->tpl_files[$handle] = $filename; $this->output($handle,$include); } /** * Complie a HTML string * * @private */ function _tpl_execute($HTMLCode) { if(!is_object($this->parser)) { $this->parser = new SmartTemplateParser($this->template_dir . $this->tpl_file); $this->parser->use_php = $this->use_php; $this->parser->reuse_code = $this->reuse_code; $this->parser->strict_mode = $this->strict_mode; $this->parser->templatephp_dir = $this->templatephp_dir; $this->parser->templateext_dir = $this->templateext_dir; } $this->parser->template = $HTMLCode; $this->parser->compile(); $_obj = $this->data; $_stack_cnt = 0; $_stack[$_stack_cnt++] = $_obj; eval(' ?'.'>' . $this->parser->compiled_content . '<?php '); } /** * Parser Wrapper * Returns Template Output as a String * * @access public * @param array $_top Content Array * @return string Parsed Template * @desc Output Buffer Parser Wrapper */ function result2 ( $HTMLCode, $include_once=true ) { ob_start(); $this->_tpl_execute( $HTMLCode ); $result = ob_get_contents(); ob_end_clean(); return $result; } /** * Assign Template Content * * Usage Example: * $page->append( 'userlist', array( 'ID' => 123, 'NAME' => 'John Doe' ) ); * $page->append( 'userlist', array( 'ID' => 124, 'NAME' => 'Jack Doe' ) ); * * @access public * @param string $name Parameter Name * @param mixed $value Parameter Value * @desc Assign Template Content */ function append ( $name, $value ) { if (is_array($value)) { $this->data[$name][] = $value; } elseif (!is_array($this->data[$name])) { $this->data[$name] .= $value; } } /** * Parser Wrapper * Returns Template Output as a String * * @access public * @param array $_top Content Array * @return string Parsed Template * @desc Output Buffer Parser Wrapper */ function result ( $handle = 'index', $include_once=true ) { ob_start(); $this->output( $handle, $include_once); $result = ob_get_contents(); ob_end_clean(); return $result; } /** * Execute parsed Template * Prints Parsing Results to Standard Output * * @access public * @param array $_top Content Array * @desc Execute parsed Template */ function output ( $handle = 'index', $include_once=true ) { // Make sure that folder names have a trailing '/' if (strlen($this->template_dir) && substr($this->template_dir, -1) != '/') { $this->template_dir .= '/'; } if (strlen($this->temp_dir) && substr($this->temp_dir, -1) != '/') { $this->temp_dir .= '/'; } $this->tpl_file = $this->tpl_files[$handle]; $_obj = $this->data; $_stack_cnt = 0; $_stack[$_stack_cnt++] = $_obj; // Check if template is already compiled $cpl_file_name = preg_replace('/[:\/.\\\\]/', '_', $this->tpl_file); if (strlen($cpl_file_name) > 0) { $this->cpl_file = $this->temp_dir . $cpl_file_name . '.php'; $compile_template = true; if($this->reuse_code) { if (is_file($this->cpl_file)) { if ($this->mtime($this->cpl_file) > $this->mtime($this->template_dir . $this->tpl_file)) { $compile_template = false; } } } // the template has been complied if(strlen($this->compiled_content[$handle])) { $compile_template = false; } if ($compile_template) { if (@include_once("class.smarttemplateparser.php")) { $this->parser = new SmartTemplateParser($this->template_dir . $this->tpl_file); $this->parser->use_php = $this->use_php; $this->parser->reuse_code = $this->reuse_code; $this->parser->strict_mode = $this->strict_mode; $this->parser->template_dir = $this->template_dir; $this->parser->templatephp_dir = $this->templatephp_dir; $this->parser->templateext_dir = $this->templateext_dir; if (!$this->parser->compile($this->cpl_file)) { exit( "SmartTemplate Parser Error: " . $this->parser->error ); } $this->compiled_content[$handle] = $this->parser->compiled_content; } else { exit( 'SmartTemplate Error[Line:'.__LINE__.']: Cannot find class.smarttemplateparser.php; check SmartTemplate installation'); } } // Execute Compiled Template if($this->reuse_code&&is_file($this->cpl_file)) ($include_once) ? include_once($this->cpl_file) : include($this->cpl_file); else { eval(' ?'.'>' . $this->compiled_content[$handle] . '<?'."define('$this->tpl_files[$handle]',1)".'?'.'>' . '<?php '); // if the complied code is not working, print out the template HTML code! if(!defined("$this->tpl_files[$handle]")) { echo 'Error template:'.$this->template_dir.$this->tpl_files[$handle]; echo '<br>Original template:<br><textarea cols=100 rows=5>'; echo file_get_contents($this->template_dir.$this->tpl_files[$handle]); echo '</textarea>'; echo '<br>Complied template:<br><textarea cols=100 rows=5>'; echo $this->compiled_content[$handle]; echo '</textarea>'; } } } else { exit( 'SmartTemplate Error[Line:'.__LINE__.']: You must set a template file name'); } } /** * Debug Template * * @access public * @param array $_top Content Array * @desc Debug Template */ function debug ( $handle, $_top = '' ) { // Prepare Template Content if (!$_top) { $_top = $this->data; } if (@include_once("class.smarttemplatedebugger.php")) { $this->debugger = new SmartTemplateDebugger($this->template_dir . $this->tpl_files[$handle]); $this->debugger->start($_top); } else { exit( 'SmartTemplate Error[Line:'.__LINE__.']: Cannot find class.smarttemplatedebugger.php; check SmartTemplate installation'); } } /** * Start Ouput Content Buffering * * Usage Example: * $page = new SmartTemplate('template.html'); * $page->use_cache(); * ... * * @access public * @desc Output Cache */ function use_cache ( $user_callback = false ) { global $user; $key = 'mfhs'; # donot cache pages when a user is logined if (empty($_POST)&&$user->logined==0) { $this->user_callback = false; if($user_callback[0] && function_exists($user_callback[0])) { $user_callback_func = $user_callback[0]; $required_params = $user_callback_func(); } if($user_callback[1] && function_exists($user_callback[1])) { $this->user_callback = $user_callback[1]; } $REQUEST_URI = preg_replace('"[/]+"', '/', $_SERVER['REQUEST_URI']); $url_parts = parse_url($REQUEST_URI); //parse_str($url_parts[query], $param_parts); parse_str($_SERVER[QUERY_STRING], $param_parts); $url_params = ''; if($required_params) foreach($required_params as $k) if(isset($param_parts[$k])) $url_params .= '&'.$k.'='.$param_parts[$k]; # inline view not cached! if(IN_PAGE=='DOWNLOAD'&&strcmp($param_parts['d'],1)) { $this->user_callback = false; return 1; } # now build the result fine url $REQUEST_URI = $url_parts['path'] . $url_params; $this->cache_filename = $this->cache_dir . 'cache_'.$user->langcode. '_' . md5($REQUEST_URI . serialize($key)) . '.ser'; if (($_SERVER['HTTP_CACHE_CONTROL'] != 'no-cache') && ($_SERVER['HTTP_PRAGMA'] != 'no-cache') && @is_file($this->cache_filename)) { if ((time() - filemtime($this->cache_filename)) < $this->cache_lifetime) { readfile($this->cache_filename); exit; } } ob_start( array( &$this, 'cache_callback' ) ); } } /** * End Ouput Content Buffering * * Usage Example: * $page = new SmartTemplate('template.html'); * $page->use_cache(); * ... * $page->end_cache(); * @access public * @desc Output Cache */ function end_cache () { if (empty($_POST)) { ob_end_flush(); } } /** * Output Buffer Callback Function * * @access private * @param string $output * @return string $output */ function cache_callback ( $output ) { if($this->user_callback) { $user_callback_func = $this->user_callback; $output = $user_callback_func($output); } echo $this->cache_filename; $output .= '<!-- The static page was generated at '.date('Y-m-d H:i:s').' -->'; if ($hd = @fopen($this->cache_filename, 'w')) { fputs($hd, $output); fclose($hd); } return $output; } /** * Determine Last Filechange Date (if File exists) * * @access private * @param string $filename * @return mixed * @desc Determine Last Filechange Date */ function mtime ( $filename ) { if (@is_file($filename)) { $ret = filemtime($filename); return $ret; } } } ?> HTML: