Exemplo n.º 1
0
{
    global $calls;
    global $tones;
    foreach ($calls as $key => $call) {
        $calls[$key]--;
        if ($calls[$key] <= 0) {
            sendTones($key, $tones[$key]);
            // sendTones() might change the counter
            if ($calls[$key] <= 0) {
                setupCall($key, false);
            }
        }
    }
}
Yate::Watch("call.answered");
Yate::Watch("chan.replaced");
Yate::Install("chan.hangup");
Yate::Install("engine.timer");
// Restart if terminated
Yate::SetLocal("restart", true);
Yate::Debug($param . ": Starting");
/* The main loop. We pick events and handle them */
for (;;) {
    $ev = Yate::GetEvent();
    /* If Yate disconnected us then exit cleanly */
    if ($ev === false) {
        break;
    }
    /* Empty events are normal in non-blocking operation.
       This is an opportunity to do idle tasks and check timers */
    if ($ev === true) {
Exemplo n.º 2
0
   where RINGBACK is a wave or autorepeat temporary tone resource like:
      tone/*ring  (this is the default)
      wave/play/path/to/custom.au
*/
require_once "libyate.php";
// A fixed format is needed as we can't know what the called will offer
$mediafmt = "mulaw";
Yate::Init();
//Yate::Debug(true);
$ringback = Yate::Arg();
if ($ringback == "") {
    $ringback = "tone/*ring";
}
Yate::Install("call.ringing", 50);
Yate::Watch("call.ringing");
Yate::SetLocal("restart", true);
for (;;) {
    $ev = Yate::GetEvent();
    if ($ev === false) {
        break;
    }
    if ($ev === true) {
        continue;
    }
    $id = $ev->GetValue("peerid");
    if ($ev->type == "incoming") {
        if ($ev->GetValue("earlymedia") == "false" && $ev->GetValue("rtp_forward") != "yes") {
            Yate::Debug("Preparing fake {$mediafmt} ringback to {$id}");
            $ev->SetParam("earlymedia", true);
            $ev->SetParam("formats", $mediafmt);
Exemplo n.º 3
0
if (Yate::Arg()) {
    Yate::Output("Executing startup time CDR cleanup");
    $query = "UPDATE call_logs SET ended= 1 where ended = 0 or ended IS NULL";
    query_nores($query);
    $query = "UPDATE extensions SET inuse_count=0";
    query_nores($query);
    // Spawn another, restartable instance
    $cmd = new Yate("engine.command");
    $cmd->id = "";
    $cmd->SetParam("line", "external register.php");
    $cmd->Dispatch();
    sleep(1);
    exit;
}
// Install handler for the wave end notify messages
Yate::Watch("engine.timer");
Yate::Install("user.register");
Yate::Install("user.unregister");
Yate::Install("user.auth");
Yate::Install("call.route");
Yate::Install("call.cdr");
Yate::Install("call.answered", 50);
Yate::Install("chan.disconnected", 50);
Yate::Install("chan.hangup");
Yate::Install("user.notify");
Yate::Install("engine.status");
Yate::Install("engine.command");
Yate::Install("engine.debug");
// Ask to be restarted if dying unexpectedly
Yate::SetLocal("restart", "true");
$query = "SELECT enabled, protocol, username, description, 'interval', formats, authname, password, server, domain, outbound , localaddress, modified, gateway as account, gateway_id, status, 1 AS gw, ip_transport FROM gateways WHERE enabled = 1 AND gateway IS NOT NULL AND username IS NOT NULL ORDER BY gateway";
Exemplo n.º 4
0
        return false;
    }
    $retval .= $banHelp;
    return false;
}
Yate::Init();
// Comment the next line to get output only in logs, not in rmanager
Yate::Output(true);
// Uncomment the next line to get debugging details
//Yate::Debug(true);
$n = round(1 * Yate::Arg());
if ($n >= 2) {
    $ban_failures = $n;
}
Yate::SetLocal("trackparam", "banbrutes");
Yate::Watch("user.auth");
Yate::Install("user.authfail", 120);
Yate::Install("engine.timer", 150);
Yate::Install("engine.command", 120);
Yate::Install("engine.help", 150);
Yate::SetLocal("restart", true);
for (;;) {
    $ev = Yate::GetEvent();
    if ($ev === false) {
        break;
    }
    if ($ev === true) {
        continue;
    }
    if ($ev->type == "incoming") {
        switch ($ev->name) {