Quick and dirty public website display

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
mycal
Posts: 65
Joined: Tue Nov 09, 2004 6:39 am

Quick and dirty public website display

Post by mycal »

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:

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
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):

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);
?>
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
Post Reply