Welcome to Geeklog Tuesday, December 12 2017 @ 08:28 pm EST

Staticpage to Access error.log

  • Contributed by:
  • Views: 7,624
Geeklog I've often needed access to my error.log from a machine that did not have an SSH client installed. I created this little hack that can live within a static page:
  1. Go to the staticpage admin screen and hit the "Create New" button.
  2. In the PHP drop-down be sure to select "execute PHP"
  3. For the group down-down, be sure to select "Root" and be sure to uncheck teh Read flag for Members and Anonymous (NOTE: this is important for security)
  4. In the "content" textarea add the following:
    global $_CONF;
    require_once $_CONF['path_system'] . 'classes/downloader.class.php';
    $dMgr = new downloader();
    $dMgr->setPath($_CONF['path_log']);
    $dMgr->_setAvailableExtensions(array('log' => 'text/plain'));
    $dMgr->setAllowedExtensions(array('log' => 'text/plain'));
    $dMgr->downloadFile('error.log');
    if ($dMgr->areErrors()) {
        $dMgr->printErrors();
    }
    
  5. Save the page

That's it. Simple, elegant and as secure as Geeklog is.