   /************************************************************************
    *                                                                      *
    *  ISDN-Anrufmonitor auf Basis von isdnlog und MySQL.                  *
    *                                                                      *
    *  Copyright(C) 2004 Leonhard Fellermayr <leo@slacky.de>               *
    *  Alle Rechte vorbehalten. Weitergabe im Rahmen der GNU Lizenz.       *
    *                                                                      *
    *  Version: 0.2                                                        *
    *  Stand: 12.10.2006                                                   *
    *  URL: http://slacky.de/docs/projects/isdnmonitor.html                *
    *                                                                      *
    ************************************************************************/


--- call_library.php.orig	2007-01-09 11:24:08.000000000 +0100
+++ call_library.php	2007-01-09 11:47:30.000000000 +0100
@@ -62,6 +78,18 @@
     
   } // exists_in_db ()
 
+  /* find ip address for host name */
+
+  function getip ($host)
+  {
+    $handle = popen ("host " . $host, "r");
+    $result = fread ($handle, 512);
+    pclose ($handle);
+
+    if (preg_match ('/has address (.*)$/', $result, $matches))
+      return $matches[1];
+  }
+
   /* DEBUG/TEST CODE */
 
   /*
--- call_action.php.orig	2007-01-09 11:24:03.000000000 +0100
+++ call_action.php	2007-01-09 11:47:37.000000000 +0100
@@ -20,7 +20,8 @@
 
   $q   = $argv[1];
   $msn = $argv[2]; 
-  $want_smb_notify = (strtolower ($argv[3]) == 'smbnotify');
+  $winserver = $argv[3];
+  $want_smb_notify = (!empty($winserver));
 
   /* repair some strange caller numbers */
 
@@ -82,7 +86,11 @@
       /* *********************************************************************** */
       /* notification of Windoze clients */
 
-      $fd = popen ("smbclient -M saphir -I 192.168.5.10", "w");
+      $ip = getip ($winserver);
+
+      if (!empty ($ip)) {
+
+      $fd = popen ("smbclient -M $winserver -I $ip", "w");
   
       fputs ($fd, "Eingehender Anruf von\n");
       fputs ($fd, $q . "\n\n");
@@ -90,6 +98,8 @@
       fputs ($fd, $data["adresse"] . "\n");
   
       pclose ($fd);
+
+      }
       
     } // endif
 
