Is notification to an external program possible?

Support and queries relating to all previous versions of ZoneMinder
zimmer62
Posts: 13
Joined: Mon Jun 27, 2005 1:06 pm

Post by zimmer62 »

Thanks! I do appriciate all of the hard work your doing. I just wish I could be of more help for great projects like this one.

I do know php quite well, if you ever need anything on that side of things.
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Buy all means feel free to help even in PHP. I myself am learning and Phil can do it but I don't think it's his fav thing. Maybe you can even double check a patch for me before I through it on my test box for a sanity check.
It's a fuction to make sure that symlinks are created and I think I'm going to call it from or place it in the zm_export_func.php else in zm_func.php
Each camera folder in the events folder is named after the primary key in the monitors table. The symlink should be the MonitorName pointing to the Id from the same table so that when you export your events it uses the symlink for the path thus giving the camera name in the path. Here's the code:

Code: Select all

<?php
/*
It will return false if the path is not a dir or if it couldn't open the folder.
It will return an array with the name of the symlinks that for some reason couldn't be created.
It will return true if it was able to create all missing symlinks.

*/
function checklinks($path)
{
# Get from the database Monitors that are configured
$sql = "select Id as MonitorId ,MonitorName from Monitors";
$result = mysql_query( $sql ) or die(mysql_error());
while($row = mysql_fetch_assoc( $result ))
{
 $Monitor['id'][] = $row['MonitorId'];
 $Monitor['name'][] = $row['MonitorName'];
}

if(!is_dir($path)) return false;
if(!($dir = opendir( $path ))) return false;
while (false !== ($file = readdir($dir)))
{
 #Get the symlinks
 if (is_link($dir))
 {
  $symlinks[] = $file;
 }
}
closedir($dir);

foreach ($symlinks as $key=>$value)
{
 if(!in_array($value,$Monitor['name']))
 {
  unlink("$path/$value");
  unset($symlinks[$key]);
 }
}
$diff = array_diff($Monitor['name'], $symlinks);
if(!empty($diff))
{
 foreach ($diff as $key=>$value)
 {
  if(!symlink("$path/{$Monitor['id'][$key]}",$value))
  {
   $symlinks_not_created[] = $value;
  }
 }
 if(empty($symlinks_not_created))
 {
  return true;
 }
 else $symlinks_not_created;
}
}
?>
Let me know what you think.
I already submited it to Phil to go over, but the more eyes the better.
Regards,
Cordel

PS Sorry for going off topic guys, didn't realize it till after the post :oops:
zimmer62
Posts: 13
Joined: Mon Jun 27, 2005 1:06 pm

Post by zimmer62 »

I private messaged you since it was off topic. we won't clutter this one anymore.
zimmer62
Posts: 13
Joined: Mon Jun 27, 2005 1:06 pm

xAP support

Post by zimmer62 »

I was looking over how some of zm works, seems like it could be very similar to how the X10 portion of zm works... in fact, I was thinking of trying to replace the zmx10.pl file with one that would send xAP messages instead. If only I knew perl better I'd jump all over this.
Locked