function get_user_config($user, $menu_source, $menu_mode) { global $language; # Retrieve phone data $update = 0; $header = Aastra_decode_HTTP_header(); $header['model'] = strtolower($header['model']); $is_softkeys_supported = Aastra_is_softkeys_supported(); # Read all menu $all = Aastra_readINIfile($menu_source . '.menu', '#', '='); # Get user config if ($is_softkeys_supported and $menu_mode == 'dynamic') { $config = Aastra_get_user_context($user, 'mymenu' . '_' . $menu_source); } else { $config = NULL; } # File does not exist if ($config == NULL) { unset($all['RESERVED']); foreach ($all as $key => $value) { if ($value[$header['model']] == 'no') { unset($all[$key]); } else { $all[$key]['title'] = Aastra_get_label($all[$key]['title'], $language); } } Aastra_natsort2d($all, 'title'); foreach ($all as $key => $value) { $config['menu'][] = $key; } if ($is_softkeys_supported and $menu_mode == 'dynamic') { $update = 1; } } else { # Read config file foreach ($config['menu'] as $key => $value) { if ($all[$value] == NULL or $all[$value][$header['model']] == 'no') { unset($config['menu'][$key]); $update = 1; } } } # Read final file if ($update == 1) { Aastra_save_user_context($user, 'mymenu' . '_' . $menu_source, $config); unset($config); $config = Aastra_get_user_context($user, 'mymenu' . '_' . $menu_source); } # Return array return $config; }
function AGI_AsteriskManager() { # Load config from freePBX $config = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'asterisk.conf', '#', '='); $this->config['username'] = '******'; $this->config['secret'] = $config['General']['password']; # Add default values to config for uninitialized values if (!isset($this->config['server'])) { $this->config['server'] = 'localhost'; } if (!isset($this->config['port'])) { $this->config['port'] = 5038; } if (!isset($this->config['username'])) { $this->config['username'] = '******'; } if (!isset($this->config['secret'])) { $this->config['secret'] = 'phpagi'; } }
if ($is_style_textmenu) { $chars_supported--; } # To handle non softkey phones if ($nb_softkeys) { $MaxLines = AASTRA_MAXLINES; } else { $MaxLines = AASTRA_MAXLINES - 2; } # Update URI $XML_SERVER .= '?user='******'&source=' . $source . '&back=' . $back; # Get user context $ARRAY_USER = get_user_config($user); # Get csv file location $error = False; $ARRAY_CONFIG = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '='); if ($ARRAY_CONFIG[$source]['location'] != '') { if ($ARRAY_CONFIG[$source]['speed'] == '0') { $SPEED = False; } else { $SPEED = True; } if ($ARRAY_CONFIG[$source]['mode'] == 'list') { $XML_SERVER .= '&mode=list'; $mode = 'list'; if ($action == 'input') { $action = 'lookup'; } } if ($asterisk) { if (!$AA_SPEEDDIAL_STATE) {
$PICTURES_DIR = $array_config['General']['pictures']; } else { $PICTURES_DIR = AASTRA_PATH_CACHE . 'pictures'; } # Rescale image smaller than 150x200 $BLOWUP = False; if ($array_config['General']['blowup'] == '1') { $BLOWUP = True; } # Default image $DEFAULT_IMAGE = array(); if ($array_config['General']['default'] != '') { $DEFAULT_IMAGE = explode(',', $array_config['General']['default']); } # Retrieve local dial plan $array_temp = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '='); # Maybe an intercom $intercom = Aastra_get_intercom_config_Asterisk(); if ($intercom != '') { if (strpos($number_original, $intercom) === 0) { $number_original = str_replace($intercom, '', $number_original); } } # Check original number $found = check_number($number_original); # Check asterisk mapping if (!$found) { $number_transformed = asterisk_mapping($number_original, $array_temp['Dialplan']); if ($number_transformed != $number_original) { $found = check_number($number_transformed); if (!$found) {
# Beginning of the active code ############################################################################# # Retrieve parameters $area = Aastra_getvar_safe('area'); # Trace Aastra_trace_call('area', 'area=' . $area); # Test User Agent Aastra_test_phone_version('1.4.2.', 0); # Get language $language = Aastra_get_language(); # Global compatibility $nb_softkeys = Aastra_number_softkeys_supported(); # Test parameter if ($area) { # Load area codes $array = Aastra_readINIfile('area_codes.txt', '#', '='); $object = new AastraIPPhoneTextScreen(); $object->setDestroyOnExit(); $object->setTitle(sprintf(Aastra_get_label('Area code %s', $language), $area)); if ($array[''][$area] != '') { $object->setText($array[''][$area]); } else { $object->setText(sprintf(Aastra_get_label('Area code %s not found.', $language), $area)); } # Softkeys if ($nb_softkeys > 0) { if ($nb_softkeys < 7) { $object->addSoftkey('4', Aastra_get_label('Back', $language), $XML_SERVER); $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit'); } else { $object->addSoftkey('9', Aastra_get_label('New Lookup', $language), $XML_SERVER);
function Aastra_status_config_Asterisk() { global $language; # Read config file $array = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'status.conf', '#', '='); # Do some cleanup foreach ($array as $key => $value) { if (!is_numeric($key) or $key < 1 or $key > 98) { unset($array[$key]); } else { if ($value['type'] != 'out' or $value['type'] != 'available' or $value['type'] != 'unavailable') { $array[$key]['type'] = 'available'; } } } # Add available $array[AA_PRESENCE_AVAILABLE] = array('label' => Aastra_get_label('Available', $language), 'type' => 'available', 'mnemonic' => '_'); # Add disconnected $array[AA_PRESENCE_DISCONNECTED] = array('label' => Aastra_get_label('Disconnected', $language), 'type' => 'unavailable', 'mnemonic' => Aastra_get_label('D', $language)); # Return array return $array; }
function Aastra_read_HDconfig_file($config) { # Read config file $array = Aastra_readINIfile($config, '#', '='); if ($array == NULL) { $array = array(); } # Process the modules foreach ($array as $key => $value) { $array[$key]['module'] = explode(',', $array[$key]['module']); array_unshift($array[$key]['module'], ''); unset($array[$key]['module'][0]); } # Return configuration return $array; }
$object->setTitle(Aastra_get_label('Information not available', $language)); $object->setText(Aastra_get_label('The information you are looking for is not available at this time. Try again later.', $language)); $output = $object->output(); exit; } } else { Aastra_debug('RSS feed empty, wrong zip code'); $object = new AastraIPPhoneTextScreen(); $object->setTitle(Aastra_get_label('Error', $language)); $object->setText(Aastra_get_label('No data available, please check the ZIP code you entered.', $language)); $output = $object->output(); exit; } } # Display the requested article or list $array_rss = Aastra_readINIfile($file_name, '#', '='); if (empty($index)) { # Reguler phone? if ($nb_softkeys < 7) { # Display list $object = new AastraIPPhoneTextMenu(); $object->setDestroyOnExit(); if (Aastra_is_style_textmenu_supported()) { $object->setStyle('radio'); } # Title $object->setTitle($array_rss[99]['title']); # Display topics foreach ($array_rss as $key => $value) { if ($key != '99') { $object->addEntry($value['title'], $value['uri'] . '&user=' . $user);
break; # Contact details # Contact details case 'zoom': # Retrieve Contact $Contact = getRecord($index); # Any number at all? if ($Contact['phone_home'] == '' and $Contact['phone_work'] != '' and $Contact['phone_mobile'] != '' and $Contact['phone_other'] != '') { # Error Message $object = new AastraIPPhoneTextScreen(); $object->setDestroyOnExit(); $object->setTitle($Contact['last_name'] . ' ' . $Contact['first_name']); $object->setText(Aastra_get_label('No attached phone number.', $language)); } else { # Retrieve configuration $array_config_asterisk = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '='); $conf = $array_config_asterisk['Dialplan']; # Prepare display if ($Contact['phone_home'] != '') { $display['home'] = prepare_number($Contact['phone_home'], 1, $conf); $dial['home'] = prepare_number($Contact['phone_home'], 0, $conf); } if ($Contact['phone_work'] != '') { $display['work'] = prepare_number($Contact['phone_work'], 1, $conf); $dial['work'] = prepare_number($Contact['phone_work'], 0, $conf); } if ($Contact['phone_mobile'] != '') { $display['mobile'] = prepare_number($Contact['phone_mobile'], 1, $conf); $dial['mobile'] = prepare_number($Contact['phone_mobile'], 0, $conf); } if ($Contact['phone_other'] != '') {
$ext_array = Aastra_read_HDconfig_file(AASTRA_PATH_CACHE . 'startup_asterisk.cfg'); # Test MAC address if (isset($ext_array[$extension]['mac'])) { if ($ext_array[$extension]['mac'] == $header['mac']) { # Should not happen so let's clean up Aastra_update_HDconfig_file(AASTRA_PATH_CACHE . 'startup_asterisk.cfg', $extension, NULL); Aastra_delete_mac($header['mac']); } } } # Test MAC address if ($continue) { # If TZ must be asked if ($AA_ASK_TZ) { # Get TZ data $array_ini = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'timezone.conf', '#', '='); $last = intval(count($array_ini['tz']) / $MaxLines); if (count($array_ini['tz']) - $last * $MaxLines != 0) { $last++; } # Create TextMenu $object = new AastraIPPhoneTextMenu(); $object->setDestroyOnExit(); if (Aastra_is_lockin_supported()) { $object->setLockIn(); } if (Aastra_size_display_line() > 16) { $object->setTitle(sprintf(Aastra_get_label('Select Timezone (%d/%d)', $language), $page, $last)); } else { $object->setTitle(sprintf(Aastra_get_label('Timezone (%d/%d)', $language), $page, $last)); }
if (strpos($os, "win") === false) { ini_set('include_path', ini_get('include_path') . ':include:../include:../../../../aastra/include'); } else { ini_set('include_path', ini_get('include_path') . ';include;../include:../../../../aastra/include'); } //error_reporting(E_ERROR | E_PARSE); //includes require_once 'AastraIPPhoneInputScreen.class.php'; require_once 'AastraIPPhoneTextMenu.class.php'; require_once 'AastraIPPhoneTextScreen.class.php'; require_once 'AastraIPPhoneFormattedTextScreen.class.php'; require_once 'AastraCommon.php'; //nedded for $XML_SERVER_PATH require_once 'DB.php'; //database parms $config = Aastra_readINIfile('/etc/amportal.conf', '#', '='); $engine = $config['']['ampdbengine']; $db_host = $config['']['ampdbhost']; $db_database = $config['']['ampdbname']; $db_username = $config['']['ampdbuser']; $db_password = $config['']['ampdbpass']; $db_url = $engine . "://" . $db_username . ":" . $db_password . "@" . $db_host . "/" . $db_database; $db = DB::connect($db_url); //get arguments $user = $_GET['user']; $searchmethod = isset($_GET['searchmethod']) ? $_GET['searchmethod'] : null; //search method : onetouch or t9 $search = isset($_GET['search']) ? $_GET['search'] : null; //name of number to search for $searchterm = isset($_GET['searchterm']) ? $_GET['searchterm'] : null; // "" ""
function query_ldap($lookup, $firstn, $lastn, $source) { global $LANGUAGE; # Retrieve LDAP basic configuration $system = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '='); $LDAP_SERVER = $system[$source]['hostname']; $LDAP_PORT = $system[$source]['port']; $LDAP_ROOT_DN = $system[$source]['basedn']; $LDAP_USERDOMAIN = $system[$source]['userdomain']; $LDAP_USERNAME = $system[$source]['username']; $LDAP_PASSWORD = $system[$source]['userpassword']; ########################################### Advanced LDAP Configuration ######################################### $LDAP_SIZELIMIT = 400; // limits the number of entries fetched. 0 means no limit. $LDAP_TIMELIMIT = 5; // max number of seconds spent on the search. 0 means no limit. # What additional attributes are retrieved from LDAP. Possible attributes: "title", "department", "company" #$LDAP_ADDITIONAL_ATTRIBUTES = array("title", "department", "company"); # LDAP attribute mapping. Put empty string if attribute does not exist in LDAP. $LDAP_PHONE_ATTRIBUTE = 'telephonenumber'; // name of the LDAP attribute that contains the office phone number $LDAP_MOBILE_ATTRIBUTE = 'mobile'; // name of the LDAP attribute that contains the mobile (cell) phone number. "mobile" or "mobiletelephonenumber". $LDAP_HOMEPHONE_ATTRIBUTE = 'homephone'; // name of the LDAP attribute that contains the home phone number, typically "homephone" ########################################### Advanced LDAP Configuration ######################################### # Prepare search filter if ($lookup != '') { $searchfilter = '(|(sn=' . $lookup . '*)(givenName=' . $lookup . '*))'; } else { if ($firstn != '' and $lastn != '') { $searchfilter = '(&(sn=' . $lastn . '*)(givenName=' . $firstn . '*))'; } else { if ($firstn != '') { $searchfilter = '(givenName=' . $firstn . '*)'; } else { $searchfilter = '(sn=' . $lastn . '*)'; } } } # Refine searchfilter in order to exclude "contacts" #$searchfilter="(&".$searchfilter."(!(objectclass=contact)))"; # Prepare LDAP attributes to look for $ldap_attribues = array('cn', 'sn', 'givenname'); array_push($ldap_attribues, $LDAP_PHONE_ATTRIBUTE, $LDAP_MOBILE_ATTRIBUTE, $LDAP_HOMEPHONE_ATTRIBUTE); # Complete with optional attributes if (is_array($LDAP_ADDITIONAL_ATTRIBUTES)) { $ldap_attribues = array_merge($ldap_attribues, $LDAP_ADDITIONAL_ATTRIBUTES); } # Connect to LDAP SERVER $ds = ldap_connect($LDAP_SERVER, $LDAP_PORT); # Connected to the LDAPserver if ($ds) { # Bind type if (trim($LDAP_USERNAME) != '') { # bind with credentials if ($LDAP_USERDOMAIN != '') { $username = $LDAP_USERDOMAIN . chr(92) . $LDAP_USERNAME; } else { $username = $LDAP_USERNAME; } $lb = ldap_bind($ds, $username, $LDAP_PASSWORD); } else { # anonymous bind $lb = ldap_bind($ds); } # Bind successful if ($lb) { # Launch the search $sr = ldap_search($ds, $LDAP_ROOT_DN, $searchfilter, $ldap_attribues, 0, $LDAP_SIZELIMIT, $LDAP_TIMELIMIT); # Search is successful if ($sr) { # Retrieve dialplan configuration $dialplan = $system['Dialplan']; # Convert comma/semicolon/whitespace separated list into array $dialplan['local'] = preg_split('/,|;|\\s/', $system['Dialplan']['local']); # Retrieve results $entries = ldap_get_entries($ds, $sr); $j = 0; # Process each answer for ($i = 0; $i < $entries['count']; $i++) { # Retrieve phone numbers $office = $entries[$i][$LDAP_PHONE_ATTRIBUTE][0]; $mobile = $entries[$i][$LDAP_MOBILE_ATTRIBUTE][0]; $home = $entries[$i][$LDAP_HOMEPHONE_ATTRIBUTE][0]; # Keep entries that contain at least one phone number (office, mobile, home). Number must have at least one digit. if (preg_match("/[0-9]+/", $office) or preg_match("/[0-9]+/", $mobile) or preg_match("/[0-9]+/", $home)) { $result_array[$j]['office'] = $office; $result_array[$j]['officeDigits'] = prepare_number($office, $dialplan); $result_array[$j]['mobile'] = $mobile; $result_array[$j]['mobileDigits'] = prepare_number($mobile, $dialplan); $result_array[$j]['home'] = $home; $result_array[$j]['homeDigits'] = prepare_number($home, $dialplan); if (empty($entries[$i]["sn"][0])) { $result_array[$j]['name'] = $entries[$i]["cn"][0]; } else { $result_array[$j]['name'] = $entries[$i]["sn"][0]; $result_array[$j]['firstname'] = $entries[$i]["givenname"][0]; } $result_array[$j]['title'] = $entries[$i]["title"][0]; $result_array[$j]['department'] = $entries[$i]["department"][0]; $result_array[$j]['company'] = $entries[$i]["company"][0]; $j++; } } # Close LDAP connection ldap_close($ds); # Return results return empty($result_array) ? NULL : $result_array; } else { # Close LDAP connection ldap_close($ds); # Display error message display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot send query to LDAP Server. Please contact your administrator.', $LANGUAGE)); exit; } } else { # Close LDAP connection ldap_close($ds); # Display error message display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot bind to LDAP Server. Please contact your administrator.', $LANGUAGE)); exit; } } else { # Display error message display_message(Aastra_get_label('Server error', $LANGUAGE), Aastra_get_label('Cannot connect to LDAP Server. Please contact your administrator.', $LANGUAGE)); exit; } }
function filter_queues($queues, $user) { # Retrieve real user $user = Aastra_get_userdevice_Asterisk($user); # Read config file $array_config = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'queues.conf', '#', '='); foreach ($queues as $key => $value) { $allowed = False; if (array_key_exists($value['Queue'], $array_config)) { if ($array_config[$value['Queue']]['allowed'] == 'ALL') { $allowed = True; } else { $temp = explode(',', $array_config[$value['Queue']]['allowed']); if (in_array($user, $temp)) { $allowed = True; } } } else { if (array_key_exists('ALL', $array_config)) { if ($array_config['ALL']['allowed'] == 'ALL') { $allowed = True; } else { $temp = explode(',', $array_config['ALL']['allowed']); if (in_array($user, $temp)) { $allowed = True; } } } } if (!$allowed) { unset($queues[$key]); } } # Return updated queues return $queues; }
function update_user_config($user, $array_key, $header, $selection1, $selection2 = NULL, $type = 'key') { # No special key yet $special = False; # Retrieve current configuration $array_temp = Aastra_readINIfile(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', '#', ':'); $array_user = $array_temp['']; # Prepare process of both keys if ($selection2) { $array_selection = array($selection1, $selection2); } else { $array_selection = array($selection1); } # Process both changes foreach ($array_selection as $selection) { # Key update if ($type == 'key') { # Update selection if ($array_key[$selection]['type'] != '' and $array_key[$selection]['type'] != 'empty') { # XML? if ($array_key[$selection]['type'] == 'xml') { $special = True; } # Update configuration (MAC.cfg) $array_user[$selection . ' type'] = $array_key[$selection]['type']; $array_user[$selection . ' value'] = $array_key[$selection]['value']; $array_user[$selection . ' label'] = $array_key[$selection]['label']; if ($array_key[$selection]['states'] != '') { $array_user[$selection . ' states'] = $array_key[$selection]['states']; } else { unset($array_user[$selection . ' states']); } if ($array_key[$selection]['locked'] != '') { $array_user[$selection . ' locked'] = $array_key[$selection]['locked']; } else { unset($array_user[$selection . ' locked']); } # Update configuration (dynamic) $array_update[] = array('param' => $selection . ' type', 'value' => $array_user[$selection . ' type']); $array_update[] = array('param' => $selection . ' value', 'value' => $array_user[$selection . ' value']); $array_update[] = array('param' => $selection . ' label', 'value' => $array_user[$selection . ' label']); if ($array_key[$selection]['states'] != '') { $array_update[] = array('param' => $selection . ' states', 'value' => $array_user[$selection . ' states']); } if ($array_key[$selection]['locked'] != '') { $array_update[] = array('param' => $selection . ' locked', 'value' => $array_user[$selection . ' locked']); } } else { # Maybe we changed a special key if ($array_user[$selection . ' type'] == 'xml') { $special = True; } # Key is not programmed but maybe locked if ($array_key[$selection]['type'] == '') { unset($array_user[$selection . ' type']); } else { $array_user[$selection . ' type'] = 'empty'; } if ($array_key[$selection]['locked'] == '1') { $array_user[$selection . ' locked'] = $array_key[$selection]['locked']; } else { unset($array_user[$selection . ' locked']); } unset($array_user[$selection . ' value']); unset($array_user[$selection . ' label']); unset($array_user[$selection . ' states']); # Update array $array_update[] = array('param' => $selection . ' type', 'value' => $array_user[$selection . ' type']); $array_update[] = array('param' => $selection . ' value', 'value' => ''); $array_update[] = array('param' => $selection . ' label', 'value' => ''); $array_update[] = array('param' => $selection . ' locked', 'value' => $array_user[$selection . ' locked']); $array_update[] = array('param' => $selection . ' states', 'value' => ''); } } else { # Update parameter $array_user[$selection] = $array_key[$selection]['value']; $array_update[] = array('param' => $selection, 'value' => $array_key[$selection]['value']); } } # Update MAC.cfg $write = @fopen(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', 'w'); if ($write) { # Dump the config file foreach ($array_user as $key => $value) { fputs($write, $key . ': ' . $value . "\n"); } # Close the MAC.cfg file fclose($write); # Update the user keys $keys = Aastra_get_user_context($user, 'keys'); foreach ($array_user as $key => $value) { if (stristr($key, 'key')) { $array_keys[$key] = $value; } if (stristr($key, 'expmod') and stristr($key, 'page')) { $array_keys[$key] = $value; } } $keys[$header['model']] = $array_keys; Aastra_save_user_context($user, 'keys', $keys); } # Update special keys if ($special) { $array_special = update_special_keys($user, $array_user); } # Save Configuration update if (!$special) { $array_selection = NULL; $array_special_keys = NULL; } $array_session = array('keys' => base64_encode(serialize(array($array_selection, $array_update, $array_special)))); Aastra_save_session('key', '120', $array_session); # Return the need for notify return $special; }