rjsws Posted May 2, 2008 Share Posted May 2, 2008 I am trying to be able to check my server status with images. I have 4 servers that I need to watch. I was thinking that if I had a list that had the names of the server followed by a little red or green circle depending on the status. Here is the list of servers: rjsws.com bbmillc.com roblaptop.gotdns.com:81 jabbaware.gotdns.com I was thinking if I could point at an image/document on the server that it the script run the "then" part, if not then it would run the "else". It seems to work locally but not anywhere else. <? error_reporting(0); $url="http://jabbaware.gotdns.com/rob/status/j.png"; $file = file_get_contents( $url ); if ($file) { echo 'Up<img src="http://rjsws.110mb.com/up.png">'; } else { echo 'Down<img src="http://rjsws.110mb.com/down.png">'; } ?> I'm going crazy here... Please help me figure out how to do this! -Rilla Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/ Share on other sites More sharing options...
conker87 Posted May 2, 2008 Share Posted May 2, 2008 I'm not too sure, but try: <?php error_reporting(0); $url="http://jabbaware.gotdns.com/rob/status/j.png"; $file = file_get_contents( $url ); if ($file > 0) { echo 'Up<img src="http://rjsws.110mb.com/up.png">'; } else { echo 'Down<img src="http://rjsws.110mb.com/down.png">'; } ?> Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-531554 Share on other sites More sharing options...
rjsws Posted May 2, 2008 Author Share Posted May 2, 2008 conker87 - Thanks for the reply. The code still isn't working. It seems like such an easy thing to do. I just can't figure it out! Well... It sorta works. It displays "Down" and the red dot. I don't know what I should do next. Someone please help -Rilla Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-531565 Share on other sites More sharing options...
conker87 Posted May 2, 2008 Share Posted May 2, 2008 You could also try: <?php error_reporting(0); $url="http://jabbaware.gotdns.com/rob/status/j.png"; $file = file_exists($url); if ($file) { echo 'Up<img src="http://rjsws.110mb.com/up.png">'; } else { echo 'Down<img src="http://rjsws.110mb.com/down.png">'; } ?> This might work, if your site is down, then technically the file doesn't exist, right? Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-531573 Share on other sites More sharing options...
rjsws Posted May 2, 2008 Author Share Posted May 2, 2008 It still doesnt work. I am totally baffled with this. Originally I was just going to do a simple page showing image files from each of the servers, so if the server was down then the image wont show. Are there any other code ideas to try? A different approch to showing one image is the server is down and a different if it's up? I'm sure there's a way to check to see if a domain is vaild e.g. rjsws.com and if it is show a image, if it's not then show another image. Ahhh... I'm going crazy! http://rjsws.110mb.com/status.php Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-531780 Share on other sites More sharing options...
conker87 Posted May 2, 2008 Share Posted May 2, 2008 Perhaps just: <?php error_reporting(0); $url="http://jabbaware.gotdns.com/rob/status/j.png"; if (file_exists($url)) { echo 'Up<img src="http://rjsws.110mb.com/up.png">'; } else { echo 'Down<img src="http://rjsws.110mb.com/down.png">'; } ?> Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-531931 Share on other sites More sharing options...
rjsws Posted May 5, 2008 Author Share Posted May 5, 2008 This can be done by using the fsockopen command. Thanks for the help -Rob Link to comment https://forums.phpfreaks.com/topic/103830-solved-help-simple-if-then-else-image-script/#findComment-533754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.