bld-live.dk saving the environment, I think…

15Aug/100

Webcams

I have had these camera's up for some time, and have had them online for some time, and then took them off again. This was mostly because I used my ASRock ION330HT to make it all work, and after I decided to no longer have it running 24/7, I had no computer to bring the images online.

Now I finally took the time to make it work again, this time with everything running over my QNAP TS-219P nas instead of the ASRock.

Check them out, you can find them in the top under "Webcams"

I have posted this in multiple categories because I am going to update this with more info about how it all works.

28Jul/100

CURL with image

This is the snippet I use for showing images from internally on my network. The idea is that only the web server is exposed to the internet, so it isn't possible to directly change anything on the picture server.

<?php
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://10.0.0.50:8080/camera.jpg");
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer))
	{
		print "Picture unavalible";
	}
	else
	{
		header('Content-Type: image/jpeg');
		print $buffer;
	}
?>
Filed under: PHP No Comments
28Jul/100

Check IP range

I needed a little something to check if one of my files was called from an internal IP, and for this I made this little function.

<?php
function validIp($IP)
	{
		$IP = ip2long($IP);
		$StartIP = ip2long("10.0.0.100");
		$EndIP   = ip2long("10.0.0.150");
		if ($IP >= $StartIP && $IP <= $EndIP)
		{
			return TRUE;
			break;
		}
		return FALSE;
	}

$ip = $_SERVER['REMOTE_ADDR'];

if (validIp($ip))
	{
		echo "Granted";
	}
	else
	{
		echo "Denied";
	}
?>
Filed under: PHP No Comments