Beispiel #1
0
function webrtc_configpageinit($pagename)
{
    global $currentcomponent;
    global $amp_conf;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    $supported_hardware = array('sip', 'pjsip', 'iax2', 'dahdi');
    // We only want to hook the 'extensions' pages.
    $th = !empty($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : '';
    if ($pagename != 'extensions' && in_array(str_replace('_generic', '', $th), $supported_hardware)) {
        return true;
    }
    $fw_ari = FreePBX::Modules()->getInfo('fw_ari');
    if (!empty($fw_ari['fw_ari']) && $fw_ari['fw_ari']['status'] == MODULE_STATUS_ENABLED) {
        if ($tech_hardware != null || $extdisplay != '' || $action == 'add') {
            $currentcomponent->addoptlistitem('webrtc_enable', 'no', 'No');
            $currentcomponent->addoptlistitem('webrtc_enable', 'yes', 'Yes');
            $currentcomponent->setoptlistopts('webrtc_enable', 'sort', false);
            $currentcomponent->addguifunc("webrtc_{$pagename}_configpageload");
            if (!empty($action)) {
                $currentcomponent->addprocessfunc("webrtc_{$pagename}_configprocess");
            }
        }
    }
}
Beispiel #2
0
 public function moduleSearch()
 {
     $results = array();
     if (!isset($_REQUEST['query'])) {
         return array();
     }
     // Make the query string usable.
     $qs = htmlentities($_REQUEST['query'], ENT_QUOTES, 'UTF-8', false);
     $mods = \FreePBX::Modules()->getModulesByMethod("search");
     foreach ($mods as $mod) {
         \modgettext::push_textdomain(strtolower($mod));
         $this->FreePBX->{$mod}->search($qs, $results);
         \modgettext::pop_textdomain();
     }
     // Remove any results from the search that are unneeded.
     foreach ($results as $i => $r) {
         if ($r['type'] == "text" || isset($r['force'])) {
             // Always return text fields that were given back to us, or if the result
             // was forced to display.
             continue;
         }
         // We should try to use UTF-8 sensible matching if possible.
         if (function_exists("mb_stripos")) {
             if (mb_stripos($r['text'], $qs) === false) {
                 // Doesn't match? Remove.
                 unset($results[$i]);
             }
         } else {
             // Use UTF-8 unsafe check.
             if (stripos($r['text'], $qs) === false) {
                 // Doesn't match? Remove.
                 unset($results[$i]);
             }
         }
     }
     return $results;
 }
function languages_hook_core($viewing_itemid, $target_menuid)
{
    $request = $_REQUEST;
    $extension = isset($request['extension']) ? $request['extension'] : '';
    $cidnum = isset($request['cidnum']) ? $request['cidnum'] : '';
    $extdisplay = isset($request['extdisplay']) ? $request['extdisplay'] : '';
    $action = isset($request['action']) ? $request['action'] : '';
    $language = isset($request['language']) ? $request['language'] : '';
    //set $extension,$cidnum if we dont already have them
    if (!$extension && !$cidnum) {
        $opts = explode('/', $extdisplay);
        $extension = $opts['0'];
        $cidnum = isset($opts['1']) ? $opts['1'] : '';
    } else {
        $extension = $extension;
        $cidnum = $cidnum;
    }
    //update if we have enough info
    if ($action == 'edtIncoming' || ($extension != '' || $cidnum != '') && $language != '') {
        languages_incoming_update($language = $language, $extension, $cidnum);
    }
    if ($action == 'delIncoming') {
        languages_incoming_delete($extension, $cidnum);
    }
    $html = '';
    if ($target_menuid == 'did') {
        $html .= '
			<!--Language-->
			<div class="element-container">
				<div class="row">
					<div class="col-md-12">
						<div class="row">
							<div class="form-group">
								<div class="col-md-3">
									<label class="control-label" for="language">' . _("Language") . '</label>
									<i class="fa fa-question-circle fpbx-help-icon" data-for="language"></i>
								</div>
								<div class="col-md-9">
		';
        $language = languages_incoming_get($extension, $cidnum);
        if (FreePBX::Modules()->moduleHasMethod('Soundlang', 'getLanguages')) {
            $languages = FreePBX::Soundlang()->getLanguages();
            $html .= '<select class="form-control" id="language" name="language">';
            $html .= '<option value=""' . ($language == "" ? "SELECTED" : "") . '>' . _("Default") . '</option>';
            foreach ($languages as $key => $val) {
                $html .= '<option value="' . $key . '"' . ($language == $key ? "SELECTED" : "") . '>' . $val . '</option>';
            }
            $html .= '</select>';
        } else {
            $html .= '<input type="text" class="form-control" id="language" name="language" value="' . $language . '">';
        }
        $html .= '
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<span id="language-help" class="help-block fpbx-help-block">' . _("Allows you to set the language for this DID.") . '</span>
					</div>
				</div>
			</div>
			<!--END Language-->
		';
    }
    return $html;
}
Beispiel #4
0
<?php

//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2015 Sangoma Technologies.
//
//
?>
<script>
	var destinations = <?php 
echo json_encode(FreePBX::Modules()->getDestinations());
?>
;
</script>
<div id="toolbar-all">
	<a href="config.php?display=announcement&amp;view=form" class="btn btn-primary"><i class="fa fa-plus"></i> <?php 
echo _('Add');
?>
</a>
</div>
<table data-toolbar="#toolbar-all" data-toggle="table" data-url="ajax.php?module=announcement&amp;command=getJSON&amp;jdata=grid" data-maintain-selected="true" data-show-columns="true" data-show-toggle="true" data-toggle="table" data-pagination="true" data-search="true"  id="table-all">
	<thead>
		<tr>
			<th data-sortable="true" data-field="description"><?php 
echo _("Description");
?>
</th>
			<th data-sortable="true" data-field="post_dest" data-formatter="aDestFormatter"><?php 
echo _("Destination");
?>
</th>
			<th data-field="announcement_id" data-formatter="actionformatter"><?php 
Beispiel #5
0
    $Ucp = FreePBX::create()->Ucp;
    $sql = "SELECT username,password,settings FROM ucp_users";
    $old = sql($sql, 'getAll', DB_FETCHMODE_ASSOC);
    foreach ($old as $user) {
        $assigned = json_decode($user['settings'], true);
        $ret = $userman->addUser($user['username'], $user['password'], 'none', 'User Migrated from UCP', array(), false);
        if ($ret['status']) {
            $userman->setAssignedDevices($ret['id'], $assigned['modules']['Voicemail']['assigned']);
            $userman->setModuleSettingByID($ret['id'], 'ucp|Voicemail', 'assigned', $assigned['modules']['Voicemail']['assigned']);
        }
    }
    $sql = 'DROP TABLE IF EXISTS ucp_users';
    $result = $db->query($sql);
}
switch (true) {
    case FreePBX::Modules()->checkStatus('ucp', MODULE_STATUS_NOTINSTALLED):
        //ok so auto enable UCP for all users
        $ucp = FreePBX::create()->Ucp;
        $ucp->enableAllUsers();
        break;
}
// VIEW_UCP_FOOTER_CONTENT
$set['value'] = 'views/dashfootercontent.php';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 1;
$set['level'] = 1;
$set['sortorder'] = 355;
$set['module'] = 'ucp';
//This will help delete the settings when module is uninstalled
$set['category'] = 'Styling and Logos';
 /**
  * Find the file for the object
  * @param string $objname The Object Name (same as class name, filename)
  * @param string $hint The location of the Class file
  * @return bool True if found or throws exception
  */
 private function loadObject($objname, $hint = null)
 {
     $objname = str_replace('FreePBX\\modules\\', '', $objname);
     $class = class_exists($this->moduleNamespace . $objname) ? $this->moduleNamespace . $objname : $objname;
     // If it already exists, we're fine.
     if (class_exists($class)) {
         //do reflection tests for ARI junk, we **dont** want to load ARI
         $class = new ReflectionClass($class);
         //this is a stop gap, remove in 13 or 14 when ARI is no longer used
         if (!$class->hasMethod('navMenu') && !$class->hasMethod('rank')) {
             return true;
         }
     }
     // This is the file we loaded the class from, for debugging later.
     $loaded = false;
     if ($hint) {
         if (!file_exists($hint)) {
             throw new Exception(sprintf(_("Attempted to load %s with a hint of %s and it didn't exist"), $objname, $hint));
         } else {
             $try = $hint;
         }
     } else {
         // Does this exist as a default Library inside BMO?
         $try = __DIR__ . "/{$objname}.class.php";
     }
     if (file_exists($try)) {
         include $try;
         $loaded = $try;
     } else {
         // It's a module, hopefully.
         // This is our root to search from
         $path = $this->Config->get_conf_setting('AMPWEBROOT') . "/admin/modules/";
         $active_modules = array_keys(FreePBX::create()->Modules->getActiveModules());
         foreach ($active_modules as $module) {
             // Lets try this one..
             //TODO: this needs to look with dirname not from webroot
             $try = $path . $module . "/{$objname}.class.php";
             if (file_exists($try)) {
                 //Now we need to make sure this is not a revoked module!
                 try {
                     $signature = FreePBX::Modules()->getSignature($module);
                     if (empty($signature['status'])) {
                         $revoked = false;
                     } else {
                         $revoked = $signature['status'] & GPG::STATE_REVOKED;
                     }
                 } catch (\Exception $e) {
                     $revoked = false;
                 }
                 //if revoked then dont load!
                 if (!$revoked) {
                     include $try;
                     $loaded = $try;
                 }
                 break;
             }
         }
     }
     // Right, after all of this we should now have our object ready to create.
     if (!class_exists($class) && !class_exists($this->moduleNamespace . $objname)) {
         // Bad things have happened.
         if (!$loaded) {
             $sobjname = strtolower($objname);
             throw new Exception(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"), $objname) . sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) amportal a ma install %s 2) amportal a ma enable %s"), $sobjname, $sobjname));
             //die_freepbx(sprintf(_("Unable to locate the FreePBX BMO Class '%s'"),$objname), sprintf(_("A required module might be disabled or uninstalled. Recommended steps (run from the CLI): 1) amportal a ma install %s 2) amportal a ma enable %s"),$sobjname,$sobjname));
         }
         // We loaded a file that claimed to represent that class, but didn't.
         throw new Exception(sprintf(_("Attempted to load %s but it didn't define the class %s"), $try, $objname));
     }
     return true;
 }
 private function tryEnable($modulename, $force)
 {
     \FreePBX::Modules()->loadAllFunctionsInc();
     if (is_array($errors = $this->mf->enable($modulename, $this->force))) {
         $this->writeln(_("The following error(s) occured:"), "error", false);
         $this->writeln(' - ' . implode("\n - ", $errors), "error", false);
     } else {
         $this->writeln(sprintf(_("Module %s successfully enabled"), $modulename));
     }
 }
Beispiel #8
0
</span>
					</div>
			</div>
		</div>
		<div class="element-container">
			<div class="row">
				<div class="col-md-3">
					<label class="control-label" for="language"><?php 
echo _("Language Code");
?>
</label>
					<i class="fa fa-question-circle fpbx-help-icon" data-for="language"></i>
				</div>
				<div class="col-md-9">
					<?php 
if (\FreePBX::Modules()->checkStatus("soundlang")) {
    ?>
						<?php 
    $langs = \FreePBX::Soundlang()->getLanguages();
    $langs = is_array($langs) ? $langs : array();
    ?>
						<select name="language" class="form-control">
							<option value=""><?php 
    echo _("Default");
    ?>
</option>
							<?php 
    foreach ($langs as $key => $lang) {
        ?>
								<option value="<?php 
        echo $key;
Beispiel #9
0
 public function runModulesOOBE($modname = false)
 {
     if (!$modname) {
         throw new \Exception("You didn't ask for a module");
     }
     $bmo = FreePBX::create();
     $mod = ucfirst($modname);
     // Firstly. Is that module already loaded? Pretty unlikely
     // at this stage of play..
     if (!class_exists("\\FreePBX\\modules\\{$mod}")) {
         // Unsurprisingly, it didn't. Let's load it.
         // We need to manually load it, as the autoloader WON'T.
         $hint = FreePBX::Config()->get("AMPWEBROOT") . "/admin/modules/{$modname}/{$mod}.class.php";
         $this->injectClass($mod, $hint);
     }
     // Now we can instantiate it
     $obj = FreePBX::$mod();
     // Awesome. Now, what was that oobe function again...?
     $xml = \FreePBX::Modules()->getXML($modname);
     $func = (string) $xml->oobe->attributes()->method;
     // Is someone taking crazy pills?
     if (!method_exists($obj, $func)) {
         // Do not i18n. This is for support, not end users.
         print "I'm sorry. The module {$modname} said that it was providing an OOBE, but when I actually asked it for '{$func}', it didn't exist. ";
         print "Please try again.\n";
         $this->completeOOBE($modname);
         return false;
     }
     // Awesome. Off you go then!
     return $obj->{$func}();
 }
Beispiel #10
0
 /**
  * Try to load a functions.inc.php if not previously loaded
  * @param  string $module The module rawname
  */
 public function loadFunctionsInc($module)
 {
     if ($this->checkStatus($module)) {
         $path = $this->FreePBX->Config->get("AMPWEBROOT");
         $ifiles = get_included_files();
         $relative = $module . "/functions.inc.php";
         $absolute = $path . "/admin/modules/" . $relative;
         $data = \FreePBX::Modules()->getInfo($module);
         $needs_zend = isset($data[$module]['depends']['phpcomponent']) && stristr($data[$module]['depends']['phpcomponent'], 'zend');
         $licFileExists = glob('/etc/schmooze/license-*.zl');
         $complete_zend = !function_exists('zend_loader_install_license') || empty($licFileExists);
         if (file_exists($absolute)) {
             if ($needs_zend && class_exists('\\Schmooze\\Zend', false) && \Schmooze\Zend::fileIsLicensed($absolute) && $complete_zend) {
                 return false;
             }
             $include = true;
             foreach ($ifiles as $file) {
                 if (strpos($file, $relative) !== false) {
                     $include = false;
                     break;
                 }
             }
             if ($include) {
                 include $absolute;
             }
         }
     }
 }
Beispiel #11
0
<!--Language Code-->
<div class="element-container">
	<div class="row">
		<div class="col-md-12">
			<div class="row">
				<div class="form-group">
					<div class="col-md-3">
						<label class="control-label" for="lang_code"><?php 
echo _("Language Code");
?>
</label>
						<i class="fa fa-question-circle fpbx-help-icon" data-for="lang_code"></i>
					</div>
					<div class="col-md-9">
<?php 
if (FreePBX::Modules()->moduleHasMethod('Soundlang', 'getLanguages')) {
    $languages = FreePBX::Soundlang()->getLanguages();
    ?>
						<select class="form-control" id="lang_code" name="lang_code">
<?php 
    foreach ($languages as $key => $val) {
        ?>
							<option value="<?php 
        echo $key;
        ?>
" <?php 
        echo $key == $lang_code ? "selected" : "";
        ?>
><?php 
        echo $val;
        ?>
Beispiel #12
0
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"/>&nbsp;' . $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"/>&nbsp;' . $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 . ', ';
                    }
                }
                $pport = rtrim($pport, ", ");
            } else {
                $pport = '';
            }
            $extrac = !empty($pport) ? sprintf(_('listening on <strong>%s</strong>'), $pport) : '';
            $device_uses = sprintf(_("This device uses %s technology %s"), "<strong>" . $devinfo_techd . "</strong>", $extrac) . (strtoupper($devinfo_tech) == 'ZAP' && ast_with_dahdi() ? " (" . _("Via DAHDi compatibility mode") . ")" : "");
            $currentcomponent->addguielem($section, new gui_label('techlabel', '<div class="alert alert-info" role="alert" style="width:100%">' . $device_uses . '</div>'), 4);
            // We need to scream loudly if this device is using a channel driver that's disabled.
            if ($devinfo_tech == "pjsip" || $devinfo_tech == "sip") {
                $sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER');
                if ($sipdriver != "both") {
                    // OK, one is disabled.
                    if ($devinfo_tech == "sip") {
                        $iwant = "chan_sip";
                    } else {
                        $iwant = "chan_pjsip";
                    }
                    if ($iwant != $sipdriver) {
                        // Poot.
                        $err = sprintf(_("<strong>CRITICAL ERROR!</strong> Required Service %s is disabled! This device is unusable!"), strtoupper($iwant));
                        $currentcomponent->addguielem($section, new gui_label('techerrlabel', $err), 3);
                    }
                }
            }
            $devopts = $currentcomponent->getgeneralarrayitem('devtechs', $devinfo_tech);
            if (is_array($devopts)) {
                foreach ($devopts as $devopt => $devoptarr) {
                    $devopname = 'devinfo_' . $devopt;
                    $devoptcurrent = isset(${$devopname}) ? ${$devopname} : $devoptarr['value'];
                    $devoptjs = isset($devoptarr['jsvalidation']) ? $devoptarr['jsvalidation'] : '';
                    $devoptfailmsg = isset($devoptarr['failvalidationmsg']) ? $devoptarr['failvalidationmsg'] : '';
                    $devdisable = isset($devoptarr['disable']) ? $devoptarr['disable'] : false;
                    $devonchange = isset($devoptarr['onchange']) ? $devoptarr['onchange'] : '';
                    $prompttext = isset($devoptarr['prompttext']) ? $devoptarr['prompttext'] : $devopt;
                    $hidden = isset($devoptarr['hidden']) ? $devoptarr['hidden'] : false;
                    $type = isset($devoptarr['type']) ? $devoptarr['type'] : (isset($devoptarr['select']) ? 'select' : 'text');
                    $text = isset($devoptarr['text']) ? $devoptarr['text'] : '';
                    // We compare the existing secret against what might be in the put to detect changes when validating
                    if ($devopt == "secret") {
                        $currentcomponent->addguielem($section, new gui_hidden($devopname . "_origional", $devoptcurrent), 4);
                        if ($devoptcurrent == '' && empty($extdisplay)) {
                            $devoptcurrent = md5(uniqid());
                        }
                    }
                    if (!$hidden && ($devoptarr['level'] == 0 || $amp_conf['ALWAYS_SHOW_DEVICE_DETAILS'] && $devoptarr['level'] < 2 || $extdisplay != '')) {
                        // editing to show advanced as well
                        // Added optional selectbox to enable the unsupported misdn module
                        $tooltip = isset($devoptarr['tt']) ? $devoptarr['tt'] : '';
                        if ($type == 'select') {
                            $currentcomponent->addguielem($section, new gui_selectbox($devopname, $devoptarr['select'], $devoptcurrent, $prompttext, $tooltip, false, $devonchange, $devdisable), 4);
                        } elseif ($type == 'text') {
                            $currentcomponent->addguielem($section, new gui_textbox($devopname, $devoptcurrent, $prompttext, $tooltip, $devoptjs, $devoptfailmsg, true, 0, $devdisable), 4);
                        } elseif ($type == 'button') {
                            $currentcomponent->addguielem($section, new gui_button($devopname, $devoptcurrent, $prompttext, $tooltip, $text, $devoptjs, $devdisable), 4);
                        }
                    } else {
                        // add so only basic
                        $currentcomponent->addguielem($section, new gui_hidden($devopname, $devoptcurrent), 4);
                    }
                }
            }
        }
    }
}
//	Caller ID Tricfecta / Superfecta was invented by Ward Mundy,
//  based on another authors work.
//
//	v 1.0.0 - 1.1.0 Created / coded by Tony Shiffer
//	V 2.0.0 - 2.20 Principle developer Jeremy Jacobs
//  v 2.2.1		Significant development by Patrick ELX
//
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU General Public License as published by
//	the Free Software Foundation; either version 2 of the License, or
//	(at your option) any later version.
//
//Define our rootpath
define("SUPERFECTA_ROOT_PATH", dirname(__FILE__) . '/');
include __DIR__ . "/includes/superfecta_base.php";
$module_info = FreePBX::Modules()->getInfo("superfecta");
$module_info = $module_info['superfecta'];
switch ($action) {
    case "add":
        $middle = load_view(__DIR__ . '/views/add_scheme.php', array("scheme_data" => FreePBX::Superfecta()->getSchemeDefaults()));
        break;
    case "schemecopy":
        //determine the highest order amount.
        $query = "SELECT MAX(ABS(value)) FROM superfectaconfig WHERE field = 'order'";
        $results = sql($query, "getAll");
        $new_order = $results[0][0] + 1;
        //set new scheme name
        $name_good = false;
        $new_name = $schemecopy . ' copy';
        $new_name_count = 2;
        while (!$name_good) {
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
					<span id="maxcallbitrate-help" class="help-block fpbx-help-block"><?php 
echo _("Maximum bitrate for video calls in kb/s");
?>
</span>
				</div>
			</div>
		</div>
		<!--END Max Bit Rate-->
	</div>
</div>
<?php 
if (\FreePBX::Modules()->moduleHasMethod("certman", "getDefaultCertDetails")) {
    ?>
	<div class="section-title" data-for="csiptls"><h3>
		<i class="fa fa-minus"></i> <?php 
    echo _("TLS/SSL/SRTP Settings");
    ?>
</h3>
	</div>
	<div class="section" data-id="csiptls">
		<div class="element-container">
			<div class="row">
				<div class="form-group">
					<div class="col-md-3">
						<label class="control-label" for="tlsenable"><?php 
    echo _("Enable TLS");
    ?>
Beispiel #15
0
    $set['defaultval'] = false;
    $set['readonly'] = 0;
    $set['hidden'] = 0;
    $set['level'] = 3;
    $set['module'] = 'cdr';
    $set['category'] = 'CDR Report Module';
    $set['emptyok'] = 0;
    $set['sortorder'] = 10;
    $set['name'] = 'Enable CEL Reporting';
    $set['description'] = 'Setting this true will enable the CDR module to drill down on CEL data for each CDR. Although the CDR module will assure there is a CEL table available, the reporting functionality in Asterisk and associated ODBC database and CEL configuration must be done outside of FreePBX either by the user or at the Distro level.';
    $set['type'] = CONF_TYPE_BOOL;
    $freepbx_conf->define_conf_setting('CEL_ENABLED', $set, true);
}
$info = FreePBX::Modules()->getInfo("cdr");
if (version_compare_freepbx($info['cdr']['dbversion'], "12.0.13", "<=")) {
    if (FreePBX::Modules()->checkStatus('ucp') && FreePBX::Modules()->checkStatus('userman')) {
        $users = FreePBX::Userman()->getAllUsers();
        foreach ($users as $user) {
            $exts = FreePBX::Ucp()->getSetting($user['username'], 'Settings', 'assigned');
            if (!empty($exts)) {
                FreePBX::Ucp()->setSetting($user['username'], 'Cdr', 'assigned', $exts);
            }
        }
    } elseif (FreePBX::Modules()->checkStatus('ucp', MODULE_STATUS_NEEDUPGRADE)) {
        out(_("Please upgrade UCP before this module so that settings can be properly migrated"));
        return false;
    } elseif (FreePBX::Modules()->checkStatus('userman', MODULE_STATUS_NEEDUPGRADE)) {
        out(_("Please upgrade Usermanager before this module so that settings can be properly migrated"));
        return false;
    }
}
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;
}