Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-19
9
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 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