$E = Aastra_getvar_safe('E', '1'); $P = Aastra_getvar_safe('P', '1'); $user = Aastra_getvar_safe('user'); # Retrieve phone information $header = Aastra_decode_HTTP_header(); if ($user == '') { $user = $header['mac']; } # Keep return URI $XML_SERVER .= '?user='******'biorhytm', 'user='******'1.4.2.', 0); Aastra_test_php_function('imagecreate', Aastra_get_label('PHP-GD extension not installed.', $language)); $nb_softkeys = Aastra_number_softkeys_supported(); # Nothing entered if ($bdate == '') { $date = Aastra_get_user_context($user, 'biorhytm'); $object = new AastraIPPhoneInputScreen(); $object->setTitle(Aastra_get_label('Biorhythms', $language)); $object->setPrompt(Aastra_get_label('Birth Date (MM/DD/YYYY)', $language)); $object->setParameter('bdate'); $object->setType('dateUS'); $object->setURL($XML_SERVER); $object->setDefault($date); $object->setDestroyOnExit(); if ($nb_softkeys == 10) { $object->addSoftkey('10', Aastra_get_label('Exit', $language), "SoftKey:Exit");
function Aastra_max_items_textmenu($header = NULL) { $return = 15; if (Aastra_test_phone_version('2.2.0.', 1, $header) == 0) { $return = 30; } return $return; }
function _generatePage($page) { # Empty List protection (to avoid 'cannot display') if ($this->_count == 0) { $tmpEntry['name'] = '[NO ENTRIES]'; $this->_list[] = $tmpEntry; $this->_count++; } # Calculate total number of pages $last = ceil($this->_count / $this->_maxLines); # Invalid page protection if (empty($page) or $page < 1) { $page = 1; } if ($page > $last) { $page = $last; } # On phones without softkeys: Add dummy entry that allows to jump to previous page if (!Aastra_is_softkeys_supported() && ($page > 1 && $last > 1)) { $this->_entries[] = new AastraIPPhoneTextMenuEntry('[' . Aastra_get_label('Previous Page', $this->_language) . ']', $this->_scrollHandlerReference . '&listPage=' . ($page - 1), NULL, NULL, NULL, NULL, NULL); } # Populate list for current page for ($i = 0; $i < $this->_maxLines and $i + ($page - 1) * $this->_maxLines < $this->_count; $i++) { # Get entry from list $tmpEntry = $this->_list[$i + ($page - 1) * $this->_maxLines]; # Add 'recentSelection' and 'recentPage' attribute to URL of the entry. # Allows to jump back to same page / selection $tmpURI = $tmpEntry['url']; # Check if URI is an HTTP(S) URL (could also be an URI like Dial:1234) if (preg_match('/^http/i', $tmpURI)) { # Check if URL already contains parameters if (preg_match('/\\?/', $tmpURI)) { $tmpEntry['url'] = $tmpEntry['url'] . '&recentSelection=' . ($i + 1) . '&recentPage=' . $page; } else { $tmpEntry['url'] = $tmpEntry['url'] . '?recentSelection=' . ($i + 1) . '&recentPage=' . $page; } } # Make sure we don't add menu items the phone firmware cannot handle if (!Aastra_is_icons_supported()) { $tmpEntry['icon'] = NULL; } if (Aastra_test_phone_version('2.0.1.', 1)) { $tmpEntry['dial'] = NULL; } $this->_entries[] = new AastraIPPhoneTextMenuEntry($tmpEntry['name'], $tmpEntry['url'], $tmpEntry['selection'], $tmpEntry['icon'], $tmpEntry['dial'], NULL, NULL); } # On phones without softkeys: Add dummy entry that allows to jump to next page if (!Aastra_is_softkeys_supported() && $page < $last) { $this->_entries[] = new AastraIPPhoneTextMenuEntry('[' . Aastra_get_label('Next Page', $this->_language) . ']', $this->_scrollHandlerReference . '&listPage=' . ($page + 1), NULL, NULL, NULL, NULL, NULL); } # On phones with softkeys:Add Next/Previous Softkeys if (Aastra_is_softkeys_supported()) { if ($page < $last) { # Add Next key if (Aastra_is_icons_supported() && !empty($this->_nextKeyIcon)) { $this->addSoftkey($this->_nextKeyPosition, Aastra_get_label('Next', $this->_language), $this->_scrollHandlerReference . '&listPage=' . ($page + 1), $this->_nextKeyIconIndex); } else { $this->addSoftkey($this->_nextKeyPosition, Aastra_get_label('Next', $this->_language), $this->_scrollHandlerReference . '&listPage=' . ($page + 1)); } } if ($page > 1 && $last > 1) { # Add Previous key if (Aastra_is_icons_supported() && !empty($this->_previousKeyIcon)) { $this->addSoftkey($this->_previousKeyPosition, Aastra_get_label('Previous', $this->_language), $this->_scrollHandlerReference . '&listPage=' . ($page - 1), $this->_previousKeyIconIndex); } else { $this->addSoftkey($this->_previousKeyPosition, Aastra_get_label('Previous', $this->_language), $this->_scrollHandlerReference . '&listPage=' . ($page - 1)); } } } # Add page info to title if ($last > 1) { # For phones with big screen if (Aastra_is_softkeys_supported()) { $this->_title = $this->_title . ' (' . Aastra_get_label('Pg.', $this->_language) . ' ' . $page . '/' . $last . ')'; } else { $this->_title = $this->_title . ' (' . $page . '/' . $last . ')'; } } }
############################################################################# # Body ############################################################################# # Retrieve parameters $user = $_GET['user']; $action = $_GET['action']; $value = $_GET['value']; $page = $_GET['page']; $score = $_GET['score']; if ($page == '') { $page = 1; } # Trace Aastra_trace_call('Yahtzee', 'user='******', action=' . $action . ', value=' . $value); # Test User Agent Aastra_test_phone_version('2.2.0.', 0); Aastra_test_phone_model(array('Aastra55i', 'Aastra57i', 'Aastra57iCT', 'Aastra8000i'), True, 0); Aastra_test_php_function('imagecreate', 'PHP-GD extension not installed.'); # Get Language $language = Aastra_get_language(); # Retrieve phone information $header = Aastra_decode_HTTP_header(); if ($user == '') { $user = $header['mac']; } # Keep return URI $XML_SERVER .= '?user=' . $user; # Number of softkeys $nb_softkeys = Aastra_number_softkeys_supported($header); # Get user context $yahtzee = get_user_context($user);
function _setupSoftKeys() { # Check if softkeys and the Dial2 softkey is supported. Don't put dial key on 6739i if (Aastra_is_softkeys_supported() && !Aastra_test_phone_version('2.0.1.', 1) && Aastra_phone_type() != 5) { $this->addSoftkey($this->_dialKeyPosition, Aastra_get_label('Dial', $this->_language), 'SoftKey:Dial2'); } parent::_setupSoftKeys(); }
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; }
if ($action == 'logout') { Aastra_update_HDconfig_file(AASTRA_PATH_CACHE . 'startup_asterisk.cfg', $user); } # Remove from Parking list Aastra_remove_parking_Asterisk($user); # Remove from VM List $count = !Aastra_is_ledcontrol_supported(); Aastra_remove_vmail_Asterisk('', $user, $count); # Retrieve Caller ID $callerid = Aastra_get_callerid_Asterisk($user); # Send an email Aastra_send_HDmail($header, $callerid . ' ' . $user, 'LOGOUT', $AA_EMAIL, $AA_SENDER); # Compute what to do $test = False; if ($header['model'] == 'Aastra6739i') { if (Aastra_test_phone_version('3.2.0.', 1, $header) == 0) { $test = True; } } else { if (Aastra_is_dynamic_sip_supported()) { $test = True; } } # Depending on Dynamic SIP support if ($test) { # Get new configuration $array_mac = Aastra_readCFGfile(AASTRA_TFTP_DIRECTORY . '/' . $header['mac'] . '.cfg', '#', ':'); $array_aastra = Aastra_readCFGfile(AASTRA_TFTP_DIRECTORY . '/aastra.cfg', '#', ':'); $array_intersect = array_intersect_key($array_aastra[''], $array_mac['']); foreach ($array_mac[''] as $key => $value) { $array_config[$key] = '';
# Check if call has been parked $park = Aastra_check_park_Asterisk($user, $number); # Display orbit if ($park != '') { # Display current status require_once 'AastraIPPhoneStatus.class.php'; $object = new AastraIPPhoneStatus(); $object->setSession('Park'); $object->setBeep(); if (Aastra_size_display_line() > 16) { $object->addEntry('1', sprintf(Aastra_get_label('Call Parked at %s', $language), $park), 'alert', 5); } else { $object->addEntry('1', sprintf(Aastra_get_label('Parked at %s', $language), $park), 'alert', 5); } # Bug 3.2.1 if (Aastra_test_phone_version('3.2.1.', '1') == 0) { sleep(4); } # End of search $found = 1; } } # No match whatsoever if ($found == 0) { require_once 'AastraIPPhoneExecute.class.php'; $object = new AastraIPPhoneExecute(); $object->addEntry(''); } # Display XML object # Trace Aastra_trace_call('onhook_asterisk', $object->generate());
Aastra_save_user_context($user, 'keys', $keys); } ############################################################################# # Main code ############################################################################# # Retrieve parameters $user = Aastra_getvar_safe('user'); $action = Aastra_getvar_safe('action', 'check'); $page = Aastra_getvar_safe('page'); # Trace Aastra_trace_call('sync_asterisk', 'user='******', action=' . $action); # Test User Agent if ($AA_FREEPBX_MODE == '1') { Aastra_test_phone_version('1.4.2.', 0); } else { Aastra_test_phone_version('2.5.3.', 0); } # Get Language $language = Aastra_get_language(); # Get header information $header = Aastra_decode_HTTP_header(); # Depending on action switch ($action) { # First Registration case 'register': # Bug 6739i on first registration if ($header['model'] == 'Aastra6739i') { $register = Aastra_get_user_context($user, 'register'); $time = time(); if ($time - $register < 2) { require_once 'AastraIPPhoneExecute.class.php';