Categories
How To Programming Projects Technology tsnLocal.net

Hamachi Web Status Images

Update…

Unfortunately, LogMeIn figured out they forgot about that page, I guess when people started reading this post and hitting it on their servers. They have removed the text status as well as all the others, and I can’t figure out why they would do such a thing.

I’m also not sure what they’re offering as an alternative either. So if you know, please leave a comment below. Thanks.

Depreciated Process…

A while back, I started a project called tsn.lcl or tsnlocal, but gave up on it when my electricity bill hit $400 in a month.

Today, I decided to fix up the domain name and get it back on the internet – at least to remove it from GoDaddy’s Parking Page – where they’re making money, not me, off of it.

When I got it published I noticed that none of the Hamachi Web Status images worked anymore, and that the link to such an image, redirected to their login page for your Hamachi Management Dashboard. However, upon further investigation, I found that there was not only an Image version of those status instances, but also a text version.

I really wanted to show the online status of all my machines again, so I wrote my own php script to parse that text data, and created some simple images to show on the website based on the returned status.

So here’s the code so you can do the same thing…

The PHP Function

[cc lang=”php”]<?php
function hamachiImg($ip) {
$url = “https://my.hamachi.cc/status/text.php?$ip”;
$status = file_get_contents($url);
$status = preg_replace(‘/\d*\.\d*\.\d*.\d* /’, ”, $status);
$image_url = “./images/$status.png”;
return $image_url;
}
?>[/cc]
This code creates a $url variable with the address to the text status, based on the $ip that is passed to it. Then it requests the data, removes the ip address and the trailing space, leaving only the status text. On the server, I have a collection of images with the 4 different statuses as their file name, and with that an $image_url is created to be returned.

The 4 possible statuses are:

  • – online
  • – offline
  • – unknown
  • – error

The HTML Code and PHP Function Call

Once you have your php function in the page (I stuck mine before the first <html> tag), you can use the php function to insert the image url when you pass it an IP…
[cc lang=”html”]<table>
<tr>
<td style=”width: 100%”>[[Neo]]:</td>
<td style=”width: 100%”> <img src=”<?php echo hamachiImg(‘5.37.117.104’); ?>”></td>
</tr>
</table>[/cc]
hamachi-exampleOnce you’ve done that, assuming you have entered a valid hamachi IP address, the results should look something like the image at right.

By [[Neo]]

I am a web programmer, system integrator, and photographer. I have been writing code since high school, when I had only a TI-83 calculator. I enjoy getting different systems to talk to each other, coming up with ways to mimic human processes using technology, and explaining how complicated things work.

Of my many blogs, this one is purely about the technology projects, ideas, and solutions that I have come across in my internet travels. It's also the place for technical updates related to my other sites that are part of The-Spot.Network.

4 replies on “Hamachi Web Status Images”

Leave a Reply to [[Neo]]Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.