I have a custom way I want my setup. I wanted to customize the console and montage pages to have 2 extra links on it. The links will be called Security and Open. I want the links to set the camera to one of two preset locations (I may be adding another camera that will also have a security and open preset location so I may have to have it set 2 cameras at once). Basically when I leave the premises I would prefer to be able to just tap the Security link and have the camera turn to the area of focus needed for security purposes and when I came back I could return the camera to the open position with a mindless tap on the Open link in passing
. As of now I added code to launch the control window for the camera but the process would be even easier if I could do it in just one tap on the screen (this is set up on a Raspberry Pi with 7" touch screen used as a small desktop monitor/control showing the cameras and hopefully the buttons/links to toggle the cameras from Open to Security)
I am using Zoneminder v1.31.1 on Xubuntu 16.04
I don't really know what I'm doing and just have tried to modify the existing code to try to get it to match my goals. I can move the camera using terminal on the server with the commands:
Code: Select all
zmcontrol.pl --preset=1 --command=presetGoto --id=18
zmcontrol.pl --preset=2 --command=presetGoto --id=18
So far I have two new files I created in the www/includes folder called Open.php and Security.php (with proper ownership and permissions) I scarfed the code from control_functions.php and modified it a bit because I wasn't sure if the variables would collide.. the two files look like this:
Code: Select all
<?php
function sendControlCommandOpen() {
$socketo = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( $socketo < 0 ) {
Fatal( "socket_create() failed: ".socket_strerror($socketo) );
}
$sockFileo = ZM_PATH_SOCKS.'/zmcontrol-18.sock';
$optionStringo = ' --preset=1 --command=presetGoto --id=18';
if ( !socket_write( $socketo, $optionStringo ) ) {
Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($socketo)) );
}
socket_close( $socketo );
}
?>
and
Code: Select all
<?php
function sendControlCommandSecurity() {
$sockets = socket_create( AF_UNIX, SOCK_STREAM, 0 );
if ( $sockets < 0 ) {
Fatal( "socket_create() failed: ".socket_strerror($sockets) );
}
$sockFiles = ZM_PATH_SOCKS.'/zmcontrol-18.sock';
$optionStrings = ' --preset=1 --command=presetGoto --id=18';
if ( !socket_write( $sockets, $optionStrings ) ) {
Fatal( "Can't write to control socket: ".socket_strerror(socket_last_error($sockets)) );
}
socket_close( $sockets );
}
?>
then in the /www/skins/classic/views/console.php I added the following:
right after the line
Code: Select all
require_once('includes/Server.php');
I added
Code: Select all
require_once('includes/Open.php');
require_once('includes/Security.php');
and later in the file where I wanted the links I added
Code: Select all
<a href="" onclick="sendControlCommandSecurity();">Security</a>
<a href="" onclick="sendControlCommandOpen();">Open</a>
but if I try one of the links debug gives me the error
Code: Select all
ERR [Uncaught ReferenceError: sendControlCommandSecurity is not defined] at https://local.website/zm/index.php line 83
Since I really don't know what I'm doing I can't figure out why I'm getting that error. I can sort of understand what the code is trying to do but the "layout / formatting / wording" I don't have a good grasp of ... this may all be completely wrong ... I might not be even close to what I want to accomplish or there may be a much simpler way of achieving my goals but ... I have been trying and at a point where I'm now stumped and don't know how to proceed. What I have figured out is ZM is sending the command
Code: Select all
/usr/bin/zmcontrol.pl --preset=1 --command=presetGoto --id=18
when I click the preset in the control window .. what I don't know is how to make a link that will send that command without having to go through all the php stuff that "figures out what monitor and what movement you are looking for"
If anyone knows html/php/javascript and can see what I'm doing wrong or know of an easier way .. this total noob would appreciate any help he can get