Re: [PHP] Image from a secure site
2007/3/12, Richard Lynch [EMAIL PROTECTED]: Instead of trying to re-invent the authentication wheel, just use http://php.net/curl wow!! Thanks you A LOOOT!!! thats amazing!!! On Thu, March 8, 2007 4:51 pm, Manolet Gmail wrote: 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 -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image from a secure site
Well in case someone need to do this... this is the code.. very easy at all.. header ('Content-type: image/jpeg'); $ch =curl_init(http://contelec.sytes.net:2002/IMAGE.JPG?cidx=20072261649239281;); curl_setopt($ch,CURLOPT_USERPWD,invitado:invitado); curl_exec($ch); curl_close($ch); 2007/3/13, Manolet Gmail [EMAIL PROTECTED]: 2007/3/12, Richard Lynch [EMAIL PROTECTED]: Instead of trying to re-invent the authentication wheel, just use http://php.net/curl wow!! Thanks you A LOOOT!!! thats amazing!!! On Thu, March 8, 2007 4:51 pm, Manolet Gmail wrote: 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 -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image from a secure site
Instead of trying to re-invent the authentication wheel, just use http://php.net/curl On Thu, March 8, 2007 4:51 pm, Manolet Gmail wrote: 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 -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image from a secure site
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