<?php
// www.bcoos.net 2006-09 1.0.2 GPL
$xoopsOption['nocache'] = 1;
include_once('../../mainfile.php');
if ($xoopsUser) {
	$xoopsModule = XoopsModule::getByDirname('system');
	if ( !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
		redirect_header(XOOPS_URL.'/', 3, _NOPERM);
		exit();
	}
	} else {
		redirect_header(XOOPS_URL.'/', 3, _NOPERM);
		exit();
	}
if ( !empty($_GET['file']) && @file_exists($_GET['file']) ) {
	echo '<html><head><title>'._DBG_OUTPUT.': '.$file.'</title>
		<script type="text/javascript">
		<!--
		self.moveTo(0,0);
		self.resizeTo(screen.availWidth,screen.availHeight);
		self.focus();
		// -->
		</script></head><body>';
	echo ex_highlight($_GET['file'], $_GET['line']);
	echo '</body></html>';
	} else {
		redirect_header(XOOPS_URL.'/', 1, _TAKINGBACK);
		exit();
	}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function ex_highlight($file, $line=0) {
ob_start();
highlight_file($file);
$content = ob_get_contents();
ob_end_clean();
$content = explode('<br />', $content);
$size    = count($content);
if (!empty($size)) {
	$size = ($size-1);
}
for ($i=0; $i<$size; $i++) {
	if ( $line && ($line == ($i+1)) ) {
		$content[$i] = '<span style="background-color: #F8F8FF;"><span style="color:#999999">'.($i+1).'&nbsp;</span><a name="'.($i+1).'" />'.$content[$i].'</span>';
		} else {
			$content[$i] = '<span style="color:#999999">'.($i+1).'&nbsp;</span><a name="'.($i+1).'" />'.$content[$i].'';
		}
}
$content = implode('<br />', $content);
return $content;
}
?>
