Jump to content

Help with update script


WalterWhite

Recommended Posts

Hi people... I am new to this forum and im sort of a beginner to PHP.. Im trying to make a script that shows, in a file which I can include on the side part of my index page, the date of a last update and plus underneath that a list of which pages I have updated. So for an example if the last time I updated was Tuesday and I only edited my news and index page it would say

 

August 6, 2013

- Home Page Updated.

- News Headlines Updated.

 

Then underneath it would show the other latest updates.. like so:

 

August 6, 2013

- Home Page Updated.

- News Headlines Updated.

 

August 5, 2013

- Staff Updated.

 

August 2, 2013

- Home Page Updated.

- Forum Updated.

- Join Page Updated.

 

I would also like to be able to set a limit on how many updates can be shown.. I had a friend who had this script years ago and I remember he done it through a .txt file and CHMOD the txt file to have written permissions. Then their was updates.php and on every page I wanted to generate an update status I would include a few lines of some scripting at the top of the file.. Plus I would list the page names and what I wanted it to show in either the txt file or updates file like index.php > Home Page Updated... However I have lost contact with him and their is no way of me finding it. I had a go and and got:

 

<?php

$pages = array(
    'Main Page' => 'index3.php',
    'Staff' => 'staff.php',
    'News Headlines' => 'news.php',
);
$list = array();

foreach($pages as $page => $file) {
    $date = filemtime($file);    
    if(!isset($list[$date])) { $list[$date] = array(); }
    array_push($list[$date], $page);
}
krsort($list);

foreach($list as $date => $pages) {
    echo date('F j, Y', $date) . "<br />\n";
    foreach($pages as $page) {
        echo "- $page Updated<br />\n";
    }
}
?>

 

But this doesn't work correctly as it starts a new date even if I update two files in the same day... Anyway I have gone on for long enough I was just wondering if anybody has any idea of how this script would be made? I am in desperate need to get it so any help would be great.. I am really unsure of how to go about it.. Thanks people and I hope to hear something back :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.