Compatible con la ultima version de php-vn-lib
This commit is contained in:
parent
5a1ef1a0a6
commit
fea94df0f3
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Agi
|
||||
{
|
||||
private static $initialized = FALSE;
|
||||
private static $agivars = array ();
|
||||
|
||||
static function init ()
|
||||
{
|
||||
if (self::$initialized)
|
||||
return;
|
||||
|
||||
self::$initialized = TRUE;
|
||||
pcntl_signal (SIGHUP, SIG_IGN);
|
||||
pcntl_signal (SIGTERM, SIG_IGN);
|
||||
|
||||
while (!feof (STDIN))
|
||||
{
|
||||
$agivar = trim (fgets (STDIN, 4096));
|
||||
|
||||
if ($agivar === '')
|
||||
break;
|
||||
|
||||
$agivar = explode (':', $agivar);
|
||||
self::$agivars[$agivar[0]] = trim ($agivar[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static function get ($agivar)
|
||||
{
|
||||
if (self::$initialized && isset (self::$agivars[$agivar]))
|
||||
return self::$agivars[$agivar];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static function exec ($cmd, &$result = NULL)
|
||||
{
|
||||
if (!self::$initialized)
|
||||
return -1;
|
||||
|
||||
fwrite (STDOUT, $cmd."\n");
|
||||
fflush (STDOUT);
|
||||
|
||||
$res = trim (fgets (STDIN, 4096));
|
||||
|
||||
if (preg_match ("/^([0-9]{1,3}) (.*)/", $res, $matches))
|
||||
{
|
||||
if (preg_match ('/^result=([0-9\-]*)( ?\((.*)\))?$/', $matches[2], $match))
|
||||
{
|
||||
$ret = (int) $match[1];
|
||||
if ($num > 0)
|
||||
$result = $match[3];
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,70 +0,0 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
|
||||
require_once ('agi.php');
|
||||
require_once ('vn/lib/app.php');
|
||||
|
||||
$app = new Vn\Lib\App ('vn-asterisk');
|
||||
$app->init ();
|
||||
$db = $app->getSysConn ();
|
||||
|
||||
Agi::init ();
|
||||
|
||||
// Formats the caller phone number
|
||||
|
||||
$callerId = str_replace ('+', '00', Agi::get ('agi_callerid'));
|
||||
|
||||
$countryPrefix = $db->getValue ('SELECT country_prefix FROM config');
|
||||
$prefixLen = strlen ($countryPrefix);
|
||||
|
||||
if (substr ($callerId, 0, $prefixLen) === $countryPrefix)
|
||||
$callerId = substr ($callerId, $prefixLen);
|
||||
|
||||
// Checks if phone number is on the blacklist
|
||||
|
||||
if ($db->getValue ('SELECT COUNT(*) > 0 FROM blacklist WHERE phone = #', [$callerId]))
|
||||
{
|
||||
Agi::exec ('HANGUP');
|
||||
exit ();
|
||||
}
|
||||
|
||||
// Checks whether its a festive day
|
||||
|
||||
$sundayFestive = $db->getValue ('SELECT sunday_festive FROM config');
|
||||
|
||||
if (date ('N') == 7 && $sundayFestive)
|
||||
{
|
||||
Agi::exec ('SET VARIABLE MACRO playback');
|
||||
Agi::exec ('SET VARIABLE ARG1 out-of-ours');
|
||||
exit ();
|
||||
}
|
||||
|
||||
// Gets the customer from the phone number
|
||||
|
||||
$customer = $db->getValue ('SELECT customer_from_phone(#)', [$callerId]);
|
||||
|
||||
if ($customer)
|
||||
{
|
||||
// Gets the customer salesperson extension
|
||||
|
||||
$extension = $db->getValue (
|
||||
'SELECT s.extension
|
||||
FROM sip s
|
||||
JOIN vn2008.Trabajadores t ON t.user_id = s.user_id
|
||||
WHERE t.id_trabajador = vn2008.Averiguar_ComercialCliente_Id(#, CURDATE())'
|
||||
,[$customer]
|
||||
);
|
||||
|
||||
if ($extension)
|
||||
{
|
||||
Agi::exec ('SET VARIABLE MACRO exten');
|
||||
Agi::exec ("SET VARIABLE ARG1 $extension");
|
||||
}
|
||||
else
|
||||
{
|
||||
Agi::exec ('SET VARIABLE MACRO playback');
|
||||
Agi::exec ('SET VARIABLE ARG1 busy');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -20,4 +20,3 @@ return [
|
|||
|
||||
];
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once (__DIR__.'/../php-vn-lib/configure.php');
|
||||
|
||||
set_include_path (
|
||||
get_include_path ()
|
||||
.PATH_SEPARATOR.__DIR__.'/lib'
|
||||
);
|
||||
|
||||
define ('_DEVELOPER_MODE', TRUE);
|
||||
define ('_CONFIG_DIR', '/home/juan/.config');
|
||||
define ('_LOG_DIR', '/tmp');
|
||||
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
vn-asterisk (1.005-deb7) stable; urgency=low
|
||||
vn-asterisk (1.008-deb7) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
config.php etc/vn-asterisk
|
||||
agi-bin/* usr/share/asterisk/agi-bin
|
||||
sounds/* usr/share/asterisk/sounds/custom
|
||||
moh/* usr/share/asterisk/moh
|
||||
incoming.php usr/share/asterisk/agi-bin
|
||||
agi.php usr/share/asterisk/agi-bin
|
||||
|
|
125
extensions.conf
125
extensions.conf
|
@ -1,125 +0,0 @@
|
|||
[general]
|
||||
|
||||
static=yes
|
||||
writeprotect=no
|
||||
|
||||
[default]
|
||||
|
||||
exten => s,1,Hangup
|
||||
|
||||
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++ Outgoing calls
|
||||
|
||||
[outgoing]
|
||||
|
||||
;-------------- Urgent calls
|
||||
|
||||
exten => _091,1,Macro(external,pri,${EXTEN})
|
||||
exten => _112,1,Macro(external,pri,${EXTEN})
|
||||
|
||||
;-------------- Internal extensions
|
||||
|
||||
exten => _1006,1,Dial(SIP/${EXTEN},14,tT)
|
||||
same => n,GotoIf($["${DIALSTATUS}" != "ANSWER"]?redirect)
|
||||
same => n(redirect),Dial(SIP/1104,,tT)
|
||||
same => n,Hangup
|
||||
|
||||
exten => _XX00,1,Queue(${EXTEN},tT)
|
||||
same => n,Hangup
|
||||
|
||||
exten => _XX98,1,RemoveQueueMember(${EXTEN:0:2}00)
|
||||
same => n,Playback(removed)
|
||||
same => n,Hangup
|
||||
|
||||
exten => _XX99,1,AddQueueMember(${EXTEN:0:2}00)
|
||||
same => n,Playback(added)
|
||||
same => n,Hangup
|
||||
|
||||
exten => _XXXX,1,Dial(SIP/${EXTEN},,tT)
|
||||
same => n,Followme(${EXTEN})
|
||||
same => n,Hangup
|
||||
|
||||
;-------------- External numbers
|
||||
|
||||
exten => _[98][1-9]XXXXXXX,1,Macro(external,pri,${EXTEN})
|
||||
exten => _[67]XXXXXXXX,1,Macro(external,pri,${EXTEN})
|
||||
exten => _900XXXXXX,1,Macro(external,pri,${EXTEN})
|
||||
|
||||
exten => _0034XXXX,1,Goto(internal,0${EXTEN:4},1)
|
||||
exten => _0034X.,1,Goto(internal,${EXTEN:4},1)
|
||||
exten => _0031XXXXXXXXX,1,Macro(external,xtratelecom,${EXTEN})
|
||||
exten => _00X.,1,Macro(external,wcd,${EXTEN})
|
||||
|
||||
exten => _0XXXX,1,Macro(authenticate,pri,${EXTEN:1:4})
|
||||
exten => _X.,1,Macro(authenticate,pri,${EXTEN})
|
||||
|
||||
;-------------- Invalid numbers
|
||||
|
||||
exten => i,1,Playback(invalid)
|
||||
same => n,Hangup
|
||||
|
||||
exten => t,1,Playback(invalid)
|
||||
same => n,Hangup
|
||||
|
||||
;-------------- Macros
|
||||
|
||||
[macro-authenticate]
|
||||
|
||||
exten => s,1,Authenticate(7070)
|
||||
same => n,Macro(external,${ARG1},${ARG2})
|
||||
|
||||
[macro-external]
|
||||
|
||||
exten => s,1,Dial(SIP/${ARG1}/${ARG2},,T)
|
||||
same => n,Hangup
|
||||
|
||||
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++ Incomings calls
|
||||
|
||||
[incoming]
|
||||
|
||||
exten => _X.,1,AGI(incoming.php)
|
||||
same => n,GotoIf($["${MACRO}" != ""]?macro:ivr)
|
||||
same => n(macro),Macro(${MACRO},${ARG1})
|
||||
same => n,Hangup
|
||||
same => n(ivr),Goto(ivr,s,1)
|
||||
|
||||
exten => _XX00,1,Macro(queue,${EXTEN})
|
||||
exten => _XXXX,1,Macro(exten,${EXTEN})
|
||||
|
||||
[ivr]
|
||||
|
||||
exten => s,1,Answer
|
||||
same => n,BackGround(custom/ivr)
|
||||
same => n,WaitExten(5)
|
||||
|
||||
exten => 1,1,Macro(queue,1500)
|
||||
exten => 2,1,Macro(queue,1100)
|
||||
exten => 3,1,Macro(queue,1400)
|
||||
exten => 4,1,Macro(queue,1500)
|
||||
exten => 5,1,Macro(queue,1500)
|
||||
exten => 6,1,Macro(queue,1000)
|
||||
|
||||
exten => i,1,Playback(invalid)
|
||||
same => n,Goto(ivr,s,1)
|
||||
|
||||
exten => t,1,Playback(invalid)
|
||||
same => n,Goto(ivr,s,1)
|
||||
|
||||
;-------------- Macros
|
||||
|
||||
[macro-queue]
|
||||
|
||||
exten => s,1,Answer
|
||||
same => n,Queue(${ARG1},t,,,60)
|
||||
same => n,Macro(playback,busy)
|
||||
|
||||
[macro-exten]
|
||||
|
||||
exten => s,1,Dial(SIP/${ARG1},60,t)
|
||||
same => n,Followme(${ARG1})
|
||||
same => n,Macro(playback,busy)
|
||||
|
||||
[macro-playback]
|
||||
|
||||
exten => s,1,Playback(custom/${ARG1})
|
||||
same => n,Hangup
|
||||
|
Loading…
Reference in New Issue