Contribute  :  Support  :  Downloads  :  Forum  :  Links  :  Polls  :  Calendar  :  Directory  :  Advanced Search  
Geeklog The Ultimate Weblog System
Welcome to Geeklog
Friday, May 16 2008 @ 05:58 AM EDT
   

Staticpage to Access error.log

GeeklogI'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.

Story Options

Trackback

Trackback URL for this entry: http://www.geeklog.net/trackback.php/ErrorLogHack

No trackback comments for this entry.
Staticpage to Access error.log | 10 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Staticpage to Access error.log
Authored by: jnordquist on Sunday, January 22 2006 @ 03:47 AM EST
All I get is:

Parse error: parse error, unexpected '&' in /home/kenosha/public_html/staticpages/index.php(59) : eval()'d code on line 1

gl 1.4
Staticpage to Access error.log
Authored by: Tony on Monday, January 23 2006 @ 10:49 AM EST
I've repeated the steps as I typed them. Please verify each step and holler back if you continue to have problems.

--Tony

---
The reason people blame things on previous generations is that there's only one other choice.
Staticpage to Access error.log
Authored by: Robin on Monday, January 23 2006 @ 03:12 AM EST
Great stuff Tony :) Works like a charm.
Thanks.

---
Geeklog Polish Support Team
Staticpage to Access error.log
Authored by: Tony on Monday, January 23 2006 @ 10:52 AM EST
Note, I omitted one small point that is importan for security. In addition to select the Root as the group, you should also uncheck the read flag on the Anonymous and Members groups. I've updated the article to read that way.

--Tony

---
The reason people blame things on previous generations is that there's only one other choice.
Staticpage to Access error.log
Authored by: 1000ideen on Saturday, February 04 2006 @ 10:29 AM EST
Great idea, I just wonder if I got it right.

When I click that static page within Geeklog the browser asks me if I want to download a file error.log. Is that correct? I had expected to see the file displayed in the browser / Geeklog window as any other static page.
Staticpage to Access error.log
Authored by: 1000ideen on Saturday, February 04 2006 @ 10:47 AM EST
Just adding: the file to download it NOT the error.log but the complete html page for what I expected the static page to look like.

In other words: I am asked to download an error.log instead of this page opening in the browser. Is this a bug or a feature? Thanks!

Staticpage to Access error.log
Authored by: Anonymous on Sunday, February 05 2006 @ 05:22 AM EST
the same happens to me, my browser asks me if I want to download this error.log file. Happens with gl 1.4 and firefox and safari...
Staticpage to Access error.log
Authored by: Tony on Monday, February 06 2006 @ 02:33 PM EST
Correct, the static page should simply download the error.log to your local filesystem. There are two reasons:

1) on high traffic sites, the error.log can be big (not to mention some GL admins forgot to rotate the log)
2) often times I need to do some searching, etc which is best done locally.

--Tony

---
The reason people blame things on previous generations is that there's only one other choice.
Staticpage to Access error.log
Authored by: mst3kroqs on Thursday, February 23 2006 @ 12:43 AM EST
Hi Tony -

I'm getting the same thing. Running GL 1.3.11rc4 BTW. What is returned in the file 'error.log' is the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My Site Name - Error Log</title>
<!--
<meta http-equiv="Pragma" content="no-cache">
-->
<link rel="stylesheet" type="text/css" href="http://www.mysite.com/layout/professional/style.css"; title="Professional">
<!-- Needed JavaScript Code -->
<script type="text/javascript">
var cleared = 0

I've enabled PHP evaluation, and set the security properly - any ideas?

-m
Staticpage to Access error.log
Authored by: mst3kroqs on Thursday, February 23 2006 @ 02:03 AM EST
Never mind - to make this work you should choose the following PHP execution drop-down option when creating the page:

PHP: 'execute PHP (return)'

Perhaps you should update the documentation accordingly.

Thanks.

-m