Exemple #1
0
        redirect_standard();
        break;
    case "delete":
        $oldItem = disa_get($itemid);
        disa_del($itemid);
        needreload();
        redirect_standard();
        break;
    case "edit":
        //just delete and re-add
        disa_edit($itemid, $_POST);
        needreload();
        redirect_standard('itemid');
        break;
}
$disas = disa_list();
?>

</div> <!-- end content div so we can display rnav properly-->

<!-- right side menu -->
<div class="rnav"><ul>
    <li><a id="<?php 
echo $itemid == '' ? 'current' : 'std';
?>
" href="config.php?display=<?php 
echo urlencode($dispnum);
?>
"><?php 
echo _("Add DISA");
?>
Exemple #2
0
function disa_get_config($engine)
{
    global $ext;
    switch ($engine) {
        case "asterisk":
            $disalist = disa_list();
            if (is_array($disalist)) {
                foreach ($disalist as $item) {
                    $nopass = false;
                    // delete it incase there was one from before (of course if it was deleted???
                    // this should all be done properly in class, see pinsets, but for now ...
                    //
                    $filename = "/etc/asterisk/disa-" . $item['disa_id'] . ".conf";
                    if (file_exists($filename)) {
                        unlink($filename);
                    }
                    if (isset($item['pin']) && !empty($item['pin']) && strtolower($item['pin']) != 'no-password') {
                        // Create the disa-$id.conf file
                        $fh = fopen($filename, "w+");
                        $pinarr = explode(',', $item['pin']);
                        if (count($pinarr) > 1) {
                            $is_file = true;
                            foreach ($pinarr as $pin) {
                                // Don't support remote MWI, too easy for users to break.
                                fwrite($fh, "{$pin}\n");
                            }
                            fclose($fh);
                            chmod($filename, 0660);
                        } else {
                            $is_file = false;
                        }
                    } else {
                        $nopass = true;
                    }
                    $thisitem = disa_get(ltrim($item['disa_id']));
                    // add dialplan
                    if ($thisitem['needconf'] == 'CHECKED') {
                        $ext->add('disa', $item['disa_id'], '', new ext_setvar('RESCOUNT', '1'));
                        $ext->add('disa', $item['disa_id'], 'loop', new ext_gotoif('$[ ${RESCOUNT} > 5]', 'end'));
                        $ext->add('disa', $item['disa_id'], '', new ext_read('RRES', 'press-1', '1', ',1,3'));
                        $ext->add('disa', $item['disa_id'], '', new ext_setvar('RESCOUNT', '$[${RESCOUNT}+1]'));
                        $ext->add('disa', $item['disa_id'], '', new ext_gotoif('$["x${RRES}"="x"]', 'loop'));
                    }
                    if (!$nopass) {
                        if ($is_file) {
                            $ext->add('disa', $item['disa_id'], '', new ext_authenticate('/etc/asterisk/disa-' . $item['disa_id'] . '.conf'));
                        } else {
                            $ext->add('disa', $item['disa_id'], '', new ext_authenticate($item['pin']));
                        }
                    } else {
                        $ext->add('disa', $item['disa_id'], '', new ext_answer(''));
                    }
                    $ext->add('disa', $item['disa_id'], '', new ext_setvar('_DISA', 'disa^' . $item['disa_id'] . '^newcall'));
                    $ext->add('disa', $item['disa_id'], 'newcall', new ext_setvar('_DISACONTEXT', $thisitem['context']));
                    $ext->add('disa', $item['disa_id'], '', new ext_setvar('_KEEPCID', 'TRUE'));
                    if ($thisitem['hangup'] == 'CHECKED') {
                        $ext->add('disa', $item['disa_id'], '', new ext_setvar('_HANGUP', '${TRUNK_OPTIONS}Hg'));
                    } else {
                        $ext->add('disa', $item['disa_id'], '', new ext_setvar('_HANGUP', '${TRUNK_OPTIONS}'));
                    }
                    $ext->add('disa', $item['disa_id'], '', new ext_setvar('TIMEOUT(digit)', $thisitem['digittimeout']));
                    $ext->add('disa', $item['disa_id'], '', new ext_setvar('TIMEOUT(response)', $thisitem['resptimeout']));
                    if ($item['cid']) {
                        $ext->add('disa', $item['disa_id'], '', new ext_setvar('CALLERID(all)', $item['cid']));
                    }
                    $ext->add('disa', $item['disa_id'], '', new ext_disa('no-password,disa-dial'));
                    $ext->add('disa', $item['disa_id'], 'end', new ext_hangup(''));
                }
                $context = 'disa-dial';
                $exten = '_[0-9a-zA-Z*#].';
                $ext->add($context, $exten, '', new ext_noop('called ${EXTEN} in ${DISACONTEXT} by ID: ${CUT(DISA,^,2)}'));
                $ext->add($context, $exten, '', new ext_dial('Local/${EXTEN}@${DISACONTEXT}', '300,${HANGUP}'));
                // Regular Trunk Dial
                $ext->add($context, $exten, '', new ext_gosub('1', 's-${DIALSTATUS}'));
                $ext->add($context, $exten, '', new ext_goto('${CUT(DISA,^,1)},${CUT(DISA,^,2)},${CUT(DISA,^,3)}'));
                $exten = 's-ANSWER';
                $ext->add($context, $exten, '', new ext_return());
                $exten = 's-CANCEL';
                $ext->add($context, $exten, '', new ext_return());
                $exten = 's-BUSY';
                $ext->add($context, $exten, '', new ext_playtones('busy'));
                $ext->add($context, $exten, '', new ext_wait('3'));
                $ext->add($context, $exten, '', new ext_return());
                $exten = '_s-.';
                $ext->add($context, $exten, '', new ext_noop('DISA Dial failed due to ${DIALSTATUS} - returning to dial tone'));
                $ext->add($context, $exten, '', new ext_playtones('congestion'));
                $ext->add($context, $exten, '', new ext_wait('3'));
                $ext->add($context, $exten, '', new ext_stopplaytones());
                $ext->add($context, $exten, '', new ext_return());
            }
            break;
    }
}