Location: PHPKode > scripts > Page highlighter > page-highlighter/highlighter.php
<?
/*******************************************
using regexp you can highlight words inside a page

example url: 

http://localhost//highlighter.php?search=(word)&url=http://www.slashdot.com

this script is not safe, so you can also enter url=file and so 
people can sniff your sourcecode, so only use it on localhost or 
add some security.
******************************************/



$report="start\\n";
require "oo_file.inc.php";

$url=$_GET["url"];
if ( $url=="" ) { $url="http://www.slashdot.org"; }

print "<base href='$url'>";

$page=new File($url,"r");
  $p=$page->read(80000000);
$page->close();
$p = preg_replace("/\r\n|\n\r|\n|\r/", "", $p);
 

// get all tags:
$rows=spliti("<",$p);
foreach( $rows as $nr=>$row ){
	if ($nr==0) 
	{
		print $row;
	}
	else
	{
		if ( 
			eregi( $_GET["search"] , strip_tags( $row) ) 
			
		)
		{
			list( $t1, $t2 ) = split(">", $row,2);
			$t2=eregi_replace( $_GET["search"], "<span style='background-color:yellow;color:black' >\\0</span>", $t2 );
			print "<$t1  > $t2";
		} 
		else 
		{
			print "<".$row;
		}	
	}
}

$report.="end\\n";
?>
Return current item: Page highlighter