Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   display datestamp in HTML (http://www.velocityreviews.com/forums/t902085-display-datestamp-in-html.html)

Phil M 03-02-2007 04:40 PM

display datestamp in HTML
 
Hi all. I have am HTML web page where I upload a file which is always
called document.pdf. Users get there, click on the icon and download
the document.pdf.

Below the icon/link where users click to get document, is there any
way to display the datestamp of document.pdf?

ie: the document you're about to download was updated: March 2 2007

My web page file name is called index.html (page where I want the
datestamp to de displayed)
The directory where I can store perl scripts (in .pl) is called /bin
The file from which I want the datestamp to be retrieved is called
document.pdf

I searched the Internet for such a simple script but couldn't find
any. I'm not a programmer, so please bear with me. Assume I find a
pl script which captures the datestamp of document.pdf, all I know is
that I have to modify the header of the .pl file to read:
#!/usr/bin/perl then upload it in /bin

THEN, what code do I have to paste in the index.html to print the
actual datestamp? The server is Apache 1.3.26

Thanks for any suggestions!

Tony Curtis 03-02-2007 05:11 PM

Re: display datestamp in HTML
 
Phil M wrote:
> Hi all. I have am HTML web page where I upload a file which is always
> called document.pdf. Users get there, click on the icon and download
> the document.pdf.
>
> Below the icon/link where users click to get document, is there any
> way to display the datestamp of document.pdf?


If the modification date of the file is what you want as the actual
document modification date, then SSI would be a much simpler solution,
but nothing to do with perl.

hth
t

Phil M 03-02-2007 05:36 PM

Re: display datestamp in HTML
 
Thanks for the quick reply. It can be either. Modification date,
upload date or file date or creation date; whatever is simpler.

Either the file datestamp (as it appears next to the filename when I
log in to the ftp web server) or the date which it was uploaded. it
doesn't matter since the date that I create the pdf file I also upload
it; so creation/modification/upload date is the same.

>If the modification date of the file is what you want as the actual
>document modification date, then SSI would be a much simpler solution,
>but nothing to do with perl.


Phil M 03-02-2007 05:48 PM

Re: display datestamp in HTML
 
> then SSI would be a much simpler solution

Thanks, I'll ask the same question on a SSI Javascript group.

Phil M 03-02-2007 06:31 PM

Re: display datestamp in HTML
 
I found a small perl script which claims to do the trick and it seems
that I can't get the code right:

Here's my web page: (note that the date doesn't appear)
http://www.greekradio.net/psa.html

This is the script: (stored in cgi/lastmodified.pl)


#!/usr/bin/perl

# Script name:
# @1 Last Modified Date and Time

# Purpose:
# This Perl script checks the "Last Modified" date and time
# of a file.

# Uses:
# Call the display via SSI using the tag below:
# <!--#include virtual="yourfolder1/yourfolder2/lastmodified.cgi" -->

# License Notice:
# Copyright 2004 UPDI Network Enterprise, www.upoint.info/cgi
# You are free to use and distribute this script as long as
# you keep this license notice intact.

################################################## ##########
# FULL PATH (not URL) to the file:
################################################## ##########
$filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";

################################################## ##########
# Turn on debug mode so that you can see the formats
################################################## ##########
$debug = "0"; # 1 = ON 0 = OFF
# Set to "0" after testing
################################################## ##########
# DO NOT EDIT BELOW THIS LINE
################################################## ##########

use POSIX 'strftime';
my $time = (stat $filename)[9];
print "Content-type: text/html\n\n";

print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;

if ($debug eq 1){
print "<p>";
print "a - ";
print strftime '%a', localtime $time;
print "<BR>";
print "A - ";
print strftime '%A', localtime $time;
print "<BR>";
print "b - ";
print strftime '%b', localtime $time;
print "<BR>";
print "B - ";
print strftime '%B', localtime $time;
print "<BR>";
print "c - ";
print strftime '%c', localtime $time;
print "<BR>";
print "d - ";
print strftime '%d', localtime $time;
print "<BR>";
print "H - ";
print strftime '%H', localtime $time;
print "<BR>";
print "I - ";
print strftime '%I', localtime $time;
print "<BR>";
print "j - ";
print strftime '%j', localtime $time;
print "<BR>";
print "m - ";
print strftime '%m', localtime $time;
print "<BR>";
print "M - ";
print strftime '%M', localtime $time;
print "<BR>";
print "p - ";
print strftime '%p', localtime $time;
print "<BR>";
print "s - ";
print strftime '%s', localtime $time;
print "<BR>";
print "U - ";
print strftime '%U', localtime $time;
print "<BR>";
print "w - ";
print strftime '%w', localtime $time;
print "<BR>";
print "W - ";
print strftime '%W', localtime $time;
print "<BR>";
print "x - ";
print strftime '%x', localtime $time;
print "<BR>";
print "X - ";
print strftime '%X', localtime $time;
print "<BR>";
print "y - ";
print strftime '%y', localtime $time;
print "<BR>";
print "Y - ";
print strftime '%Y', localtime $time;
print "<BR>";
print "Z - ";
print strftime '%Z', localtime $time;
}

Thanks for any suggestions on what I might be doing wrong.

Phil M 03-02-2007 06:46 PM

Re: display datestamp in HTML
 
I also saved the file as an shtml, same results:

http://www.greekradio.net/psa.shtml

Mumia W. 03-02-2007 07:40 PM

Re: display datestamp in HTML
 
On 03/02/2007 10:40 AM, Phil M wrote:
> Hi all. I have am HTML web page where I upload a file which is always
> called document.pdf. Users get there, click on the icon and download
> the document.pdf.
>
> Below the icon/link where users click to get document, is there any
> way to display the datestamp of document.pdf?
>
> ie: the document you're about to download was updated: March 2 2007
> [...]


This is how you might find out the datestamp:

use POSIX qw(asctime);
my $filename = 'my.flat';
print asctime(localtime((stat $filename)[9]));

Read the documentation for asctime and stat. I'm assuming that you're a
Windows user:

Start->Run->"perldoc POSIX"
Start->Run->"perldoc -f stat"

After you have the datestamp in a string, printing it should be
elementary. Good luck.

anno4000@radom.zrz.tu-berlin.de 03-03-2007 01:04 PM

Re: display datestamp in HTML
 
Phil M <jimmyc@trexagi.net> wrote in comp.lang.perl.misc:
> I found a small perl script which claims to do the trick and it seems
> that I can't get the code right:


Then show your code. We can't help you with what we don't get to see.

> Here's my web page: (note that the date doesn't appear)
> http://www.greekradio.net/psa.html


How about saying *where* the date is supposed to appear?

> This is the script: (stored in cgi/lastmodified.pl)
>
> #!/usr/bin/perl
>
> # Script name:
> # @1 Last Modified Date and Time
>
> # Purpose:
> # This Perl script checks the "Last Modified" date and time
> # of a file.
>
> # Uses:
> # Call the display via SSI using the tag below:
> # <!--#include virtual="yourfolder1/yourfolder2/lastmodified.cgi" -->
>
> # License Notice:
> # Copyright 2004 UPDI Network Enterprise, www.upoint.info/cgi
> # You are free to use and distribute this script as long as
> # you keep this license notice intact.
>
> ################################################## ##########
> # FULL PATH (not URL) to the file:
> ################################################## ##########
> $filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";
>
> ################################################## ##########
> # Turn on debug mode so that you can see the formats
> ################################################## ##########
> $debug = "0"; # 1 = ON 0 = OFF
> # Set to "0" after testing
> ################################################## ##########
> # DO NOT EDIT BELOW THIS LINE
> ################################################## ##########
>
> use POSIX 'strftime';
> my $time = (stat $filename)[9];
> print "Content-type: text/html\n\n";
>
> print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;
>
> if ($debug eq 1){
> print "<p>";
> print "a - ";
> print strftime '%a', localtime $time;
> print "<BR>";
> print "A - ";
> print strftime '%A', localtime $time;
> print "<BR>";
> print "b - ";
> print strftime '%b', localtime $time;
> print "<BR>";
> print "B - ";
> print strftime '%B', localtime $time;
> print "<BR>";
> print "c - ";
> print strftime '%c', localtime $time;
> print "<BR>";
> print "d - ";
> print strftime '%d', localtime $time;
> print "<BR>";
> print "H - ";
> print strftime '%H', localtime $time;
> print "<BR>";
> print "I - ";
> print strftime '%I', localtime $time;
> print "<BR>";
> print "j - ";
> print strftime '%j', localtime $time;
> print "<BR>";
> print "m - ";
> print strftime '%m', localtime $time;
> print "<BR>";
> print "M - ";
> print strftime '%M', localtime $time;
> print "<BR>";
> print "p - ";
> print strftime '%p', localtime $time;
> print "<BR>";
> print "s - ";
> print strftime '%s', localtime $time;
> print "<BR>";
> print "U - ";
> print strftime '%U', localtime $time;
> print "<BR>";
> print "w - ";
> print strftime '%w', localtime $time;
> print "<BR>";
> print "W - ";
> print strftime '%W', localtime $time;
> print "<BR>";
> print "x - ";
> print strftime '%x', localtime $time;
> print "<BR>";
> print "X - ";
> print strftime '%X', localtime $time;
> print "<BR>";
> print "y - ";
> print strftime '%y', localtime $time;
> print "<BR>";
> print "Y - ";
> print strftime '%Y', localtime $time;
> print "<BR>";
> print "Z - ";
> print strftime '%Z', localtime $time;
> }


Which garbage dump did you search to find this "script"? The author
doesn't have the slightest idea about programming, let alone Perl.
Programming is, among other things, about letting the computer do
the work.

Stripped of its pompous commentary and its pathetically repetitious
code, replace the whole thing by this:

#!/usr/bin/perl
use strict; use warnings;
use POSIX 'strftime';

my $filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";

my $debug = 1;
my $time = (stat $filename)[9] or die "Can't stat '$filename': $!";

print "Content-type: text/html\n\n";

print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;

if ( $debug ) {
my $fmt = '<p>' . join '<BR>', map "$_ - %$_",
qw( a A b B c d H I j m p s U w W x X y Y Z);
print strftime $fmt, localtime $time;
}
__END__

> Thanks for any suggestions on what I might be doing wrong.


You're not showing what you're doing. How can we say what you're doing
wrong?

Anno

Phil M 03-03-2007 04:33 PM

Re: display datestamp in HTML
 
>Stripped of its pompous commentary and its pathetically repetitious
>code, replace the whole thing by this:


Anno,

YOUR CODE WORKED! here:
http://s135598769.onlinehome.us/greekradio/psa.shtml

However, I had to rename the file with a .shtml to work. Is there any
way to keep the .html extension?

Also, you may want to make this small and very efficient code
available somewhere because it may find good use among people with
webcams. For example, every time a webcam a photo is uploaded, you
code will display the datestamp and timestamp of the photo, rather
than the date/time of the web page. Good work!

Please inform for the .shtml issue.

Thanks again.

Joe Smith 05-18-2007 06:13 PM

Re: display datestamp in HTML
 
Phil M wrote:

> However, I had to rename the file with a .shtml to work. Is there any
> way to keep the .html extension?


You'll have to ask the person who controls the configuration file for
the web server. If they don't allow individual .htaccess files, the
answer is "no".
-Joe


All times are GMT. The time now is 11:24 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.