<?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:

        https://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!

I'm always messing around with the back-end.. See a bug? Wait a minute and try again. Still see a bug? Mail Me!