0

I want my IP cam streaming on my website. Since I have this piece of code but if you look at the source code, you'll see of course the complete data as user and pass. That is not the intention, I looked at RewriteRule option in .htaccess but don't know how to formulate, or maybe another solution to protect my user and pass data. Who can help me get out the thinking circle and gives a move in the right direction (or example).

<?php
$url = '123.456.7.890:1234';
$user = 'naam';
$pass = 'wachtwoord';

$cam = "http://$url/videostream.cgi?user=$user&pwd=$pass";
?>

<html>
<body>
...
<img name="main" id="main" border="0" width="640" height="480" src="<?php echo("$cam"); ?>">
...
</body>
</html>
Harry
  • 786
  • 1
  • 8
  • 27

2 Answers2

1

If camera response you with image you can get it in PHP code and then add it to image src like base64 data.

For example

<?php
$url = '123.456.7.890:1234';
$user = 'naam';
$pass = 'wachtwoord';

$cam = "http://$url/videostream.cgi?user=$user&pwd=$pass";
$image = file_get_contents($cam); // Or use CURL 

// Here you need to replace $type of your camera
$image_src = 'data:image/' . $type . ';base64,' . base64_encode($image);
?>

<html>
<body>
...
<img name="main" id="main" border="0" 
          width="640" height="480" src="<?php echo $image_src ?>">
...
</body>
</html>
Spell
  • 8,188
  • 2
  • 16
  • 19
  • What do you mean by 'replace $type of your camera'? – Harry Nov 09 '13 at 20:59
  • It`s about variable `$type`. If your camera outputs jpeg image from that url - you need to set up a `$type = 'jpeg';` and every think will work. After concatination in src attr after data we will see mime type of image that are in base64. – Spell Nov 09 '13 at 21:05
  • I tried your solution but we are talking about a videostream not a image. The script does not show anything... – Harry Nov 09 '13 at 21:23
0

You should use your server side to create a image. Solution can be found here: Create Image From Url Any File Type

You can create a PHP file that outputs the image or something. If you do that, you can load the image like this: <img src="http://domain.com/image.php?id=1">

Then in image.php, you can load from your DB, or whatever you like. However, when you have the real image info, you can make a "fake" image as descriped in the link above.

Community
  • 1
  • 1
andershagbard
  • 1,116
  • 2
  • 14
  • 38