PHP script that provides a basic web-page asking for a date. That date is then used to get the log file for that date from a directory containing many log files (one for each date). If the log file exists, then it is downloaded; otherwise, the script returns with "No logs for that date".

Recommended Answers

All 3 Replies

Are you looking for a ready made script, or do you want to build one yourself?

Or
Create a webpage with a list of dates, place it in a hidden folder with no links to it.
Each date is a link to open the error logfile with that name. When the file opens in your browser, you save it for offline use.
You could then just copy the dates to a new file, and use a search and replace to update the dates to the next month in your text editor, which would update the month in the date and in that date's link.

You could also create a script that automatically updates and saves a new file each month with that month's dates in it.

There's always more than one way to do things.

This is completely untested code (I'm just writing it blind) so it might have bugs, but this is the general idea:

<?php

// Get date passed in via query string
$date = $_GET['date'];

// Attempt to retrieve log file with date specified
$log_file = file_get_contents("/var/log/my_files/$date.log");

if ($log_file === false)
{
    echo "No log for that date";
}
else
{
    echo $log_file;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.