Exemplo n.º 1
0
                $object->addEntry(Aastra_get_label('Confirm Calls: Yes', $language), $XML_SERVER . '&action=change_grpconf');
            } else {
                $object->addEntry(Aastra_get_label('Confirm Calls: No', $language), $XML_SERVER . '&action=change_grpconf');
            }
            $object->addEntry(sprintf(Aastra_get_label('%s phone number(s)', $language), count($array_fm['grplist'])), $XML_SERVER . '&action=change_grplist');
            # Softkeys
            if ($nb_softkeys) {
                if ($nb_softkeys == 6) {
                    $object->addSoftkey('1', Aastra_get_label('Change', $language), 'SoftKey:Select');
                    $object->addSoftkey('2', Aastra_get_label('My Numbers', $language), $XML_SERVER . '&action=info');
                    $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                } else {
                    $object->addSoftkey('1', Aastra_get_label('My Numbers', $language), $XML_SERVER . '&action=info');
                    $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
                }
            }
        }
        break;
        # Default
    # Default
    default:
        # Debug
        Aastra_debug('Unexpected action:' . $action);
        require_once 'AastraIPPhoneExecute.class.php';
        $object = new AastraIPPhoneExecute();
        $object->addEntry('');
        break;
}
# Display answer
$object->output();
exit;
Exemplo n.º 2
0
            # Change action
            $action = 'del_message';
            $orig_d = 'playing';
            break;
            # Stop
        # Stop
        case 'end':
            $action = $orig_p;
            if ($orig_p == 'list') {
                $last_msg = $msg;
            }
            break;
            # Others
        # Others
        default:
            Aastra_debug('Unexpected cause for play_exit, cause=' . $cause);
            break;
    }
}
# Process delete
if ($action == 'del_message') {
    # Retrieve messages
    if (!isset($messages)) {
        $messages = Aastra_get_vmessages_Asterisk($user);
    }
    # Retrieve context
    $message = message_context($messages, $msg);
    # Message found
    if ($message['found']) {
        # Delete message
        sscanf($msg, '%4s-%s', $msg_id, $msg_folder);
Exemplo n.º 3
0
function Aastra_check_signature_Asterisk($user)
{
    global $AA_FREEPBX_MODE;
    global $AA_PHONE_SIGNATURE;
    # Return if device/user mode
    if ($AA_FREEPBX_MODE == '2' or !$AA_PHONE_SIGNATURE) {
        return;
    }
    # Retrieve stored signature
    $signature = Aastra_read_signature($user);
    # Maybe a first time
    if ($signature['signature'] == '') {
        # Store the signature
        Aastra_store_signature($user);
    } else {
        # Check signature
        if (Aastra_getphone_fingerprint() != $signature['signature']) {
            # Debug
            Aastra_debug('function=Aastra_check_signature, Phone fingerprint mismatch. Stored=' . $signature['signature'] . ' Current= ' . Aastra_getphone_fingerprint());
            # Display Error
            $output = "<AastraIPPhoneTextScreen>\n";
            $output .= "<Title>Authentication Error</Title>\n";
            $output .= "<Text>You are not authorized to use this application. Please contact your administrator.</Text>\n";
            $output .= "</AastraIPPhoneTextScreen>\n";
            header("Content-Type: text/xml");
            header("Content-Length: " . strlen($output));
            echo $output;
            exit;
        }
    }
}
Exemplo n.º 4
0
function lookup_directory($source, $lookup, $firstn, $lastn, $company, $array_user)
{
    # So far so good
    $return[0] = True;
    # Open and read file
    $handle = @fopen($source, 'r');
    $index = 0;
    $directory = array();
    if ($handle) {
        while ($line = fgets($handle, 200)) {
            $value = explode(",", trim($line, "\n"));
            if ($lookup != '') {
                if (stristr($value[0] . ' ' . $value[1] . ' ' . $value[2], $lookup)) {
                    if ($value[4] != '' or $value[5] != '' or $value[6] != '') {
                        $directory[$index]['first'] = $value[0];
                        $directory[$index]['last'] = $value[1];
                        $directory[$index]['company'] = $value[2];
                        $directory[$index]['title'] = $value[3];
                        $directory[$index]['work'] = $value[4];
                        $directory[$index]['home'] = $value[5];
                        $directory[$index]['mobile'] = $value[6];
                        $index++;
                    }
                }
            } else {
                if ($firstn != '') {
                    $test_firstn = starts_with($value[0], $firstn);
                } else {
                    $test_firstn = True;
                }
                if ($lastn != '') {
                    $test_lastn = starts_with($value[1], $lastn);
                } else {
                    $test_lastn = True;
                }
                if ($company != '') {
                    $test_company = starts_with($value[2], $company);
                } else {
                    $test_company = True;
                }
                if ($test_firstn and $test_lastn and $test_company) {
                    if ($value[4] != '' or $value[5] != '' or $value[6] != '') {
                        $directory[$index] = array('first' => $value[0], 'last' => $value[1], 'company' => $value[2], 'title' => $value[3], 'work' => $value[4], 'home' => $value[5], 'mobile' => $value[6]);
                        if ($company != '') {
                            $directory2[$value[2]][] = array('first' => $value[0], 'last' => $value[1], 'index' => $index);
                        }
                        $index++;
                    }
                }
            }
        }
        fclose($handle);
    } else {
        Aastra_debug('Cannot open contact file ' . $source);
        $return[0] = False;
    }
    # Sort the data
    if ($return[0]) {
        switch ($array_user['sort']) {
            case 'first':
                if ($company != '') {
                    foreach ($directory2 as $key => $value) {
                        $directory2[$key] = Aastra_array_multi_sort($value, 'first', 'asc', TRUE);
                    }
                } else {
                    $directory = Aastra_array_multi_sort($directory, 'first', 'asc', TRUE);
                }
                break;
            case 'last':
                if ($company != '') {
                    foreach ($directory2 as $key => $value) {
                        $directory2[$key] = Aastra_array_multi_sort($value, 'last', 'asc', TRUE);
                    }
                } else {
                    $directory = Aastra_array_multi_sort($directory, 'last', 'asc', TRUE);
                }
                break;
        }
        $return[1] = $directory;
        if ($company != '') {
            $return[2] = $directory2;
        }
    }
    # Return results
    return $return;
}
Exemplo n.º 5
0
function Aastra_xml2array($url, $get_attributes = 1, $priority = 'tag', $encoding = 'iso')
{
    # XML parser must be available
    if (!function_exists('xml_parser_create')) {
        return array();
    }
    $parser = xml_parser_create('');
    # Read content
    ini_set('user_agent', $_SERVER['HTTP_USER_AGENT']);
    if (!($fp = @fopen($url, 'rb'))) {
        Aastra_debug('Failed to open URL=' . $url . ' HTTP header=' . print_r($http_response_header, True));
        return array();
    }
    $contents = '';
    while (!feof($fp)) {
        $contents .= fread($fp, 8192);
    }
    fclose($fp);
    # Set XML decoding parameters
    if ($encoding == 'utf8') {
        xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
    }
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parse_into_struct($parser, trim($contents), $xml_values);
    xml_parser_free($parser);
    if (!$xml_values) {
        return array();
    }
    # Init arrays
    $xml_array = array();
    $parents = array();
    $opened_tags = array();
    $arr = array();
    $current =& $xml_array;
    $repeated_tag_index = array();
    # Browse the values
    foreach ($xml_values as $data) {
        unset($attributes, $value);
        extract($data);
        $result = array();
        $attributes_data = array();
        if (isset($value)) {
            if ($priority == 'tag') {
                $result = $value;
            } else {
                $result['value'] = $value;
            }
        }
        if (isset($attributes) and $get_attributes) {
            foreach ($attributes as $attr => $val) {
                if ($priority == 'tag') {
                    $attributes_data[$attr] = $val;
                } else {
                    $result['attr'][$attr] = $val;
                }
            }
        }
        if ($type == 'open') {
            $parent[$level - 1] =& $current;
            if (!is_array($current) or !in_array($tag, array_keys($current))) {
                $current[$tag] = $result;
                if ($attributes_data) {
                    $current[$tag . '_attr'] = $attributes_data;
                }
                $repeated_tag_index[$tag . '_' . $level] = 1;
                $current =& $current[$tag];
            } else {
                if (isset($current[$tag][0])) {
                    $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
                    $repeated_tag_index[$tag . '_' . $level]++;
                } else {
                    $current[$tag] = array($current[$tag], $result);
                    $repeated_tag_index[$tag . '_' . $level] = 2;
                    if (isset($current[$tag . '_attr'])) {
                        $current[$tag]['0_attr'] = $current[$tag . '_attr'];
                        unset($current[$tag . '_attr']);
                    }
                }
                $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
                $current =& $current[$tag][$last_item_index];
            }
        } elseif ($type == 'complete') {
            if (!isset($current[$tag])) {
                $current[$tag] = $result;
                $repeated_tag_index[$tag . '_' . $level] = 1;
                if ($priority == 'tag' and $attributes_data) {
                    $current[$tag . '_attr'] = $attributes_data;
                }
            } else {
                if (isset($current[$tag][0]) and is_array($current[$tag])) {
                    $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
                    if ($priority == 'tag' and $get_attributes and $attributes_data) {
                        $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
                    }
                    $repeated_tag_index[$tag . '_' . $level]++;
                } else {
                    $current[$tag] = array($current[$tag], $result);
                    $repeated_tag_index[$tag . '_' . $level] = 1;
                    if ($priority == 'tag' and $get_attributes) {
                        if (isset($current[$tag . '_attr'])) {
                            $current[$tag]['0_attr'] = $current[$tag . '_attr'];
                            unset($current[$tag . '_attr']);
                        }
                        if ($attributes_data) {
                            $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
                        }
                    }
                    $repeated_tag_index[$tag . '_' . $level]++;
                }
            }
        } elseif ($type == 'close') {
            $current =& $parent[$level - 1];
        }
    }
    # Return array
    return $xml_array;
}
Exemplo n.º 6
0
                 fputs($handle, 'description=' . $allItems[$y]['description'] . "\n");
                 fputs($handle, 'uri=' . $XML_SERVER . '&zip=' . $zip . '&index=' . ($y + 1) . "\n");
             }
             fputs($handle, "[99]\n");
             fputs($handle, 'title=' . $main . "\n");
             fclose($handle);
         } else {
             Aastra_debug('Can not open ' . $file_name . ' in write mode');
             $object = new AastraIPPhoneTextScreen();
             $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();
Exemplo n.º 7
0
function create_mac($mac, $extension, $username, $secret, $callerid, $model, $profile, $tz_name, $tz_code, $lang_code, $lang)
{
    global $AA_XML_SERVER;
    global $AA_PROXY_SERVER;
    global $AA_REGISTRAR_SERVER;
    global $AA_XMLDIRECTORY;
    global $AA_PRESENCE_STATE;
    global $AA_SPEEDDIAL_STATE;
    global $AA_ASK_TZ;
    global $AA_FREEPBX_MODE;
    global $language;
    # So far so good
    $return = True;
    # Read profile file
    if ($AA_FREEPBX_MODE == '1') {
        $array_profile = Aastra_readCFGfile($profile . '-user.prf', '#', ':');
    } else {
        $array_profile = Aastra_readCFGfile($profile . '-device-nouser.prf', '#', ':');
    }
    if (count($array_profile) == 0) {
        Aastra_debug('Profile file ' . $profile . ' not available');
        return False;
    }
    # Check if model is available
    if (count($array_profile[$model]) == 0) {
        Aastra_debug('Phone model ' . $model . ' not configured in the Profile file (' . $profile . ')');
        return False;
    }
    # Get park configuration
    $park = Aastra_get_park_config_Asterisk();
    # Get polling value
    $polling = Aastra_get_polling_interval_Asterisk();
    # Prepare replace strings
    $search = array('/\\$\\$AA_SIPAUTHNAME_AA\\$\\$/', '/\\$\\$AA_SIPSECRET_AA\\$\\$/', '/\\$\\$AA_SIPUSERNAME_AA\\$\\$/', '/\\$\\$AA_SIPCALLERID_AA\\$\\$/', '/\\$\\$AA_TZ_NAME_AA\\$\\$/', '/\\$\\$AA_TZ_CODE_AA\\$\\$/', '/\\$\\$AA_XML_SERVER_AA\\$\\$/', '/\\$\\$AA_PROXY_SERVER_AA\\$\\$/', '/\\$\\$AA_REGISTRAR_SERVER_AA\\$\\$/', '/\\$\\$AA_PARKINGLOT_AA\\$\\$/', '/\\$\\$AA_XMLDIRECTORY_AA\\$\\$/', '/\\$\\$AA_INTERCOM_CODE_AA\\$\\$/', '/\\$\\$AA_POLLING_INT_AA\\$\\$/');
    $replace = array(quotemeta($username), $secret, quotemeta($extension), quotemeta($callerid), $tz_name, $tz_code, $AA_XML_SERVER, $AA_PROXY_SERVER, $AA_REGISTRAR_SERVER, $park['parkext'], $AA_XMLDIRECTORY, Aastra_get_intercom_config_Asterisk(), $polling);
    # Also use the core piece for device and user
    if ($AA_FREEPBX_MODE == '2') {
        foreach ($array_profile['Core'] as $key => $value) {
            $line = preg_replace($search, $replace, $value);
            if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                $pieces = explode(' ', $key);
                $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
            }
            $array_config[$key] = $line;
        }
    }
    # Use the common piece
    foreach ($array_profile['Common'] as $key => $value) {
        $line = preg_replace($search, $replace, $value);
        if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
            $pieces = explode(' ', $key);
            $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
        }
        $array_config[$key] = $line;
    }
    # Model exists
    if ($array_profile[$model] != NULL) {
        # Check if full template
        if (key_exists('template', $array_profile[$model])) {
            $template = $array_profile[$model]['template'];
        } else {
            $template = $model;
        }
        # Use the template
        foreach ($array_profile[$template] as $key => $value) {
            if ($key != 'template') {
                $line = preg_replace($search, $replace, $value);
                if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                    $pieces = explode(' ', $key);
                    $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
                }
                $array_config[$key] = $line;
            }
        }
        # Use the add-ons
        if ($template != $model) {
            foreach ($array_profile[$model] as $key => $value) {
                if ($key != 'template') {
                    $line = preg_replace($search, $replace, $value);
                    $array_config[$key] = $line;
                }
            }
        }
    }
    # Read user custom configuration
    $array_user = Aastra_readCFGfile('user-custom.prf', '#', ':');
    # User/Device exists
    if ($array_user[$extension] != NULL) {
        # Use the user configuration additions
        foreach ($array_user[$extension] as $key => $value) {
            $line = preg_replace($search, $replace, $value);
            if (stristr($line, '$$AA_KEYPRESS_AA$$')) {
                $pieces = explode(' ', $key);
                $line = preg_replace('/\\$\\$AA_KEYPRESS_AA\\$\\$/', $pieces[0], $line);
            }
            $array_config[$key] = $line;
        }
    }
    # Remove TZ if not needed
    if (!$AA_ASK_TZ) {
        unset($array_config['time zone name']);
        unset($array_config['time zone code']);
    }
    # Process language
    if ($lang_code != '') {
        $array_config['language'] = $lang_code;
        if (Aastra_test_phone_version('2.0.1.', '1') == 0) {
            $array_config['web language'] = $lang_code;
            $array_wl = array('fr' => 'French', 'it' => 'Italian', 'es' => 'Spanish', 'en' => 'English', 'de' => 'German', 'pt' => 'Portuguese');
            if ($array_wl[substr($lang, 0, 2)] != '') {
                $array_config['input language'] = $array_wl[substr($lang, 0, 2)];
            }
        }
    }
    # User mode
    if ($AA_FREEPBX_MODE == '1') {
        # Retrieve user keys
        $keys = Aastra_get_user_context($username, 'keys');
        # User has existing keys
        if (count($keys[$model]) != 0) {
            # Remove all profile keys
            foreach ($array_config as $key => $value) {
                if (stristr($key, 'key')) {
                    unset($array_config[$key]);
                }
            }
            # Add user keys
            foreach ($keys[$model] as $key => $value) {
                $array_config[$key] = $value;
            }
        }
        # Process day/night keys
        foreach ($array_config as $key => $value) {
            if (strstr($value, 'daynight.php')) {
                $pieces = explode(' ', $key);
                if (stristr($pieces[0], 'expmod')) {
                    $appli = $pieces[0] . ' ' . $pieces[1];
                } else {
                    $appli = $pieces[0];
                }
                $url = parse_url($value);
                parse_str($url['query'], $parse);
                if ($parse['index'] != '') {
                    $index = $parse['index'];
                } else {
                    $index = '';
                }
                if (!Aastra_is_daynight_appli_allowed_Asterisk($username, $index)) {
                    unset($array_config[$appli . ' type']);
                    unset($array_config[$appli . ' label']);
                    unset($array_config[$appli . ' value']);
                    unset($array_config[$appli . ' states']);
                }
            }
        }
        # Process presence
        if (!$AA_PRESENCE_STATE) {
            foreach ($array_config as $key => $value) {
                if (strstr($value, 'away.php')) {
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $appli = $pieces[0] . ' ' . $pieces[1];
                    } else {
                        $appli = $pieces[0];
                    }
                    break;
                }
            }
            if ($appli != '') {
                unset($array_config[$appli . ' type']);
                unset($array_config[$appli . ' label']);
                unset($array_config[$appli . ' value']);
                unset($array_config[$appli . ' states']);
            }
        }
        # Process speed dial
        if (!$AA_SPEEDDIAL_STATE) {
            foreach ($array_config as $key => $value) {
                if (strstr($value, 'speed.php')) {
                    $pieces = explode(' ', $key);
                    if (stristr($pieces[0], 'expmod')) {
                        $appli = $pieces[0] . ' ' . $pieces[1];
                    } else {
                        $appli = $pieces[0];
                    }
                    break;
                }
            }
            if ($appli != '') {
                unset($array_config[$appli . ' type']);
                unset($array_config[$appli . ' label']);
                unset($array_config[$appli . ' value']);
                unset($array_config[$appli . ' states']);
            }
        }
    }
    # Translate the needed parameters
    foreach ($array_config as $key => $value) {
        $test = False;
        if (stristr($key, 'key') and stristr($key, 'label')) {
            $test = True;
        }
        if (stristr($key, 'xml application title')) {
            $test = True;
        }
        if ($test) {
            $array_config[$key] = Aastra_get_label($value, $language);
        }
    }
    # Config file
    $write = @fopen(AASTRA_TFTP_DIRECTORY . '/' . $mac . '.cfg', 'w');
    # No problem with the file
    if ($write) {
        # Dump the config file
        foreach ($array_config as $key => $value) {
            fputs($write, $key . ': ' . $value . "\n");
        }
        # Close the MAC.cfg file
        fclose($write);
    } else {
        # Trace
        Aastra_debug('Cannot write MAC.cfg (' . AASTRA_TFTP_DIRECTORY . '/' . $mac . '.cfg )');
        $return = False;
    }
    # Return result
    return $return;
}
Exemplo n.º 8
0
                 fputs($handle, 'uri=' . $XML_SERVER . '&index=' . ($index + 1) . '&rank=' . ($y + 1) . "\n");
             }
             fclose($handle);
         } else {
             Aastra_debug('Cannot open ' . $file_name . ' in write mode');
             $object = new AastraIPPhoneTextScreen();
             $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));
             if (Aastra_is_softkeys_supported()) {
                 $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
             }
             $output = $object->output();
             exit;
         }
     } else {
         Aastra_debug('No item in the RSS feed');
         $object = new AastraIPPhoneTextScreen();
         $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));
         if (Aastra_is_softkeys_supported()) {
             $object->addSoftkey('6', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
         }
         $output = $object->output();
         exit;
     }
 }
 # Display the requested article or list
 $array_rss = Aastra_readINIfile($file_name, '#', '=');
 if (empty($rank)) {
     # Special for no softkey phones
     if (Aastra_is_softkeys_supported()) {
 function log($message)
 {
     Aastra_debug($message);
 }