Help - Search - Members - Calendar
Full Version: Update Image
Invision Power Services > Community Forums > Community Web Design and Coding
Michael P
Hi, I am wondering how to create an image similar to the ones in the IPB ACP which say version upto date, or update available.

Either something as basic as that or something more complicated like.

image URL = check.php?clientID=xxx

this checks for data in the page where clientID=xxx to display if website is licensed, or to display if support is still available etc.

Can anyone help me out,

Regards,

Michael
Chad
I'll post the code I use for you.

CODE
<?php
$crrnt_version = @implode("",file("_PATH_TO_LATEST_VERSION_FILE_"));
$val = preg_replace("/^v(.+?)\.(.+?)/","\\1.\\2",$_GET['v']);

$val = preg_replace( "/\\\$/"      , "$"        , $val ); // Yeah, I doubt it
$val = preg_replace( "/\r/"        , ""              , $val ); // Remove literal carriage returns
$val = str_replace( "&"            , "&amp;"         , $val ); // Change out amp;
$val = str_replace( "<!--"         , "<!--"  , $val ); // No HTML Comments!
$val = str_replace( "-->"          , "-->"       , $val ); // ^
$val = preg_replace( "/<script/i"  , "<script"   , $val ); // So you want to run a script?  I don't think so
$val = preg_replace( "/\n/"        , "<br>"          , $val ); // Convert literal newlines
$val = str_replace( "!"            , "!"         , $val ); // No Excl!
$val = str_replace( ">"            , "&gt;"          , $val ); // No >
$val = str_replace( "<"            , "&lt;"          , $val ); // No <
$val = str_replace( "\""           , "&quot;"        , $val ); // No Quotes
$val = str_replace( "'"            , "'"         , $val ); // IMPORTANT: It helps to increase sql query safety.

if ($val!=$crrnt_version)
{
 header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header('content-type: image/gif');
 readfile('_PATH_TO_UPDATE_IMAGE_');
}
elseif ($val==$crrnt_version)
{
 header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header('content-type: image/gif');
 readfile('_PATH_TO_UPDATE_TO_DATE_IMAGE_');
}
?>


Call that code like so:

CODE
<a href='_PATH_TO_YOUR_SITE_'><img src='_PATH_TO_SCRIPT_FILE_?v={$yours}' alt='version check down' border='0' /></a>


Make sure its a GIF image. You can modify the script to use a PNG or JPEG.
You can play around with the code to see what goodies you come up with. original.gif

Chad
Michael P
I set the top line to
CODE
$crrnt_version = @implode("55",file("yey.gif"));


But when I go to url.php?v=55 it shows the need to update image

sad.gif

What did i do wrong?
Michael P
Nevermind - I googled $crrnt_version and found your full example - didnt realise that would store the version number in a txt file,

cheers chad
Chad
No problem.

I guess I should have said the current version is in a text file. tongue.gif
Sorry about that. wink.gif

Chad
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.