forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.7 KiB
69 lines
1.7 KiB
2 years ago
|
<?php
|
||
|
|
||
|
//#!/bin/bash
|
||
|
|
||
|
function cria_callback($ORIGEM, $CONTEXTO, $DESTINO, $RAMALDESTINO, $PRIORIDADE) {
|
||
|
|
||
|
if ($CONTEXTO == "ext-voicemail") {
|
||
|
$PRIORIDADE = explode('|', $DESTINO)[1];
|
||
|
#1 = ocupado
|
||
|
#4 = ausente
|
||
|
#7 = silencio
|
||
|
|
||
|
switch ($PRIORIDADE) {
|
||
|
|
||
|
case 'ocupado':
|
||
|
$PRIORIDADE = 1;
|
||
|
break;
|
||
|
case 'ausente':
|
||
|
|
||
|
$PRIORIDADE = 4;
|
||
|
break;
|
||
|
case 'silencio':
|
||
|
$PRIORIDADE = 7;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
$DESTINO = explode('|', $DESTINO)[0];
|
||
|
}
|
||
|
|
||
|
$CALLFILE = "Channel: Local/$ORIGEM@saida-pstn/n\n"
|
||
|
. "MaxRetries: 20\n"
|
||
|
. "RetryTime: 15\n"
|
||
|
. "WaitTime: 45\n"
|
||
|
. "Context: $CONTEXTO\n"
|
||
|
. "Extension: $DESTINO\n"
|
||
|
. "Priority: $PRIORIDADE\n"
|
||
|
. "Callerid: $ORIGEM\n"
|
||
|
. "Set: RAMAL = $RAMALDESTINO\n"
|
||
|
. "Set: CALLBACK = SIM\n"
|
||
|
. "\n";
|
||
|
|
||
|
|
||
|
$FILE_NAME = sprintf("%s-%s.call", date("Y-m-d-H-i-s"), $DESTINO);
|
||
|
file_put_contents($FILE_NAME, $CALLFILE);
|
||
|
system(sprintf("chown pbx:pbx %s", $FILE_NAME));
|
||
|
system(sprintf("chmod --recursive u = rwX, g = rX, o = %s", $FILE_NAME));
|
||
|
// system(sprintf("mv %s /var/spool/asterisk/outgoing", $FILE_NAME));
|
||
|
system(sprintf("mv %s /tmp", $FILE_NAME));
|
||
|
}
|
||
|
|
||
|
//sleep(10);
|
||
|
cria_callback($argv[1], $argv[2], $argv[3], $argv[4], 1);
|
||
|
|
||
|
exit;
|
||
|
/*
|
||
|
CALLFILE=$(cat <<-EOF1
|
||
|
Channel: Local/$ORIGEM@saida-pstn/n
|
||
|
MaxRetries: 20
|
||
|
RetryTime: 15
|
||
|
WaitTime: 45
|
||
|
Context: $CONTEXTO
|
||
|
Extension: $DESTINO
|
||
|
Priority: $PRIORIDADE
|
||
|
Callerid: $ORIGEM
|
||
|
Set: RAMAL=$RAMALDESTINO
|
||
|
Set: CALLBACK=SIM
|
||
|
EOF1
|
||
|
)
|
||
|
*/
|