<?php
    $GLOBALS['highlight'] = 'home';

    $total_lines = 0;
    $total_size = 0;
    $i = 0;

    include('include/parts/header.php');
?>
    
<div class="header">File Statistics</div>
<div class="content">
<div class="border">
<?php
    read_dir('./', $total_lines, $total_size, $i);
    read_dir('./themes/default/', $total_lines, $total_size, $i);
    read_dir('./include/', $total_lines, $total_size, $i);
    read_dir('./include/action/', $total_lines, $total_size, $i);
    read_dir('./include/action/admin/', $total_lines, $total_size, $i);
    read_dir('./include/ajax/', $total_lines, $total_size, $i);
    read_dir('./include/functions/', $total_lines, $total_size, $i);
    read_dir('./include/graphic/', $total_lines, $total_size, $i);
    read_dir('./include/show/', $total_lines, $total_size, $i);
    read_dir('./include/show/admin/', $total_lines, $total_size, $i);
    echo '<div class="content" style="font-size: 14px; margin-bottom: 0px;">';    
    echo '<b>' . $total_lines . '</b> lines total<br />';
    echo '<b>' . round($total_size/1024) . '</b> kilobytes total';
    echo '</div>';
?>
</div>
</div>
<?php
    include('include/parts/footer.php');

    function read_dir($dir, &$total, &$total_size, &$i)
    {
        if (is_dir($dir))
        {
            echo '<div class="header">' . $dir . '</div>';
           if ($dir_handle = opendir($dir))
           {
               while (($file = readdir($dir_handle)) !== false)
               {
                    if (!is_dir($dir . $file))
                    {
                        if (strstr($file, '.log') === false && strstr($file, '.access') === false)
                        {
                            $lines = count(file($dir . $file));
                            $size = filesize($dir . $file);
                            echo '<div class="content">';
                            echo '<table with="100%" cellpadding="0" cellspacing="0" border="0"><tr>';
                            echo '<td width="400"><a href="?s=file_code&dir=' . str_replace('.', '', $dir) . '&file=' . $file . '">' . $file . '</a></td><td width="95"><b>' . $lines . '</b> lines</td><td width="150"><b>' . $size . '</b> bytes</td><td>Updated on ' . date("Y-m-d", filemtime($dir . $file)) . '</td>';
                            echo '</tr></table>';
                            echo '</div>';
                            $total += $lines;
                            $total_size += $size;
                            $i++;
                        }
                    }
               }
               closedir($dir_handle);
           }
        }
    }

?>