Image from a secure site

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi, i install 4 IP cameras and i want to extract the images from their
web interface that is protected be a username and password (HTTP AUTH)
and show it into another system. so i do a function to connect to it
and get the image...

function subd($host,$port,$ownername,$passw,$request) {
 $sock = fsockopen($host,$port);
 if(!$sock) {
   print('Socket error');
   exit();
 }

 $authstr = "$ownername:$passw";
 $pass = base64_encode($authstr);
 $in = "GET $request\r\n";
 $in .= "HTTP/1.0\r\n";
 $in .= "Host:$host\r\n";
 $in .= "Authorization: Basic $pass\r\n";
 $in .= "\r\n";

 fputs($sock, $in);
 while (!feof($sock)) {
     $result .= fgets ($sock,128);
 }
 fclose( $sock );

 return $result;
}


and next i want to print it into the browser..


$request = "/IMAGE.JPG?cidx=20072261649239281";
$result = subd('contelec.sytes.net',2002,"invitado","invitado",$request);
header ('Content-type: image/jpeg');
imagejpeg($result);
exit();

but doesnt work.... if you want to check the cam you can go to
http://contelec.sytes.net:2002 the username is invitado and the
password is invitado.

please help me!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux