php, page last edited script

Discussion forum for MOD Writers regarding MOD Development.
User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: php, page last edited script

Post by Erik Frèrejean »

Untested, but something like:

Code: Select all

$path_to_file = $phpbb_root_path . 'language/en/common.' . $phpEx;
$template->assign_var('COMMON_LAST_EDITED', $user->format_date(filemtime($path_to_file))); 
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Thanks Erik, but how do I make it so that it checks more than one file and display the date of the last modified?
I am done with phpBB

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: php, page last edited script

Post by Erik Frèrejean »

Written from the top of my head:

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: index.php 9614 2009-06-18 11:04:54Z nickvergessen $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

$check_files = array(
   $phpbb_root_path . 'language/en/common.' . $phpEx,
   $phpbb_root_path . 'styles/prosilver/template/index_body.html',
   $phpbb_root_path . 'index.' . $phpEx,
);

$last_edit_time = 0;
$last_edit_file = '';
foreach ($check_files as $file)
{
    $_filemtime = filemtime($file);

    if ($last_edit_time < $_filemtime)
    {
        $last_edit_time = $_filemtime;
        $last_edit_file = $file;
    }
}

$template->assign_vars(array(
    'LAST_EDITED'    => $user->format_date($last_edit_time),
    'LAST_EDITED_F'    => $last_edit_file,
));

echo'<pre>';print_r($template);exit; 
Last edited by Erik Frèrejean on Wed Sep 08, 2010 9:53 pm, edited 2 times in total.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

'That code gives this debug: filemtime() [function.filemtime]: stat failed for 0 and display the default 1970 date.
I am done with phpBB

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: php, page last edited script

Post by Erik Frèrejean »

Sorry, must have been sleeping when I wrote that :/. Updated the code in my last post (works on my local host ;))
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: php, page last edited script

Post by stokerpiller »

Thanks a lot Erik, works like a charm.
Beers on me :D
I am done with phpBB

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: php, page last edited script

Post by Erik Frèrejean »

I'll send you the bill ;).
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: php, page last edited script

Post by ToonArmy »

Erik Frèrejean wrote:Written from the top of my head: [...]
Bah, much easier.

Code: Select all

<?php

$files = array(
'foo.txt',
'bar.php',
'test.png',
);

$modified = max(array_map('filemtime', $files)); 
Chris SmithGitHub

Locked

Return to “[3.0.x] MOD Writers Discussion”