<?php
(!defined('IN_PowerBB')) ? die() : '';
define('FOOTER_NAME','PowerBBFooterMOD');
class PowerBBFooterMOD
{
	function run()
	{
		global $PowerBB;
		// Get style list
		$StyleListArr 							= 	array();

		// Clean data
		$StyleListArr['proc']					=	array();
		$StyleListArr['proc']['*']				=	array('method'=>'clean','param'=>'html');

		// Where setup
		$StyleListArr['where'][0]				=	array();
		$StyleListArr['where'][0]['con']		=	'AND';
		$StyleListArr['where'][0]['name']		=	'style_on';
		$StyleListArr['where'][0]['oper']		=	'=';
		$StyleListArr['where'][0]['value']		=	'1';

		// Order setup
		$StyleListArr['order'] 					= 	array();
		$StyleListArr['order']['field'] 		= 	'style_order';
		$StyleListArr['order']['type'] 			= 	'ASC';

		$PowerBB->_CONF['template']['while']['StyleList'] = $PowerBB->style->GetStyleList($StyleListArr);

		///////////

		// Get lang list
		$LangListArr 							= 	array();

		// Clean data
		$LangListArr['proc']					=	array();
		$LangListArr['proc']['*']				=	array('method'=>'clean','param'=>'html');

		// Where setup
		$LangListArr['where'][0]				=	array();
		$LangListArr['where'][0]['con']		=	'AND';
		$LangListArr['where'][0]['name']		=	'lang_on';
		$LangListArr['where'][0]['oper']		=	'=';
		$LangListArr['where'][0]['value']		=	'1';

		// Order setup
		$LangListArr['order'] 					= 	array();
		$LangListArr['order']['field'] 		= 	'lang_order';
		$LangListArr['order']['type'] 			= 	'ASC';

		$PowerBB->_CONF['template']['while']['LangList'] = $PowerBB->lang->GetLangList($LangListArr);
		////////////
       if ($PowerBB->_CONF['info_row']['active_subject_today'])
		{
	       /**
		   * Ok , are you ready to get subject today nm ? :)
		   */
			$day 	= 	date('j');
			$month 	= 	date('n');
			$year 	= 	date('Y');

			$from 	= 	mktime(0,0,0,$month,$day,$year);
			$to 	= 	mktime(23,59,59,$month,$day,$year);

	       $forum_not = $PowerBB->_CONF['info_row']['last_subject_writer_not_in'];

	        $subject_today_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['subject'] . " WHERE native_write_time BETWEEN " . $from . " AND " . $to . " AND section not in (" .$forum_not. ") AND review_subject<>1 AND delete_topic<>1 "));
			$PowerBB->template->assign('subject_today_nm',$subject_today_nm);
        }
       $PowerBB->template->assign('timer',$PowerBB->sys_functions->time(time()));

        // Get Footer
		$PowerBB->template->display('footer');

        ///////


		if (!empty($PowerBB->_GET['debug']))
		{
			$x = 1;

			foreach ($PowerBB->_CONF['temp']['queries'] as $k => $v)
			{
				echo $x . ': ' . $v . '<hr />';

				$x++;

			}
		}           /*
				     $PowerBB->template->assign('query_num',$PowerBB->_CONF['temp']['query_numbers']);
                       echo $PowerBB->_CONF['temp']['query_numbers'].'<br />';
                       */



		// Kill everything , Hey PowerBB you should be lovely with server because it's Powered by Linux ;)
		unset($PowerBB->_CONF);
		unset($PowerBB->table);
		unset($PowerBB->DB->sql_query);
		unset($PowerBB->template->display);
 		unset($PowerBB->template->_vars);
 		unset($PowerBB->_GET);
 		unset($PowerBB->_POST);
 		unset($PowerBB->_SERVER);
 		unset($PowerBB->_COOKIE);
 		unset($PowerBB->_FILES);

        /*
		// shutdown we register this but it might not be used
		if (phpversion() < '5.0.5')
		{
		   function cleans()
		   {
			$arr=@get_defined_vars ();
			@array_walk($arr,'unset');
		   }

           @register_shutdown_function('cleans');
		}


		$PowerBB->template->assign('memory_usage',@memory_get_usage());
		$mem_usage = @memory_get_usage();


        if ($mem_usage < 1024)
            echo $mem_usage." bytes";
        elseif ($mem_usage < 1048576)
            echo round($mem_usage/1024,2)." kilobytes";
        else
            echo round($mem_usage/1048576,2)." megabytes";

 		unset($PowerBB);
         */
	}
}

?>
