Solved

How can i tell if a text file or HTML file is modified from the web.

Posted on 2004-04-19
9
175 Views
Last Modified: 2010-04-05
Hi,

  How can i detect if a webpage is modified on the web via HTTP, I would like to write a program that will check a HTML/Text file to see if it has been updated or modified and display a popup message saying "web page updated". for example, If i create a text file "Blah.txt" and upload it to my webpage. everytime i edit "blah.txt" I want my program to popup a message saying update or webpage has been modified without downloading the file, Checking with be timer based of course.. More points will be awarded if requested. Souce code please.

Thanks,
Forton
0
Comment
Question by:Forton
  • 4
  • 4
9 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10860971

   On the server you can use for example PHP and filemtime($filename) which gives you the file modified time and store it in hidden field.

   From the client you should read this hidden field
0
 
LVL 4

Expert Comment

by:mbprogrammer
ID: 10862168
in your request add this line :
If-Modified-Since: ' + RFC1123_Date(Your_Desired_DateTime) + ' GMT'
. the server will send the doc if it's newer than your given time.
0
 
LVL 4

Expert Comment

by:mbprogrammer
ID: 10862217
here is the source code for RFC1123 function :

you cannot use Delphi own function because the date must be specified in  english and Delphi use the current language.

function RFC1123_Date(aDate : TDateTime) : String;
const
   StringWeekDay : String = 'MonTueWedThuFriSatSun';
   StringMonth   : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
var
   Year, Month, Day       : Word;
   Hour, Min,   Sec, MSec : Word;
   DayOfWeek              : Word;
begin
   DecodeDate(aDate, Year, Month, Day);
   DecodeTime(aDate, Hour, Min,   Sec, MSec);
   DayOfWeek := ((Trunc(aDate) - 2) mod 7);
   Result := Copy(StringWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
             Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
                    [Day, Copy(StringMonth, 1 + 3 * (Month - 1), 3),
                     Year, Hour, Min, Sec]);
end;
0
 

Author Comment

by:Forton
ID: 10862479
Hi mbprogrammer,

 I'm a little confused on the "If-Modified-Since: ' + RFC1123_Date(Your_Desired_DateTime) + ' GMT'. the server will send the doc if it's newer than your given time" I want to ad this to a timmer but confused on the if modified syntex to excute the  request line, i know where your going with this and its a great idea. Thats what i want to do..

Forton.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:mbprogrammer
ID: 10862683
you shoud add that line in your request string and then send your request to server
0
 

Author Comment

by:Forton
ID: 10864343
Hi,
 
 I still cannot make any sense of how to use the commandline or how its suppose to get the date by (Your_Desired_DateTime) or how to get my program to tell me if its modified or not, could you make a demo app, posting it here or emailing it to my email hyperon@eudoramail.com.
I will also give more points if needed.

Thanks,
Forton.
0
 
LVL 4

Accepted Solution

by:
mbprogrammer earned 500 total points
ID: 10867088
Ok lets start from first :
 Your program want to know whether any updates after 2004/04/19
 for the file http://www.mypage.com/updates/myfile.txt
 is available or not.
 It should send a request to web server.
 for doing this, you should do one of bellow methods :

 1 :
    you should send a http request like bellow
    (via http components such as ICS or Indy) :

     "GET /updates/myfile.txt HTTP/1.1
     Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
     Connection: Keep-Alive
     Accept-Language: en
     User-Agent: Mozilla/3.0 (compatible)
     Host:www.mypage.com
     If-Modified-Since: Mon, 19 Apr 2004 00:00:00 GMT"

   which tells web server to send the file
   if the file is newer than 2004/04/19.
   and if your web server is Http ver 1.1 then you can specify
   a range for your file for resuming after a breakdownload or .....
   it's like this :
     'Range: bytes=0-1'
   the first integer indicates the start position and the seccond is
   length of data you want.if you dont specify the seccond integer
   the server will send it from start position you specified to end.
   
   for creating this time --> 'Mon, 19 Apr 2004 00:00:00 GMT'
   from this --> 2004/04/19 ,you should use RFC1123 function
    plus a GMT string after the result of the function.

 2:
   you can upload a file in your server which contains information
   about your application updates and other things
   (for example what's new and ...).Then your program will download
   that file and process it's information for any info it needs.
0
 

Author Comment

by:Forton
ID: 10868271
HI

 I have a text file on a server, i can get the file no problem with my program, using http get, i cannot figure the excute commandline you have posted. I keep getting date invalid while trying to ecute your code.


Forton.
0
 

Author Comment

by:Forton
ID: 10869881
ok i fixed it, i screwed up on a few things but fixed now. Thank you so much..


Forton.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now