Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.php > #3194

Re: get pages age

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups alt.php
Subject Re: get pages age
Date Mon, 10 Jul 2017 07:00:07 +0200
Lines 37
Message-ID <esgfunF3a9mU1@mid.individual.net> (permalink)
References <afr32o.o3c.19.1@news.alt.net>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace individual.net Tvj8T9aDXWYSoujZkScVJwTB1M1y4SiIv4VaMo6RKmm8aCbFas
Cancel-Lock sha1:LVXdbEvdx7ax0Q63VFd7n/9axI0=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0
In-Reply-To <afr32o.o3c.19.1@news.alt.net>
Content-Language en-GB
Xref csiph.com alt.php:3194

Show key headers only | View raw


On 07/10/17 01:17, Ed Mullen wrote:
> So, let's say we have a site with x pages and we would like to create a
> list of the pages ordered by their last modified date.
> 
> How to do using any method, maybe PHP.
> 
> BTW, each page on the site contains this footer code:
> 
> <?php
> $current_file_name = ($_SERVER['REQUEST_URI']);
> $current_path = ($_SERVER['DOCUMENT_ROOT']);
> $full_name = $current_path.$current_file_name;
> $last_modified = filemtime($full_name);
> print("This page last changed: ");
> print(date("F j, Y - h:i A", $last_modified));
> print(" USA Eastern Time");
> ?>
> 
> which displays the last modified date of each page. Not sure if that
> even is relevant.
> 

I'm assuming that your pages are including all the content which is
static instead of fetching the dynamic data from a database.

Then you need to begin with list all the pages, you can use the dir()
function ( http://php.net/manual/en/function.dir.php ) and get the
filetime() for each file, store those in an array with the time in
unixtime as the key and the filename as the value, this requires that
each file has it's unique time, or else you need to have an array of
file names instead of a single value. Then user ksort (
http://php.net/manual/en/function.ksort.php ) to sort the values, use
the numeric sorting.

-- 

 //Aho

Back to alt.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-09 19:17 -0400
  Re: get pages age "J.O. Aho" <user@example.net> - 2017-07-10 07:00 +0200
    Re: get pages age Ed Mullen <ejEMOVER@edmullen.net> - 2017-07-10 10:43 -0400
  Re: get pages age robamman2019@gmail.com - 2019-12-19 04:44 -0800

csiph-web