2
Contributors
13
Replies
14
Views
6 Years
Discussion Span
Last Post by TS77
0

Yep. You need the url of the image, then copy and resize it. Should be simple enough. Loads of resize scripts online.

0

Ardav, I think you have mistaken my request.

I can already get PHP to display images, thats not what I want.

I suppose its like a portfolio site. If I own 3 websites, site 1 is called 1.com, site 2 is called 2.com and site 3 is called me.com

I want a visitor to visit me.com and in there, will be a screenshot of 1.com and 2.com.

If I make changes to the code of 2.com, then I want me.com to display the image on pageload (or refresh) automatically, without the need for me to make a screenshot and update it upon every site change.

0

Ah I see. In which case, you need to check the lastupdated datetime of the site against the lastupdated image. If site updated since the image - create a new image.

0

I see, now I just need to Google how to get me.com to look at 1.com datetime update, then compare it against the current image timestamp, then screenshot it if it is out of date and then do the same with 2.com

Thanks Ardav

0

Getting the file modified time of a remote file is really challenging. You could do it via curl, but these scripts can be a pain to install. I've tried a number of them and find them to be problematic.

One approach that may work would be to have a new page (datecheck.php) in the remote sites with the following data:

<?php
echo filemtime("index.php");
?>

So from your site, call this:

$site1LastUpdate = file_get_contents("http://www.site1.com/datecheck.php");

Your host needs to allow file_get_contents from a remote site, otherwise you may be stuck with curl.
Check this against an image file on the site displaying the images:

$site1ImageUpdate = filemtime("images/site1.jpg");

THen once you have the dates, you can compare them:

if($site1LastUpdate > $site1ImageUpdate){
  //create new image and overwrite the last
}else{
  //use the current site image
}

This could be slow if you had to do this for many images though.

Anyway, thought I'd throw that your way. Perhaps somebody could offer a better solution?

0

I will give it a go, thank you so much for your time.

There is a few images to load though (about 12) hopefully this should be enough :)

0

If you have more than one page in one website, then you can add them to the same datecheck.php file, to avoid making to many calls.

0

I wonder if something like:

<div style="display:inline">
<div width="300px" height="auto">
<?php include ( 'http://www.1.com' ); ?>
</div>
<div width="300px" height="auto">
<?php include ( 'http://www.1.com' ); ?>
</div>
</div>

would work?

Edited by TS77: Hadn't completed sentence!

0

Was wondering whilst I was in work, going to try it tonight (unless you tell me it wont work lol)

0

Tried this which works apart from the resizing issue:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
#outerWrapper {
	margin-right: auto;
	margin-left: auto;
	width: 400px;
}
#google {
	float: left;
	width: 200px;
	max-height: 300px!important;
}
#yahoo {
	float: right;
	width: 200px;
	max-height: 300px!important;
}
</style>
</head>

<body>
<div id="outerWrapper">
<div id="google">
<?php
readfile("http://www.google.co.uk");
?>
</div>
<div id="yahoo">
<?php
readfile("http://www.yahoo.com");
?>
</div>
</div>
</body>
</html>

Edited by TS77: n/a

0

What are you doing with this? Are you displaying the whole contents of the remote pages on your site? I don't see why you'd want to do that. You're not creating an image here - you're outputting html to your page. Just have a look at the underlying html.

I really really don't suggest you do this.

You just need an up-to-date screenshot.

Did you try my suggestion: http://www.daniweb.com/web-development/php/threads/352992/1500664#post1500664

Edited by diafol: n/a

0

The contents would be a live feed of my previous work in a small container.

But I did try your code and got 2 problems, firstly:

Notice: Undefined variable: site1LastUpdate in C:\wamp\www\Test\1.php on line 16

and

Notice: Undefined variable: site1ImageUpdate in C:\wamp\www\Test\1.php on line 16

I know I have to declare them but I am unsure where.

The other problem I had was the last part:

if($site1LastUpdate > $site1ImageUpdate){
  [B]//create new image and overwrite the last[/B]
}else{
  [B]//use the current site image[/B]
}

This was the bit I didnt understand how to do, how can PHP take a screenshot? I tried researching the answer but to be honest, it all seemed a little to advanced for me. So I found the readfile solution that does what I need, but just need to figure out how to resize it (or get your code to work lol)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.