Closed Thread Icon

Preserved Topic: Last modified Pages that link to <a href="https://ozoneasylum.com/backlink?for=21236" title="Pages that link to Preserved Topic: Last modified" rel="nofollow" >Preserved Topic: Last modified\

 
Author Thread
Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 11-11-2001 02:15

Is there a way to find out of the last modified date of the file that is on another server (different computer)?

I need it in ASP, but any other language might give me a clue as well.

Thx

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 11-11-2001 11:13

You didn't specify which protocol you plan on using (HTTP, FTP, etc.), so I'll assume that you want to use HTTP protocol. If so, HTTP header that web server sends back when you request some specific document (html page, image file, etc.) contains "Last-Modified" string which is the thing that you want. And now to explain how to fetch HTTP header (I don't know how ASP works, so I'll talk generally). You must establish raw TCP/IP socket connection (you should also insure that you're connecting to the right port - 80 is mostly used for HTTP) with server that's hosting the file whose last modified timestamp you want to get. After that you must send "HEAD" HTTP request (you can also use "GET", but we only need header, not actual document) to the server and fetch the result that it sends back. After that simply parse the result (look for "Last-Modified" string). Here's how you can get HTTP header with PHP:

<?php

$fp = fsockopen ("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
&nbsp;&nbsp;&nbsp;&nbsp;echo "$errstr ($errno)<br>\n";
} else {
&nbsp;&nbsp;&nbsp;&nbsp;fputs ($fp, "HEAD /folder/file.ext HTTP/1.1\r\nHost: w&#119;w.example.&#99;om\r\n\r\n");
&nbsp;&nbsp;&nbsp;&nbsp;while (!feof($fp)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo fgets ($fp,128);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;fclose ($fp);
}

?>


Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 11-11-2001 23:35

Thanks Max,

I don't see this solution using ASP.

My web cam page is hosted on my computer, and the rest of the web site on another server.
Now what I want to do is to add small "on" or "off" to the "web cam" link.

The idea was to check the last modified time of the image, and if it is less then 30 seconds difference between last modified time and current time I would say "off" if not, I would say "on".

I'll keep looking for the ASP solution. There might be some components out there, but I don't want to do that. It is not that important.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-12-2001 11:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-12-2001 11:34

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 11-12-2001 17:52

Thanks InI, I know about FSO, that's how I found out the last modified date of the file that is on the server (where my site is hosted), but I need to know the last modified date for the file that is on an another server, let's say http://www.ozoneasylum.com/images/ASYLUM44b.jpg
FSO won't work here. I can map the drive using TCP/IP but I don't wanna do that, since the importance of this is not that big.
I think Max gave me the right directon.

Thanks anyway.
Sash

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-12-2001 18:17

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 11-12-2001 21:37

Sash, you should really consider switching over to PHP, heh...


Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 11-15-2001 22:15

Max, I hear you but here is the solution:

<%@ Language=VBScript %>
<%
Function getURLHeader(url, method, headerName)

Dim oXmlHttp
' Create an xmlhttp object:
Set oXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

' Opens the connection to the remote server.
oXmlHttp.Open method, url, False
oXmlHttp.Send
getURLHeader = oXmlHttp.getResponseHeader(headerName)
set oXmlHttp = nothing

End Function

Response.Write getURLHeader("http://www.google.com/images/logo.gif", "GET", "Last-Modified")
%>

Pretty neat stuff.
Weeeee

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-15-2001 23:39

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 11-15-2001 23:42

I guess there is still code tweaking here. Some servers understand Microsoft.XMLHTTP instead of MSXML2.ServerXMLHTTP.

Also, the date doesn't seem to be formated properly, so regexp or replace might help.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 11-16-2001 00:05

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 11-16-2001 08:26

Sash, you should use "HEAD" instead of "GET" method, because "HEAD" will only return HTTP header, while "GET" will return complete file (incl. HTTP headers) and your server will actually have to download whole file first...


butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 09-22-2002 04:13

Does the header that's returned always have a Last-Modified string in it?

I've run the code that mr.maX posted above and I get the return info, but I don't see anything that resembles a last modified time. Is there something else I need to do?

Thanks

-Butcher-

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 09-23-2002 09:14

Hello Sash,

the object you used looks like it exists on every default IIS installation, so your codes works w/o extra components right?


I was refered to this http://www.serverobjects.com/comp/asphttp3.htm when I wanted to get html pages using ASP.


Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 09-25-2002 02:10

I've been looking at the headers returned by butcher's implementation of that code and the results seem highly variable so I'm wondering what are the conditions/server settings which determine what is sent back and why?

___________________
Emps

FAQs: Emperor

« BackwardsOnwards »

Show Forum Drop Down Menu