<?php

require_once "func.tpl.inc";

$max_loop = 40;
$fieldsets = array(array("legend1", "text for field1"), 
	array("legend2", "text for field2"), array("legend3", "text for field3"));
	
set_vartag('V_fs_legend', '$fieldsets[$j][0]');
set_vartag('V_fs_text', '$fieldsets[$j][1]');
set_vartag('V_version', 'JFTM v7, final version');
set_vartag('V_time', date("h:i:s"));
set_vartag('V_date', date("d m Y"));
set_vartag('V_page_title', "N.A.F. - JFTM testversion");
set_vartag('V_err_number', '$i');



print(get_template("header"));
print("<h2>Information</h2>");
print("<p>Looping $max_loop times, and calculating mean page generation time</p>");

$start_time = exec_time();

ob_start();
for($tmp_var = 0; $tmp_var < $max_loop; $tmp_var++)
{
	if ($tmp_var == 1)
		$test_page = ob_get_contents();
	
	print(get_template('header'));
	
	set_vartag('V_page_title', 'No vars set ...');
	print(get_template('title'));
	print(get_template('index4'));
	
	
	
	set_vartag('V_page_title', 'Vars set tot normal values ...');
	print(get_template('title'));
	
	
	
	set_vartag('V_section', '_info');
	set_vartag('V_sub_section', '_register');
	print(get_template('index4'));
	
	
	
	set_vartag('V_section', '_info');
	set_vartag('V_sub_section', '_login');
	print(get_template('index4'));
	
	set_vartag('V_section', '_error');
	set_vartag('V_sub_section', '_1');
	print(get_template('index4'));
	
	set_vartag('V_section', '_error');
	set_vartag('V_sub_section', '');
	for($i=0; $i<3; $i++)
	{
		print(get_template('index4'));
	}
	
	
	for($j=0; $j<count($fieldsets); $j++)
	{
		print(get_template('fieldset'));
	}
	
	set_vartag('V_page_title', 'Vars set to special values ...');
	print(get_template('title'));
	
	print(get_template('nested'));
	
	set_vartag('V_section', '_unknwon1');
	set_vartag('V_sub_section', '_unknown2');
	print(get_template('index4'));
}
ob_clean();

$total = round((exec_time() - $start_time), 5);
print("Done. <br /><b>Total needed time: $total sec <br />Mean time:".round($total / $max_loop, 5)."</b>");
print("<br /><a href='index.php'>Back to index.php</a>");
print("<br /> <br /><hr /><hr /><h2>Used testpage</h2><hr />");

print($test_page);

/* @return microtime (in seconds)
 * @desc calculates microtime (for runtime) */
function exec_time()
{
	$mtime = explode( " ", microtime());
	$msec = (double)$mtime[0];
	$sec = (double)$mtime[1];

	return $sec + $msec;
}
