logparser.php 934 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class Model {
  3. /**
  4. * collect a list of logs we're able to work with..
  5. * this is pretty crude; since we're only able to (nicely) format access.log at present, this function will be
  6. * rewritten to be more fluid, in future versions
  7. *
  8. * you can select any log you'd like, but only access.log will have all of it's slots formatted appropriately :)
  9. */
  10. public function log_locations($dir = Config::LOGPATH) {
  11. $target_dir = scandir($dir);
  12. $list = array();
  13. // recursively navigate the log directory so dirs like /var/log/apache2 are also offered
  14. foreach($target_dir as $value) {
  15. if($value === '.' || $value === '..') {continue;}
  16. if(is_file("$dir/$value")) {$list[]="$dir/$value";continue;}
  17. foreach($this->log_locations("$dir/$value") as $value) {
  18. $list[] = $value;
  19. }
  20. }
  21. return $list;
  22. }
  23. }