\n",$back_colour_hex);
printf("");
if(strcmp($request_uri,"")==0 && strcmp($query_string,"")==0)
{
$msg=" Error: DOCUMENT_URI or QUERY_STRING not set ";
log_append($error_log,$client_ip,"DOCUMENT_URI or QUERY_STRING not set",$user_agent);
html_errorpage($msg,$css_file);
die;
}
// Read the file //////////////////////////////////////////////
$lines_read=0;
$debug_limit=100;
// Open our log file ...
$fp=@fopen($filename_path,"r");
if(!$fp)
{
$msg="Failed to open ".$log_filename; // Don't include the full path (filename_path)
log_append($error_log,$client_ip,$msg,$user_agent);
html_errorpage($msg,$css_file);
die;
}
// Wind file pointer to N lines from EOF
fset_lines_from_eof($fp, $display_lines); // Don't test return
// Parse highlighting keywords
$highlight_keyword_found=false;
$highlight=$cgi_args["highlight"];
$highlight_keywords=explode(" ",$highlight);
$highlight_count=count($highlight_keywords);
// Read the file and display it ...
while(!feof($fp))
{
$highlight_keyword_found=false;
$buffer=fgets($fp);
if($buffer)
{
//printf("Line: '%s' ",$highlight_count);
if($highlight_count > 0)
//if(strcmp($highlight_count,"")!=0)
{
$highlight_keyword_found=false;
for($j=0; $j < $highlight_count; $j++)
{
//printf("check on '%s' '%s' \n",$highlight_keywords[$j],stristr($buffer,$highlight_keywords[$j]));
if(strcmp($highlight_keywords[$j],"") > 0) // No args creates an array with x1 element == ""
{
if(stristr($buffer,$highlight_keywords[$j])!=false) // haystack,needle
{
$highlight_keyword_found=true;
break;
}
}
}
}
//printf("Debug: highlight_keyword_found? %s '%s' ",$highlight_keyword_found,$highlight_keywords[$j]);
if($highlight_keyword_found==true)
{
printf("",$font_name,$font_size,$highlight_colour_hex);
//printf("%s",buffer);
safeprint($buffer);
printf("",$font_name,$font_size,$fore_colour_hex);
$highlight_keyword_found=false;
}
else
{
safeprint($buffer);
}
++ $lines_read;
if($lines_read >= $display_lines)
break;
}
}
fclose($fp);
if($lines_read < 1)
printf("\n ** The file is currently empty ** \n");
/////////////////////////////////////////////////////////////////////////////////////
// Close off...
/////////////////////////////////////////////////////////////////////////////////////
printf("");
printf(" |
");
printf("