function core_did_create_update($did_vars) { $did_create['extension'] = isset($did_vars['extension']) ? $did_vars['extension'] : ''; $did_create['cidnum'] = isset($did_vars['cidnum']) ? $did_vars['cidnum'] : ''; if (count(core_did_get($did_create['extension'], $did_create['$cidnum']))) { return core_did_edit_properties($did_vars); //already exists so just edit properties } else { $did_create['faxexten'] = isset($did_vars['faxexten']) ? $did_vars['faxexten'] : ''; $did_create['faxemail'] = isset($did_vars['faxemail']) ? $did_vars['faxemail'] : ''; $did_create['answer'] = isset($did_vars['answer']) ? $did_vars['answer'] : '0'; $did_create['wait'] = isset($did_vars['wait']) ? $did_vars['wait'] : '0'; $did_create['privacyman'] = isset($did_vars['privacyman']) ? $did_vars['privacyman'] : ''; $did_create['alertinfo'] = isset($did_vars['alertinfo']) ? $did_vars['alertinfo'] : ''; $did_create['ringing'] = isset($did_vars['ringing']) ? $did_vars['ringing'] : ''; $did_create['mohclass'] = isset($did_vars['mohclass']) ? $did_vars['mohclass'] : 'default'; $did_create['description'] = isset($did_vars['description']) ? $did_vars['description'] : ''; $did_create['grppre'] = isset($did_vars['grppre']) ? $did_vars['grppre'] : ''; $did_create['delay_answer'] = isset($did_vars['delay_answer']) ? $did_vars['delay_answer'] : '0'; $did_create['pricid'] = isset($did_vars['pricid']) ? $did_vars['pricid'] : ''; $did_create['channel'] = isset($did_vars['channel']) ? $did_vars['channel'] : ''; // pre 2.4 $did_dest = isset($did_vars['destination']) ? $did_vars['destination'] : ''; return core_did_add($did_vars, $did_dest); } }
$desc = empty($inroute['description']) ? "" : htmlspecialchars($inroute['description']) . "<br />"; echo "\t<li><a " . ($extdisplay == $inroute['extension'] . "/" . $inroute['cidnum'] ? 'class="current"' : '') . " href=\"config.php?display={$dispnum}&didfilter={$didfilter}&rnavsort={$rnavsort}&extdisplay=" . urlencode($inroute['extension']) . "/" . urlencode($inroute['cidnum']) . "\">{$desc} {$displaydid} / {$displaycid} </a></li>\n"; } } ?> </ul> </div> <?php if ($action == 'delIncoming') { echo '<br><h3>Route ' . $extdisplay . ' ' . _("deleted") . '!</h3><br><br><br><br><br><br><br><br>'; } else { if ($extdisplay) { //create variables for the selected route's settings $extarray = explode('/', $extdisplay, 2); $ininfo = core_did_get($extarray[0], $extarray[1]); if (is_array($ininfo) && !empty($ininfo)) { extract($ininfo); $description = htmlspecialchars($description); $extension = htmlspecialchars($extension); $cidnum = htmlspecialchars($cidnum); $alertinfo = htmlspecialchars($alertinfo); $grppre = htmlspecialchars($grppre); $delete_url = true; ?> <h2><?php echo _("Route"); ?> : <?php echo !empty($description) ? $description : $extdisplay; ?>
function sipstation_get_config($account_key, $online = true, $filter_sections = array()) { global $db; global $ast_codec_hash; global $codec_array; if (!empty($account_key)) { $json_array = array(); $xml_parser = sipstation_get_settings($account_key, $online); if (!empty($xml_parser->data)) { foreach ($xml_parser->data['xml'] as $key => $value) { switch ($key) { case 'xml_version': case 'query_status': case 'query_status_message': case 'sip_username': case 'sip_password': case 'num_trunks': case 'monthly_cost': case 'cid_format': case 'nat_troubleshooting': if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) { continue; } $json_array[$key] = trim("{$value}"); break; case 'gateways': case 'e911_address': case 'registered_status': if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) { continue; } foreach ($value as $key2 => $value2) { if (is_array($value2)) { foreach ($value2 as $gw => $value3) { $json_array[$key][$key2][$gw] = $value3 ? trim($value3) : ''; } } else { $json_array[$key][$key2] = $value2 ? trim($value2) : ''; } } if ($key == 'registered_status') { foreach ($value as $key2 => $value2) { if (is_array($value2)) { if ($value2['contact_ip'] == $value2['network_ip']) { $json_array[$key][$key2]['ips_match'] = 'yes'; } else { $json_array[$key][$key2]['ips_match'] = is_private_ip($value2['contact_ip']) ? 'private' : 'no'; } } else { if ($key2 != 'registered') { continue; } if ($json_array[$key]['contact_ip'] == $json_array[$key]['network_ip'] && $value2 == 'yes') { $json_array[$key]['ips_match'] = 'yes'; } else { $json_array[$key]['ips_match'] = 'no'; $json_array[$key]['ips_match'] = is_private_ip($json_array[$key]['contact_ip']) ? 'private' : 'no'; } } } } break; case 'dids': if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) { continue; } if (!empty($value['did']) && !is_array($value['did'])) { $tmp = $value['did']; unset($value['did']); $value['did'][] = $tmp; $single = true; } else { $single = false; } $idx = 0; foreach ($value['did'] as $did) { $path = $single ? "/xml/dids/did" : "/xml/dids/did/{$idx}"; $idx++; $failover = $xml_parser->attributes[$path]['failover']; $did = trim($did); $exten = core_did_get($did); if (empty($exten)) { $json_array[$key][$did] = array('destination' => 'blank', 'desc' => _("Not Set"), 'description' => '', 'failover' => "{$failover}"); } else { $dest_results = framework_identify_destinations($exten['destination']); if (is_array($dest_results[$exten['destination']])) { /* This is really bad but the calls to core_users get are so heavy and core_users_list don't give details that we will do this for now and deal with it later. */ $user_cid_hash = array(); $sql = "SELECT `extension`, `outboundcid` FROM `users`"; $user_cids = $db->getAll($sql, DB_FETCHMODE_ASSOC); if (DB::IsError($user_cids)) { freepbx_debug("Failed trying to get user cids"); freepbx_debug($user_cids->getMessage()); $user_cids = array(); } foreach ($user_cids as $item) { $user_cid_hash[$item['extension']] = $item['outboundcid']; } foreach ($dest_results[$exten['destination']] as $mod => $info) { //$destination = (substr($exten['destination'],0,15) == 'from-did-direct' ? $exten['destination'] : 'assigned'); $is_checked = 0; if (substr($exten['destination'], 0, 15) == 'from-did-direct') { $destination = $exten['destination']; $exten_arr = explode(',', $destination); if (isset($exten_arr[1]) && isset($user_cid_hash[$exten_arr[1]])) { $is_checked = preg_match('/^\\s*[<]?(' . $did . ')[>]?\\s*$|^\\s*"[^"]*"\\s*<(' . $did . ')>\\s*$/', $user_cid_hash[$exten_arr[1]]); } else { $is_checked = 0; } } else { $destination = 'assigned'; } $json_array[$key][$did] = array('destination' => $destination, 'desc' => $info['description'], 'description' => $exten['description'], 'outboundcid' => $is_checked, 'failover' => "{$failover}"); break; } } else { $json_array[$key][$did] = array('destination' => 'blank', 'desc' => _("Not Set"), 'description' => '', 'failover' => "{$failover}"); } } } break; case 'asterisk_settings': if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) { continue; } $json_array['asterisk_settings']['peer'] = $value['peer']['setting']; break; case 'codecs': if (!empty($filter_sections) && (!isset($filter_sections[$key]) || !$filter_sections[$key])) { continue; } $codec_array = $value['codec']; /* filter the Asterisk codec hash to only those that we are told are supported */ $ast_codec_hash = array_filter(array_map('sipstation_supported_codecs', $ast_codec_hash)); break; default: } $json_array['status'] = 'success'; } } else { $json_array['status'] = 'noserver'; } } else { $json_array['status'] = 'nokey'; } return $json_array; }
function core_users_edit($extension, $vars) { global $db; global $amp_conf; global $astman; //I we are editing, we need to remember existing user<->device mapping, so we can delete and re-add if ($astman) { $ud = $astman->database_get("AMPUSER", $extension . "/device"); $current_vmcontext = $astman->database_get("AMPUSER", $extension . "/voicemail"); $new_vmcontext = isset($vars['vmcontext']) ? $vars['vmcontext'] : 'novm'; $vars['device'] = $ud; } else { die_freepbx("Cannot connect to Asterisk Manager with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"]); } // clean and check the did to make sure it is not being used by another extension or in did routing // $newdid_name = isset($newdid_name) ? $db->escapeSimple($newdid_name) : ''; $newdid = isset($vars['newdid']) ? $vars['newdid'] : ''; $newdid = preg_replace("/[^0-9._XxNnZz\\[\\]\\-\\+]/", "", trim($newdid)); $newdidcid = isset($vars['newdidcid']) ? trim($vars['newdidcid']) : ''; if (!preg_match('/^priv|^block|^unknown|^restrict|^unavail|^anonym/', strtolower($newdidcid))) { $newdidcid = preg_replace("/[^0-9._XxNnZz\\[\\]\\-\\+]/", "", $newdidcid); } // Well more ugliness since the javascripts are already in here if ($newdid != '' || $newdidcid != '') { $existing = core_did_get($newdid, $newdidcid); if (!empty($existing)) { echo "<script>javascript:alert('" . sprintf(_("A route with this DID/CID: %s/%s already exists"), $existing['extension'], $existing['cidnum']) . "')</script>"; return false; } } //delete and re-add if (core_sipname_check($vars['sipname'], $extension)) { core_users_del($extension, true); core_users_add($vars, true); // If the vmcontext has changed, we need to change all the links. In extension mode, the link // to the current fixed device will get changed, but none others will // if ($current_vmcontext != $new_vmcontext) { $user_devices = explode('&', $ud); foreach ($user_devices as $user_device) { exec("rm -f /var/spool/asterisk/voicemail/device/" . $user_device); if ($new_context != 'novm') { exec("/bin/ln -s /var/spool/asterisk/voicemail/" . $new_vmcontext . "/" . $extension . "/ /var/spool/asterisk/voicemail/device/" . $user_device); } } } } return true; }