本文整理汇总了PHP中FreePBX::Sipsettings方法的典型用法代码示例。如果您正苦于以下问题:PHP FreePBX::Sipsettings方法的具体用法?PHP FreePBX::Sipsettings怎么用?PHP FreePBX::Sipsettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreePBX
的用法示例。
在下文中一共展示了FreePBX::Sipsettings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="codecw"><?php
echo _("Codecs");
?>
</label>
</div>
<div class="col-md-9">
<?php
echo \show_help(_("This is the default Codec setting for new Trunks and Extensions."));
?>
<?php
$seq = 1;
echo '<ul class="sortable">';
foreach (FreePBX::Sipsettings()->getCodecs('audio', true) as $codec => $codec_state) {
$codec_trans = _($codec);
$codec_checked = $codec_state ? 'checked' : '';
echo '<li><a href="#">' . '<img src="assets/sipsettings/images/arrow_up_down.png" height="16" width="16" border="0" alt="move" style="float:none; margin-left:-6px; margin-bottom:-3px;cursor:move" /> ' . '<input type="checkbox" ' . ($codec_checked ? 'value="' . $seq++ . '" ' : '') . 'name="voicecodecs[' . $codec . ']" ' . 'id="' . $codec . '" ' . 'class="audio-codecs" ' . $codec_checked . ' />' . '<label for="' . $codec . '"> ' . '<small>' . $codec_trans . '</small>' . " </label></a></li>\n";
}
echo '</ul>';
?>
</div>
</div>
</div>
</div>
</div>
</div>
<!--END Codecs-->
</div>
</form>
示例2: generateEndpoint
//.........这里部分代码省略.........
unset($config['transport']);
} else {
$endpoint[] = "transport=" . $config['transport'];
}
}
$endpoint[] = "aggregate_mwi=" . (isset($config['aggregate_mwi']) ? $config['aggregate_mwi'] : "yes");
if (!empty($config['namedcallgroup'])) {
$endpoint[] = "named_call_group=" . $config['namedcallgroup'];
}
if (!empty($config['namedpickupgroup'])) {
$endpoint[] = "named_pickup_group=" . $config['namedpickupgroup'];
}
if (!empty($config['avpf'])) {
$endpoint[] = "use_avpf=" . $config['avpf'];
}
if (!empty($config['icesupport'])) {
$endpoint[] = "ice_support=" . $config['icesupport'];
}
if (!empty($config['media_use_received_transport']) && version_compare($this->version, "12.4.0", "ge")) {
$endpoint[] = "media_use_received_transport=" . $config['media_use_received_transport'];
}
if (!empty($config['trustrpid'])) {
$endpoint[] = "trust_id_inbound=" . $config['trustrpid'];
}
if (!empty($config['match'])) {
$identify[] = "match=" . $config['match'];
}
if (!empty($config['mediaencryption'])) {
$endpoint[] = "media_encryption=" . $config['mediaencryption'];
} else {
// Automatically enable sdes if possible
//
// Requires sipsettings 13.0.16 or higher
if ($this->freepbx->Modules->moduleHasMethod('Sipsettings', 'getTLSConfig')) {
if (\FreePBX::Sipsettings()->getTLSConfig()) {
$endpoint[] = "media_encryption=sdes";
}
}
}
if (!empty($config['timers'])) {
$endpoint[] = "timers=" . $config['timers'];
}
if (!empty($config['mediaencryptionoptimistic'])) {
$endpoint[] = "media_encryption_optimistic=" . $config['mediaencryptionoptimistic'];
}
if (!empty($config['device_state_busy_at']) && is_numeric($config['device_state_busy_at']) && $config['device_state_busy_at'] > 0) {
$endpoint[] = "device_state_busy_at=" . $config['device_state_busy_at'];
}
if (isset($config['sendrpid'])) {
if ($config['sendrpid'] == "yes" || $config['sendrpid'] == "both") {
$endpoint[] = "send_rpid=yes";
}
if ($config['sendrpid'] == "pai" || $config['sendrpid'] == "both") {
$endpoint[] = "send_pai=yes";
}
}
//rtp_symmetric needs to be yes for NAT --mjordan, Digium
$endpoint[] = !empty($config['rtp_symmetric']) ? "rtp_symmetric=" . $config['rtp_symmetric'] : "rtp_symmetric=yes";
//rewrite_contact needs to be yes for NAT --mjordan, Digium
$endpoint[] = !empty($config['rewrite_contact']) ? "rewrite_contact=" . $config['rewrite_contact'] : "rewrite_contact=yes";
$endpoint[] = !empty($config['force_rport']) ? "force_rport=" . $config['force_rport'] : "force_rport=yes";
if (!empty($this->language)) {
$endpoint[] = "language=" . $this->language;
}
// Auth
$auth[] = "auth_type=userpass";
示例3: out
out(_("ulaw, alaw, gsm, g726 added"));
}
if ($haspjsip) {
FreePBX::create()->Config->set_conf_values(array('ASTSIPDRIVER' => 'both'), true, true);
} else {
FreePBX::create()->Config->set_conf_values(array('ASTSIPDRIVER' => 'chansip'), true, true);
}
$ss->setConfig("udpport-0.0.0.0", $pjsip_port);
$ss->setConfig("tcpport-0.0.0.0", $pjsip_port);
$ss->setConfig("tlsport-0.0.0.0", $pjsiptls_port);
$ss->setConfig("binds", array("udp" => array("0.0.0.0" => "on")));
} else {
out(_("already exists"));
}
//OK let's do some migrating for BMO
$ss = FreePBX::Sipsettings();
if (!$ss->getConfig('rtpstart') || !$ss->getConfig('rtpend')) {
out(_("Migrate rtp.conf values if needed and initialize"));
$sql = "SELECT data FROM sipsettings WHERE keyword = 'rtpstart'";
$rtpstart = sql($sql, 'getOne');
if (!$rtpstart) {
$sql = "SELECT value FROM admin WHERE variable = 'RTPSTART'";
$rtpstart = sql($sql, 'getOne');
if ($rtpstart) {
out(sprintf(_("saving previous value of %s"), $rtpstart));
}
}
if ($rtpstart) {
out(_('Migrating rtpstart Setting from Old Format to BMO Object'));
$ss->setConfig('rtpstart', $rtpstart);
}
示例4: answer_externsetup
private function answer_externsetup()
{
if ($_REQUEST['answer'] != "yes") {
return;
}
include 'Natget.class.php';
$n = new Natget();
$myip = $n->getVisibleIP();
$myroutes = $n->getRoutes();
\FreePBX::Sipsettings()->setConfig('externip', $myip);
// Update routes
$ssroutes = \FreePBX::Sipsettings()->getConfig('localnets');
if (!is_array($ssroutes)) {
$ssroutes = array();
}
// I don't like these loops, it feels messy.
foreach ($myroutes as $r) {
// $r = [ "1.2.3.0", "24" ]
$found = false;
foreach ($ssroutes as $current) {
// $current = {"net":"1.2.3.0","mask":"24"}
if ($current['net'] == $r[0] && $current['mask'] == $r[1]) {
$found = true;
break;
}
}
if (!$found) {
$ssroutes[] = array("net" => $r[0], "mask" => $r[1]);
}
}
$ssroutes = \FreePBX::Sipsettings()->setConfig('localnets', $ssroutes);
return true;
}
示例5: sipsettings_edit
function sipsettings_edit($sip_settings)
{
global $db;
global $amp_conf;
$save_settings = array();
$save_to_admin = array();
// Used only by ALLOW_SIP_ANON for now
$vd = new sipsettings_validate();
// TODO: this is where I will build validation before saving
//
$integer_msg = _("%s must be a non-negative integer");
foreach ($sip_settings as $key => $val) {
switch ($key) {
case 'bindaddr':
$msg = _("Bind Address (bindaddr) must be an IP address.");
$ipv6_ok = version_compare($amp_conf['ASTVERSION'], '1.8', 'ge');
$save_settings[] = array($key, $db->escapeSimple($vd->is_ip($val, $key, $msg, $ipv6_ok)), '2', SIP_NORMAL);
break;
case 'bindport':
$msg = _("Bind Port (bindport) must be between 1024..65535, default 5060");
$save_settings[] = array($key, $db->escapeSimple($vd->is_ip_port($val, $key, $msg)), '1', SIP_NORMAL);
break;
case 'rtpholdtimeout':
// validation: must be > $sip_settings['rtptimeout'] (and of course a proper number)
//$vd->log_error();
if ($val < $sip_settings['rtptimeout']) {
$msg = _("rtpholdtimeout must be higher than rtptimeout");
$vd->log_error($val, $key, $msg);
}
$msg = sprintf($integer_msg, $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_int($val, $key, $msg)), '10', SIP_NORMAL);
break;
case 'rtptimeout':
case 'rtpkeepalive':
case 'checkmwi':
case 'registertimeout':
case 'minexpiry':
case 'maxexpiry':
case 'defaultexpiry':
$msg = sprintf($integer_msg, $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_int($val, $key, $msg)), '10', SIP_NORMAL);
break;
case 'maxcallbitrate':
case 'registerattempts':
$msg = sprintf($integer_msg, $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_int($val, $key, $msg)), '10', SIP_NORMAL);
break;
case 'sip_language':
$msg = "Language must be alphanumeric and installed";
$save_settings[] = array($key, $db->escapeSimple($vd->is_alphanumeric($val, $key, $msg)), '0', SIP_NORMAL);
break;
case 'context':
$msg = sprintf(_("%s must be alphanumeric"), $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_alphanumeric($val, $key, $msg)), '0', SIP_NORMAL);
break;
case 'externrefresh':
$msg = sprintf($integer_msg, $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_int($val, $key, $msg)), '41', SIP_NORMAL);
break;
case 'nat':
$save_settings[] = array($key, $val, '39', SIP_NORMAL);
break;
case 'externip_val':
if ($sip_settings['nat_mode'] == 'externip') {
if (trim($val) == "" && !FreePBX::create()->Sipsettings->getConfig('externip')) {
$msg = _("External IP can not be blank when NAT Mode is set to Static and no default IP address provided on the main page");
$vd->log_error($val, $key, $msg);
} else {
$save_settings[] = array($key, $val, '40', SIP_NORMAL);
}
}
break;
case 'externhost_val':
if (trim($val) == '' && $sip_settings['nat_mode'] == 'externhost') {
$msg = _("Dynamic Host can not be blank");
$vd->log_error($val, $key, $msg);
}
$save_settings[] = array($key, $val, '40', SIP_NORMAL);
break;
case 'jbenable':
$save_settings[] = array($key, $val, '4', SIP_NORMAL);
break;
case 'jbforce':
case 'jbimpl':
case 'jblog':
$save_settings[] = array($key, $val, '5', SIP_NORMAL);
break;
case 'jbmaxsize':
case 'jbresyncthreshold':
$msg = sprintf($integer_msg, $key);
$save_settings[] = array($key, $db->escapeSimple($vd->is_int($val, $key, $msg)), '5', SIP_NORMAL);
break;
case 'nat_mode':
case 'g726nonstandard':
case 't38pt_udptl':
case 'videosupport':
case 'canreinvite':
case 'notifyringing':
case 'notifyhold':
case 'allowguest':
//.........这里部分代码省略.........
示例6: _
</td>
</tr>
</table>
</td>
</tr>
<tr class="nat-settings externip">
<td><a href="#" class="info"><?php
echo _("Override External IP");
?>
<span><?php
echo _("External Static IP or FQDN as seen on the WAN side of the router. (asterisk: externip)") . " " . _("Note that this will, by default, inherit the settings from the General page");
?>
</span></a></td>
<?php
$placeholder = FreePBX::Sipsettings()->getConfig('externip');
if (!$placeholder) {
$placeholder = "Enter IP Address";
}
?>
<td><input type="text" id="externip_val" name="externip_val" value="<?php
echo $externip_val;
?>
" placeholder="<?php
echo $placeholder;
?>
" tabindex="<?php
echo ++$tabindex;
?>
"></td>
</tr>
示例7: core_devices_configpageload
function core_devices_configpageload()
{
global $currentcomponent;
global $amp_conf;
$tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
if ($tech_hardware == 'virtual') {
return true;
}
// Init vars from $_REQUEST[]
$display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
if ($action == 'del') {
// Deleted
if ($display != 'extensions') {
$currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay . ' ' . _("deleted"), false));
}
} elseif ($extdisplay == '' && $tech_hardware == '') {
// Adding
if ($display != 'extensions') {
$currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Device")), 0);
} else {
$currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add an Extension")), 0);
}
$currentcomponent->addguielem('_top', new gui_label('instructions', _("Please select your Device below then click Submit")));
$currentcomponent->addguielem('Device', new gui_selectbox('tech_hardware', $currentcomponent->getoptlist('devicelist'), '', _("Device"), '', false));
} else {
$deviceInfo = array();
if ($extdisplay) {
// Editing
$deviceInfo = core_devices_get($extdisplay);
if ($display != 'extensions') {
$currentcomponent->addguielem('_top', new gui_pageheading('title', _("Device") . ": {$extdisplay}", false), 0);
$delURL = '?' . $_SERVER['QUERY_STRING'] . '&action=del';
$tlabel = sprintf(_("Delete Device %s"), $extdisplay);
$label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/telephone_delete.png"/> ' . $tlabel . '</span>';
$currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
if ($deviceInfo['device_user'] != 'none') {
$editURL = '?display=users&skip=0&extdisplay=' . $deviceInfo['user'];
$tlabel = $deviceInfo['devicetype'] == 'adhoc' ? sprintf(_("Edit Default User: %s"), $deviceInfo['user']) : sprintf(_("Edit Fixed User: %s"), $deviceInfo['user']);
$label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_edit.png"/> ' . $tlabel . '</span>';
$currentcomponent->addguielem('_top', new gui_link('edit_user', $label, $editURL, true, false), 0);
}
}
} else {
$tmparr = explode('_', $tech_hardware);
$deviceInfo['tech'] = $tmparr[0];
$deviceInfo['hardware'] = $tmparr[1];
unset($tmparr);
if ($display != 'extensions') {
$currentcomponent->addguielem('_top', new gui_pageheading('title', sprintf(_("Add %s Device"), strtoupper($deviceInfo['tech']))), 0);
} else {
$currentcomponent->addguielem('_top', new gui_pageheading('title', sprintf(_("Add %s Extension"), strtoupper($deviceInfo['tech']))), 0);
}
}
// Ensure they exist before the extract
$devinfo_description = $devinfo_emergency_cid = null;
$devinfo_devicetype = $devinfo_user = $devinfo_hardware = null;
$devinfo_tech = null;
if (is_array($deviceInfo)) {
extract($deviceInfo, EXTR_PREFIX_ALL, 'devinfo');
}
// Setup vars for use in the gui later on
$fc_logon = featurecodes_getFeatureCode('core', 'userlogon');
$fc_logoff = featurecodes_getFeatureCode('core', 'userlogoff');
$msgInvalidDevID = _("Please enter a device id.");
$msgInvalidDevDesc = _("Please enter a valid Description for this device");
$msgInvalidEmergCID = _("Please enter a valid Emergency CID");
$msgInvalidExtNum = _("Please enter a valid extension number.");
// Actual gui
$currentcomponent->addguielem('_top', new gui_hidden('action', $extdisplay ? 'edit' : 'add'));
$currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
if ($display != 'extensions') {
$section = _("Device Info");
if ($extdisplay) {
// Editing
$currentcomponent->addguielem($section, new gui_hidden('deviceid', $extdisplay));
} else {
// Adding
$currentcomponent->addguielem($section, new gui_textbox('deviceid', $extdisplay, _("Device ID"), _("Give your device a unique integer ID. The device will use this ID to authenticate to the system."), '!isInteger()', $msgInvalidDevID, false));
}
$currentcomponent->addguielem($section, new gui_textbox('description', $devinfo_description, _("Description"), _("The CallerID name for this device will be set to this description until it is logged into."), '!isAlphanumeric() || isWhitespace()', $msgInvalidDevDesc, false));
$currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, _("Emergency CID"), _("This CallerID will always be set when dialing out an Outbound Route flagged as Emergency. The Emergency CID overrides all other CallerID settings."), '!isCallerID()', $msgInvalidEmergCID));
$currentcomponent->addguielem($section, new gui_selectbox('devicetype', $currentcomponent->getoptlist('devicetypelist'), $devinfo_devicetype, _("Device Type"), _("Devices can be fixed or adhoc. Fixed devices are always associated to the same extension/user. Adhoc devices can be logged into and logged out of by users.") . ' ' . $fc_logon . ' ' . _("logs into a device.") . ' ' . $fc_logoff . ' ' . _("logs out of a device."), false));
$currentcomponent->addguielem($section, new gui_selectbox('deviceuser', $currentcomponent->getoptlist('deviceuserlist'), $devinfo_user, _("Default User"), _("Fixed devices will always mapped to this user. Adhoc devices will be mapped to this user by default.<br><br>If selecting 'New User', a new User Extension of the same Device ID will be set as the Default User."), false));
} else {
$section = _("Extension Options");
$currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, _("Emergency CID"), _("This CallerID will always be set when dialing out an Outbound Route flagged as Emergency. The Emergency CID overrides all other CallerID settings."), '!isCallerID()', $msgInvalidEmergCID));
}
$currentcomponent->addguielem($section, new gui_hidden('tech', $devinfo_tech));
$currentcomponent->addguielem($section, new gui_hidden('hardware', $devinfo_hardware));
if ($devinfo_tech && $devinfo_tech != "virtual") {
$section = _("Device Options");
$devinfo_techd = $devinfo_tech == 'sip' ? 'CHAN_SIP' : strtoupper($devinfo_tech);
if (FreePBX::Modules()->moduleHasMethod("sipsettings", "getBinds")) {
$out = FreePBX::Sipsettings()->getBinds();
foreach ($out[$devinfo_tech] as $ip => $data1) {
foreach ($data1 as $protocol => $port) {
$pport .= $ip . ":" . $port . ', ';
}
//.........这里部分代码省略.........
示例8: getSipPorts
public function getSipPorts()
{
// Returns an array of ports or ranges used by SIP or PJSIP.
$udp = array();
$tcp = array();
// Let's get chansip settings if we need them.
if ($this->chansip) {
$bindport = "";
$settings = \FreePBX::Sipsettings()->getChanSipSettings(true);
foreach ($settings as $arr) {
if (empty($arr['data'])) {
continue;
}
if ($arr['keyword'] == 'bindport') {
$bindport = $arr['data'];
break;
}
}
if (empty($bindport)) {
$bindport = 5060;
}
$udp[] = array("dest" => "0.0.0.0", "dport" => $bindport, "name" => "chansip");
// TODO: chan_sip TCP.. Maybe
}
// Do we have pjsip?
if ($this->pjsip) {
// Woo. What are our settings?
$ss = \FreePBX::Sipsettings();
$allBinds = $ss->getConfig("binds");
$websocket = false;
foreach ($allBinds as $type => $listenArr) {
// What interface(s) are we listening on?
foreach ($listenArr as $ipaddr => $mode) {
if ($mode != "on") {
continue;
}
if ($type == "ws" || $type == "wss") {
$websocket = \FreePBX::Config()->get('HTTPBINDPORT');
continue;
}
$port = $ss->getConfig($type . "port-" . $ipaddr);
if (!$port) {
continue;
}
if ($type == "tcp") {
$tcp[] = array("dest" => $ipaddr, "dport" => $port, "name" => "pjsip");
} elseif ($type == "udp") {
$udp[] = array("dest" => $ipaddr, "dport" => $port, "name" => "pjsip");
} else {
throw new \Exception("Unknown protocol {$type}");
}
}
}
if ($websocket) {
$tcp[] = array("dest" => $ipaddr, "dport" => $websocket, "name" => "pjsip");
}
}
$retarr = array("udp" => $udp, "tcp" => $tcp);
return $retarr;
}
示例9: getSvc_chansip
private function getSvc_chansip()
{
$retarr = array("name" => _("CHAN_SIP Protocol"), "defzones" => array("internal"), "descr" => _("This is the legacy chan_sip driver."), "fw" => array());
$driver = \FreePBX::Config()->get('ASTSIPDRIVER');
if ($driver == "both" || $driver == "chan_sip") {
$tcp = false;
$bindport = 5060;
// Note bug in sipsettings =< 13.0.14.5 that getChanSipSettings won't
// return correct details when not returnraw
$settings = \FreePBX::Sipsettings()->getChanSipSettings(true);
foreach ($settings as $arr) {
if ($arr['keyword'] == "tcpenable" && $arr['data'] == "yes") {
$tcp = true;
continue;
}
if ($arr['keyword'] == "bindport") {
$bindport = $arr['data'];
continue;
}
}
$retarr['fw'][] = array("protocol" => "udp", "port" => $bindport);
if ($tcp) {
$retarr['fw'][] = array("protocol" => "tcp", "port" => $bindport);
}
}
// Make sure there's actually some binds.
if (!$retarr['fw']) {
$retarr['descr'] = _("CHANSIP is not available on this machine");
$retarr['disabled'] = true;
}
return $retarr;
}