Image with url and digest authentication

For me with openhab 2.2 and 2.3 image view for ip cameras (Trendnet) was definitely not working anymore, as digest authentication is not supported in newer versions.

As a workaround I have found this nice php-Script, that i integreted in the nginx-proxy-server (Basic authentication enabled as for openhab)

<?php
/* IP Camera Proxy
 * PHP frontend to interface with cheap password-protected webcams and 
 * pull images for public display on a website
 * 
 * Copyright Will Bradley, 2012 (www.zyphon.com)
 * Distributed under a Creative Commons Attribution 3.0 license
 * http://creativecommons.org/licenses/by/3.0/
 *
 * To use, change EXAMPLE.COM, the port number, EXAMPLEUSER, & EXAMPLEPASSWORD
 * to their correct values for your setup. I use cheap Hootoo-brand cameras
 * for my setup, yours may be different regarding snapshot urls and auth
 * mechanisms. Then, host this on a PHP site and access it at 
 * /snapshot.php?camera=1
 * 
 */

if($_GET['camera'] == 1) 
{
	$url = 'http://#IPadresse#:80/image/jpeg.cgi';  // remember there needs to be a ? between the URL and the random number. Don't remove the question mark.
	
	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl_handle,CURLOPT_URL,$url); 
	curl_setopt($curl_handle, CURLOPT_USERPWD, "user:password");
  	curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); 
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	
	if (empty($buffer))
	{
	    print "";
	}
	elseif($buffer == "Can not get image.")
	{
	    print "Can not get image.";
	}
	else
	{
	    header("Content-Type: image/jpeg");
	    print $buffer;
	}
}
elseif($_GET['camera'] == 2) 
{
	$url = 'http://#IPadresse#:80/image/jpeg.cgi';  // remember there needs to be a ? between the URL and the random number.  Don't remove the question mark.
	
	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl_handle,CURLOPT_URL,$url); 
	curl_setopt($curl_handle, CURLOPT_USERPWD, "user:password");
 	curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); 
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	
	if (empty($buffer))
	{
	    print "";
	}
	elseif($buffer == "Can not get image.")
	{
	    print "Can not get image.";
	}
	else
	{
	    header("Content-Type: image/jpeg");
	    print $buffer;
	}
}
elseif($_GET['camera'] == 3) 
{
	$url = 'http://#IPadresse#:80/Streaming/channels/1/picture';  // remember there needs to be a ? between the URL and the random number. Don't remove the question mark.
	
	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl_handle,CURLOPT_URL,$url); 
	curl_setopt($curl_handle, CURLOPT_USERPWD, "user:password");
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	
	if (empty($buffer))
	{
	    print "1";
	}
	elseif($buffer == "Can not get image.")
	{
	    print "Can not get image.";
	}
	else
	{
	    header("Content-Type: image/jpeg");
	    print $buffer;
	}
}
elseif($_GET['camera'] == 4) 
{
	$url = 'http://#IPadresse#:80/Streaming/channels/1/picture';  // remember there needs to be a ? between the URL and the random number. Don't remove the question mark.
	
	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl_handle,CURLOPT_URL,$url); 
	curl_setopt($curl_handle, CURLOPT_USERPWD, "user:password");
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	
	if (empty($buffer))
	{
	    print "";
	}
	elseif($buffer == "Can not get image.")
	{
	    print "Can not get image.";
	}
	else
	{
	    header("Content-Type: image/jpeg");
	    print $buffer;
	}
}
elseif($_GET['camera'] == 5) 
{
	$url = 'http://#IPadresse#:80/Streaming/channels/1/picture';  // remember there needs to be a ? between the URL and the random number. Don't remove the question mark.
	
	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($curl_handle,CURLOPT_URL,$url); 
	curl_setopt($curl_handle, CURLOPT_USERPWD, "user:password");
	$buffer = curl_exec($curl_handle);
	curl_close($curl_handle);
	
	if (empty($buffer))
	{
	    print "";
	}
	elseif($buffer == "Can not get image.")
	{
	    print "Can not get image.";
	}
	else
	{
	    header("Content-Type: image/jpeg");
	    print $buffer;
	}
}
else 
{
	print "Error: No camera requested.";
}

?>