Forum Moderators: coopster

Message Too Old, No Replies

Webpage update notification

Webpage update notification

         

suman haldar

2:46 am on Mar 8, 2006 (gmt 0)

10+ Year Member



Dear Friends,

I want to write PHP script which will use fsockopen to connect to a webpage. and it will check whether the content is changed. If the content is changed it will send a notification to an email address.
Now the first part.

opening a socket connection to a webpage and then returning the file pointer.

and last sending the notification email using the mail function is much clear to me.

But How can I can I check the content. Where the page is changed. And What is the change. There I am stuck. I am weak in the regular expression part.

Wish some guru here can help me out on this case.

Thanks in advance.

Suman Haldar

jatar_k

5:29 pm on Mar 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld suman haldar,

try this page, the user comments have exactly what you are looking for

[php.net...]

suman haldar

12:27 am on Mar 9, 2006 (gmt 0)

10+ Year Member



Dear jatar_k,

I have gone through the document. Which time it will return the remote server time. Or the time in my server where i m running my script?
Is there any way to determine what is the server time of the remote system?

jatar_k

12:51 am on Mar 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the third comment down says it will return the last modified time of the file and has a function someone wrote to do it

suman haldar

3:22 am on Mar 9, 2006 (gmt 0)

10+ Year Member



The third Example


<?php

function filemtime_remote($uri)
{
$uri = parse_url($uri);
$handle = @fsockopen($uri['host'],80);
if(!$handle)
return 0;

fputs($handle,"GET $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($handle))
{
$line = fgets($handle,1024);
if(!trim($line))
break;

$col = strpos($line,':');
if($col!== false)
{
$header = trim(substr($line,0,$col));
$value = trim(substr($line,$col+1));
if(strtolower($header) == 'last-modified')
{
$result = strtotime($value);
break;
}
}
}
fclose($handle);
return $result;
}
echo filemtime_remote('http://example.example.com/index.php');

?>

They said the function will return the last modification date of a JPG file. But in my case it is always returning a 0. Do you have any idea why?