Beispiel #1
0
function callme_startcall($to, $from, $new_path)
{
    global $astman;
    $channel = "Local/{$to}@from-internal/n";
    $context = "vm-callme";
    $extension = "s";
    $priority = "1";
    $callerid = "VMAIL/{$from}";
    $engine_info = engine_getinfo();
    $version = $engine_info['version'];
    if (version_compare($version, "1.6", "ge")) {
        $variable = "MSG={$new_path},MBOX={$from}";
    } else {
        $variable = "MSG={$new_path}|MBOX={$from}";
    }
    /* Arguments to Originate: channel, extension, context, priority, timeout, callerid, variable, account, application, data */
    $status = $astman->Originate($channel, $extension, $context, $priority, NULL, $callerid, $variable, NULL, NULL, NULL);
    if (is_array($status)) {
        foreach ($status as $status_elem) {
            if (preg_match('/Originate successfully queued/', $status_elem, $matches) != 0) {
                return CALLME_SUCCESS;
            }
        }
    }
    return CALLME_FAILURE;
}
 function dayNightObject($item)
 {
     global $amp_conf;
     $this->id = $item;
     if ($amp_conf['USEDEVSTATE']) {
         $engine_info = engine_getinfo();
         $version = $engine_info['version'];
         $this->DEVSTATE = version_compare($version, "1.6", "ge") ? "DEVICE_STATE" : "DEVSTATE";
     } else {
         $this->DEVSTATE = false;
     }
 }
 public function doConfigPageInit($page)
 {
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
     //the extension we are currently displaying
     $managerdisplay = isset($_REQUEST['managerdisplay']) ? $_REQUEST['managerdisplay'] : '';
     $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';
     $secret = isset($_REQUEST['secret']) ? $_REQUEST['secret'] : '';
     $deny = isset($_REQUEST['deny']) ? $_REQUEST['deny'] : '0.0.0.0/0.0.0.0';
     $permit = isset($_REQUEST['permit']) ? $_REQUEST['permit'] : '127.0.0.1/255.255.255.0';
     $engineinfo = engine_getinfo();
     $writetimeout = isset($_REQUEST['writetimeout']) ? $_REQUEST['writetimeout'] : '100';
     $astver = $engineinfo['version'];
     //if submitting form, update database
     global $amp_conf;
     if ($action == 'add' || $action == 'delete') {
         $ampuser = $amp_conf['AMPMGRUSER'];
         if ($ampuser == $name) {
             $action = 'conflict';
         }
     }
     switch ($action) {
         case "add":
             $rights = manager_format_in($_REQUEST);
             manager_add($name, $secret, $deny, $permit, $rights['read'], $rights['write'], $writetimeout);
             $_REQUEST['managerdisplay'] = $name;
             needreload();
             break;
         case "delete":
             manager_del($managerdisplay);
             needreload();
             break;
         case "edit":
             //just delete and re-add
             manager_del($name);
             $rights = manager_format_in($_REQUEST);
             manager_add($name, $secret, $deny, $permit, $rights['read'], $rights['write'], $writetimeout);
             needreload();
             break;
         case "conflict":
             //do nothing we are conflicting with the FreePBX Asterisk Manager User
             break;
     }
 }
Beispiel #4
0
function languages_hookGet_config($engine)
{
    global $ext;
    global $version;
    switch ($engine) {
        case "asterisk":
            $priority = 'report';
            if (version_compare($version, "1.4", "ge")) {
                $ext->splice('macro-user-callerid', 's', $priority, new ext_execif('$["${DB(AMPUSER/${AMPUSER}/language)}" != ""]', 'Set', 'CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)}'));
            } else {
                $ext->splice('macro-user-callerid', 's', $priority, new ext_execif('$["${DB(AMPUSER/${AMPUSER}/language)}" != ""]', 'Set', 'LANGUAGE()=${DB(AMPUSER/${AMPUSER}/language)}'));
            }
            $engine_info = engine_getinfo();
            $version = $engine_info['version'];
            $routes = languages_incoming_get();
            foreach ($routes as $current => $route) {
                if ($route['extension'] == '' && $route['cidnum']) {
                    //callerID only
                    $extension = 's/' . $route['cidnum'];
                    $context = $route['pricid'] ? 'ext-did-0001' : 'ext-did-0002';
                } else {
                    if ($route['extension'] && $route['cidnum'] || $route['extension'] == '' && $route['cidnum'] == '') {
                        //callerid+did / any/any
                        $context = 'ext-did-0001';
                    } else {
                        //did only
                        $context = 'ext-did-0002';
                    }
                    $extension = ($route['extension'] != '' ? $route['extension'] : 's') . ($route['cidnum'] == '' ? '' : '/' . $route['cidnum']);
                }
                if (version_compare($version, "1.4", "ge")) {
                    $ext->splice($context, $extension, 1, new ext_setvar('CHANNEL(language)', $route['language']));
                } else {
                    $ext->splice($context, $extension, 1, new ext_setvar('LANGUAGE', $route['language']));
                }
            }
            break;
    }
}
Beispiel #5
0
function callrecording_hookGet_config($engine)
{
    global $ext;
    global $version;
    // Inbound Routes Recording hooks
    $routes = callrecording_display_get('did');
    foreach ($routes as $current => $route) {
        if ($route['extension'] == '' && $route['cidnum']) {
            //callerID only
            $extension = 's/' . $route['cidnum'];
            $context = $route['pricid'] ? 'ext-did-0001' : 'ext-did-0002';
        } else {
            if ($route['extension'] && $route['cidnum'] || $route['extension'] == '' && $route['cidnum'] == '') {
                //callerid+did / any/any
                $context = 'ext-did-0001';
            } else {
                //did only
                $context = 'ext-did-0002';
            }
            $extension = ($route['extension'] != '' ? $route['extension'] : 's') . ($route['cidnum'] == '' ? '' : '/' . $route['cidnum']);
        }
        $ext->splice($context, $extension, 1, new ext_gosub('1', 's', 'sub-record-check', 'in,${EXTEN},' . $route['callrecording']));
    }
    // Outbound Routes recording hooks
    $allroutes = core_routing_list();
    // Make them easier to parse
    $routearr = array();
    foreach ($allroutes as $route) {
        $route['callrecording'] = "dontcare";
        $routearr[$route['route_id']] = $route;
    }
    // Which routes do we know about?
    $recordings = callrecording_display_get('routing');
    foreach ($recordings as $rroute) {
        if (isset($routearr[$rroute['route_id']])) {
            $routearr[$rroute['route_id']]['callrecording'] = $rroute['callrecording'];
        }
    }
    // Now actually splice them.
    foreach ($routearr as $routeid => $route) {
        $context = 'outrt-' . $routeid;
        $patterns = core_routing_getroutepatternsbyid($routeid);
        foreach ($patterns as $pattern) {
            $fpattern = core_routing_formatpattern($pattern);
            $extension = $fpattern['dial_pattern'];
            $ext->splice($context, $extension, 1, new ext_gosub('1', 's', 'sub-record-check', 'out,${EXTEN},' . $route['callrecording']));
        }
    }
    // Add in call recording checks for Parking, if it exists.
    $ext->splice('macro-parked-call', 's', 1, new ext_gosub('1', 's', 'sub-record-check', 'parking,${AMPUSER},${AMPUSER}'));
    // Bugfix for Asterisk 11 - CDR(recordingfile) is getting lost when it's added in one-touch-record.
    // See https://issues.asterisk.org/jira/browse/ASTERISK-19853
    $ast_info = engine_getinfo();
    $astver = $ast_info["version"];
    if (version_compare($astver, '12', 'lt')) {
        $ext->splice("macro-hangupcall", 's', 0, new ext_execif('$["${CALLFILENAME}"!="" & "${CDR(recordingfile)}"=""]', 'Set', 'CDR(recordingfile)=${CALLFILENAME}.${MON_FMT}'));
    }
}
Beispiel #6
0
function fax_detect($astver = null)
{
    global $amp_conf;
    global $astman;
    if ($astver === null) {
        $engineinfo = engine_getinfo();
        $astver = $engineinfo['version'];
    }
    $ast_ge_14 = version_compare($astver, '1.4', 'ge');
    $ast_ge_18 = version_compare($astver, '1.8', 'ge');
    $fax = null;
    $appfax = $receivefax = false;
    //return false by default in case asterisk isnt reachable
    if ($amp_conf['AMPENGINE'] == 'asterisk' && isset($astman) && $astman->connected()) {
        //check for fax modules
        $module_show_command = $ast_ge_14 ? 'module show like ' : 'show modules like ';
        $app = $astman->send_request('Command', array('Command' => $module_show_command . 'res_fax'));
        if (preg_match('/[1-9] modules loaded/', $app['data'])) {
            $fax['module'] = 'res_fax';
        } else {
            $receive = $astman->send_request('Command', array('Command' => $module_show_command . 'app_fax'));
            if (preg_match('/[1-9] modules loaded/', $receive['data'])) {
                $fax['module'] = 'app_fax';
            }
        }
        if (!isset($fax['module'])) {
            $app = $astman->send_request('Command', array('Command' => $module_show_command . 'app_rxfax'));
            $fax['module'] = preg_match('/[1-9] modules loaded/', $app['data']) ? 'app_rxfax' : null;
        }
        $response = $astman->send_request('Command', array('Command' => $module_show_command . 'app_nv_faxdetect'));
        $fax['nvfax'] = preg_match('/[1-9] modules loaded/', $response['data']) ? true : false;
        $response = $astman->send_request('Command', array('Command' => $module_show_command . 'res_fax_digium'));
        $fax['ffa'] = preg_match('/[1-9] modules loaded/', $response['data']) ? true : false;
        if ($ast_ge_18) {
            if ($fax['ffa']) {
                $fax['spandsp'] = false;
            } else {
                $response = $astman->send_request('Command', array('Command' => $module_show_command . 'res_fax_spandsp'));
                $fax['spandsp'] = preg_match('/[1-9] modules loaded/', $response['data']) ? true : false;
            }
        }
        switch ($fax['module']) {
            case 'res_fax':
                $fax['receivefax'] = 'receivefax';
                break;
            case 'app_rxfax':
                $fax['receivefax'] = 'rxfax';
                break;
            case 'app_fax':
                $application_show_command = $ast_ge_14 ? 'core show applications like ' : 'show applications like ';
                $response = $astman->send_request('Command', array('Command' => $application_show_command . 'receivefax'));
                if (preg_match('/1 Applications Matching/', $response['data'])) {
                    $fax['receivefax'] = 'receivefax';
                } else {
                    $response = $astman->send_request('Command', array('Command' => $application_show_command . 'rxfax'));
                    if (preg_match('/1 Applications Matching/', $response['data'])) {
                        $fax['receivefax'] = 'rxfax';
                    } else {
                        $fax['receivefax'] = 'none';
                    }
                }
                break;
        }
        //get license count
        $lic = $astman->send_request('Command', array('Command' => 'fax show stats'));
        foreach (explode("\n", $lic['data']) as $licdata) {
            $d = explode(':', $licdata);
            $data[trim($d['0'])] = isset($d['1']) ? trim($d['1']) : null;
        }
        $fax['license'] = isset($data['Licensed Channels']) ? $data['Licensed Channels'] : '';
    }
    return $fax;
}
Beispiel #7
0
function module_get_annoucements()
{
    global $db;
    global $amp_conf;
    $firstinstall = false;
    $type = null;
    $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
    $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
    // if not set so this is a first time install
    // get a new hash to account for first time install
    //
    if (!isset($result['data']) || trim($result['data']) == "") {
        $firstinstall = true;
        $install_hash = _module_generate_unique_id();
        $installid = $install_hash['uniqueid'];
        $type = $install_hash['type'];
        // save the hash so we remeber this is a first time install
        //
        $data4sql = $db->escapeSimple($installid);
        sql("INSERT INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
        $data4sql = $db->escapeSimple($type);
        sql("INSERT INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
        // Not a first time so save the queried hash and check if there is a type set
        //
    } else {
        $installid = $result['data'];
        $sql = "SELECT * FROM module_xml WHERE id = 'type'";
        $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
        if (isset($result['data']) && trim($result['data']) != "") {
            $type = $result['data'];
        }
    }
    // Now we have the id and know if this is a firstime install so we can get the announcement
    //
    $options = "?installid=" . urlencode($installid);
    if (trim($type) != "") {
        $options .= "&type=" . urlencode($type);
    }
    if ($firstinstall) {
        $options .= "&firstinstall=yes";
    }
    $engver = engine_getinfo();
    if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
        $options .= "&astver=" . urlencode($engver['version']);
    } else {
        $options .= "&astver=" . urlencode($engver['raw']);
    }
    $options .= "&phpver=" . urlencode(phpversion());
    $distro_info = _module_distro_id();
    $options .= "&distro=" . urlencode($distro_info['pbx_type']);
    $options .= "&distrover=" . urlencode($distro_info['pbx_version']);
    $fn = "http://mirror.freepbx.org/version-" . getversion() . ".html" . $options;
    if (!$amp_conf['MODULEADMINWGET']) {
        ini_set('user_agent', 'Wget/1.10.2 (Red Hat modified)');
        $announcement = @file_get_contents($fn);
    } else {
        $announcement = '';
    }
    if (empty($announcement)) {
        $fn2 = str_replace('&', '\\&', $fn);
        exec("wget -O - {$fn2} 2>> /dev/null", $data_arr, $retcode);
        $announcement = implode("\n", $data_arr);
    }
    return $announcement;
}
 private function showEngine()
 {
     $engine = engine_getinfo();
     foreach ($engine as $key => $value) {
         $this->writeln(str_pad($key, 15, ' ', STR_PAD_LEFT) . ': ' . $value);
     }
 }
Beispiel #9
0
    public function coreDIDHook($page)
    {
        if ($page == 'did') {
            $target_menuid = $page;
            $tabindex = null;
            $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
            $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : '';
            $cidnum = isset($_REQUEST['cidnum']) ? $_REQUEST['cidnum'] : '';
            $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : '';
            //if were editing, get save parms. Get parms
            if (!$extension && !$cidnum) {
                //set $extension,$cidnum if we dont already have them
                if ($extdisplay) {
                    $opts = explode('/', $extdisplay);
                    $extension = $opts['0'];
                    $cidnum = isset($opts['1']) ? $opts['1'] : '';
                } else {
                    $extension = $cidnum = '';
                }
            }
            $fax = fax_get_incoming($extension, $cidnum);
            $html = $fdinput = '';
            if ($target_menuid == 'did') {
                $fax_dahdi_faxdetect = fax_dahdi_faxdetect();
                $fax_sip_faxdetect = fax_sip_faxdetect();
                $dahdi = ast_with_dahdi() ? _('Dahdi') : _('Zaptel');
                $fax_detect = fax_detect();
                $fax_settings = fax_get_settings();
                //ensure that we are using destination for both fax detect and the regular calls
                $html = '<script type="text/javascript">$(document).ready(function(){
				$("input[name=Submit]").click(function(){
					if($("input[name=faxenabled]:checked").val()=="true" && !$("[name=gotoFAX]").val()){//ensure the user selected a fax destination
					alert(' . _('"You have selected Fax Detection on this route. Please select a valid destination to route calls detected as faxes to."') . ');return false; }	}) });</script>';
                $fdhelp = _("Attempt to detect faxes on this DID.");
                $fdhelp .= '<ul>';
                $fdhelp .= '<li>' . _("No: No attempts are made to auto-determine the call type; all calls sent to destination set in the 'General' tab. Use this option if this DID is used exclusively for voice OR fax.") . '</li>';
                $fdhelp .= '<li>' . _("Yes: try to auto determine the type of call; route to the fax destination if call is a fax, otherwise send to regular destination. Use this option if you receive both voice and fax calls on this line") . '</li>';
                if ($fax_settings['legacy_mode'] == 'yes' || $fax['legacy_email'] !== null) {
                    $fdhelp .= '<li>' . _('Legacy: Same as YES, only you can enter an email address as the destination. This option is ONLY for supporting migrated legacy fax routes. You should upgrade this route by choosing YES, and selecting a valid destination!') . '</li>';
                }
                $fdhelp .= '</ul>';
                //dont allow detection to be set if we have no valid detection types
                if (!$fax_dahdi_faxdetect && !$fax_sip_faxdetect && !$fax_detect['nvfax']) {
                    $js = "if (\$(this).val() == 'true'){alert('" . _('No fax detection methods found or no valid license. Faxing cannot be enabled.') . "');return false;}";
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_yes" value="true"  onclick="' . $js . '"/><label for="faxenabled_yes">Yes</label></span>';
                    $fdinput .= '<input type="radio" id="faxenabled_no" name="faxenabled" value="false" CHECKED /><label for="faxenabled_no">No</label>';
                } else {
                    /*
                     * show detection options
                     *
                     * js to show/hide the detection settings. Second slide is always in a
                     * callback so that we ait for the fits animation to complete before
                     * playing the second
                     */
                    $faxing = !empty($fax);
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_yes" value="true" ' . ($faxing ? 'CHECKED' : '') . ' /><label for="faxenabled_yes">' . _('Yes') . '</label>';
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_no" value="false" ' . (!$faxing ? 'CHECKED' : '') . '/><label for="faxenabled_no">' . _('No') . '</label>';
                    if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
                        $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_legacy" value="legacy"' . ($fax['legacy_email'] !== null ? ' CHECKED ' : '') . 'onclick="' . $jslegacy . '"/><label for="faxenabled_legacy">' . _('Legacy');
                    }
                }
                $html .= '
					<!--Detect Faxes-->
					<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="faxenabled">' . _("Detect Faxes") . '</label>
											<i class="fa fa-question-circle fpbx-help-icon" data-for="faxenabled"></i>
										</div>
										<div class="col-md-9 radioset">
											' . $fdinput . '
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<span id="faxenabled-help" class="help-block fpbx-help-block">' . $fdhelp . '</span>
							</div>
						</div>
					</div>
					<!--END Detect Faxes-->
				';
                $info = engine_getinfo();
                $fdthelp = _("Type of fax detection to use.");
                $fdthelp .= '<ul>';
                $fdthelp .= '<li>' . $dahdi . ': ' . _("use ") . $dahdi . _(" fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ") . $dahdi . '.conf</li>';
                $fdthelp .= '<li>' . _("Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files") . '</li>';
                $fdthelp .= '<li>' . _("NV Fax Detect: Use NV Fax Detection; Requires NV Fax Detect to be installed and recognized by asterisk") . '</li>';
                $fdthelp .= '</ul>';
                $html .= '
				<!--Fax Detection type-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdtype">
					<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="faxdetection">' . _("Fax Detection type") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="faxdetection"></i>
									</div>
									<div class="col-md-9 radioset">
										<input type="radio" name="faxdetection" id="faxdetectiondahdi" value="dahdi" ' . ($fax['detection'] == "dahdi" ? "CHECKED" : "") . ' ' . ($fax_dahdi_faxdetect ? '' : 'disabled') . '>
										<label for="faxdetectiondahdi">' . _("Dahdi") . '</label>
										<input type="radio" name="faxdetection" id="faxdetectionnvfax" value="nvfax" ' . ($fax['detection'] == "nvfax" ? "CHECKED" : "") . ' ' . ($fax_detect['nvfax'] ? '' : 'disabled') . '>
										<label for="faxdetectionnvfax">' . _("NVFax") . '</label>
										<input type="radio" name="faxdetection" id="faxdetectionsip" value="sip" ' . ($fax['detection'] == "sip" ? "CHECKED" : "") . ' ' . ($info['version'] >= "1.6.2" && $fax_sip_faxdetect ? '' : 'disabled') . '>
										<label for="faxdetectionsip">' . _("SIP") . '</label>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="faxdetection-help" class="help-block fpbx-help-block">' . $fdthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Detection type-->
				';
                if (!$fax['detectionwait']) {
                    $fax['detectionwait'] = 4;
                }
                //default wait time is 4 second
                $fdthelp = _('How long to wait and try to detect fax. Please note that callers to a Dahdi channel will hear ringing for this amount of time (i.e. the system wont "answer" the call, it will just play ringing).');
                $html .= '
				<!--Fax Detection Time-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdtime">
					<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="faxdetectionwait">' . _("Fax Detection Time") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="faxdetectionwait"></i>
									</div>
									<div class="col-md-9">
										<input type="number" min="2" max="11" class="form-control" id="faxdetectionwait" name="faxdetectionwait" value="' . $fax['detectionwait'] . '">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="faxdetectionwait-help" class="help-block fpbx-help-block">' . $fdthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Detection Time-->
				';
                if (!empty($fax['legacy_email']) || $fax_settings['legacy_mode'] == 'yes') {
                    $fedhelp = _("Address to email faxes to on fax detection.<br />PLEASE NOTE: In this version of FreePBX, you can now set the fax destination from a list of destinations. Extensions/Users can be fax enabled in the user/extension screen and set an email address there. This will create a new destination type that can be selected. To upgrade this option to the full destination list, select YES to Detect Faxes and select a destination. After clicking submit, this route will be upgraded. This Legacy option will no longer be available after the change, it is provided to handle legacy migrations from previous versions of FreePBX only.");
                    $html .= '
					<!--Fax Email Destination-->
					<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdemail">
						<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="legacy_email"><?php echo _("Fax Email Destination") ?></label>
											<i class="fa fa-question-circle fpbx-help-icon" data-for="legacy_email"></i>
										</div>
										<div class="col-md-9">
											<input type="text" class="form-control" id="legacy_email" name="legacy_email" value="' . $fax['legacy_email'] . '">
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<span id="legacy_email-help" class="help-block fpbx-help-block">' . $fedhelp . '</span>
							</div>
						</div>
					</div>
					<!--END Fax Email Destination-->
					';
                }
                $faxdesthelp = _('Where to send the faxes');
                $html .= '
				<!--Fax Destination-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fddest">
					<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="gotofax">' . _("Fax Destination") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="gotofax"></i>
									</div>
									<div class="col-md-9">';
                $html .= $fax_detect ? drawselects(isset($fax['destination']) ? $fax['destination'] : null, 'FAX', false, false) : '';
                $html .= '
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="gotofax-help" class="help-block fpbx-help-block">' . $faxdesthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Destination-->
				<script type="text/javascript">
				$("[name=\'faxenabled\']").change(function(){
					if($(this).val() == \'true\'){
						$("#fdtype").removeClass("hidden");
						$("#fdtime").removeClass("hidden");
						$("#fddest").removeClass("hidden");
					}else{
						$("#fdtype").addClass("hidden");
						$("#fdtime").addClass("hidden");
						$("#fddest").addClass("hidden");
					}
				});
				</script>
				';
            }
            $ret = array();
            $ret[] = array('title' => _("Fax"), 'rawname' => 'fax', 'content' => $html);
            return $ret;
        }
    }
Beispiel #10
0
 function astinfo(&$astman)
 {
     $this->astman =& $astman;
     $arr = engine_getinfo();
     $this->version = $arr['version'];
 }
function timeconditions_timegroups_get_times($timegroup, $convert = false, $timecondition_id = null)
{
    global $db, $version;
    $tmparray = array();
    if ($convert && (!isset($version) || $version == '')) {
        $engineinfo = engine_getinfo();
        $version = $engineinfo['version'];
    }
    if ($convert) {
        $ast_ge_16 = version_compare($version, '1.6', 'ge');
    }
    $sql = "SELECT id, time FROM timegroups_details WHERE timegroupid = {$timegroup}";
    $results = $db->getAll($sql);
    if (DB::IsError($results) || !is_array($results)) {
        $results = array();
    }
    $tz = '';
    if ($timecondition_id > 0) {
        $systz = date_default_timezone_get();
        $timezone = $db->getOne("SELECT timezone FROM timeconditions WHERE timeconditions_id = {$timecondition_id}");
        //If timezone is empty or "drfault" we use the current system tz
        $timezone = empty($timezone) ? $systz : $timezone;
        $timezone = $timezone == 'default' ? $systz : $timezone;
        $tz = "|{$timezone}";
    }
    foreach ($results as $val) {
        $val[1] .= $tz;
        $times = $convert && $ast_ge_16 ? strtr($val[1], '|', ',') : $val[1];
        $tmparray[] = array($val[0], $times);
    }
    return $tmparray;
}
/**
 * function generate_module_repo_url
 * short create array of full URLs to get a file from repo
 * use this function to generate an array of URLs for all configured REPOs
 * @author Philippe Lindheimer
 *
 * @pram string
 * @returns string
 */
function generate_module_repo_url($path, $add_options = false)
{
    global $db;
    global $amp_conf;
    $urls = array();
    if ($add_options) {
        $firstinstall = false;
        $type = null;
        $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
        $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
        // if not set so this is a first time install
        // get a new hash to account for first time install
        //
        if (!isset($result['data']) || trim($result['data']) == "") {
            $firstinstall = true;
            $install_hash = _module_generate_unique_id();
            $installid = $install_hash['uniqueid'];
            $type = $install_hash['type'];
            // save the hash so we remeber this is a first time install
            //
            $data4sql = $db->escapeSimple($installid);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
            $data4sql = $db->escapeSimple($type);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
            // Not a first time so save the queried hash and check if there is a type set
            //
        } else {
            $installid = $result['data'];
            $sql = "SELECT * FROM module_xml WHERE id = 'type'";
            $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
            if (isset($result['data']) && trim($result['data']) != "") {
                $type = $result['data'];
            }
        }
        // Now we have the id and know if this is a firstime install so we can get the announcement
        //
        $options = "?installid=" . urlencode($installid);
        if (trim($type) != "") {
            $options .= "&type=" . urlencode($type);
        }
        if ($firstinstall) {
            $options .= "&firstinstall=yes";
        }
        // We check specifically for false because evenif blank it means the file
        // was there so we want module.xml to do appropriate actions
        $brandid = _module_brandid();
        if ($brandid !== false) {
            $options .= "&brandid=" . urlencode($brandid);
        }
        $deploymentid = _module_deploymentid();
        if ($deploymentid !== false) {
            $options .= "&depolymentid=" . urlencode($deploymentid);
        }
        $engver = engine_getinfo();
        if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
            $options .= "&astver=" . urlencode($engver['version']);
        } else {
            $options .= "&astver=" . urlencode($engver['raw']);
        }
        $options .= "&phpver=" . urlencode(phpversion());
        $distro_info = _module_distro_id();
        $options .= "&distro=" . urlencode($distro_info['pbx_type']);
        $options .= "&distrover=" . urlencode($distro_info['pbx_version']);
        $options .= "&fpbxver=" . urlencode(getversion());
        if (function_exists('core_users_list')) {
            $options .= "&ucount=" . urlencode(count(core_users_list()));
        }
        $path .= $options;
        // Other modules may need to add 'get' paramters to the call to the repo. Check and add them
        // here if we are adding paramters. The module should return an array of key/value pairs each of which
        // is to be appended to the GET parameters. The variable name will be prepended with the module name
        // when sent.
        //
        $repo_params = array();
        foreach (mod_func_iterator('module_repo_parameters_callback', $path) as $mod => $res) {
            if (is_array($res)) {
                foreach ($res as $p => $v) {
                    $path .= '&' . urlencode($mod) . '_' . urlencode($p) . '=' . urlencode($v);
                }
            }
        }
    }
    $repos = explode(',', $amp_conf['MODULE_REPO']);
    foreach ($repos as $repo) {
        $urls[] = $repo . $path;
    }
    return $urls;
}
Beispiel #13
0
     }
     // VMX_LOOPS
     //
     $vmx_loops_opts[1] = sprintf(_("%s Retry"), 1);
     for ($i = 2; $i < 5; $i++) {
         $vmx_loops_opts[$i] = sprintf(_("%s Retries"), $i);
     }
     show_view(dirname(__FILE__) . '/views/dialplan.php', array('settings' => $settings, 'direct_dial_opts' => $direct_dial_opts, 'voicemail_gain_opts' => $voicemail_gain_opts, 'vmx_timeout_opts' => $vmx_timeout_opts, 'vmx_repeat_opts' => $vmx_repeat_opts, 'vmx_loops_opts' => $vmx_loops_opts));
     break;
 case "bsettings":
 case "settings":
     $output = '';
     /* get settings */
     $settings = voicemail_get_settings($uservm, $action, $extension);
     /* Get Asterisk version. */
     $ast_info = engine_getinfo();
     $version = $ast_info["version"];
     $text_size = 40;
     if (!empty($extension)) {
         show_view(dirname(__FILE__) . '/views/settings.php', array('action' => $action, 'extension' => $extension, 'version' => $version, 'settings' => $settings, 'tooltips' => $tooltips, 'display_settings' => $acct_settings, 'display_tips' => $tooltips["account"], 'id_prefix' => 'acct'));
         $id_prefix = "acct";
         $display_settings = $acct_settings;
     } else {
         show_view(dirname(__FILE__) . '/views/settings.php', array('action' => $action, 'extension' => $extension, 'version' => $version, 'settings' => $settings, 'tooltips' => $tooltips, 'display_settings' => $gen_settings, 'display_tips' => $tooltips["general"], 'id_prefix' => 'gen'));
         $id_prefix = "gen";
         $display_settings = $gen_settings;
     }
     $display_name_row = "";
     if ($action == "bsettings") {
         /* Display account name */
         $display_name = isset($settings["name"]) ? $settings["name"] : _("No name defined; this is configured from the Extensions or Users page.");
/** Check if a module meets dependencies. 
 * @param  mixed  The name of the module, or the modulexml Array
 * @return mixed  Returns true if dependencies are met, or an array 
 *                containing a list of human-readable errors if not.
 *                NOTE: you must use strict type checking (===) to test
 *                for true, because  array() == true !
 */
function module_checkdepends($modulename)
{
    // check if we were passed a modulexml array, or a string (name)
    // ensure $modulexml is the modules array, and $modulename is the name (as a string)
    if (is_array($modulename)) {
        $modulexml = $modulename;
        $modulename = $modulename['rawname'];
    } else {
        $modulexml = module_getinfo($modulename);
    }
    $errors = array();
    // special handling for engine
    $engine_dependency = false;
    // if we've found ANY engine dependencies to check
    $engine_matched = false;
    // if an engine dependency has matched
    $engine_errors = array();
    // the error strings for engines
    if (isset($modulexml['depends'])) {
        foreach ($modulexml['depends'] as $type => $requirements) {
            // if only a single item, make it an array so we can use the same code as for multiple items
            // this is because if there is  <module>a</module><module>b</module>  we will get array('module' => array('a','b'))
            if (!is_array($requirements)) {
                $requirements = array($requirements);
            }
            foreach ($requirements as $value) {
                switch ($type) {
                    case 'version':
                        if (preg_match('/^(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d*[beta|alpha|rc|RC]?\\d+(\\.[^\\.]+)*)$/i', $value, $matches)) {
                            // matches[1] = operator, [2] = version
                            $installed_ver = getversion();
                            $operator = !empty($matches[1]) ? $matches[1] : 'ge';
                            // default to >=
                            $compare_ver = $matches[2];
                            if (version_compare_freepbx($installed_ver, $compare_ver, $operator)) {
                                // version is good
                            } else {
                                $errors[] = _module_comparison_error_message('FreePBX', $compare_ver, $installed_ver, $operator);
                            }
                        }
                        break;
                    case 'phpversion':
                        /* accepted formats
                        			   <depends>
                        				   <phpversion>5.1.0<phpversion>       TRUE: if php is >= 5.1.0
                        					 <phpversion>gt 5.1.0<phpversion>    TRUE: if php is > 5.1.0
                        				</depends>
                        			*/
                        if (preg_match('/^(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d*[beta|alpha|rc|RC]?\\d+(\\.[^\\.]+)*)$/i', $value, $matches)) {
                            // matches[1] = operator, [2] = version
                            $installed_ver = phpversion();
                            $operator = !empty($matches[1]) ? $matches[1] : 'ge';
                            // default to >=
                            $compare_ver = $matches[2];
                            if (version_compare($installed_ver, $compare_ver, $operator)) {
                                // php version is good
                            } else {
                                $errors[] = _module_comparison_error_message('PHP', $compare_ver, $installed_ver, $operator);
                            }
                        }
                        break;
                    case 'phpcomponent':
                        /* accepted formats
                        			   <depends>
                        				   <phpcomponent>zlib<phpversion>        TRUE: if extension zlib is loaded
                        				   <phpcomponent>zlib 1.2<phpversion>    TRUE: if extension zlib is loaded and >= 1.2
                        			 	   <phpcomponent>zlib gt 1.2<phpversion> TRUE: if extension zlib is loaded and > 1.2	
                        			   </depends>
                        			*/
                        $phpcomponents = explode('||', $value);
                        $newerrors = array();
                        foreach ($phpcomponents as $value) {
                            if (preg_match('/^([a-z0-9_]+|Zend (Optimizer|Guard Loader))(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.\\d*[beta|alpha|rc|RC]*\\d+)+))?$/i', $value, $matches)) {
                                // matches[1] = extension name, [3]=comparison operator, [4] = version
                                $compare_ver = isset($matches[4]) ? $matches[4] : '';
                                if (extension_loaded($matches[1])) {
                                    if (empty($compare_ver)) {
                                        // extension is loaded and no version specified
                                    } else {
                                        if (($installed_ver = phpversion($matches[1])) != '') {
                                            $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                                            // default to >=
                                            if (version_compare($installed_ver, $compare_ver, $operator)) {
                                                // version is good
                                            } else {
                                                $newerrors[] = _module_comparison_error_message("PHP Component " . $matches[1], $compare_ver, $installed_ver, $operator);
                                            }
                                        } else {
                                            $newerrors[] = _module_comparison_error_message("PHP Component " . $matches[1], $compare_ver, "<no version info>", $operator);
                                        }
                                    }
                                } else {
                                    if ($compare_version == '') {
                                        $newerrors[] = sprintf(_('PHP Component %s is required but missing from you PHP installation.'), $matches[1]);
                                    } else {
                                        $newerrors[] = sprintf(_('PHP Component %s version %s is required but missing from you PHP installation.'), $matches[1], $compare_version);
                                    }
                                }
                            }
                        }
                        if (count($newerrors) == count($phpcomponents)) {
                            $errors = array_merge($errors, $newerrors);
                        }
                        break;
                    case 'module':
                        // Modify to allow versions such as 2.3.0beta1.2
                        if (preg_match('/^([a-z0-9_]+)(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.\\d*[beta|alpha|rc|RC]*\\d+)+))?$/i', $value, $matches)) {
                            // matches[1] = modulename, [3]=comparison operator, [4] = version
                            $modules = module_getinfo($matches[1]);
                            if (isset($modules[$matches[1]])) {
                                $needed_module = "<strong>" . (isset($modules[$matches[1]]['name']) ? $modules[$matches[1]]['name'] : $matches[1]) . "</strong>";
                                switch ($modules[$matches[1]]['status']) {
                                    case MODULE_STATUS_ENABLED:
                                        if (!empty($matches[4])) {
                                            // also doing version checking
                                            $installed_ver = $modules[$matches[1]]['dbversion'];
                                            $compare_ver = $matches[4];
                                            $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                                            // default to >=
                                            if (version_compare_freepbx($installed_ver, $compare_ver, $operator)) {
                                                // version is good
                                            } else {
                                                $errors[] = _module_comparison_error_message($needed_module . ' module', $compare_ver, $installed_ver, $operator);
                                            }
                                        }
                                        break;
                                    case MODULE_STATUS_BROKEN:
                                        $errors[] = sprintf(_('Module %s is required, but yours is broken. You should reinstall ' . 'it and try again.'), $needed_module);
                                        break;
                                    case MODULE_STATUS_DISABLED:
                                        $errors[] = sprintf(_('Module %s is required, but yours is disabled.'), $needed_module);
                                        break;
                                    case MODULE_STATUS_NEEDUPGRADE:
                                        $errors[] = sprintf(_('Module %s is required, but yours is disabled because it needs to ' . 'be upgraded. Please upgrade %s first, and then try again.'), $needed_module, $needed_module);
                                        break;
                                    default:
                                    case MODULE_STATUS_NOTINSTALLED:
                                        $errors[] = sprintf(_('Module %s is required, yours is not installed.'), $needed_module);
                                        break;
                                }
                            } else {
                                $errors[] = sprintf(_('Module %s is required.'), $matches[1]);
                            }
                        }
                        break;
                    case 'file':
                        // file exists
                        // replace embedded amp_conf %VARIABLES% in string
                        $file = _module_ampconf_string_replace($value);
                        if (!file_exists($file)) {
                            $errors[] = sprintf(_('File %s must exist.'), $file);
                        }
                        break;
                    case 'engine':
                        /****************************
                         *  NOTE: there is special handling for this check. We want to "OR" conditions, instead of
                         *        "AND"ing like the rest of them. 
                         */
                        // we found at least one engine, so mark that we're matching this
                        $engine_dependency = true;
                        if (preg_match('/^([a-z0-9_]+)(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.[^\\.]+)*))?$/i', $value, $matches)) {
                            // matches[1] = engine, [3]=comparison operator, [4] = version
                            $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                            // default to >=
                            $engine = engine_getinfo();
                            if ($engine['engine'] == $matches[1] && (empty($matches[4]) || version_compare($engine['version'], $matches[4], $operator))) {
                                $engine_matched = true;
                            } else {
                                // add it to the error messages
                                if ($matches[4]) {
                                    // version specified
                                    $operator_friendly = str_replace(array('gt', 'ge', 'lt', 'le', 'eq', 'ne'), array('>', '>=', '<', '<=', '=', 'not ='), $operator);
                                    $engine_errors[] = $matches[1] . ' (' . $operator_friendly . ' ' . $matches[4] . ')';
                                } else {
                                    // no version
                                    $engine_errors[] = $matches[1];
                                }
                            }
                        }
                        break;
                }
            }
        }
        // special handling for engine
        // if we've had at least one engine dependency check, and no engine dependencies matched, we have an error
        if ($engine_dependency && !$engine_matched) {
            $engineinfo = engine_getinfo();
            $yourengine = $engineinfo['engine'] . ' ' . $engineinfo['version'];
            // print it nicely
            if (count($engine_errors) == 1) {
                $errors[] = sprintf(_('Requires engine %s, you have: %s'), $engine_errors[0], $yourengine);
            } else {
                $errors[] = sprintf(_('Requires one of the following engines: %s; you have: %s'), implode(', ', $engine_errors), $yourengine);
            }
        }
    }
    if (count($errors) > 0) {
        return $errors;
    } else {
        return true;
    }
}
Beispiel #15
0
function timeconditions_timegroups_get_times($timegroup, $convert = false)
{
    global $db;
    global $version;
    if ($convert && (!isset($version) || $version == '')) {
        $engineinfo = engine_getinfo();
        $version = $engineinfo['version'];
    }
    if ($convert) {
        $ast_ge_16 = version_compare($version, '1.6', 'ge');
    }
    $sql = "select id, time from timegroups_details where timegroupid = {$timegroup}";
    $results = $db->getAll($sql);
    if (DB::IsError($results)) {
        $results = null;
    }
    foreach ($results as $val) {
        $times = $convert && $ast_ge_16 ? strtr($val[1], '|', ',') : $val[1];
        $tmparray[] = array($val[0], $times);
    }
    return $tmparray;
}
Beispiel #16
0
			<select name="opt#w" tabindex="<?php 
    echo ++$tabindex;
    ?>
">
			<?php 
    $optselect = strpos($options, "w");
    echo '<option value=""' . ($optselect === false ? ' SELECTED' : '') . '>' . _("No") . '</option>';
    echo '<option value="w"' . ($optselect !== false ? ' SELECTED' : '') . '>' . _("Yes") . '</option>';
    ?>
		
			</select>		
		</td>
	</tr>

<?php 
    $engineinfo = engine_getinfo();
    $astver = $engineinfo['version'];
    if (version_compare($astver, '1.4', 'ge')) {
        ?>
	<tr>
		<td><a href="#" class="info"><?php 
        echo _("Talker Optimization:");
        ?>
<span><?php 
        echo _("Turns on talker optimization. With talker optimization, Asterisk treats talkers who\nare not speaking as being muted, meaning that no encoding is done on transmission\nand that received audio that is not registered as talking is omitted, causing no\nbuildup in background noise.");
        ?>
</span></a></td>
		<td>
			<select name="opt#o">
			<?php 
        $optselect = strpos($options, "o");
 /**
  * function generate_module_repo_url
  * short create array of full URLs to get a file from repo
  * use this function to generate an array of URLs for all configured REPOs
  * @author Philippe Lindheimer
  *
  * @pram string
  * @returns string
  */
 function generate_remote_urls($path, $add_options = false)
 {
     global $db;
     global $amp_conf;
     $urls = array();
     $options = array();
     if ($add_options) {
         $firstinstall = false;
         $type = null;
         $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
         $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
         // if not set so this is a first time install
         // get a new hash to account for first time install
         //
         $install_hash = $this->_generate_unique_id();
         $installid = $install_hash['uniqueid'];
         $type = $install_hash['type'];
         if (!isset($result['data']) || trim($result['data']) == "" || $installid != $result['data']) {
             //Yes they do the same thing but thats ok
             if (!isset($result['data']) || trim($result['data']) == "") {
                 $firstinstall = true;
                 $data4sql = $db->escapeSimple($installid);
                 sql("REPLACE INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
                 $data4sql = $db->escapeSimple($type);
                 sql("REPLACE INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
             } else {
                 $install_hash = $this->_regenerate_unique_id();
                 $installid = $install_hash['uniqueid'];
                 $type = $install_hash['type'];
             }
         } else {
             $installid = $result['data'];
             $sql = "SELECT * FROM module_xml WHERE id = 'type'";
             $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
             if (isset($result['data']) && trim($result['data']) != "") {
                 $type = $result['data'];
             }
         }
         // Now we have the id and know if this is a firstime install so we can get the announcement
         //
         $options['installid'] = $installid;
         if (trim($type) != "") {
             $options['type'] = trim($type);
         }
         if ($firstinstall) {
             $options['firstinstall'] = 'yes';
         }
         //Now that we do everything in post format send back module versions
         $modules_local = $this->getinfo(false, false, true);
         foreach ($modules_local as $m => $mod) {
             if ($mod['status'] != MODULE_STATUS_BROKEN) {
                 $options['modules'][$m]['version'] = $mod['version'];
                 $options['modules'][$m]['status'] = $mod['status'];
                 $options['modules'][$m]['rawname'] = $mod['rawname'];
                 $options['modules'][$m]['license'] = !empty($mod['license']) ? $mod['license'] : "unknown";
             }
         }
         // We check specifically for false because evenif blank it means the file
         // was there so we want module.xml to do appropriate actions
         $brandid = $this->_brandid();
         if ($brandid !== false) {
             $options['brandid'] = $brandid;
         }
         $deploymentid = $this->_deploymentid();
         if ($deploymentid !== false) {
             $options['deploymentid'] = $deploymentid;
         }
         $engver = engine_getinfo();
         if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
             $options['astver'] = $engver['version'];
         } else {
             $options['astver'] = $engver['raw'];
         }
         $options['phpver'] = phpversion();
         $distro_info = $this->_distro_id();
         $options['distro'] = $distro_info['pbx_type'];
         $options['distrover'] = $distro_info['pbx_version'];
         $options['pbxver'] = getversion();
         if (function_exists('core_users_list')) {
             $options['ucount'] = count(core_users_list());
         }
         // Other modules may need to add 'get' paramters to the call to the repo. Check and add them
         // here if we are adding paramters. The module should return an array of key/value pairs each of which
         // is to be appended to the GET parameters. The variable name will be prepended with the module name
         // when sent.
         //
         $repo_params = array();
         foreach (mod_func_iterator('module_repo_parameters_callback', $path) as $mod => $res) {
             if (is_array($res)) {
                 foreach ($res as $p => $v) {
                     $options[$mod . '_' . $p] = $v;
                 }
             }
         }
     }
     $repos = explode(',', $amp_conf['MODULE_REPO']);
     return array('mirrors' => $repos, 'path' => $path, 'options' => $options, 'query' => http_build_query($options));
 }
Beispiel #18
0
function fax_hook_core($viewing_itemid, $target_menuid)
{
    //hmm, not sure why engine_getinfo() isnt being called here?! should probobly read: $info=engine_getinfo();
    //this is what serves fax code to inbound routing
    $tabindex = null;
    $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : '';
    $cidnum = isset($_REQUEST['cidnum']) ? $_REQUEST['cidnum'] : '';
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : '';
    //if were editing, get save parms. Get parms
    if ($type != 'setup') {
        if (!$extension && !$cidnum) {
            //set $extension,$cidnum if we dont already have them
            $opts = explode('/', $extdisplay);
            $extension = $opts['0'];
            $cidnum = $opts['1'];
        }
        $fax = fax_get_incoming($extension, $cidnum);
    } else {
        $fax = null;
    }
    $html = '';
    if ($target_menuid == 'did') {
        $fax_dahdi_faxdetect = fax_dahdi_faxdetect();
        $fax_sip_faxdetect = fax_sip_faxdetect();
        $dahdi = ast_with_dahdi() ? _('Dahdi') : _('Zaptel');
        $fax_detect = fax_detect();
        $fax_settings = fax_get_settings();
        //ensure that we are using destination for both fax detect and the regular calls
        $html = '<script type="text/javascript">$(document).ready(function(){
		$("input[name=Submit]").click(function(){
			if($("input[name=faxenabled]:checked").val()=="true" && !$("[name=gotoFAX]").val()){//ensure the user selected a fax destination
			alert(' . _('"You have selected Fax Detection on this route. Please select a valid destination to route calls detected as faxes to."') . ');return false; }	}) });</script>';
        $html .= '<tr><td colspan="2"><h5>';
        $html .= _('Fax Detect');
        $html .= '<hr></h5></td></tr>';
        $html .= '<tr>';
        $html .= '<td><a href="#" class="info">';
        $html .= _("Detect Faxes") . '<span>' . _("Attempt to detect faxes on this DID.") . "<ul><li>" . _("No: No attempts are made to auto-determine the call type; all calls sent to destination below. Use this option if this DID is used exclusively for voice OR fax.") . "</li><li>" . _("Yes: try to auto determine the type of call; route to the fax destination if call is a fax, otherwise send to regular destination. Use this option if you receive both voice and fax calls on this line") . "</li>";
        if ($fax_settings['legacy_mode'] == 'yes' || $fax['legacy_email'] !== null) {
            $html .= '<li>' . _('Legacy: Same as YES, only you can enter an email address as the destination. This option is ONLY for supporting migrated legacy fax routes. You should upgrade this route by choosing YES, and selecting a valid destination!') . '</li>';
        }
        $html .= '</ul></span></a>:</td>';
        //dont allow detection to be set if we have no valid detection types
        if (!$fax_dahdi_faxdetect && !$fax_sip_faxdetect && !$fax_detect['nvfax']) {
            $js = "if (\$(this).val() == 'true'){alert('" . _('No fax detection methods found or no valid license. Faxing cannot be enabled.') . "');return false;}";
            $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED />No';
            $html .= '<input type="radio" name="faxenabled" value="true"  onclick="' . $js . '"/>Yes</td></tr>';
            $html .= '</table><table>';
        } else {
            /* 
             * show detection options
             *
             * js to show/hide the detection settings. Second slide is always in a 
             * callback so that we ait for the fits animation to complete before 
             * playing the second
             */
            if ($fax['legacy_email'] === null && $fax_settings['legacy_mode'] == 'no') {
                $jsno = "\$('.faxdetect').slideUp();";
                $jsyes = "\$('.faxdetect').slideDown();";
            } else {
                $jsno = "\$('.faxdetect').slideUp();\$('.legacyemail').slideUp();";
                $jsyes = "\$('.legacyemail').slideUp('400',function(){\n\t\t\t\t\t\t\t\$('.faxdetect').slideDown()\n\t\t\t\t\t\t});";
                $jslegacy = "\$('.faxdest27').slideUp('400',function(){ \n\t\t\t\t\t\t\t\t\$('.faxdetect, .legacyemail').not(\$('.faxdest27')).slideDown();\n\t\t\t\t\t\t});";
            }
            $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED onclick="' . $jsno . '"/>No';
            $html .= '<input type="radio" name="faxenabled" value="true" ' . ($fax ? 'CHECKED' : '') . ' onclick="' . $jsyes . '"/>Yes';
            if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
                $html .= '<input type="radio" name="faxenabled" value="legacy"' . ($fax['legacy_email'] !== null ? ' CHECKED ' : '') . 'onclick="' . $jslegacy . '"/>Legacy';
            }
            $html .= '</td></tr>';
            $html .= '</table>';
        }
        //fax detection+destinations, hidden if there is fax is disabled
        $html .= '<table class=faxdetect ' . ($fax ? '' : 'style="display: none;"') . '>';
        $info = engine_getinfo();
        $html .= '<tr><td width="156px"><a href="#" class="info">' . _('Fax Detection type') . '<span>' . _("Type of fax detection to use.") . "<ul><li>" . $dahdi . ": " . _("use ") . $dahdi . _(" fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ") . $dahdi . ".conf</li><li>" . _("Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files") . "</li><li>" . _("NV Fax Detect: Use NV Fax Detection; Requires NV Fax Detect to be installed and recognized by asterisk") . "</li></ul>" . '.</span></a>:</td>';
        $html .= '<td><select name="faxdetection" tabindex="' . ++$tabindex . '">';
        //$html.='<option value="Auto"'.($faxdetection == 'auto' ? 'SELECTED' : '').'>'. _("Auto").'</option>';<li>Auto: allow the system to chose the best fax detection method</li>
        $html .= '<option value="dahdi" ' . ($fax['detection'] == 'dahdi' ? 'SELECTED' : '') . ' ' . ($fax_dahdi_faxdetect ? '' : 'disabled') . '>' . $dahdi . '</option>';
        $html .= '<option value="nvfax"' . ($fax['detection'] == 'nvfax' ? 'SELECTED' : '') . ($fax_detect['nvfax'] ? '' : 'disabled') . '>' . _("NVFax") . '</option>';
        $html .= '<option value="sip" ' . ($fax['detection'] == 'sip' ? 'SELECTED' : '') . ' ' . ($info['version'] >= "1.6.2" && $fax_sip_faxdetect ? '' : 'disabled') . '>' . _("Sip") . '</option>';
        $html .= '</select></td></tr>';
        $html .= '<tr><td><a href="#" class="info">' . _("Fax Detection Time") . '<span>' . _('How long to wait and try to detect fax. Please note that callers to a ' . $dahdi . ' channel will hear ringing for this amount of time (i.e. the system wont "answer" the call, it will just play ringing)') . '.</span></a>:</td>';
        $html .= '<td><select name="faxdetectionwait" tabindex="' . ++$tabindex . '">';
        if (!$fax['detectionwait']) {
            $fax['detectionwait'] = 4;
        }
        //default wait time is 4 second
        for ($i = 2; $i < 11; $i++) {
            $html .= '<option value="' . $i . '" ' . ($fax['detectionwait'] == $i ? 'SELECTED' : '') . '>' . $i . '</option>';
        }
        $html .= '</select></td></tr>';
        if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
            $html .= '</table>';
            $html .= '<table class="legacyemail"' . ($fax['legacy_email'] === null ? ' style="display: none;"' : '') . '>';
            $html .= '<tr ><td><a href="#" class="info">' . _("Fax Email Destination") . '<span>' . _('Address to email faxes to on fax detection.<br />PLEASE NOTE: In this version of FreePBX, you can now set the fax destination from a list of destinations. Extensions/Users can be fax enabled in the user/extension screen and set an email address there. This will create a new destination type that can be selected. To upgrade this option to the full destination list, select YES to Detect Faxes and select a destination. After clicking submit, this route will be upgraded. This Legacy option will no longer be available after the change, it is provided to handle legacy migrations from previous versions of FreePBX only.') . '.</span></a>:</td>';
            $html .= '<td><input name="legacy_email" value="' . $fax['legacy_email'] . '"></td></tr>';
            $html .= '</table>';
            $html .= '<table class="faxdest27 faxdetect" style="display: none" >';
        }
        $html .= '<tr class="faxdest"><td><a href="#" class="info">' . _("Fax Destination") . '<span>' . _('Where to send the call if we detect that its a fax') . '.</span></a>:</td>';
        $html .= '<td>';
        $html .= $fax_detect ? drawselects(isset($fax['destination']) ? $fax['destination'] : null, 'FAX', false, false) : '';
        $html .= '</td></tr></table>';
        $html .= '<table>';
    }
    return $html;
}