<?php //  ۞ // text {  encoding:utf-8 ; bom:no ; linebreaks:unix ; tabs:4sp  ; }
                                                                
$version 0.2;
/*
    function tail()

    returns $tail_size lines from $file
    like a unix tail, handy for log files

    (c) 2001->tomorrow! ~ cor + corz.org ;o)

    Please view the license for this free software, here:

        http://corz.org/free-scripts-licence.nfo

*/
/*
    example..    */

$show_lines 50;
$refs_log $_SERVER['DOCUMENT_ROOT'].'/inc/log/.ht_bots';

echo 
'<strong>last ',($show_lines 5),' bots..</strong><br />
<textarea name="refs_tail" rows=21 cols=100 style="font:12px courier">'
,tail($refs_log$show_lines),'</textarea>';


/*
function tail()    */
function tail($file$tail_size) {
    
$tail_string '';
    if (
file_exists($file)) {
        
$file_contents implode('',file($file));
        
$lines explode("\n"$file_contents);
        
$line_count count($lines);
        for (
$i=($line_count-$tail_size);$i $line_count;$i++) {
            
$tail_string .= $lines[$i]."\n";
        }
    } else {
        
$tail_string 'couldn\'t find the log file';
    }
return 
$tail_string;
}
/* end function tail($file,$tail_size)
*/

?>
back to the source menu
downloadtest

Welcome to corz.org!

If something isn't working, I'm probably improving it, try again in a minute. If it's still not working, please mail me!