function certman_devices_configprocess()
{
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extension = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $tech = isset($_POST['tech']) ? $_POST['tech'] : null;
    switch ($action) {
        case 'add':
            $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
        case 'edit':
            if ($_POST['dtls_enable'] == 'yes') {
                $settings = array();
                foreach ($_POST as $key => $value) {
                    if (preg_match('/^dtls_(.*)/', $key, $matches)) {
                        $settings[$matches[1]] = $value;
                    }
                }
                FreePBX::Certman()->addDTLSOptions($extension, $settings);
            } else {
                FreePBX::Certman()->removeDTLSOptions($extension);
            }
            break;
        case 'del':
            FreePBX::Certman()->removeDTLSOptions($extension);
            break;
    }
}
Beispiel #2
0
function webrtc_configpageload($mode)
{
    global $currentcomponent;
    $webrtc = FreePBX::Webrtc();
    $certman = FreePBX::Certman();
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $webrtc_select = $currentcomponent->getoptlist('webrtc_enable');
    $webrtc_value = $webrtc->checkEnabled($extdisplay) ? 'yes' : 'no';
    $mcerts = $certman->getAllManagedCertificates();
    $status = $webrtc->validVersion();
    $mode = $webrtc->getSocketMode();
    if ($status === true) {
        if (!empty($mcerts)) {
            if ($mode == 'pjsip') {
                $currentcomponent->addguielem('WebRTC Phone', new gui_label('webrtc_message', _('The WebSockets Interface is running through PJSIP, PJSIP is not supported at this time. Please enable the chan_sip driver (along with pjsip or by itself) or alert the FreePBX Developers')));
                $currentcomponent->addguielem('Device Options', new gui_hidden('webrtc_enable', $webrtc_value));
            } else {
                $currentcomponent->addguielem('WebRTC Phone', new gui_selectbox('webrtc_enable', $webrtc_select, $webrtc_value, _('Enable WebRTC Old ARI Phone'), sprintf(_('Enables WebRTC for this %s in the Asterisk Recording Interface (ARI). Note: ARI is depreciated in favor of UCP'), $mode), false));
                $certs = array();
                foreach ($mcerts as $cert) {
                    $certs[] = array("text" => $cert['basename'], "value" => $cert['cid']);
                }
                $settings = $webrtc->getClientSettingsByUser($extdisplay);
                $cert = !empty($settings['certid']) ? $settings['certid'] : '';
                $currentcomponent->addguielem('WebRTC Phone', new gui_selectbox('webrtc_dtls_certificate', $certs, $cert, _('Use Certificate'), _("The Certificate to use from Certificate Manager"), false));
            }
        } else {
            $currentcomponent->addguielem('WebRTC Phone', new gui_label('webrtc_message', sprintf(_('To utilize WebRTC in ARI you must add at least one certificate %s through Certificate Manager'), $mode)));
            $currentcomponent->addguielem('Device Options', new gui_hidden('webrtc_enable', $webrtc_value));
        }
    } else {
        $currentcomponent->addguielem('Device Options', new gui_hidden('webrtc_enable', $webrtc_value));
    }
}
Beispiel #3
0
<?php

if (!empty($message)) {
    $messagehtml = '<div class="alert alert-' . $message['type'] . '">' . $message['message'] . '</div>';
}
$fwapi = \FreePBX::Certman()->getFirewallAPI();
$letext = sprintf(_("LetsEncrypt requires the following hosts to be permitted for inbound http access:<br /> <tt>%s</tt>"), join(", ", $fwapi->getRequiredHosts()));
// Is firewall enabled and available?
if ($fwapi->isAvailable()) {
    // Are our hosts already set up?
    if (!$fwapi->hostsConfigured()) {
        // They're not. Add a warning and a button
        $alert = "<form class='fpbx-submit' name='frm_fixfirewall' id='updatefw' method='post'>";
        $alert .= "<div class='alert alert-warning'><h3>" . _("Firewall Warning") . "</h3>";
        $alert .= "<p class='col-sm-12'>{$letext}</p>";
        // Adding col-sm-12 fixes the padding in the alert
        $alert .= "<div class='clearfix'><p class='col-sm-9'>" . _("These hosts <strong>are not configured in the System Firewall</strong>. LetsEncrypt will not be able to validate this host, and certificate issueance will fail. To automatically add these hosts, please click on the 'Update Firewall' button.") . "</p>";
        $alert .= "<p class='col-sm-3'><button class='btn btn-default pull-right' type='submit' name='updatefw' value='updatefw'>" . _("Update Firewall") . "</button></p></div>";
        $alert .= "</div></form>";
    } else {
        $alert = "<div class='alert alert-success'><h3>" . _("Firewall Validated") . "</h3>";
        $alert .= "<p>{$letext}</p>";
        $alert .= "<p>" . _("These entries are correctly set up in the Firewall module. However, it's possible that other external firewalls may block access. If you are having problems validating your certificate, this could be the issue.") . "</p>";
        $alert .= "</div>";
    }
} else {
    $alert = "<div class='alert alert-info'><h3>" . _("Firewall Warning") . "</h3>";
    $alert .= "<p>{$letext}</p>";
    $alert .= "<p>" . _("PBX System Firewall is not in use so this can not be verified. Please manually verify inbound connectivity.") . "</p>";
    $alert .= "</div>";
}
				<div class="form-group">
					<div class="col-md-3">
						<label class="control-label" for="csipcalistfile"><?php 
    echo _("Certificate Manager");
    ?>
</label>
						<i class="fa fa-question-circle fpbx-help-icon" data-for="csipcalistfile"></i>
					</div>
					<div class="col-md-9">
						<select class="form-control" id="csipcalistfile" name="csipcertid">
							<option value=""><?php 
    echo "--" . _("Select a Certificate") . "--";
    ?>
</option>
							<?php 
    foreach (\FreePBX::Certman()->getAllManagedCertificates() as $cert) {
        ?>
								<option value="<?php 
        echo $cert['cid'];
        ?>
" <?php 
        echo $csipcertid == $cert['cid'] ? 'selected' : '';
        ?>
><?php 
        echo $cert['basename'];
        ?>
</option>
							<?php 
    }
    ?>
						</select>
function sipsettings_hookGet_config($engine)
{
    global $core_conf;
    global $ext;
    // is this the best way to pass this?
    switch ($engine) {
        case "asterisk":
            if (isset($core_conf) && is_a($core_conf, "core_conf")) {
                $raw_settings = sipsettings_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->_sip_general as $entry) {
                    switch (strtolower($entry['key'])) {
                        case 'allow':
                        case 'disallow':
                            unset($core_conf->_sip_general[$idx]);
                            break;
                        default:
                            // do nothing
                    }
                    $idx++;
                }
                $interim_settings = array();
                foreach ($raw_settings as $var) {
                    switch ($var['type']) {
                        case SIP_NORMAL:
                            $interim_settings[$var['keyword']] = $var['data'];
                            break;
                        case SIP_CUSTOM:
                            $sip_settings[] = array($var['keyword'], $var['data']);
                            break;
                        default:
                            // Error should be above
                    }
                }
                unset($raw_settings);
                // Add any defaults that should be in there
                $def = FreePBX::Sipsettings()->getChanSipDefaults();
                foreach ($def as $k => $v) {
                    if (!isset($interim_settings[$k]) && $v) {
                        $interim_settings[$k] = $v;
                    }
                }
                /* Codecs First */
                $core_conf->addSipGeneral('disallow', 'all');
                foreach (FreePBX::Sipsettings()->getCodecs('audio') as $codec => $enabled) {
                    if ($enabled != '') {
                        $core_conf->addSipGeneral('allow', $codec);
                    }
                }
                unset($codecs);
                if ($interim_settings['videosupport'] == 'yes') {
                    foreach (FreePBX::Sipsettings()->getCodecs('video') as $codec => $enabled) {
                        if ($enabled != '') {
                            $core_conf->addSipGeneral('allow', $codec);
                        }
                    }
                }
                unset($video_codecs);
                /* next figure out what we need to write out (deal with things like nat combos, etc. */
                $nat_mode = $interim_settings['nat_mode'];
                $jbenable = $interim_settings['jbenable'];
                $foundexternip = false;
                // Ensure default TLS Settings for chansip are available
                if (empty($interim_settings['tlsbindport'])) {
                    // Note - this is TCP, not UDP.
                    $interim_settings['tlsbindport'] = 5061;
                }
                if (!empty($interim_settings['tlsbindaddr'])) {
                    $interim_settings['tlsbindaddr'] = $interim_settings['tlsbindaddr'] . ":" . $interim_settings['tlsbindport'];
                } else {
                    // [::] means 'listen on all interfaces, both ipv4 and ipv6' when in sipsettings.
                    $interim_settings['tlsbindaddr'] = "[::]:" . $interim_settings['tlsbindport'];
                }
                // There is no sip setting 'tlsbindport', so make sure we remove it before writing the file.
                unset($interim_settings['tlsbindport']);
                foreach ($interim_settings as $key => $value) {
                    switch ($key) {
                        case 'csipcertid':
                            if (!empty($value) && $interim_settings['tlsenable'] == 'yes' && FreePBX::Modules()->moduleHasMethod("certman", "getDefaultCertDetails")) {
                                $cert = FreePBX::Certman()->getCertificateDetails($value);
                                if (!empty($cert['files']['crt']) && !empty($cert['files']['key'])) {
                                    $sip_settings[] = array('tlsprivatekey', $cert['files']['key']);
                                    $sip_settings[] = array('tlscertfile', $cert['files']['crt']);
                                    if (isset($cert['files']['ca-bundle'])) {
                                        $sip_settings[] = array('tlscafile', $cert['files']['ca-bundle']);
                                    }
                                }
                            }
                            break;
                        case 'nat_mode':
                            break;
                        case 'externhost_val':
                            if ($nat_mode == 'externhost' && $value != '') {
                                $sip_settings[] = array('externhost', $value);
                            }
                            break;
                        case 'externrefresh':
                            if ($nat_mode == 'externhost' && $value != '') {
                                $sip_settings[] = array($key, $value);
                            }
                            break;
                        case 'externip_val':
                            if ($nat_mode == 'externip' && $value != '') {
                                $foundexternip = true;
                                $sip_settings[] = array('externip', $value);
                            }
                            break;
                        case 'jbforce':
                        case 'jbimpl':
                        case 'jbmaxsize':
                        case 'jbresyncthreshold':
                        case 'jblog':
                            if ($jbenable == 'yes' && $value != '') {
                                $sip_settings[] = array($key, $value);
                            }
                            break;
                        case 'language':
                            if ($value != '') {
                                $sip_settings[] = array('language', $value);
                                $ext->addGlobal('SIPLANG', $value);
                            }
                            break;
                            //FREEPBX-9737 AND FREEPBX-6518 In Asterisk 11+ nat=yes is deprecated.
                        //FREEPBX-9737 AND FREEPBX-6518 In Asterisk 11+ nat=yes is deprecated.
                        case 'nat':
                            global $amp_conf;
                            $astge11 = version_compare($amp_conf['ASTVERSION'], '11.5', 'ge');
                            if ($astge11) {
                                switch ($value) {
                                    case 'yes':
                                        $value = "force_rport,comedia";
                                        break;
                                    case 'never':
                                        $value = "no";
                                        break;
                                    case 'route':
                                        $value = "force_rport";
                                        break;
                                }
                            }
                            $sip_settings[] = array($key, $value);
                            break;
                        case 't38pt_udptl':
                            if ($value != 'no') {
                                if ($value == 'yes') {
                                    $sip_settings[] = array('t38pt_udptl', 'yes,redundancy,maxdatagram=400');
                                } elseif ($value == 'fec') {
                                    $sip_settings[] = array('t38pt_udptl', 'yes,fec');
                                } elseif ($value == 'redundancy') {
                                    $sip_settings[] = array('t38pt_udptl', 'yes,redundancy');
                                } elseif ($value == 'none') {
                                    $sip_settings[] = array('t38pt_udptl', 'yes,none');
                                }
                            }
                            break;
                        default:
                            // Ignore localnet settings from chansip sipsettings, they're now in general
                            if (substr($key, 0, 9) == "localnet_" || substr($key, 0, 8) == "netmask_") {
                                break;
                            }
                            $sip_settings[] = array($key, $value);
                            break;
                    }
                }
                // Is there a global external IP settings? If there wasn't one specified
                // as part of the chan_sip settings, check to see if there's one here.
                if (!$foundexternip && $nat_mode == "externip") {
                    $externip = FreePBX::create()->Sipsettings->getConfig('externip');
                    if ($externip) {
                        $sip_settings[] = array("externip", $externip);
                    }
                }
                // Now do the localnets
                $localnets = FreePBX::create()->Sipsettings->getConfig('localnets');
                if (!empty($localnets) && is_array($localnets)) {
                    foreach ($localnets as $arr) {
                        $sip_settings[] = array("localnet", $arr['net'] . "/" . $arr['mask']);
                    }
                }
                unset($interim_settings);
                if (is_array($sip_settings)) {
                    foreach ($sip_settings as $entry) {
                        if ($entry[1] != '') {
                            $core_conf->addSipGeneral($entry[0], $entry[1]);
                        }
                    }
                }
            }
            break;
    }
    return true;
}
<?php

//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2014 Schmooze Com Inc.
//
$request = $_REQUEST;
$certman = FreePBX::Certman();
$message = array();
$request['action'] = !empty($request['action']) ? $request['action'] : "";
echo $certman->myShowPage($request['action']);