From: <abe...@us...> - 2013-07-25 18:35:29
|
Revision: 6154 http://sourceforge.net/p/astlinux/code/6154 Author: abelbeck Date: 2013-07-25 18:35:25 +0000 (Thu, 25 Jul 2013) Log Message: ----------- web interface, Voicemail tab, support FOP2 UserEvent: FOP2RELOADVOICEMAIL to sync mailbox status Modified Paths: -------------- branches/1.0/package/webinterface/altweb/admin/dnshosts.php branches/1.0/package/webinterface/altweb/admin/voicemail.php Modified: branches/1.0/package/webinterface/altweb/admin/dnshosts.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/dnshosts.php 2013-07-24 16:53:09 UTC (rev 6153) +++ branches/1.0/package/webinterface/altweb/admin/dnshosts.php 2013-07-25 18:35:25 UTC (rev 6154) @@ -228,7 +228,7 @@ putHtml('<tr><td class="dialogText" style="text-align: right;">'); putHtml('IP Address:<input type="text" size="42" maxlength="39" name="ip" value="'.$ldb['ip'].'" />'); putHtml('</td><td class="dialogText" style="text-align: right;">'); - putHtml('Host Name:<input type="text" size="24" maxlength="128" name="name" value="'.$ldb['name'].'" />'); + putHtml('Host Name(s):<input type="text" size="28" maxlength="128" name="name" value="'.$ldb['name'].'" />'); putHtml('</td></tr>'); putHtml('<tr><td class="dialogText" style="text-align: right;" colspan="2">'); putHtml('MAC Address matched via DHCP for IPv4 address <i>(optional)</i>:<input type="text" size="20" maxlength="17" name="mac" value="'.$ldb['mac'].'" />'); @@ -243,7 +243,7 @@ if (($n = count($db['data'])) > 0) { echo '<td class="dialogText" style="text-align: left; font-weight: bold;">', "IP Address", "</td>"; - echo '<td class="dialogText" style="text-align: left; font-weight: bold;">', "Host Name", "</td>"; + echo '<td class="dialogText" style="text-align: left; font-weight: bold;">', "Host Name(s)", "</td>"; echo '<td class="dialogText" style="text-align: left; font-weight: bold;">', "MAC Address", "</td>"; echo '<td class="dialogText" style="text-align: center; font-weight: bold;">', "Delete", "</td>"; for ($i = 0; $i < $n; $i++) { Modified: branches/1.0/package/webinterface/altweb/admin/voicemail.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/voicemail.php 2013-07-24 16:53:09 UTC (rev 6153) +++ branches/1.0/package/webinterface/altweb/admin/voicemail.php 2013-07-25 18:35:25 UTC (rev 6154) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2012 Lonnie Abelbeck +// Copyright (C) 2008-2013 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -12,6 +12,7 @@ // 07-20-2008, Added special user "staff" permissions // 07-21-2008, Added externnotify support // 09-05-2012, Automatically create "Old" folder if it doesn't exist +// 07-25-2013, Add support for FOP2 UserEvent: FOP2RELOADVOICEMAIL // // System location of the asterisk voicemail directory $VOICEMAILDIR = '/var/spool/asterisk/voicemail/'; @@ -20,6 +21,54 @@ require_once '../common/functions.php'; +// Function: asteriskAMI_UserEvent +// +function asteriskAMI_UserEvent($user, $pass, $event) { + + $event_list = explode(',', $event); + + if (($socket = @fsockopen('127.0.0.1', '5038', $errno, $errstr, 5)) === FALSE) { + return(FALSE); + } + fputs($socket, "Action: login\r\n"); + fputs($socket, "Username: $user\r\n"); + fputs($socket, "Secret: $pass\r\n"); + fputs($socket, "Events: off\r\n\r\n"); + + fputs($socket, "Action: UserEvent\r\n"); + foreach ($event_list as $value) { + fputs($socket, "$value\r\n"); + } + fputs($socket, "\r\n"); + + fputs($socket, "Action: logoff\r\n\r\n"); + + stream_set_timeout($socket, 5); + $info = stream_get_meta_data($socket); + while (! feof($socket) && ! $info['timed_out']) { + $line = fgets($socket, 256); + $info = stream_get_meta_data($socket); + if (strncasecmp($line, 'Response: Error', 15) == 0) { + while (! feof($socket) && ! $info['timed_out']) { + fgets($socket, 256); + $info = stream_get_meta_data($socket); + } + fclose($socket); + return(FALSE); + } + if (strncasecmp($line, 'Message: Event Sent', 19) == 0) { + break; + } + } + while (! feof($socket) && ! $info['timed_out']) { + fgets($socket, 256); + $info = stream_get_meta_data($socket); + } + fclose($socket); + + return(0); +} + // Function: getVMdataTXT // function getVMdataTXT($path) { @@ -123,17 +172,24 @@ // Function: notifyVMdir // -function notifyVMdir($dir, $path, $count) { +function notifyVMdir($dir, $path, $count, $fop2) { global $global_prefs; $value = substr($path, strlen($dir)); $tokens = explode('/', $value); - if ($tokens[2] !== 'INBOX') { + $context = $tokens[0]; + $mbox = $tokens[1]; + $folder = $tokens[2]; + + if ($fop2 && is_addon_package('fop2')) { + $user_event= 'UserEvent: FOP2RELOADVOICEMAIL,Mailbox: '.$mbox.'@'.$context.',Server: 0'; + asteriskAMI_UserEvent('fop2', 'astlinux', $user_event); + } + + if ($folder !== 'INBOX') { return(FALSE); } - $context = $tokens[0]; - $mbox = $tokens[1]; - + if (getPREFdef($global_prefs, 'voicemail_extern_notify') === 'yes') { if (($ph = popen("grep -m 1 '^externnotify' /etc/asterisk/voicemail.conf", "r")) !== FALSE) { if (! feof($ph)) { @@ -235,11 +291,11 @@ } } $cnt = sequenceVMdir($fpath); - notifyVMdir($msg['dir'], $fpath, $cnt); + notifyVMdir($msg['dir'], $fpath, $cnt, FALSE); $cnt = sequenceVMdir($tpath); - notifyVMdir($msg['dir'], $tpath, $cnt); - + notifyVMdir($msg['dir'], $tpath, $cnt, TRUE); + return($cnt == 0 ? FALSE : $cnt); } @@ -308,7 +364,7 @@ if ($resequence > 0) { for ($i = 0; $i < count($delete); $i++) { $cnt = sequenceVMdir($VOICEMAILDIR.$delete[$i]); - notifyVMdir('', $delete[$i], $cnt); + notifyVMdir('', $delete[$i], $cnt, TRUE); } $result = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |