seriosbrad Posted January 26, 2010 Share Posted January 26, 2010 Alright I have a link that generates an online/offline image according to the status of a server. http://www.domain.com/script.php?ip=11.11.111.111&port=12354 By directly going to that link, it displays the image fine. However what I want to do is use that link like this: <img src="http://www.domain.com/script.php?ip=11.11.111.111&port=12354"> and [img=http://www.domain.com/script.php?ip=11.11.111.111&port=12354] And have that turn into an image based on the status of the server. Here is my script <?php $ip = $_GET["ip"]; $port = $_GET["port"]; $timeout = 1; function ip($address){ list($ip,$port)=explode(":",$address); if($fp=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,1)) { print "<img src='images/status/up.png'>"; fclose($fp); }else{ print "<img src='images/status/down.png'>"; } } ip("$ip:$port"); ?> Please bare in mind that I am not a coder, I can understand some thing from copy+pasting and trial & error. Link to comment https://forums.phpfreaks.com/topic/189922-help-turning-domaincomfilephpidxxx-into-an-image/ Share on other sites More sharing options...
premiso Posted January 27, 2010 Share Posted January 27, 2010 <?php $ip = $_GET["ip"]; $port = $_GET["port"]; $timeout = 1; header('Content-Type: image/png'); function ip($address){ list($ip,$port)=explode(":",$address); if($fp=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,1)) { //print "<img src='images/status/up.png'>"; fclose($fp); readfile($_SERVER['DOCUMENT_ROOT'] . "/images/status/up.png"); }else{ readfile($_SERVER['DOCUMENT_ROOT'] . "/images/status/down.png"); } } ip("$ip:$port"); ?> Give that a shot. This is assuming images is located in your webserver root (IE http://www.yoursite.com/images). Link to comment https://forums.phpfreaks.com/topic/189922-help-turning-domaincomfilephpidxxx-into-an-image/#findComment-1002144 Share on other sites More sharing options...
seriosbrad Posted January 27, 2010 Author Share Posted January 27, 2010 Would you look at that, it works! Thanks premiso you've been a great help! Link to comment https://forums.phpfreaks.com/topic/189922-help-turning-domaincomfilephpidxxx-into-an-image/#findComment-1002148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.