Page 2 of 2

Posted: Sat Feb 24, 2007 5:56 am
by onion2k
Ah. Clever.

What they're doing is just displaying an image from their server. For example, imagine you have an HTML page with an image in it called "http://www.domain.com/upgrade.jpg" ... that just displays the image from domain.com. Using PHP you can dynamically generate an image (with GD). So if you set php properly you can call something like upgrade.jpg?version=123, and build an image based on that. Obviously you'd make a "you need to upgrade" image if the latest version was lower than the version passed in the GET request.

Essentially it completely bypasses PHP. It's just done in the browser. That's a very sensible approach really because it doesn't rely on URL wrappers or external calls of any sort being available on the server.

Posted: Sat Feb 24, 2007 3:55 pm
by tarja311
Thanks for that bit of info.

I have looked up GD and used the following code:

Code: Select all

<?php
function LoadPNG($imgname)
{
   $im = @imagecreatefrompng($imgname); /* Attempt to open */
   if (!$im) { /* See if it failed */
       $im  = imagecreatetruecolor(150, 30); /* Create a blank image */
       $bgc = imagecolorallocate($im, 255, 255, 255);
       $tc  = imagecolorallocate($im, 0, 0, 0);
       imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
       /* Output an errmsg */
       imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
   }
   return $im;
}
header("Content-Type: image/png");
$img = LoadPNG("http://mydomain.com/upgrade.png");
imagepng($img);
?>
Unfortunately this requires that i have the fopen wrappers on also. All i receive is a timeout for about 3-5 minutes then the "Error loading" message. It only works if i call for the image locally. Anyways, is this what you meant in the post above?

Posted: Sat Feb 24, 2007 3:58 pm
by nickvd
try a normal image tag..

<img src="http://mydomain.com/upgrade.png">

Posted: Sat Feb 24, 2007 4:30 pm
by tarja311
Using just the image tag works fine, but the situation has to be conditional. If my apps version is this, show this image, if my apps version is that, show that image.

Without the fopen wrapper i am totally stumped here. :cry:

Posted: Sat Feb 24, 2007 4:47 pm
by nickvd
Without url fopen, you will be forced to display the image, and if the version is out of date, insert into the image that it needs upgrading, and if it's not, don't insert anything.

Posted: Sat Feb 24, 2007 7:35 pm
by tarja311
Ok but how does the app know it is out of date if it can't connect to the remote server to check against version number?

I'm sorry to sound so newbie-ish.

Posted: Sat Feb 24, 2007 10:06 pm
by nickvd
That's just it.. the app won't. The only way that I can see the app being able to determine whether or not it is current is to have url fopen turned on.

The best you will be able to do is to display a message that it should be upgraded.