コード例 #1
0
 public function doConfigPageInit($page)
 {
     $request = $_REQUEST;
     $error_displays = array();
     $action = isset($request['action']) ? $request['action'] : '';
     $post_codec = isset($request['codec']) ? $request['codec'] : array();
     $post_vcodec = isset($request['vcodec']) ? $request['vcodec'] : array();
     $iax_settings['codecpriority'] = isset($request['codecpriority']) ? $request['codecpriority'] : 'host';
     $iax_settings['bandwidth'] = isset($request['bandwidth']) ? $request['bandwidth'] : 'unset';
     $iax_settings['videosupport'] = isset($request['videosupport']) ? $request['videosupport'] : 'no';
     $iax_settings['maxregexpire'] = isset($request['maxregexpire']) ? htmlspecialchars($request['maxregexpire']) : '3600';
     $iax_settings['minregexpire'] = isset($request['minregexpire']) ? htmlspecialchars($request['minregexpire']) : '60';
     $iax_settings['jitterbuffer'] = isset($request['jitterbuffer']) ? $request['jitterbuffer'] : 'no';
     $iax_settings['forcejitterbuffer'] = isset($request['forcejitterbuffer']) ? $request['forcejitterbuffer'] : 'no';
     $iax_settings['maxjitterbuffer'] = isset($request['maxjitterbuffer']) ? htmlspecialchars($request['maxjitterbuffer']) : '200';
     $iax_settings['resyncthreshold'] = isset($request['resyncthreshold']) ? htmlspecialchars($request['resyncthreshold']) : '1000';
     $iax_settings['maxjitterinterps'] = isset($request['maxjitterinterps']) ? htmlspecialchars($request['maxjitterinterps']) : '10';
     $iax_settings['bindaddr'] = isset($request['bindaddr']) ? htmlspecialchars($request['bindaddr']) : '';
     $iax_settings['bindport'] = isset($request['bindport']) ? htmlspecialchars($request['bindport']) : '';
     $iax_settings['delayreject'] = isset($request['delayreject']) ? htmlspecialchars($request['delayreject']) : 'yes';
     $codecs = array('ulaw' => '', 'alaw' => '', 'slin' => '', 'g726' => '', 'gsm' => '', 'g729' => '', 'ilbc' => '', 'g723' => '', 'g726aal2' => '', 'adpcm' => '', 'lpc10' => '', 'speex' => '', 'g722' => '', 'siren7' => '', 'siren14' => '');
     // With the new sorting, the vars should come to us in the sorted order so just use that
     //
     $pri = 1;
     foreach (array_keys($post_codec) as $codec) {
         $codecs[$codec] = $pri++;
     }
     $iax_settings['codecs'] = $codecs;
     $video_codecs = array('h261' => '', 'h263' => '', 'h263p' => '', 'h264' => '');
     $pri = 1;
     foreach (array_keys($post_vcodec) as $vcodec) {
         $video_codecs[$vcodec] = $pri++;
     }
     $iax_settings['video_codecs'] = $video_codecs;
     $p_idx = $n_idx = 0;
     while (isset($request["iax_custom_key_{$p_idx}"])) {
         if ($request["iax_custom_key_{$p_idx}"] != '') {
             $iax_settings["iax_custom_key_{$n_idx}"] = htmlspecialchars($request["iax_custom_key_{$p_idx}"]);
             $iax_settings["iax_custom_val_{$n_idx}"] = htmlspecialchars($request["iax_custom_val_{$p_idx}"]);
             $n_idx++;
         }
         $p_idx++;
     }
     switch ($action) {
         case "edit":
             //just delete and re-add
             if (($errors = iaxsettings_edit($iax_settings)) !== true) {
                 $error_displays = process_errors($errors);
             } else {
                 needreload();
                 //redirect_standard();
             }
             break;
         default:
             /* only get them if first time load, if they pressed submit, use values from POST */
             $iax_settings = iaxsettings_get();
     }
     $error_displays = array_merge($error_displays, iaxsettings_check_custom_files());
 }
コード例 #2
0
ファイル: form.php プロジェクト: ringfreejohn/pbxframework
<?php

//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2015 Sangoma Technologies.
$iaxsettings = iaxsettings_get();
extract($iaxsettings, EXTR_SKIP);
//Custom Fields
$idx = 1;
$var_iax_custom_key = "iax_custom_key_{$idx}";
$var_iax_custom_val = "iax_custom_val_{$idx}";
$iaxcinputs = '';
while (isset(${$var_iax_custom_key})) {
    if (${$var_iax_custom_key} != '') {
        $iaxcinputs .= <<<END
<input type="text" id="iax_custom_key_{$idx}" name="iax_custom_key_{$idx}" class="form-control iax-custom" value="{${$var_iax_custom_key}}"> =
<input type="text" id="iax_custom_val_{$idx}" name="iax_custom_val_{$idx}" class="form-control" value="{${$var_iax_custom_val}}">
END;
    }
    $idx++;
    $var_iax_custom_key = "iax_custom_key_{$idx}";
    $var_iax_custom_val = "iax_custom_val_{$idx}";
}
$seq = 1;
$rows = array();
$c = max(array_values($codecs)) + 1;
$c++;
$rows[0] = '<ul class="sortable" id="acodeclist">';
foreach ($codecs as $codec => $codec_state) {
    $codec_trans = _($codec);
    $codec_checked = $codec_state ? 'checked' : '';
    $count = !empty($codec_state) ? $codec_state : $c++;
コード例 #3
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function iaxsettings_hookGet_config($engine)
{
    global $core_conf;
    switch ($engine) {
        case "asterisk":
            if (isset($core_conf) && is_a($core_conf, "core_conf")) {
                $raw_settings = iaxsettings_get(true);
                /* TODO: This is example concept code
                
                           The only real conflicts are codecs (mainly cause
                           it will look ugly. So we should strip those but
                           leave the rest. If we overrite it, oh well
                
                				 */
                $idx = 0;
                foreach ($core_conf->_iax_general as $entry) {
                    switch (strtolower($entry['key'])) {
                        case 'allow':
                        case 'disallow':
                            unset($core_conf->_iax_general[$idx]);
                            break;
                        default:
                            // do nothing
                    }
                    $idx++;
                }
                foreach ($raw_settings as $var) {
                    switch ($var['type']) {
                        case IAX_NORMAL:
                            $interim_settings[$var['keyword']] = $var['data'];
                            break;
                        case IAX_CODEC:
                            $codecs[$var['keyword']] = $var['data'];
                            break;
                        case IAX_VIDEO_CODEC:
                            $video_codecs[$var['keyword']] = $var['data'];
                            break;
                        case IAX_CUSTOM:
                            $iax_settings[] = array($var['keyword'], $var['data']);
                            break;
                        default:
                            // Error should be above
                    }
                }
                unset($raw_settings);
                /* Codecs First */
                $core_conf->addIaxGeneral('disallow', 'all');
                foreach ($codecs as $codec => $enabled) {
                    if ($enabled != '') {
                        $core_conf->addIaxGeneral('allow', $codec);
                    }
                }
                unset($codecs);
                if ($interim_settings['videosupport'] == 'yes') {
                    foreach ($video_codecs as $codec => $enabled) {
                        if ($enabled != '') {
                            $core_conf->addIaxGeneral('allow', $codec);
                        }
                    }
                }
                unset($video_codecs);
                /* next figure out what we need to write out (deal with things like nat combos, etc. */
                $jitterbuffer = $interim_settings['jitterbuffer'];
                if (is_array($interim_settings)) {
                    foreach ($interim_settings as $key => $value) {
                        switch ($key) {
                            case 'videosupport':
                                break;
                            case 'maxjitterbuffer':
                            case 'maxjitterinterps':
                            case 'resyncthreshold':
                            case 'forcejitterbuffer':
                                if ($jitterbuffer == 'yes' && $value != '') {
                                    $iax_settings[] = array($key, $value);
                                }
                                break;
                            case 'bandwidth':
                                if ($value != 'unset') {
                                    $iax_settings[] = array($key, $value);
                                }
                                break;
                            case 'iax_language':
                                if ($value != '') {
                                    $iax_settings[] = array('language', $value);
                                }
                                break;
                            default:
                                $iax_settings[] = array($key, $value);
                        }
                    }
                }
                unset($interim_settings);
                if (is_array($iax_settings)) {
                    foreach ($iax_settings as $entry) {
                        if ($entry[1] != '') {
                            $core_conf->addIaxGeneral($entry[0], $entry[1]);
                        }
                    }
                }
            }
            break;
    }
    return true;
}