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
https://forums.phpfreaks.com/topic/280942-help-with-update-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.