File size: 1.53Kb
<?php
StartTimer();
$this_file = '/error_log.php';
$this_file_length = strlen($this_file);
$this_path = __FILE__;
$root = substr($this_path, 0, -($this_file_length));
$error_logs = array();
function list_files($path = '') {
global $error_logs;
if ($handle = @opendir($path)) {
while (false !== ($filename = readdir($handle))) {
if ($filename != '.' && $filename != '..') {
if(is_dir($path.'/'.$filename)) {
list_files($path.'/'.$filename);
} else {
if (is_file($path.'/'.$filename)) {
if($filename == 'error_log') {
$error_logs[] = array('file' => $path.'/'.$filename, 'size' => filesize($path.'/'.$filename));
unlink($path.'/'.$filename);
}
}
}
}
}
closedir($handle);
} else {
die('Invalid Directory');
}
}
### Function: Start Timer
function StartTimer() {
global $timestart;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$timestart = $mtime;
return true;
}
### Function: Stop Timer
function StopTimer($precision=5) {
global $timestart;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$timeend = $mtime;
$timetotal = $timeend-$timestart;
$scripttime = number_format($timetotal,$precision);
return $scripttime;
}
### Function: Format Size
function format_size($rawSize) {
if($rawSize / 1073741824 > 1) {
return round($rawSize/1073741824, 1).'GB';
} elseif ($rawSize / 1048576 > 1) {
return round($rawSize/1048576, 1).'MB';
} elseif ($rawSize / 1024 > 1) {
return round($rawSize/1024, 1).'KB';
} else {
return round($rawSize, 1).'b';
}
}
### Get The error_log Files
list_files($root);
?>