dq skipthisword at searchlores dot org
08-Nov-2002 12:26
<?php
{
/* NoBloatIndex
nobloatindex.php enhances your PHP
manual by reducing the
index to those entries you care about. You
just have to
provide a file with those headers that you want to have
commented out in the manual.
You may customize the four
variables below
$filename should point either to index.html or
funcref.html within the PHP manual directory.
$filediscard shall
contain a list of lines with the
function reference headers you
don't care about. For
example, if you don't care about Informix
functions,
just add a line with the text: Informix functions
$signature is a text string part of the html comment
disabling that
entry.
$nbr_backups is the max number of backups of the file
about to be modified. The backup files will be named
like the
original file with a numerical extension.
*/
$filename='..\manual\index.html';
$filediscard='discard.txt';
$signature='NoBloat';
$nbr_backups=10;
// you may customize the
four variables above
error_reporting(E_ALL);
for($i=0;$i<$nbr_backups;$i++) {
$filebak=sprintf($filename.'.%0'.
strlen((string)($nbr_backups-1)).'d',$i);
if(!file_exists($filebak))
break;
}
$contents=join('',file($filename));
if(!rename($filename,$filebak)) copy($filename,$filebak);
$signature='--'.$signature.'--';
$contents=str_replace(array('<!'.$signature,
$signature.'>'),'',$contents);
foreach(file($filediscard) as
$discard) {
$discard=trim($discard);
if(strlen($discard)==0)
continue;
$pattern='@(<DT\s*>[^<>]*<A[^<>]*>[^<>]*'.
preg_quote($discard,'@').
'[^<>]*</A\s*></DT\s*>)@sU';
$ra=preg_split($pattern,$contents,-1,
PREG_SPLIT_DELIM_CAPTURE);
$i=(count($ra)-1)/2;
if($i!=1)
print("Warning: $i matches found for
\"$discard\"\n");
$contents=array_shift($ra);
for(;$i>0;$i--) $contents.='<!'.$signature.
array_shift($ra).$signature.'>'.array_shift($ra);
} // end
foreach
$fh=@fopen($filename,'wb');
if($fh) {
fwrite($fh,$contents);
fclose($fh);
}
}
?>