Quick and dirty public website display
Posted: Thu May 28, 2009 12:41 am
I wanted to display one of my monitors on my public website hosted at godaddy, nothing real time, just updated ever min or so.
Here is my super simple and dirty hack:
Create a shell script "putpic" on the zoneminder box with the following (change monitor-X to the monitor you wish to upload:
On godaddy or other web host make a file called put.php, in this test case this file is in a writable directory called webcam (IE webcam/put.php):
Finally hook "putpic" in a crontab on the zoneminder box at 1 or 2 min
Then link the image to display in your webpage /webcam/image.jpg
This is a very dirty hack, the put.php should not be in the writable directory and authentication should be added, you should even make sure the uploaded file is of a certain size and actually an image file.
Have fun, hope it is useful for someone
Mycal
Here is my super simple and dirty hack:
Create a shell script "putpic" on the zoneminder box with the following (change monitor-X to the monitor you wish to upload:
Code: Select all
wget "http://127.0.0.1/cgi-bin/zm/zms?mode=single&monitor=X&scale=100" -O /tmp/tmp.jpg
curl -T /tmp/tmp.jpg <yourwebsite>/webcam/put.php
Code: Select all
<?php
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
/* Open a file for writing */
$fp = fopen("image.jpg", "w");
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
/* Close the streams */
fclose($fp);
fclose($putdata);
?>
Then link the image to display in your webpage /webcam/image.jpg
This is a very dirty hack, the put.php should not be in the writable directory and authentication should be added, you should even make sure the uploaded file is of a certain size and actually an image file.
Have fun, hope it is useful for someone
Mycal