MyBB Community Forums

Full Version: Editing $contents
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

How can I edit this function:

function output_page($contents)
{
	global $db, $lang, $theme, $plugins, $mybb;
	global $debug, $templatecache, $templatelist, $maintimer, $globaltime, $parsetime;

	$contents = parse_page($contents);
	$totaltime = $maintimer->stop();

	if($mybb->usergroup['cancp'] == 1)
	{
		if($mybb->settings['extraadmininfo'] != 0)
		{
			$phptime = $maintimer->format($maintimer->totaltime - $db->query_time);
			$query_time = $maintimer->format($db->query_time);

			if($maintimer->totaltime > 0)
			{
				$percentphp = number_format((($phptime/$maintimer->totaltime) * 100), 2);
				$percentsql = number_format((($query_time/$maintimer->totaltime) * 100), 2);
			}
			else
			{
				// if we've got a super fast script...  all we can do is assume something
				$percentphp = 0;
				$percentsql = 0;
			}

			$phpversion = phpversion();

			$serverload = get_server_load();

			if(my_strpos(getenv("REQUEST_URI"), "?"))
			{
				$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "&debug=1";
			}
			else
			{
				$debuglink = htmlspecialchars(getenv("REQUEST_URI")) . "?debug=1";
			}

			if($mybb->settings['gzipoutput'] != 0)
			{
				$gzipen = "Enabled";
			}
			else
			{
				$gzipen = "Disabled";
			}

			if(function_exists("memory_get_usage"))
			{
				$memory_usage = " / Memory Usage: ".get_friendly_size(memory_get_peak_usage(true));
			}

			$other = "PHP version: $phpversion / Server Load: $serverload / GZip Compression: $gzipen";
			$debugstuff = "Generated in $totaltime seconds ($percentphp% PHP / $percentsql% MySQL)<br />SQL Queries: $db->query_count /  Global Parsing Time: $globaltime$memory_usage<br />$other<br />[<a href=\"$debuglink\" target=\"_blank\">advanced details</a>]<br />";
			$contents = str_replace("<debugstuff>", $debugstuff, $contents);
		}

		if($mybb->debug_mode == true)
		{
			debug_page();
		}
	}

	$contents = str_replace("<debugstuff>", "", $contents);
	$contents = $plugins->run_hooks("pre_output_page", $contents);

	if($mybb->settings['gzipoutput'] == 1)
	{
		if(version_compare(PHP_VERSION, '4.2.0', '>='))
		{
			$contents = gzip_encode($contents, $mybb->settings['gziplevel']);
		}
		else
		{
			$contents = gzip_encode($contents);
		}
	}
	
	@header("Content-type: text/html; charset={$lang->settings['charset']}");
	
	echo $contents;

	$plugins->run_hooks("post_output_page");

	// If the use shutdown functionality is turned off, run any shutdown related items now.
	if($mybb->settings['useshutdownfunc'] == 0 && $mybb->use_shutdown != true)
	{
		run_shutdown();
	}
}

Via plugin, I was trying do as in example: http://emovip.co.cc/?p=6&cat=2

But it does not work. What should I do?