From f0c59d090504710f9bad12bfacafbd7b240b38a4 Mon Sep 17 00:00:00 2001 From: Sascha Daniels Date: Mon, 1 Aug 2016 17:22:29 +0200 Subject: [PATCH 01/42] Problems with some firmware versions --- opt/gemeinschaft/htdocs/prov/snom/settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/snom/settings.php b/opt/gemeinschaft/htdocs/prov/snom/settings.php index 1fc3f36b8..7ba644d66 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/settings.php +++ b/opt/gemeinschaft/htdocs/prov/snom/settings.php @@ -725,8 +725,8 @@ function _settings_out() } } psetting('dnd_mode' , $dnd_mode, true); -psetting('dnd_on_code' , 'dnd-on'); -psetting('dnd_off_code' , 'dnd-off'); +psetting('dnd_on_code' , 'dnd-on@'. $host)); +psetting('dnd_off_code' , 'dnd-off@'. $host)); psetting('preselection_nr' , ''); From 2db5135e9c633f18920f626e7d4d2e7ac1124dbc Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Nov 2014 14:06:21 +0100 Subject: [PATCH 02/42] added Yealink T46G and T48G support --- .../htdocs/prov/yealink/.htaccess | 15 + .../htdocs/prov/yealink/fw/.gitignore | 3 + .../htdocs/prov/yealink/fw/get_firmware | 73 ++ .../htdocs/prov/yealink/old_snippets.php | 633 ++++++++++++++ opt/gemeinschaft/htdocs/prov/yealink/pb.php | 326 +++++++ .../htdocs/prov/yealink/settings.php | 810 ++++++++++++++++++ 6 files changed, 1860 insertions(+) create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/.htaccess create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore create mode 100755 opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/pb.php create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/settings.php diff --git a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess new file mode 100644 index 000000000..01f5f5eea --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess @@ -0,0 +1,15 @@ +# Gemeinschaft +# $Revision: 1 $ + +# Provisioning for Tiptel *requires* mod_rewrite in order to work! + + + RewriteEngine on + + # The phone asks for + # .cfg + + # Rewrite requests for .txt + RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + + diff --git a/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore b/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore new file mode 100644 index 000000000..a2bf6f55b --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore @@ -0,0 +1,3 @@ +*.cfg +*.com +*.rom diff --git a/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware b/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware new file mode 100755 index 000000000..c2640fef2 --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware @@ -0,0 +1,73 @@ +#!/usr/bin/php -q + +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +\*******************************************************************/ + +define( 'GS_VALID', true ); /// this is a parent file + + +function _tiptel_normalize_version( $fwvers ) +{ + $tmp = explode('.', $fwvers); + $v0 = str_pad((int)@$tmp[0], 2, '0', STR_PAD_LEFT); + $v1 = str_pad((int)@$tmp[1], 2, '0', STR_PAD_LEFT); + $v2 = str_pad((int)@$tmp[2], 2, '0', STR_PAD_LEFT); + $v3 = str_pad((int)@$tmp[3], 2, '0', STR_PAD_LEFT); + return $v0.'.'.$v1.'.'.$v2.'.'.$v3; +} + +$urls = array('http://update.tiptel.nl/tiptel/','http://update.tiptel.nl/tiptel/beta/'); +$modelscfg = array( + 'ip280' => 'y000000000007.cfg', + 'ip284' => 'y000000000004.cfg', + 'ip286' => 'y000000000000.cfg' +); + +foreach ($urls as $url ) { + foreach ($modelscfg as $model => $cfg) { + $err=0; $out=array(); + exec( 'wget -q -O - '.$url.$cfg, $out, $err ); + foreach ($out as $line) { + if (preg_match('/firmware_name/',$line) ) { + $fw_vers = (preg_match('/(\d+\.\d+\.\d+\.\d+)/', @$line, $m) ? $m[1] : '0.0.0.0'); + $fw_vers_nrml = _tiptel_normalize_version( $fw_vers ); + if (! file_exists($fw_vers_nrml.'.rom') ) { + echo 'Fetching firmware '. $fw_vers_nrml .' for '. $model .' ... '; + $err=0; $out=array(); + exec( 'wget -q -O '.$fw_vers_nrml.'.rom '.$url.$fw_vers.'.rom', $out, $err ); + if ( $err === 0 ) { + echo 'Done' ,"\n"; + } else { + echo 'Failed' ,"\n"; + } + } else { + echo 'Firmware File '. $fw_vers_nrml .'.rom exits' ,"\n"; + } + } + } + } +} + +?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php b/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php new file mode 100644 index 000000000..28b30ba96 --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php @@ -0,0 +1,633 @@ +executeGetOne( 'SELECT `active` FROM `callwaiting` WHERE `user_id`='. $user_id ); +//psetting('Features|Call_Waiting', ($callwaiting ? '1' : '0') ); # 0 = disable, 1 = enable +psetting('Features|Call_Waiting', '1'); # 0 = disable, 1 = enable +psetting('Features|EnableHotline', '0'); # 0 = disable, 1 = enable +psetting('Features|Hotlinenumber', ''); # Hotline Number ??? +psetting('Features|BusyToneDelay', '0'); # 0, 3 or 5 sec +psetting('Features|Refuse_Code', '486'); # 404 = Not found, 480 = Temporarliy not available, 486 = Busy here +psetting('Features|DND_Code', '480'); # 404 = Not found, 480 = Temporarliy not available, 486 = Busy here +psetting('Features|DND_On_Code', 'dnd-on'); # SIP dial when press dnd-button +psetting('Features|DND_Off_Code', 'dnd-off'); # SIP dial when press dnd-button +psetting('Features|AllowIntercom', '1'); # 0 = disable, 1 = enable +psetting('Features|IntercomMute', '0'); # 0 = disable, 1 = enable +psetting('Features|IntercomTone', '1'); # 0 = disable, 1 = enable +psetting('Features|IntercomBarge', '1'); # 0 = disable, 1 = enable +psetting('Features|ButtonSoundOn', '1'); # 0 = disable, 1 = enable + +# AutoRedial +psetting('AutoRedial|path', '/yealink/config/Features/Phone.cfg'); +psetting('AutoRedial|EnableRedial', '0'); # 0 = disable, 1 = enable +psetting('AutoRedial|RedialInterval', '30'); # 1 to 300s, default 30 +psetting('AutoRedial|RedialTimes', '10'); # 1 to 300, default 10 + +# AutoAnswer +psetting('AutoAnswer|path', '/yealink/config/Features/Phone.cfg'); +psetting('AutoAnswer|Enable', '0'); # 0 = disable, 1 = enable + +# PoundSend +psetting('PoundSend|path', '/yealink/config/Features/Phone.cfg'); +psetting('PoundSend|Enable', '1'); # 0 = disable, 1 = #, 2 = * + +# Emergency +psetting('Emergency|path', '/yealink/config/Features/Phone.cfg'); +psetting('Emergency|Num', ''); # Emergency Number ??? + +# RingerDevice +psetting('RingerDevice|path', '/yealink/config/Features/Phone.cfg'); +psetting('RingerDevice|IsUseHeadset', '0'); # 0 = use speaker, 1 = use headset + + +##################################################################### +# /yealink/config/Features/Message.cfg +##################################################################### +psetting('Message|path', '/yealink/config/Features/Message.cfg'); +psetting('Message|VoiceNumber0', 'voicemail'); +psetting('Message|VoiceNumber1', ''); +psetting('Message|VoiceNumber2', ''); +psetting('Message|VoiceNumber3', ''); +psetting('Message|VoiceNumber4', ''); +psetting('Message|VoiceNumber5', ''); + + +##################################################################### +# /yealink/config/voip/tone.ini +##################################################################### +psetting('Country|path', '/yealink/config/voip/tone.ini'); +psetting('Country|Country', 'Germany'); + + +##################################################################### +# /yealink/config/Advanced/Advanced.cfg +##################################################################### +psetting('Webserver Type|path', '/yealink/config/Advanced/Advanced.cfg'); +psetting('Webserver Type|WebType', '1'); # 0 = disabled, 1 = HTTP&HTTPS, 2 = HTTP, 3 = HTTPS + +psetting('Advanced|path', '/yealink/config/Advanced/Advanced.cfg'); +psetting('Advanced|var_enabled', '1'); + + +##################################################################### +# /yealink/config/WebItemsLevel.cfg +##################################################################### +# 0 = item is visible in all access level (user, var, admin) +# 1 = item is visible in admin and var level +# 2 = item is only visible in admin level + +psetting('Phone|path', '/yealink/config/WebItemsLevel.cfg'); +psetting('Phone|features', '2'); +psetting('Phone|SMS', '2'); + + +##################################################################### +# /yealink/config/voip/sipAccount0.cfg +##################################################################### + +# account +psetting('account|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('account|Enable', '1'); # 0 = disable, 1 = enable +psetting('account|Label', $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname']); +psetting('account|DisplayName', $user['callerid']); +psetting('account|UserName', $user_ext); +psetting('account|AuthName', $user_ext); +psetting('account|Password', $user['secret']); +psetting('account|SIPServerHost', $host); +psetting('account|SIPServerPort', '5060'); +psetting('account|UseOutboundProxy', '0'); # 0 = disable, 1 = enable +psetting('account|OutboundHost', ''); +psetting('account|OutboundPort', '5061'); +psetting('account|Transport', '0'); # 0 = UDP, 1 = TCP, 2 = TLS +psetting('account|BakOutboundHost', ''); +psetting('account|BakOutboundPort', '5062'); +psetting('account|proxy-require', ''); +psetting('account|AnonymousCall', '0'); # 0 = disable, 1 = enable +psetting('account|RejectAnonymousCall', '0'); # 0 = disable, 1 = enable +psetting('account|Expire', '3600'); +psetting('account|SIPListenPort', '5060'); +psetting('account|Enable 100Rel', '0'); # 0 = disable, 1 = enable +psetting('account|precondition', '0'); # 0 = disable, 1 = enable +psetting('account|SubsribeRegister', '1'); # 0 = disable, 1 = enable +psetting('account|SubsribeMWI', '0'); # 0 = disable, 1 = enable +psetting('account|CIDSource', '0'); # 0 = FROM, 1 = PAI +psetting('account|EnableSessionTimmer', '0'); # 0 = disable, 1 = enable +psetting('account|SessionExpires', ''); # 1 to 999 +psetting('account|SessionRefresher', '0'); # 0 = UAC, 1 = UAS +psetting('account|EnableUserEqualPhone', '1'); # 0 = disable, 1 = enable +psetting('account|srtp_encryption', '0'); # 0 = disable, 1 = enable +psetting('account|ptime', '0'); # 0 = disable, 10,20,30,40,50 or 60ms +psetting('account|ShareLine', '0'); # 0 = disable, 1 = enable +psetting('account|dialoginfo_callpickup', '0'); # 0 = disable, 1 = enable +psetting('account|AutoAnswer', '0'); # 0 = disable, 1 = enable +psetting('account|MissedCallLog', '0'); # 0 = disable, 1 = enable +psetting('account|AnonymousCall_OnCode', ''); +psetting('account|AnonymousCall_OffCode', ''); +psetting('account|AnonymousReject_OnCode', ''); +psetting('account|AnonymousReject_OffCode', ''); +psetting('account|BLANumber', ''); +psetting('account|BLASubscribePeriod', '300'); # 60 to 7200, default 300 +psetting('account|SubscribeMWIExpire', '3600'); # 0 to 84600, default 3600 +psetting('account|CIDSource', '0'); # 0 = FROM, 1 = PAI +psetting('account|RegisterMAC', '1'); # 0 = disable, 1 = enable +psetting('account|RegisterLine', '1'); # 0 = disable, 1 = enable +psetting('account|RegFailRetryInterval', '30'); # 0 to 1800, default 30 + +# audio0 +psetting('audio0|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio0|enable', '0'); # 0 = disable, 1 = enable +psetting('audio0|PayloadType', 'PCMU'); +psetting('audio0|priority', '1'); +psetting('audio0|rtpmap', '0'); + +# audio1 +psetting('audio1|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio1|enable', '1'); # 0 = disable, 1 = enable +psetting('audio1|PayloadType', 'PCMA'); +psetting('audio1|priority', '2'); +psetting('audio1|rtpmap', '8'); + +# audio2 +psetting('audio2|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio2|enable', '0'); # 0 = disable, 1 = enable +psetting('audio2|PayloadType', 'G732_53'); +psetting('audio2|priority', '3'); +psetting('audio2|rtpmap', '4'); + +# audio3 +psetting('audio3|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio3|enable', '0'); # 0 = disable, 1 = enable +psetting('audio3|PayloadType', 'G732_63'); +psetting('audio3|priority', '4'); +psetting('audio3|rtpmap', '4'); + +# audio4 +psetting('audio4|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio4|enable', '0'); # 0 = disable, 1 = enable +psetting('audio4|PayloadType', 'G729'); +psetting('audio4|priority', '5'); +psetting('audio4|rtpmap', '18'); + +# audio5 +psetting('audio5|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio5|enable', '0'); # 0 = disable, 1 = enable +psetting('audio5|PayloadType', 'G722'); +psetting('audio5|priority', '6'); +psetting('audio5|rtpmap', '9'); + +# audio6 +psetting('audio6|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio6|enable', '0'); +psetting('audio6|PayloadType', 'iLBC'); +psetting('audio6|priority', '7'); +psetting('audio6|rtpmap', '97'); + +# audio7 +psetting('audio7|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio7|enable', '0'); # 0 = disable, 1 = enable +psetting('audio7|PayloadType', 'G726-16'); +psetting('audio7|priority', '8'); +psetting('audio7|rtpmap', '112'); + +# audio8 +psetting('audio8|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio8|enable', '0'); # 0 = disable, 1 = enable +psetting('audio8|PayloadType', 'G726-24'); +psetting('audio8|priority', '9'); +psetting('audio8|rtpmap', '102'); + +# audio9 +psetting('audio9|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio9|enable', '0'); # 0 = disable, 1 = enable +psetting('audio9|PayloadType', 'G726-32'); +psetting('audio9|priority', '10'); +psetting('audio9|rtpmap', '2'); + +# audio10 +psetting('audio10|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('audio10|enable', '0'); # 0 = disable, 1 = enable +psetting('audio10|PayloadType', 'G726-40'); +psetting('audio10|priority', '11'); +psetting('audio10|rtpmap', '104'); + +# DTMF +psetting('DTMF|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('DTMF|DTMFInbandTransfer', '1'); # 0 = INBAND, 1 = RFC2833, 2 = SIP INFO +psetting('DTMF|InfoType', '0'); # 0 = disable, 1 = DTMF-Relay, 2 = DTMF, 3 = Telephone-Event +psetting('DTMF|DTMFPayload', '101'); # 96 to 255 + +# NAT +psetting('NAT|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('NAT|NATTraversal', '0'); # 0 = disable, 1 = enable +//psetting('NAT|STUNServer', ''); +//psetting('NAT|STUNPort', '10000'); # default 10000 +//psetting('NAT|EnableUDPUpdate', '1'); # 0 = disable, 1 = enable +//psetting('NAT|UDPUpdateTime', '30'); # in seconds +//psetting('NAT|rport', '0'); # 0 = disable, 1 = enable + +# ADVANCED +psetting('ADVANCED|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('ADVANCED|default_t1', '0.5'); # default 0.5 +psetting('ADVANCED|default_t2', '4'); # default 4 +psetting('ADVANCED|default_t4', '5'); # default 5 + +# blf +psetting('blf|path', '/yealink/config/voip/sipAccount0.cfg'); +psetting('blf|SubscribePeriod', '1800'); # in seconds +psetting('blf|BLFList_URI', ''); + + +##################################################################### +# /yealink/config/voip/sipAccountX.cfg //FIXME don't function +##################################################################### + +/*switch ($phone_model) { + case 'ip280': $max_sip_accounts = 13; break; + case 'ip284': $max_sip_accounts = 13; break; + case 'ip286': $max_sip_accounts = 13; break; + default: $max_sip_accounts = 0; +} + +for ($i=1; $i<$max_sip_accounts; ++$i) { + //gs_log(GS_LOG_NOTICE, 'SIP Account '.$i); //FIXME + psetting('account|path', '/yealink/config/voip/sipAccount'.$i.'.cfg'); + psetting('account|Enable', '0'); # 0 = disable, 1 = enable +}*/ + + + + +##################################################################### +# set Keys (only ip284, ip286) +##################################################################### + +# DKtype: +# 0 = N/A +# 1 = Conference +# 2 = Forward +# 3 = Transfer +# 4 = Hold +# 5 = DND +# 6 = Redial +# 7 = Call Return +# 8 = SMS +# 9 = Call Pickup +# 10 = Call Park +# 11 = Custom +# 12 = Voicemail +# 13 = Speeddial +# 14 = Intercom +# 15 = Line (for line key only) +# 16 = blf +# 17 = URL +# 18 = Group Listening +# 19 = Public Hold +# 20 = Private Hold +# 27 = XML Browser + +if ( in_array($phone_model, array('ip284','ip286'), true) ) { + + # reset Keys on Phone + $max_keys = 10; + for ($i=1; $i <= $max_keys; $i++) { + psetting('memory'.$i.'|path', '/yealink/config/vpPhone/vpPhone.ini'); + psetting('memory'.$i.'|Line', '0'); + psetting('memory'.$i.'|type', ''); + psetting('memory'.$i.'|Value', ''); + psetting('memory'.$i.'|DKtype', '0'); + psetting('memory'.$i.'|PickupValue', ''); + } + + # reset Line Keys on Phone + for ($i=11; $i <= 16; $i++) { + psetting('memory'.$i.'|path', '/yealink/config/vpPhone/vpPhone.ini'); + psetting('memory'.$i.'|Line', $i-10); + psetting('memory'.$i.'|type', ''); + psetting('memory'.$i.'|Value', ''); + psetting('memory'.$i.'|DKtype', '15'); + psetting('memory'.$i.'|PickupValue', ''); + } + + # reset programmable Keys on Phone + //FIXME + + # reset Keys on Expansions Modul ( the correct order 3 2 1) + for ($j=3; $j >= 1; $j--) { + for ($i=0; $i <= 37; $i++) { + psetting('Key'.$i.'|path', '/yealink/config/vpPhone/Ext38_0000000000000'.$j.'.cfg'); + psetting('Key'.$i.'|Line', '0'); + psetting('Key'.$i.'|type', ''); + psetting('Key'.$i.'|Value', ''); + psetting('Key'.$i.'|DKtype', '0'); + psetting('Key'.$i.'|PickupValue', ''); + } + } + + + $softkeys = null; + $GS_Softkeys = gs_get_key_prov_obj( $phone_type ); + if ($GS_Softkeys->set_user( $user['user'] )) { + if ($GS_Softkeys->retrieve_keys( $phone_type, array( + '{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), + '{GS_P_PBX}' => $pbx, + '{GS_P_EXTEN}' => $user_ext, + '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, + '{GS_P_USER}' => $user['user'] + ) )) { + $softkeys = $GS_Softkeys->get_keys(); + } + } + if (! is_array($softkeys)) { + gs_log( GS_LOG_WARNING, 'Failed to get softkeys' ); + } else { + foreach ($softkeys as $key_name => $key_defs) { + if (array_key_exists('slf', $key_defs)) { + $key_def = $key_defs['slf']; + } elseif (array_key_exists('inh', $key_defs)) { + $key_def = $key_defs['inh']; + } else { + continue; + } + $key_idx = (int)lTrim(subStr($key_name,1),'0'); + if ($key_def['function'] === 'f0') continue; + //setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active')); + + # Keys on Phone + if ($key_idx >= 1 && $key_idx <= 10 ) { + psetting('memory'.$key_idx.'|path', '/yealink/config/vpPhone/vpPhone.ini'); + psetting('memory'.$key_idx.'|Line', '0'); + psetting('memory'.$key_idx.'|Value', $key_def['data']); + psetting('memory'.$key_idx.'|DKtype', subStr($key_def['function'],1)); + + # for BLF + if (subStr($key_def['function'],1) == 16 ) { + psetting('memory'.$key_idx.'|type', 'blf'); + psetting('memory'.$key_idx.'|PickupValue', '*81*'.$key_def['data']); + } + } + + # Keys on Expansion Modul + if ($key_idx >= 100 ) { + $key_tmp = (int)lTrim(subStr($key_idx,1),'0'); + psetting('Key'.$key_tmp.'|path', '/yealink/config/vpPhone/Ext38_0000000000000'.subStr($key_idx,0,1).'.cfg'); + psetting('Key'.$key_tmp.'|Line', '0'); + psetting('Key'.$key_tmp.'|Value', $key_def['data']); + psetting('Key'.$key_tmp.'|DKtype', subStr($key_def['function'],1)); + + # for BLF + if (subStr($key_def['function'],1) == 16 ) { + psetting('Key'.$key_tmp.'|type', 'blf'); + psetting('Key'.$key_tmp.'|PickupValue', '*81*'.$key_def['data']); + } + } + } + } + + # XML Browser for Phonebook on Line Key 2 + psetting('memory12|path', '/yealink/config/vpPhone/vpPhone.ini'); + psetting('memory12|Value', $prov_url_yealink.'pb.php?u='.$user_ext); + psetting('memory12|DKtype', '27'); + psetting('memory12|PickupValue', __('Tel.buch')); + psetting('memory12|Label', __('Tel.buch')); + + # XML Browser for Dial-Log on Line Key 3 + psetting('memory13|path', '/yealink/config/vpPhone/vpPhone.ini'); + psetting('memory13|Value', $prov_url_yealink.'dial-log.php?u='.$user_ext); + psetting('memory13|DKtype', '27'); + psetting('memory13|PickupValue', __('Anruf Listen')); + psetting('memory13|Label', __('Anruf Listen')); + +} + +?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/yealink/pb.php b/opt/gemeinschaft/htdocs/prov/yealink/pb.php new file mode 100644 index 000000000..ed933270d --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/pb.php @@ -0,0 +1,326 @@ + +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +\*******************************************************************/ + +define( 'GS_VALID', true ); /// this is a parent file +require_once( dirName(__FILE__) .'/../../../inc/conf.php' ); +include_once( GS_DIR .'inc/db_connect.php' ); +include_once( GS_DIR .'inc/gettext.php' ); +include_once( GS_DIR .'inc/string.php' ); +include_once( GS_DIR .'inc/group-fns.php' ); + +header( 'Content-Type: application/xml; charset=utf-8' ); +header( 'Expires: 0' ); +header( 'Pragma: no-cache' ); +header( 'Cache-Control: private, no-cache, must-revalidate' ); +header( 'Vary: *' ); + +function yealinkXmlEsc( $str ) +{ + return htmlEnt( $str ); +} + +function _ob_send() +{ + if (! headers_sent()) { + header( 'Content-Type: application/xml; charset=utf-8' ); + header( 'Content-Length: '. (int)@ob_get_length() ); + } + @ob_end_flush(); + die(); +} + +function _err( $msg='' ) +{ + @ob_end_clean(); + ob_start(); + echo + '', "\n", + '', "\n", + '', yealinkXmlEsc(__('Fehler')), '', "\n", + '', yealinkXmlEsc( __('Fehler') .': '. $msg ), '', "\n", + '', "\n"; + _ob_send(); +} + +function getUserID( $ext ) +{ + global $db; + + if (! preg_match('/^\d+$/', $ext)) + _err( 'Invalid username' ); + + $user_id = (int)$db->executeGetOne( 'SELECT `_user_id` FROM `ast_sipfriends` WHERE `name`=\''. $db->escape($ext) .'\'' ); + if ($user_id < 1) + _err( 'Unknown user' ); + return $user_id; +} + + +if (! gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { + gs_log( GS_LOG_DEBUG, "Yealink provisioning not enabled" ); + _err( 'Not enabled' ); +} + +$type = trim( @$_REQUEST['t'] ); +if (! in_array( $type, array('gs','prv','imported'), true )) { + $type = false; +} +$page = (int)trim( @$_REQUEST['p'] ); +$search = (int)trim( @$_REQUEST['s'] ); +$query = trim( @$_REQUEST['q'] ); + + +$per_page = 10; +$db = gs_db_slave_connect(); + + +/* +$typeToTitle = array( + 'imported' => "Firma (aus LDAP)", + 'gs' => "Firma", # should normally be "Gemeinschaft" + 'prv' => "Pers\xC3\xB6nlich", +); +*/ +$tmp = array( + 15=>array( + 'k' => 'gs' , + 'v' => gs_get_conf('GS_PB_INTERNAL_TITLE', __("Intern")) ), + 25=>array( + 'k' => 'prv', + 'v' => gs_get_conf('GS_PB_PRIVATE_TITLE' , __("Pers\xC3\xB6nlich")) ) +); +if (gs_get_conf('GS_PB_IMPORTED_ENABLED')) { + $pos = (int)gs_get_conf('GS_PB_IMPORTED_ORDER', 9) * 10; + $tmp[$pos] = array( + 'k' => 'imported', + 'v' => gs_get_conf('GS_PB_IMPORTED_TITLE', __("Extern")) + ); +} +kSort($tmp); +foreach ($tmp as $arr) { + $typeToTitle[$arr['k']] = $arr['v']; +} + + +$url_yealink_pb = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH .'yealink/pb.php'; + + + +#################################### SEARCH SCREEN { +if ($search === 1) { + + $user = trim( @$_REQUEST['u'] ); + $user_id = getUserID( $user ); + + ob_start(); + + echo '',"\n"; + echo + '', "\n", + '', yealinkXmlEsc(__('Suchen')), '', "\n", + '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type) ,'', "\n", + '', "\n", + '', yealinkXmlEsc(__('Suche nach')), '', "\n", + 'q',"\n", + '', "\n", + '', "\n"; + + _ob_send(); +} +#################################### SEARCH SCREEN } + + + +#################################### INITIAL SCREEN { +if (! $type) { + + $user = trim( @$_REQUEST['u'] ); + $user_id = getUserID( $user ); + + $user_groups = gs_group_members_groups_get(array($user_id), 'user'); + $permission_groups = gs_group_permissions_get($user_groups, 'phonebook_user'); + $group_members = gs_group_members_get($permission_groups); + + ob_start(); + echo + '', "\n", + '', "\n", + '', yealinkXmlEsc(__('Telefonbuch')) ,'', "\n\n"; + foreach ($typeToTitle as $t => $title) { + $cq = 'SELECT COUNT(*) FROM '; + switch ($t) { + case 'gs' : $cq .= '`users` WHERE `id` IN ('.implode(',',$group_members).') AND `id`!='.$user_id; break; + case 'imported': $cq .= '`pb_ldap`' ; break; + case 'prv' : $cq .= '`pb_prv` WHERE `user_id`='. $user_id ; break; + default : $cq = false; + } + $c = $cq ? (' ('. (int)@$db->executeGetOne( $cq ) .')') : ''; + echo + '', "\n", + '', yealinkXmlEsc($title), $c, '', "\n", + '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$t), '', "\n", + '', "\n\n"; + } + echo '', "\n"; + _ob_send(); + +} +#################################### INITIAL SCREEN } + + + +#################################### PHONEBOOK { +if ($type === 'gs') { + + $user = trim( @ $_REQUEST['u'] ); + $user_id = getUserID( $user ); + + $user_groups = gs_group_members_groups_get(array($user_id), 'user'); + $permission_groups = gs_group_permissions_get($user_groups, 'phonebook_user'); + $group_members = gs_group_members_get($permission_groups); + + $where = ''; + if (strLen($query) > 0) + $where = 'AND (`u`.`lastname` LIKE \'%'. $query .'%\' OR `u`.`firstname` LIKE \'%'. $query .'%\')'; + + $query = +'SELECT SQL_CALC_FOUND_ROWS `u`.`lastname` `ln`, `u`.`firstname` `fn`, `s`.`name` `ext` +FROM + `users` `u` JOIN + `ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`) +WHERE + `u`.`id` IN ('.implode(',',$group_members).') AND + `u`.`id`!='.$user_id.' + '. ($where ? $where : '') .' +ORDER BY `u`.`lastname`, `u`.`firstname` +LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; + +} +elseif ($type === 'prv') { + + $user = trim( @ $_REQUEST['u'] ); + $user_id = getUserID( $user ); + + $where = ''; + if (strLen($query) > 0) + $where = 'AND (`pb`.`lastname` LIKE \'%'. $query .'%\' OR `pb`.`firstname` LIKE \'%'. $query .'%\')'; + + $query = +'SELECT SQL_CALC_FOUND_ROWS `pb`.`lastname` `ln`, `pb`.`firstname` `fn`, `pb`.`number` `ext` +FROM `pb_prv` `pb` +WHERE + `pb`.`user_id`='.$user_id.' + '. ($where ? $where : '') .' +ORDER BY `pb`.`lastname`, `pb`.`firstname` +LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; + +} +elseif ($type === 'imported') { + + $query = +'SELECT SQL_CALC_FOUND_ROWS `lastname` `ln`, `firstname` `fn`, `number` `ext` +FROM `pb_ldap` +ORDER BY `lastname`, `firstname` +LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; + +} + +if (in_array( $type, array('gs','prv','imported'), true )) { + ob_start(); + echo '',"\n"; + + $rs = $db->execute($query); + $num_total = @$db->numFoundRows(); + $num_pages = ceil($num_total / $per_page); + + $page_title = $typeToTitle[$type]; + if ($num_pages > 1) $page_title.= ' '.($page+1).'/'.$num_pages; + + if ( $rs && $rs->numRows() !== 0 ) { + + echo + '', "\n", + '', yealinkXmlEsc( $page_title ), '', "\n"; + while ($r = $rs->fetchRow()) { + $name = $r['ln'] .( strLen($r['fn'])>0 ? (', '.$r['fn']) : '' ); + $number = $r['ext']; + echo + '', + '', yealinkXmlEsc( $name ) ,' (', yealinkXmlEsc( $number ) ,')', + '', $number ,'', + '', "\n"; + } + echo "\n"; + + echo + '', "\n", + '', yealinkXmlEsc(__("Zur\xC3\xBCck")), '', "\n", + 'SoftKey:Exit', "\n", + '', "\n"; + + echo '', "\n"; + if($page > 0) { + echo '', yealinkXmlEsc('<< '.$page), '', "\n"; + echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&p='.($page-1)), '', "\n"; + } else { + echo '', yealinkXmlEsc(__('Suchen')), '', "\n"; + echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&s=1'), '', "\n"; + } + echo '', "\n"; + + echo '', "\n"; + if($page < $num_pages-1 ) { + echo '', yealinkXmlEsc(($page+2).' >>'), '', "\n"; + echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&p='.($page+1)), '', "\n"; + } else { + echo '', "\n"; + echo '', "\n"; + } + echo '', "\n"; + + echo + '', "\n", + '', yealinkXmlEsc(__("W\xC3\xA4hlen")), '', "\n", + 'SoftKey:Dial', "\n", + '', "\n"; + + echo '', "\n"; + + } else { + + echo + '', "\n", + '', yealinkXmlEsc( $typeToTitle[$type] ), '', "\n", + '', yealinkXmlEsc( __("Dieses Telefonbuch enth\xC3\xA4lt keine Eintr\xC3\xA4ge.") ), '', "\n", + '', "\n"; + + } + _ob_send(); +} +#################################### PHONEBOOK } + + +?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php new file mode 100644 index 000000000..77fbf975a --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -0,0 +1,810 @@ + +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +\*******************************************************************/ + +define( 'GS_VALID', true ); /// this is a parent file + +header( 'Expires: 0' ); +header( 'Pragma: no-cache' ); +header( 'Cache-Control: private, no-cache, must-revalidate' ); +header( 'Vary: *' ); + + +require_once( dirName(__FILE__) .'/../../../inc/conf.php' ); +require_once( GS_DIR .'inc/util.php' ); +require_once( GS_DIR .'inc/gs-lib.php' ); +require_once( GS_DIR .'inc/prov-fns.php' ); +require_once( GS_DIR .'inc/quote_shell_arg.php' ); +set_error_handler('err_handler_die_on_err'); + +function _yealink_astlang_to_yealinklang($langcode) +{ + $lang_default = 'German'; + + $lang_transtable = array( + 'de' => 'German', + 'en' => 'English', + 'us' => 'English', + ); + + $lang_ret = $lang_transtable[$langcode]; + if(strlen($lang_ret) == 0) + return $lang_default; + + return $lang_ret; +} + +function _yealink_normalize_version( $fwvers ) +{ + $tmp = explode('.', $fwvers); + $v0 = str_pad((int)@$tmp[0], 2, '0', STR_PAD_LEFT); + $v1 = str_pad((int)@$tmp[1], 2, '0', STR_PAD_LEFT); + $v2 = str_pad((int)@$tmp[2], 2, '0', STR_PAD_LEFT); + $v3 = str_pad((int)@$tmp[3], 2, '0', STR_PAD_LEFT); + return $v0.'.'.$v1.'.'.$v2.'.'.$v3; +} + +function _yealink_fwcmp( $fwvers1, $fwvers2 ) +{ + //$fwvers1 = _yealink_normalize_version( $fwvers1 ); # we trust it has been normalized! + $fwvers2 = _yealink_normalize_version( $fwvers2 ); + return strCmp($fwvers1, $fwvers2); +} + +function _settings_err( $msg='' ) +{ + @ob_end_clean(); + @ob_start(); + echo '# ', ($msg != '' ? $msg : 'Error') ,"\n"; + gs_log( GS_LOG_DEBUG, $msg ); + if (! headers_sent()) { + header( 'Content-Type: text/plain; charset=utf-8' ); + header( 'Content-Length: '. (int)@ob_get_length() ); + } + @ob_end_flush(); + exit(1); +} + +function _redirect_tiptel() +{ + $prov_url_tiptel = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH.'tiptel/'.$_REQUEST['mac'].'.cfg'; + + gs_log( GS_LOG_DEBUG, 'Redirecting to Tiptel Provisoning: '.$prov_url_tiptel ); + + $options = array('http' => array('user_agent' => @$_SERVER['HTTP_USER_AGENT'])); + $context = stream_context_create($options); + $response = file_get_contents($prov_url_tiptel, false, $context); + + ob_start(); + echo $response; + if (! headers_sent()) { + header( 'Content-Type: text/plain; charset=utf-8' ); + header( 'Content-Length: '. (int)@ob_get_length() ); + } + @ob_end_flush(); + exit(1); +} + +if (! gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + gs_log( GS_LOG_DEBUG, "Yealink provisioning not enabled" ); + _settings_err( 'Not enabled.' ); +} + +$requester = gs_prov_check_trust_requester(); +if (! $requester['allowed']) { + _settings_err( 'No! See log for details.' ); +} + +$mac = preg_replace( '/[^0-9A-F]/', '', strToUpper( @$_REQUEST['mac'] ) ); +if (strLen($mac) !== 12) { + gs_log( GS_LOG_NOTICE, "Yealink provisioning: Invalid MAC address \"$mac\" (wrong length)" ); + # don't explain this to the users + _settings_err( 'No! See log for details.' ); +} +if (hexDec(subStr($mac,0,2)) % 2 == 1) { + gs_log( GS_LOG_NOTICE, "Yealink provisioning: Invalid MAC address \"$mac\" (multicast address)" ); + # don't explain this to the users + _settings_err( 'No! See log for details.' ); +} +if ($mac === '000000000000') { + gs_log( GS_LOG_NOTICE, "Yealink provisioning: Invalid MAC address \"$mac\" (huh?)" ); + # don't explain this to the users + _settings_err( 'No! See log for details.' ); +} + +# make sure the phone is a Yealink: +# +if (subStr($mac,0,6) !== '001565') { + gs_log( GS_LOG_NOTICE, "Yealink provisioning: MAC address \"$mac\" is not a Yealink phone" ); + # don't explain this to the users + _settings_err( 'No! See log for details.' ); +} + +# HTTP_USER_AGENTs +# +# yealink SIP-T46G: "Yealink SIP-T46G 28.72.0.25 00:15:65:5b:53:84" +# +$ua = trim( @$_SERVER['HTTP_USER_AGENT'] ); +$ua_parts = explode(' ', $ua); +# redirect Tiptel phones to Tiptel provisioning +if (strToLower(@$ua_parts[0]) == 'tiptel') { + gs_log( GS_LOG_WARNING, "Phone with MAC \"$mac\" (Tiptel) has invalid User-Agent (\"". $ua ."\"); Redirecting to Tiptel provisioning!" ); + + _redirect_tiptel(); +} +else if (strToLower(@$ua_parts[0]) !== 'yealink') { + gs_log( GS_LOG_WARNING, "Phone with MAC \"$mac\" (Yealink) has invalid User-Agent (\"". $ua ."\")" ); + # don't explain this to the users + _settings_err( 'No! See log for details.' ); +} + +gs_log( GS_LOG_DEBUG, "Yealink model $ua found." ); + +# find out the type of the phone: +if (preg_match('/SIP-(T46G|T48G)/', @$ua_parts[1], $m)) # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" + $phone_model = 'SIP-'.$m[1]; +else + $phone_model = 'unknown'; + +$phone_type = 'yealink-'.strToLower($phone_model); # e.g. "yealink-sip-t46g" or "yealink-sip-t48g" +# to be used when auto-adding the phone + +# find out the firmware version of the phone +$fw_vers = (preg_match('/(\d+\.\d+\.\d+\.\d+)/', @$ua_parts[2], $m)) + ? $m[1] : '0.0.0.0'; + +$fw_vers_nrml = _yealink_normalize_version( $fw_vers ); + +gs_log( GS_LOG_DEBUG, "Yealink phone \"$mac\" asks for settings (UA: ...\"$ua\") - model: $phone_model" ); + +$prov_url_yealink = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH .'yealink/'; + + +require_once( GS_DIR .'inc/db_connect.php' ); +require_once( GS_DIR .'inc/nobody-extensions.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_callforward_get.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_keys_get.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_prov_params_get.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_user_prov_params_get.php' ); +include_once( GS_DIR .'inc/cron-rule.php' ); + + +$settings = array(); + +function psetting( $param, $val='' ) +{ + global $settings; + + $settings[$param] = $val; +} + +function _settings_out() //TODO Variablen löschen (warte auf RE von Yealink) +{ + global $settings; + + echo "#!version:1.0.0.1\n"; + + foreach ($settings as $param => $val) { + echo $param .' = '. $val . "\n"; + } +} + + +$db = gs_db_master_connect(); +if (! $db) { + gs_log( GS_LOG_WARNING, "Yealink phone asks for settings - Could not connect to DB" ); + _settings_err( 'Could not connect to DB.' ); +} + +# do we know the phone? +# +$user_id = @gs_prov_user_id_by_mac_addr( $db, $mac ); +if ($user_id < 1) { + if (! GS_PROV_AUTO_ADD_PHONE) { + gs_log( GS_LOG_NOTICE, "New phone $mac not added to DB. Enable PROV_AUTO_ADD_PHONE" ); + _settings_err( 'Unknown phone. (Enable PROV_AUTO_ADD_PHONE in order to auto-add)' ); + } + gs_log( GS_LOG_NOTICE, "Adding new Yealink phone $mac to DB" ); + + $user_id = @gs_prov_add_phone_get_nobody_user_id( $db, $mac, $phone_type, $requester['phone_ip'] ); + if ($user_id < 1) { + gs_log( GS_LOG_WARNING, "Failed to add nobody user for new phone $mac" ); + _settings_err( 'Failed to add nobody user for new phone.' ); + } +} + + +# is it a valid user id? +# +$num = (int)$db->executeGetOne( 'SELECT COUNT(*) FROM `users` WHERE `id`='. $user_id ); +if ($num < 1) + $user_id = 0; + +if ($user_id < 1) { + # something bad happened, nobody (not even a nobody user) is logged + # in at that phone. assign the default nobody user of the phone: + $user_id = @gs_prov_assign_default_nobody( $db, $mac, null ); + if ($user_id < 1) { + _settings_err( 'Failed to assign nobody account to phone '. $mac ); + } +} + + +# get host for user +# +$host = @gs_prov_get_host_for_user_id( $db, $user_id ); +if (! $host) { + _settings_err( 'Failed to find host.' ); +} +$pbx = $host; # $host might be changed if SBC configured + + +# who is logged in at that phone? +# +$user = @gs_prov_get_user_info( $db, $user_id ); +if (! is_array($user)) { + _settings_err( 'DB error.' ); +} + + +# store the current firmware version and type information in the database: +# +@$db->execute( + 'UPDATE `phones` SET '. + '`firmware_cur`=\''. $db->escape($fw_vers_nrml) .'\', '. + '`type`=\''. $db->escape($phone_type) .'\' '. + 'WHERE `mac_addr`=\''. $db->escape($mac) .'\'' + ); + + +# firmware update +# +if (! gs_get_conf('GS_YEALINK_PROV_FW_UPDATE')) { + gs_log( GS_LOG_DEBUG, 'Yealink firmware update not enabled' ); +} else { + # get phone_id + $phone_id = (int)$db->executeGetOne( 'SELECT `id` FROM `phones` WHERE `mac_addr`=\''. $db->escape($mac) .'\'' ); + + # do we have to update to a default version? + # + $fw_was_upgraded_manually = (int)$db->executeGetOne( + 'SELECT `fw_manual_update` '. + 'FROM `phones` '. + 'WHERE `id`='. $phone_id + ); + if ($fw_was_upgraded_manually) { + gs_log( GS_LOG_DEBUG, "Phone $mac: Firmware was upgraded \"manually\". Not scheduling an upgrade." ); + } else { + $fw_default_vers = _yealink_normalize_version(trim(gs_get_conf('GS_YEALINK_PROV_FW_DEFAULT_'.strToUpper($phone_model)))); + if (in_array($fw_default_vers, array(null, false,''), true)) { + gs_log( GS_LOG_DEBUG, "Phone $mac: No default firmware set in config file" ); + } elseif (subStr($fw_default_vers,0,2) === '00') { + gs_log( GS_LOG_DEBUG, "Phone $mac: Bad default firmware set in config file" ); + } else { + if ($fw_vers_nrml != $fw_default_vers) { + gs_log( GS_LOG_NOTICE, "Phone $mac: The Firmware version ($fw_vers_nrml) differs from the default version ($fw_default_vers), scheduling an upgrade ..." ); + # simply add a provisioning job to the database. This is done to be clean and we cann trace the job. + $ok = $db->execute( + 'INSERT INTO `prov_jobs` ('. + '`id`, '. + '`inserted`, '. + '`running`, '. + '`trigger`, '. + '`phone_id`, '. + '`type`, '. + '`immediate`, '. + '`minute`, '. + '`hour`, '. + '`day`, '. + '`month`, '. + '`dow`, '. + '`data` '. + ') VALUES ('. + 'NULL, '. + ((int)time()) .', '. + '0, '. + '\'client\', '. + ((int)$phone_id) .', '. + '\'firmware\', '. + '0, '. + '\'*\', '. + '\'*\', '. + '\'*\', '. + '\'*\', '. + '\'*\', '. + '\''. $db->escape($fw_default_vers) .'\''. + ')' + ); + } + } + } + + # check provisioning jobs + # + $rs = $db->execute( + 'SELECT `id`, `running`, `minute`, `hour`, `day`, `month`, `dow`, `data` '. + 'FROM `prov_jobs` '. + 'WHERE `phone_id`='.$phone_id.' AND `type`=\'firmware\' '. + 'ORDER BY `running` DESC, `inserted`' ); + /*if (! $rs) { + gs_log( GS_LOG_WARNING, "DB error" ); + return; + }*/ + while ($job = $rs->fetchRow()) { + if ($job['running']) { + break; + } + + # check cron rule + $c = new CronRule(); + $ok = $c->set_Rule( $job['minute'] .' '. $job['hour'] .' '. $job['day'] .' '. $job['month'] .' '. $job['dow'] ); + if (! $ok) { + gs_log( GS_LOG_WARNING, "Phone $mac: Job ".$job['id']." has a bad cron rule (". $c->errMsg ."). Deleting ..." ); + $db->execute( 'DELETE FROM `prov_jobs` WHERE `id`='.((int)$job['id']).' AND `running`=0' ); + unset($c); + continue; + } + if (! $c->validate_time()) { + gs_log( GS_LOG_DEBUG, "Phone $mac: Job ".$job['id'].": Rule does not match" ); + unset($c); + continue; + } + unset($c); + gs_log( GS_LOG_DEBUG, "Phone $mac: Job ".$job['id'].": Rule match" ); + + $fw_new_vers = _yealink_normalize_version( $job['data'] ); + if (subStr($fw_new_vers,0,2)=='00') { + gs_log( GS_LOG_NOTICE, "Phone $mac: Bad new fw version $fw_new_vers" ); + $db->execute( 'DELETE FROM `prov_jobs` WHERE `id`='.((int)$job['id']).' AND `running`=0' ); + continue; + } + if ( (subStr($fw_new_vers,0,2) != '18' && $phone_model === 'ip28xs') + || (subStr($fw_new_vers,0,2) != '09' && $phone_model === 'ip280') + || (subStr($fw_new_vers,0,2) != '06' && $phone_model === 'ip284') + || (subStr($fw_new_vers,0,2) != '02' && $phone_model === 'ip286') ) { + gs_log( GS_LOG_NOTICE, "Phone $mac: Bad new fw version $fw_new_vers for $phone_model" ); + $db->execute( 'DELETE FROM `prov_jobs` WHERE `id`='.((int)$job['id']).' AND `running`=0' ); + continue; + } + $firmware_path = '/opt/gemeinschaft/htdocs/prov/yealink/fw/'.$fw_new_vers.'.rom'; + if ( ! file_exists($firmware_path) || ! is_readable($firmware_path) ) { + gs_log( GS_LOG_NOTICE, "Phone $mac: ".$firmware_path." not exits or not readable" ); + $db->execute( 'DELETE FROM `prov_jobs` WHERE `id`='.((int)$job['id']).' AND `running`=0' ); + continue; + } + if ( $fw_new_vers == $fw_vers_nrml ) { + gs_log( GS_LOG_NOTICE, "Phone $mac: FW $fw_vers_nrml == $fw_new_vers" ); + $db->execute( 'DELETE FROM `prov_jobs` WHERE `id`='.((int)$job['id']).' AND `running`=0' ); + continue; + } + + gs_log( GS_LOG_NOTICE, "Phone $mac: Upgrade FW $fw_vers_nrml -> $fw_new_vers" ); + + # Configure + ###It configures the access URL of the firmware file. + ###The default value is blank.It takes effect after a reboot. + psetting('firmware.url', $prov_url_yealink.'fw/'.$fw_new_vers.'.rom'); + + break; + } +} + + +# store the user's current IP address in the database: +# +if (! @gs_prov_update_user_ip( $db, $user_id, $requester['phone_ip'] )) { + gs_log( GS_LOG_WARNING, 'Failed to store current IP addr of user ID '. $user_id ); +} + + +# get SIP proxy to be set as the phone's outbound proxy +# +$sip_proxy_and_sbc = gs_prov_get_wan_outbound_proxy( $db, $requester['phone_ip'], $user_id ); +if ($sip_proxy_and_sbc['sip_server_from_wan'] != '') { + $host = $sip_proxy_and_sbc['sip_server_from_wan']; +} + + +# get extension without route prefix +# +if (gs_get_conf('GS_BOI_ENABLED')) { + $hp_route_prefix = (string)$db->executeGetOne( + 'SELECT `value` FROM `host_params` '. + 'WHERE '. + '`host_id`='. (int)$user['host_id'] .' AND '. + '`param`=\'route_prefix\'' + ); + $user_ext = (subStr($user['name'],0,strLen($hp_route_prefix)) === $hp_route_prefix) + ? subStr($user['name'], strLen($hp_route_prefix)) : $user['name']; + gs_log( GS_LOG_DEBUG, "Mapping ext. ". $user['name'] ." to $user_ext for provisioning - route_prefix: $hp_route_prefix, host id: ". $user['host_id'] ); +} else { + $hp_route_prefix = ''; + $user_ext = $user['name']; +} + +##################################################################### +# Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) +##################################################################### + +# Language +##It configures the language of the web user interface. +##Chinese_S is only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. +##Chinese_T is only applicable to SIP-T46G IP phones. +##French, Portuguese and Spanish are not applicable to SIP-T19P and SIP-T21P IP phones. +psetting('lang.wui', 'English'); +##It configures the language of the phone user interface. +##Chinese_S and Chinese_T are only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. +##The default value is English. +psetting('lang.gui', _yealink_astlang_to_yealinklang($user['language'])); + + +# Remote Phonebook +###X ranges from 1 to 5 +###remote_phonebook.data.X.url = +###remote_phonebook.data.X.name = +psetting('remote_phonebook.data.1.url', $prov_url_yealink.'pb.php?u='.$user_ext); +psetting('remote_phonebook.data.1.name', 'Tel.buch'); +###Except T41P/T42G Models +psetting('remote_phonebook.display_name', 'Tel.buch'); + +# Show Remote Phonebook on Home Screen +psetting('programablekey.2.type', '47'); +psetting('programablekey.2.line', '1'); +psetting('programablekey.2.value', ''); +psetting('programablekey.2.label', 'Tel.buch'); + +##It enables or disables the phone to perform a remote phone book search when receiving an incoming call. +##0-Disabled,1-Enabled. +##The default value is 0. +psetting('features.remote_phonebook.enable', '0'); +##It configures the interval (in seconds) for the phone to update the data of the remote phone book from the remote phone book server. +##The default value is 21600.Integer from 3600 to 2592000. +psetting('features.remote_phonebook.flash_time', '21600'); + +# Ringtone +# exp.: tftp://192.168.1.100/Ring9.wav +# http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav +#psetting('ringtone.url', 'http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav'); +#psetting('ringtone.delete', ''); +#Delete all the custom ringtones uploaded through auto provisioning +#psetting('ringtone.delete', 'http://localhost/all'); + +# Security +###Define the login username and password of the user, var and administrator. +###If you change the username of the administrator from "admin" to "admin1", your new administrator's username should be configured as: security.user_name.admin = admin1. +###If you change the password of the administrator from "admin" to "admin1pwd", your new administrator's password should be configured as: security.user_password = admin1:admin1pwd. +###The following examples change the user's username to "user23" and the user's password to "user23pwd". +###security.user_name.user = user23 +###security.user_password = user23:user23pwd +###The following examples change the var's username to "var55" and the var's password to "var55pwd". +###security.user_name.var = var55 +###security.user_password = var55:var55pwd +#psetting('security.user_name.user', ''); +#psetting('security.user_name.admin', ''); +#psetting('security.user_name.var', ''); +psetting('security.user_password', 'admin:'.gs_get_conf('GS_YEALINK_PROV_HTTP_PASS')); + +if ( in_array($phone_type, array('yealink-sip-t46g','yealink-sip-t48g'), true) ) { + $max_keys = 10; + + # RESET KEYS + for ($i=1; $i <= $max_keys; $i++) { + psetting('linekey.'.$i.'.line', '0'); + psetting('linekey.'.$i.'.value', ''); + psetting('linekey.'.$i.'.pickup_value', ''); + psetting('linekey.'.$i.'.extension', ''); + psetting('linekey.'.$i.'.type', '0'); + psetting('linekey.'.$i.'.xml_phonebook', '0'); + psetting('linekey.'.$i.'.label', ''); + } + + # TODO: RESET PROGRAMMABLE KEYS? + # TODO: RESET EXP KEYS? + + $softkeys = null; + $GS_Softkeys = gs_get_key_prov_obj( $phone_type ); + if ($GS_Softkeys->set_user( $user['user'] )) { + if ($GS_Softkeys->retrieve_keys( $phone_type, array( + '{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), + '{GS_P_PBX}' => $pbx, + '{GS_P_EXTEN}' => $user_ext, + '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, + '{GS_P_USER}' => $user['user'] + ) )) { + $softkeys = $GS_Softkeys->get_keys(); + } + } + if (! is_array($softkeys)) { + gs_log( GS_LOG_WARNING, 'Failed to get softkeys' ); + } else { + gs_log( GS_LOG_DEBUG, 'Num Softkeys to set: '.count($softkeys) ); + + foreach ($softkeys as $key_name => $key_defs) { + if (array_key_exists('slf', $key_defs)) { + $key_def = $key_defs['slf']; + } elseif (array_key_exists('inh', $key_defs)) { + $key_def = $key_defs['inh']; + } else { + continue; + } + + $key_idx = (int)lTrim(subStr($key_name,1),'0'); + if ($key_def['function'] === 'f0') continue; + + ####################################################################################### + ## Line Keys ## + ####################################################################################### + if ($key_idx >= 1 && $key_idx <= $max_keys ) { + gs_log( GS_LOG_DEBUG, 'Set LineKey('.$key_idx.') value=\''.$key_def['data'].'\' type=\''.subStr($key_def['function'],1).'\' label=\''.$key_def['label'].'\'' ); + + ###It configures the desired line to apply the key feature.Integer from 1 to 6 + psetting('linekey.'.$key_idx.'.line', 1); + ###It configures the value of the line key feature. + ###For example, when setting the key feature to BLF, it configures the number of the monitored user. + ###The default value is blank. + psetting('linekey.'.$key_idx.'.value', $key_def['data']); + # for BLF + if (subStr($key_def['function'],1) == 16 ) { + ###It configures the pickup code for BLF feature or conference ID followed by the # sign for Meet-Me conference feature. + ###It only applies to BLF and Meet-Me conference features. + ###The default value is blank + psetting('linekey.'.$key_idx.'.pickup_value', '*81*'); + } + ###It configures the key feature for the line key X. + #The valid types are: + #0-NA 1-Conference 2-Forward 3-Transfer 4-Hold 5-DND 7-Call Return 8-SMS 9-Directed Pickup + #10-Call Park 11-DTMF 12-Voice Mail 13-Speed Dial 14-Intercom 15-Line 16-BLF 17-URL 18-Group Listening + #20-Private Hold 22-XML Group 23-Group Pickup 24-Multicast Paging 25-Record 27-XML Browser + #34-Hot Desking 35-URL Record 38-LDAP 39-BLF List + #40-Prefix 41-Zero Touch 42-ACD 45-Local Group 46-Network Group 49-Custom Button + #50-Keypad Lock 55-Meet-Me Conference 56-Retrieve Park 57-Hoteling 58-ACD Grace 59-Sisp Code + #60-Emergency 61-Directory + #---- + #0-NA £¨Only for T41/T42/T46) + #22-XML Group (Not support T20) + #38-LDAP (Not support T20) + #46-Network Group (Not support T20) + #8-SMS (Only support T21/T46/T22/T26/T28) + #17-URL (Only support T41/T42/T46) + #49-Custom Button (Only support T20/T22/T26/T28) + psetting('linekey.'.$key_idx.'.type', subStr($key_def['function'],1)); + ###It configures the desired local group/XML group/network group for the line key X. + ###It only applies to the Local Group, XML Group and Network Group features. + ###XML Group and Network Group features are not applicable to SIP-T20P IP phones. + // psetting('linekey.'.$key_idx.'.xml_phonebook', '0'); + ###It configures the label displayed on the LCD screen for each line key. + ###The default value is blank. + psetting('linekey.'.$key_idx.'.label', $key_def['label']); + } + + # TODO: Programmable Keys + # TODO: Keys on Expansion Modul + } + } + +} + +##################################################################### +# MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) +##################################################################### +# Account1 Basic Settings +psetting('account.1.enable', '1'); # 0 = disable, 1 = enable +psetting('account.1.label', $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname']); +psetting('account.1.display_name', $user['callerid']); +psetting('account.1.auth_name', $user_ext); +psetting('account.1.user_name', $user_ext); +psetting('account.1.password', $user['secret']); +psetting('account.1.outbound_proxy_enable', '0'); # 0 = disable, 1 = enable +psetting('account.1.outbound_host', ''); +psetting('account.1.outbound_port', '5061'); +##It configures the local SIP port for account 1. The default value is 5060. +psetting('account.1.sip_listen_port', '5060'); +##It configures the transport type for account 1. 0-UDP,1-TCP,2-TLS,3-DNS-NAPTR +psetting('account.1.transport', '0'); ##The default value is 0. + +// # Failback +psetting('account.1.sip_server.1.address', $host); +psetting('account.1.sip_server.1.port', '5060'); + +// # Register Advanced +// ##It configures the SIP server type for account X.0-Default,2-BroadSoft,4-Cosmocom,6-UCAP +// ##The default value is 0. +psetting('account.1.sip_server_type', '0'); + +// psetting('account.1.unregister_on_reboot', ''); +// psetting('account.1.sip_trust_ctrl', ''); +// psetting('account.1.proxy_require', ''); +// psetting('account.1.srv_ttl_timer_enable', ''); +// psetting('account.1.register_mac', '1'); # 0 = disable, 1 = enable +// psetting('account.1.register_line', '1'); # 0 = disable, 1 = enable +// psetting('account.1.reg_fail_retry_interval', '30'); # 0 to 1800, default 30 + +// # NAT +// ##It enables or disables the NAT traversal for account X.0-Disabled,1-Enabled +// ##The default value is 0. +// psetting('account.1.nat.nat_traversal', ''); +// ##It configures the IP address or domain name of the STUN server for account X. +// ##The default value is blank. +// psetting('account.1.nat.stun_server', ''); +// ##It configures the port of the STUN server for account X. +// ##The default value is 3478. +// psetting('account.1.nat.stun_port', ''); +// ##It configures the type of keep-alive packets sent by the phone to the NAT device to keep the communication port open so that NAT can continue to function for account X. +// ##The default value is 1. +// psetting('account.1.nat.udp_update_enable', ''); +// ##It configures the keep-alive interval (in seconds) for account X. +// ##The default value is 30.Integer from 15 to 2147483647 +// psetting('account.1.nat.udp_update_time', ''); +// ##It enables or disables NAT Rport feature for account X.0-Disabled,1-Enabled +// ##The default value is 0. +// psetting('account.1.nat.rport', ''); + +// # Pickup +// ##It enables or disables the phone to pick up a call according to the SIP header of dialog-info for account X +// ##0-Disabled,1-Enabled. +// ##The default value is 0. +<<<<<<< HEAD +======= +// Must be DISABLED to work on Asterisk PBX +>>>>>>> abc790b9b6e321c242309513c3fda63ca3175a38 +psetting('account.1.dialoginfo_callpickup', '0'); +// ##It configures the group pickup code for account X. +// ##The default value is blank. +psetting('account.1.group_pickup_code', ''); +// ##It configures the directed pickup code for account X. +// ##The default value is blank. +psetting('account.1.direct_pickup_code', '*81*'); + +# Time +##It configures the time zone.For more available time zones, refer to Time Zones on page 215. +##The default value is +8. +psetting('local_time.time_zone', '+'.( ((int)date('Z')) / 3600)); +##It configures the time zone name.For more available time zone names, refer to Time Zones on page 215. +##The default time zone name is China(Beijing). +psetting('local_time.ntp_server1', gs_get_conf('GS_YEALINK_PROV_NTP')); + +####################################################################################### +## Features Pickup(Except T20P model) ## +####################################################################################### +##It enables or disables the phone to display the GPickup soft key when the phone is in the pre-dialing screen. +##0-Disabled,1-Enabled. +##The default value is 0. +psetting('features.pickup.group_pickup_enable', '0'); + +##It configures the group call pickup code. +##The default value is blank. +psetting('features.pickup.group_pickup_code', ''); + +##It enables or disables the phone to display the DPickup soft key when the phone is in the pre-dialing screen. +##0-Disabled,1-Enabled. +##The default value is 0. +psetting('features.pickup.direct_pickup_enable', '1'); + +##It configures the directed call pickup code. +##The default value is blank. +psetting('features.pickup.direct_pickup_code', '*81*'); + +##It enables or disables the phone to display a visual alert when the monitored user receives an incoming call. +##0-Disabled,1-Enabled. +##The default value is 0. +psetting('features.pickup.blf_visual_enable', '1'); + +##It enables or disables the phone to play an audio alert when the monitored user receives an incoming call. +##0-Disabled,1-Enabled. +##The default value is 0. +psetting('features.pickup.blf_audio_enable', '0'); + + +##################################################################### +# Override provisioning parameters (group profile) +##################################################################### +$prov_params = null; +$GS_ProvParams = gs_get_prov_params_obj( $phone_type ); +if ($GS_ProvParams->set_user( $user['user'] )) { + if ($GS_ProvParams->retrieve_params( $phone_type, array( + '{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), + '{GS_P_PBX}' => $pbx, + '{GS_P_EXTEN}' => $user_ext, + '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, + '{GS_P_USER}' => $user['user'] + ) )) { + $prov_params = $GS_ProvParams->get_params(); + } +} + +gs_log( GS_LOG_DEBUG, "Retrieved ".count($prov_params)." Group-Profile parameters for phone_type: ".$phone_type ); + +if (! is_array($prov_params)) { + gs_log( GS_LOG_WARNING, 'Failed to get provisioning parameters (group)' ); +} else { + foreach ($prov_params as $param_name => $param_arr) { + foreach ($param_arr as $param_index => $param_value) { + if ($param_index == -1) { + # not an array + if (! array_key_exists($param_name, $settings)) { + # new parameter + gs_log( GS_LOG_DEBUG, "Group prov. param \"$param_name\": \"$param_value\"" ); + } else { + # override parameter + gs_log( GS_LOG_DEBUG, "Overriding group prov. param \"$param_name\": \"$param_value\"" ); + } + + psetting($param_name, $param_value); + } else { + # array + gs_log( GS_LOG_NOTICE, "Group prov. param \"$param_name\"[$param_index]: Yealink does not support arrays" ); + } + } + } +} +unset($prov_params); +unset($GS_ProvParams); + + +##################################################################### +# Override provisioning parameters (user profile) +##################################################################### +$prov_params = @gs_user_prov_params_get( $user['user'], $phone_type ); + +gs_log( GS_LOG_DEBUG, "Retrieved ".count($prov_params)." User-Profile parameters for phone_type: ".$phone_type.", user: ".$user['user'] ); + +if (! is_array($prov_params)) { + gs_log( GS_LOG_WARNING, 'Failed to get provisioning parameters (user)' ); +} else { + foreach ($prov_params as $p) { + if ($p['index'] === null + || $p['index'] == -1) { + # not an array + if (! array_key_exists($p['param'], $settings)) { + # new parameter + gs_log( GS_LOG_DEBUG, 'User prov. param "'.$p['param'].'": "'.$p['value'].'"' ); + } else { + # override parameter + gs_log( GS_LOG_DEBUG, 'Overriding user prov. param "'.$p['param'].'": "'.$p['value'].'"' ); + } + + psetting($p['param'], $p['value']); + } else { + # array + gs_log( GS_LOG_NOTICE, 'User prov. param "'.$p['param'].'"['.$p['index'].']: Yealink does not support arrays"' ); + } + } +} +unset($prov_params); + + +##################################################################### +# output +##################################################################### +ob_start(); +_settings_out(); +if (! headers_sent()) { + header( 'Content-Type: text/plain; charset=utf-8' ); + # avoid chunked transfer-encoding + header( 'Content-Length: '. (int)@ob_get_length() ); +} +@ob_flush(); + +?> From 04cd157d9652ece9ec1820c0c09d4d10b4bfb506 Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:18:37 +0100 Subject: [PATCH 03/42] yealink changes --- etc/gemeinschaft/gemeinschaft.php | 55 +- .../htdocs/gui/mod/inc_keyprof.php | 82 +++ .../htdocs/gui/mod/prov_phones.php | 2 + .../htdocs/gui/mod/prov_provparams.php | 4 + .../htdocs/prov/tiptel/settings.php | 2 + .../htdocs/prov/yealink/fw/.gitignore | 3 - .../htdocs/prov/yealink/fw/get_firmware | 73 -- .../htdocs/prov/yealink/old_snippets.php | 633 ------------------ opt/gemeinschaft/inc/conf.php | 12 +- .../inc/gs-fns/gs_prov_params_get.php | 29 +- 10 files changed, 175 insertions(+), 720 deletions(-) delete mode 100644 opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore delete mode 100755 opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware delete mode 100644 opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index 75fc80761..870bd5540 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -58,16 +58,16 @@ //----------------------[ Master ]----------------------// -$DB_MASTER_HOST = '192.168.1.130'; +$DB_MASTER_HOST = '127.0.0.1'; $DB_MASTER_USER = 'gemeinschaft'; -$DB_MASTER_PWD = ''; +$DB_MASTER_PWD = '9ad951b941bb68cf6b4625f44c1a40'; $DB_MASTER_DB = 'asterisk'; //----------------------[ Slave ]-----------------------// $DB_SLAVE_HOST = '127.0.0.1'; $DB_SLAVE_USER = 'gemeinschaft'; -$DB_SLAVE_PWD = ''; +$DB_SLAVE_PWD = '9ad951b941bb68cf6b4625f44c1a40'; $DB_SLAVE_DB = 'asterisk'; //--------------------[ CDR Master ]--------------------// @@ -224,7 +224,7 @@ * PROVISIONING ***********************************************************/ -$PROV_HOST = '192.168.1.130'; +$PROV_HOST = '192.168.178.22'; //$PROV_PORT = 0; # 0 for default port for $PROV_SCHEME //$PROV_SCHEME = 'http'; # without "://" $PROV_PATH = '/gemeinschaft/prov/'; @@ -490,6 +490,49 @@ # 'f20' Private Hold # 'f27' XML Browser +//-----------------------[ Yealink ]-----------------------// + +$YEALINK_PROV_ENABLED = true; # do provisioning for Tiptel? + +$YEALINK_PROV_HTTP_PASS = 'admin'; # e.g. "gEheiM23y89sdo23", default: 'admin' + # to password protect the phone's web gui. + # changing these values will likely cause automatic rebooting to fail + +//$YEALINK_PROV_NTP = @$PROV_HOST; +//$YEALINK_PROV_NTP = '192.168.1.130'; + # NTP Server. the stupid Tiptel needs it + + # Set $LOG_LEVEL to "NOTICE" or even "DEBUG" and + # tail -f /var/log/gemeinschaft/gs.log + # Test the update mechanism with 1 or 2 phones. This is especially + # important with PoE (Power over Ethernet) switches. +$YEALINK_PROV_FW_UPDATE = false; # allow firmware updates? + +//$YEALINK_PROV_KEY_BLACKLIST = ''; + # do not show these softkey functions in GUI, + # comma separated list (e.g. 'f5,f12,f17'), default: '' + # 'f13' SpeedDial + # 'f16' BLF + # 'f1' Conference + # 'f2' Forward + # 'f3' Transfer + # 'f4' Hold + # 'f5' DND + # 'f6' Redial + # 'f7' Call Return + # 'f8' SMS + # 'f9' Call Pickup + # 'f10' Call Park + # 'f11' Custom + # 'f12' Voicemail + # 'f14' Intercom + # 'f15' Line + # 'f17' URL + # 'f18' Group Listening + # 'f19' Public Hold + # 'f20' Private Hold + # 'f27' XML Browser + //-----------------------[ Polycom ]----------------------// @@ -584,7 +627,7 @@ # does not control where apache, mysql, zaptel etc. put their # lock files -$CALL_INIT_FROM_NET = '192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8'; +$CALL_INIT_FROM_NET = '192.168.178.0/16, 172.16.0.0/12, 10.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8'; # a comma (,) separated list of IP addresses or # / pairs from where calls can be inited # with HTTP GET @@ -716,7 +759,7 @@ ***********************************************************/ $LOG_TO = 'file'; # 'file'|'syslog' -$LOG_LEVEL = 'NOTICE'; # "FATAL"|"WARNING"|"NOTICE"|"DEBUG" +$LOG_LEVEL = 'DEBUG'; # "FATAL"|"WARNING"|"NOTICE"|"DEBUG" # these settings affect only file logging: //$LOG_FILE = '/var/log/gemeinschaft/gs.log'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 32ef66661..7dbf545f5 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -113,6 +113,10 @@ $phone_types['tiptel-ip284'] = 'Tiptel IP 284'; if (in_array('*', $enabled_models) || in_array('ip286', $enabled_models)) $phone_types['tiptel-ip286'] = 'Tiptel IP 286'; + if (in_array('*', $enabled_models) || in_array('yealink-sip-t46g', $enabled_models)) + $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; + if (in_array('*', $enabled_models) || in_array('yealink-sip-t48g', $enabled_models)) + $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; } @@ -235,6 +239,36 @@ unset($key_functions_tiptel[$keyfn]); } +$key_functions_yealink = array( + 'f0' => __('Leer'), + 'f13' => __('Zielwahl'), # SpeedDial + 'f16' => __('BLF'), # BLF + //'f1' => __('Konferenz'), # Conference + //'f2' => __('Forward'), # Forward + 'f3' => __('Übergabe'), # Transfer + 'f4' => __('Halten'), # Hold + 'f5' => __('Nicht stören'), # DND + //'f6' => __('Redial'), # Redial + //'f7' => __('CallReturn'), # Call Return + //'f8' => __('SMS'), # SMS + //'f9' => __('CallPickup'), # Call Pickup + //'f10' => __('CallPark'), # Call Park + //'f11' => __('Custom'), # Custom + //'f12' => __('Voicemail'), # Voicemail + //'f14' => __('Intercom'), # Intercom + //'f15' => __('Leitung'), # Line (for line key only) + //'f17' => __('URL'), # URL + //'f18' => __('GroupListening'), # Group Listening + //'f19' => __('PublicHold'), # Public Hold + //'f20' => __('PrivateHold'), # Private Hold + //'f27' => __('XML Browser'), # XML Browser +); +$key_function_none_yealink = 'f0'; +$key_functions_blacklist = preg_split('/[\\s,]+/', gs_get_conf('GS_YEALINK_PROV_KEY_BLACKLIST')); +foreach ($key_functions_blacklist as $keyfn) { + if (array_key_exists($keyfn, $key_functions_yealink)) + unset($key_functions_yealink[$keyfn]); +} $key_default = array( @@ -307,6 +341,10 @@ if (array_key_exists('tiptel-ip284', $phone_types)) $phone_type = 'tiptel-ip284'; elseif (array_key_exists('tiptel-ip286', $phone_types)) $phone_type = 'tiptel-ip286'; } + if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + if (array_key_exists('yealink-sip-t46g', $phone_types)) $phone_type = 'yealink-sip-t46g'; + elseif (array_key_exists('yealink-sip-t48g', $phone_types)) $phone_type = 'yealink-sip-t48g'; + } } if (in_array($phone_type, array('snom-300', 'snom-320', 'snom-360', 'snom-370', 'snom-870', 'snom-760', 'snom-720', 'snom-725', 'snom-710', 'snom-715', 'snom-821'), true)) { $phone_layout = 'snom'; @@ -323,6 +361,9 @@ } elseif (in_array($phone_type, array('tiptel-ip284', 'tiptel-ip286'), true)) { $phone_layout = 'tiptel'; $key_function_none = $key_function_none_tiptel; +} elseif (in_array($phone_type, array('yealink-sip-t46g', 'yealink-sip-t48g'), true)) { + $phone_layout = 'yealink'; + $key_function_none = $key_function_none_tiptel; } else { $phone_layout = false; $key_function_none = false; @@ -1265,6 +1306,44 @@ function gs_dlg_abort() ); } break; + case 'yealink': + //if ($show_ext_modules >= 0) { + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 10, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + //} + if ($show_ext_modules >= 1) { + $key_levels += array( + 1 => array('from'=> 100, 'to'=> 118, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Spalte') .' 1') + ); + $key_levels += array( + 2 => array('from'=> 119, 'to'=> 137, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Spalte') .' 2') + ); + } + if ($show_ext_modules >= 2) { + $key_levels += array( + 3 => array('from'=> 200, 'to'=> 218, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Spalte') .' 1') + ); + $key_levels += array( + 4 => array('from'=> 219, 'to'=> 237, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Spalte') .' 2') + ); + } + if ($show_ext_modules >= 3) { + $key_levels += array( + 5 => array('from'=> 300, 'to'=> 318, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Spalte') .' 1') + ); + $key_levels += array( + 6 => array('from'=> 319, 'to'=> 337, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Spalte') .' 2') + ); + } + break; } //if (in_array($phone_layout, array('snom', 'grandstream', 'tiptel'), true)) { @@ -1496,6 +1575,9 @@ function gs_dlg_abort() case 'tiptel': $fns =& $key_functions_tiptel; break; + case 'yealink': + $fns =& $key_functions_yealink; + break; } foreach ($fns as $function => $title) { //if ($can_write || $function === $key['function']) { diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php index 00d180f2c..7e97753c0 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php @@ -99,6 +99,8 @@ function _mac_addr_display( $mac ) $phone_types['tiptel-ip280' ] = 'Tiptel IP 280'; $phone_types['tiptel-ip284' ] = 'Tiptel IP 284'; $phone_types['tiptel-ip286' ] = 'Tiptel IP 286'; + $phone_types['yealink-sip-t46G' ] = 'Yealink SIP T46G'; + $phone_types['yealink-sip-t48G' ] = 'Yealink SIP T48G'; } if (gs_get_conf('GS_POLYCOM_PROV_ENABLED')) { $phone_types['polycom-spip-300'] = 'Polycom SoundPoint IP 300'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php index 58be1fa42..13210dc8c 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php @@ -65,6 +65,10 @@ $phone_types['aastra-55i'] = 'Aastra 55i'; $phone_types['aastra-57i'] = 'Aastra 57i'; } +if (gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { + $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; + $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; +} if (gs_get_conf('GS_GRANDSTREAM_PROV_ENABLED')) { $phone_types['grandstream-ht287' ] = 'Grandstream HT 287'; $phone_types['grandstream-bt110' ] = 'Grandstream BT 110'; diff --git a/opt/gemeinschaft/htdocs/prov/tiptel/settings.php b/opt/gemeinschaft/htdocs/prov/tiptel/settings.php index 78f1976a8..6ab296f6d 100644 --- a/opt/gemeinschaft/htdocs/prov/tiptel/settings.php +++ b/opt/gemeinschaft/htdocs/prov/tiptel/settings.php @@ -89,6 +89,8 @@ function _settings_err( $msg='' ) if (! gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { gs_log( GS_LOG_DEBUG, "Tiptel provisioning not enabled" ); _settings_err( 'Not enabled.' ); +} else { + gs_log( GS_LOG_DEBUG, "Tiptel provisioning enabled" ); } diff --git a/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore b/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore deleted file mode 100644 index a2bf6f55b..000000000 --- a/opt/gemeinschaft/htdocs/prov/yealink/fw/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.cfg -*.com -*.rom diff --git a/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware b/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware deleted file mode 100755 index c2640fef2..000000000 --- a/opt/gemeinschaft/htdocs/prov/yealink/fw/get_firmware +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/php -q - -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301, USA. -\*******************************************************************/ - -define( 'GS_VALID', true ); /// this is a parent file - - -function _tiptel_normalize_version( $fwvers ) -{ - $tmp = explode('.', $fwvers); - $v0 = str_pad((int)@$tmp[0], 2, '0', STR_PAD_LEFT); - $v1 = str_pad((int)@$tmp[1], 2, '0', STR_PAD_LEFT); - $v2 = str_pad((int)@$tmp[2], 2, '0', STR_PAD_LEFT); - $v3 = str_pad((int)@$tmp[3], 2, '0', STR_PAD_LEFT); - return $v0.'.'.$v1.'.'.$v2.'.'.$v3; -} - -$urls = array('http://update.tiptel.nl/tiptel/','http://update.tiptel.nl/tiptel/beta/'); -$modelscfg = array( - 'ip280' => 'y000000000007.cfg', - 'ip284' => 'y000000000004.cfg', - 'ip286' => 'y000000000000.cfg' -); - -foreach ($urls as $url ) { - foreach ($modelscfg as $model => $cfg) { - $err=0; $out=array(); - exec( 'wget -q -O - '.$url.$cfg, $out, $err ); - foreach ($out as $line) { - if (preg_match('/firmware_name/',$line) ) { - $fw_vers = (preg_match('/(\d+\.\d+\.\d+\.\d+)/', @$line, $m) ? $m[1] : '0.0.0.0'); - $fw_vers_nrml = _tiptel_normalize_version( $fw_vers ); - if (! file_exists($fw_vers_nrml.'.rom') ) { - echo 'Fetching firmware '. $fw_vers_nrml .' for '. $model .' ... '; - $err=0; $out=array(); - exec( 'wget -q -O '.$fw_vers_nrml.'.rom '.$url.$fw_vers.'.rom', $out, $err ); - if ( $err === 0 ) { - echo 'Done' ,"\n"; - } else { - echo 'Failed' ,"\n"; - } - } else { - echo 'Firmware File '. $fw_vers_nrml .'.rom exits' ,"\n"; - } - } - } - } -} - -?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php b/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php deleted file mode 100644 index 28b30ba96..000000000 --- a/opt/gemeinschaft/htdocs/prov/yealink/old_snippets.php +++ /dev/null @@ -1,633 +0,0 @@ -executeGetOne( 'SELECT `active` FROM `callwaiting` WHERE `user_id`='. $user_id ); -//psetting('Features|Call_Waiting', ($callwaiting ? '1' : '0') ); # 0 = disable, 1 = enable -psetting('Features|Call_Waiting', '1'); # 0 = disable, 1 = enable -psetting('Features|EnableHotline', '0'); # 0 = disable, 1 = enable -psetting('Features|Hotlinenumber', ''); # Hotline Number ??? -psetting('Features|BusyToneDelay', '0'); # 0, 3 or 5 sec -psetting('Features|Refuse_Code', '486'); # 404 = Not found, 480 = Temporarliy not available, 486 = Busy here -psetting('Features|DND_Code', '480'); # 404 = Not found, 480 = Temporarliy not available, 486 = Busy here -psetting('Features|DND_On_Code', 'dnd-on'); # SIP dial when press dnd-button -psetting('Features|DND_Off_Code', 'dnd-off'); # SIP dial when press dnd-button -psetting('Features|AllowIntercom', '1'); # 0 = disable, 1 = enable -psetting('Features|IntercomMute', '0'); # 0 = disable, 1 = enable -psetting('Features|IntercomTone', '1'); # 0 = disable, 1 = enable -psetting('Features|IntercomBarge', '1'); # 0 = disable, 1 = enable -psetting('Features|ButtonSoundOn', '1'); # 0 = disable, 1 = enable - -# AutoRedial -psetting('AutoRedial|path', '/yealink/config/Features/Phone.cfg'); -psetting('AutoRedial|EnableRedial', '0'); # 0 = disable, 1 = enable -psetting('AutoRedial|RedialInterval', '30'); # 1 to 300s, default 30 -psetting('AutoRedial|RedialTimes', '10'); # 1 to 300, default 10 - -# AutoAnswer -psetting('AutoAnswer|path', '/yealink/config/Features/Phone.cfg'); -psetting('AutoAnswer|Enable', '0'); # 0 = disable, 1 = enable - -# PoundSend -psetting('PoundSend|path', '/yealink/config/Features/Phone.cfg'); -psetting('PoundSend|Enable', '1'); # 0 = disable, 1 = #, 2 = * - -# Emergency -psetting('Emergency|path', '/yealink/config/Features/Phone.cfg'); -psetting('Emergency|Num', ''); # Emergency Number ??? - -# RingerDevice -psetting('RingerDevice|path', '/yealink/config/Features/Phone.cfg'); -psetting('RingerDevice|IsUseHeadset', '0'); # 0 = use speaker, 1 = use headset - - -##################################################################### -# /yealink/config/Features/Message.cfg -##################################################################### -psetting('Message|path', '/yealink/config/Features/Message.cfg'); -psetting('Message|VoiceNumber0', 'voicemail'); -psetting('Message|VoiceNumber1', ''); -psetting('Message|VoiceNumber2', ''); -psetting('Message|VoiceNumber3', ''); -psetting('Message|VoiceNumber4', ''); -psetting('Message|VoiceNumber5', ''); - - -##################################################################### -# /yealink/config/voip/tone.ini -##################################################################### -psetting('Country|path', '/yealink/config/voip/tone.ini'); -psetting('Country|Country', 'Germany'); - - -##################################################################### -# /yealink/config/Advanced/Advanced.cfg -##################################################################### -psetting('Webserver Type|path', '/yealink/config/Advanced/Advanced.cfg'); -psetting('Webserver Type|WebType', '1'); # 0 = disabled, 1 = HTTP&HTTPS, 2 = HTTP, 3 = HTTPS - -psetting('Advanced|path', '/yealink/config/Advanced/Advanced.cfg'); -psetting('Advanced|var_enabled', '1'); - - -##################################################################### -# /yealink/config/WebItemsLevel.cfg -##################################################################### -# 0 = item is visible in all access level (user, var, admin) -# 1 = item is visible in admin and var level -# 2 = item is only visible in admin level - -psetting('Phone|path', '/yealink/config/WebItemsLevel.cfg'); -psetting('Phone|features', '2'); -psetting('Phone|SMS', '2'); - - -##################################################################### -# /yealink/config/voip/sipAccount0.cfg -##################################################################### - -# account -psetting('account|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('account|Enable', '1'); # 0 = disable, 1 = enable -psetting('account|Label', $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname']); -psetting('account|DisplayName', $user['callerid']); -psetting('account|UserName', $user_ext); -psetting('account|AuthName', $user_ext); -psetting('account|Password', $user['secret']); -psetting('account|SIPServerHost', $host); -psetting('account|SIPServerPort', '5060'); -psetting('account|UseOutboundProxy', '0'); # 0 = disable, 1 = enable -psetting('account|OutboundHost', ''); -psetting('account|OutboundPort', '5061'); -psetting('account|Transport', '0'); # 0 = UDP, 1 = TCP, 2 = TLS -psetting('account|BakOutboundHost', ''); -psetting('account|BakOutboundPort', '5062'); -psetting('account|proxy-require', ''); -psetting('account|AnonymousCall', '0'); # 0 = disable, 1 = enable -psetting('account|RejectAnonymousCall', '0'); # 0 = disable, 1 = enable -psetting('account|Expire', '3600'); -psetting('account|SIPListenPort', '5060'); -psetting('account|Enable 100Rel', '0'); # 0 = disable, 1 = enable -psetting('account|precondition', '0'); # 0 = disable, 1 = enable -psetting('account|SubsribeRegister', '1'); # 0 = disable, 1 = enable -psetting('account|SubsribeMWI', '0'); # 0 = disable, 1 = enable -psetting('account|CIDSource', '0'); # 0 = FROM, 1 = PAI -psetting('account|EnableSessionTimmer', '0'); # 0 = disable, 1 = enable -psetting('account|SessionExpires', ''); # 1 to 999 -psetting('account|SessionRefresher', '0'); # 0 = UAC, 1 = UAS -psetting('account|EnableUserEqualPhone', '1'); # 0 = disable, 1 = enable -psetting('account|srtp_encryption', '0'); # 0 = disable, 1 = enable -psetting('account|ptime', '0'); # 0 = disable, 10,20,30,40,50 or 60ms -psetting('account|ShareLine', '0'); # 0 = disable, 1 = enable -psetting('account|dialoginfo_callpickup', '0'); # 0 = disable, 1 = enable -psetting('account|AutoAnswer', '0'); # 0 = disable, 1 = enable -psetting('account|MissedCallLog', '0'); # 0 = disable, 1 = enable -psetting('account|AnonymousCall_OnCode', ''); -psetting('account|AnonymousCall_OffCode', ''); -psetting('account|AnonymousReject_OnCode', ''); -psetting('account|AnonymousReject_OffCode', ''); -psetting('account|BLANumber', ''); -psetting('account|BLASubscribePeriod', '300'); # 60 to 7200, default 300 -psetting('account|SubscribeMWIExpire', '3600'); # 0 to 84600, default 3600 -psetting('account|CIDSource', '0'); # 0 = FROM, 1 = PAI -psetting('account|RegisterMAC', '1'); # 0 = disable, 1 = enable -psetting('account|RegisterLine', '1'); # 0 = disable, 1 = enable -psetting('account|RegFailRetryInterval', '30'); # 0 to 1800, default 30 - -# audio0 -psetting('audio0|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio0|enable', '0'); # 0 = disable, 1 = enable -psetting('audio0|PayloadType', 'PCMU'); -psetting('audio0|priority', '1'); -psetting('audio0|rtpmap', '0'); - -# audio1 -psetting('audio1|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio1|enable', '1'); # 0 = disable, 1 = enable -psetting('audio1|PayloadType', 'PCMA'); -psetting('audio1|priority', '2'); -psetting('audio1|rtpmap', '8'); - -# audio2 -psetting('audio2|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio2|enable', '0'); # 0 = disable, 1 = enable -psetting('audio2|PayloadType', 'G732_53'); -psetting('audio2|priority', '3'); -psetting('audio2|rtpmap', '4'); - -# audio3 -psetting('audio3|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio3|enable', '0'); # 0 = disable, 1 = enable -psetting('audio3|PayloadType', 'G732_63'); -psetting('audio3|priority', '4'); -psetting('audio3|rtpmap', '4'); - -# audio4 -psetting('audio4|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio4|enable', '0'); # 0 = disable, 1 = enable -psetting('audio4|PayloadType', 'G729'); -psetting('audio4|priority', '5'); -psetting('audio4|rtpmap', '18'); - -# audio5 -psetting('audio5|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio5|enable', '0'); # 0 = disable, 1 = enable -psetting('audio5|PayloadType', 'G722'); -psetting('audio5|priority', '6'); -psetting('audio5|rtpmap', '9'); - -# audio6 -psetting('audio6|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio6|enable', '0'); -psetting('audio6|PayloadType', 'iLBC'); -psetting('audio6|priority', '7'); -psetting('audio6|rtpmap', '97'); - -# audio7 -psetting('audio7|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio7|enable', '0'); # 0 = disable, 1 = enable -psetting('audio7|PayloadType', 'G726-16'); -psetting('audio7|priority', '8'); -psetting('audio7|rtpmap', '112'); - -# audio8 -psetting('audio8|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio8|enable', '0'); # 0 = disable, 1 = enable -psetting('audio8|PayloadType', 'G726-24'); -psetting('audio8|priority', '9'); -psetting('audio8|rtpmap', '102'); - -# audio9 -psetting('audio9|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio9|enable', '0'); # 0 = disable, 1 = enable -psetting('audio9|PayloadType', 'G726-32'); -psetting('audio9|priority', '10'); -psetting('audio9|rtpmap', '2'); - -# audio10 -psetting('audio10|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('audio10|enable', '0'); # 0 = disable, 1 = enable -psetting('audio10|PayloadType', 'G726-40'); -psetting('audio10|priority', '11'); -psetting('audio10|rtpmap', '104'); - -# DTMF -psetting('DTMF|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('DTMF|DTMFInbandTransfer', '1'); # 0 = INBAND, 1 = RFC2833, 2 = SIP INFO -psetting('DTMF|InfoType', '0'); # 0 = disable, 1 = DTMF-Relay, 2 = DTMF, 3 = Telephone-Event -psetting('DTMF|DTMFPayload', '101'); # 96 to 255 - -# NAT -psetting('NAT|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('NAT|NATTraversal', '0'); # 0 = disable, 1 = enable -//psetting('NAT|STUNServer', ''); -//psetting('NAT|STUNPort', '10000'); # default 10000 -//psetting('NAT|EnableUDPUpdate', '1'); # 0 = disable, 1 = enable -//psetting('NAT|UDPUpdateTime', '30'); # in seconds -//psetting('NAT|rport', '0'); # 0 = disable, 1 = enable - -# ADVANCED -psetting('ADVANCED|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('ADVANCED|default_t1', '0.5'); # default 0.5 -psetting('ADVANCED|default_t2', '4'); # default 4 -psetting('ADVANCED|default_t4', '5'); # default 5 - -# blf -psetting('blf|path', '/yealink/config/voip/sipAccount0.cfg'); -psetting('blf|SubscribePeriod', '1800'); # in seconds -psetting('blf|BLFList_URI', ''); - - -##################################################################### -# /yealink/config/voip/sipAccountX.cfg //FIXME don't function -##################################################################### - -/*switch ($phone_model) { - case 'ip280': $max_sip_accounts = 13; break; - case 'ip284': $max_sip_accounts = 13; break; - case 'ip286': $max_sip_accounts = 13; break; - default: $max_sip_accounts = 0; -} - -for ($i=1; $i<$max_sip_accounts; ++$i) { - //gs_log(GS_LOG_NOTICE, 'SIP Account '.$i); //FIXME - psetting('account|path', '/yealink/config/voip/sipAccount'.$i.'.cfg'); - psetting('account|Enable', '0'); # 0 = disable, 1 = enable -}*/ - - - - -##################################################################### -# set Keys (only ip284, ip286) -##################################################################### - -# DKtype: -# 0 = N/A -# 1 = Conference -# 2 = Forward -# 3 = Transfer -# 4 = Hold -# 5 = DND -# 6 = Redial -# 7 = Call Return -# 8 = SMS -# 9 = Call Pickup -# 10 = Call Park -# 11 = Custom -# 12 = Voicemail -# 13 = Speeddial -# 14 = Intercom -# 15 = Line (for line key only) -# 16 = blf -# 17 = URL -# 18 = Group Listening -# 19 = Public Hold -# 20 = Private Hold -# 27 = XML Browser - -if ( in_array($phone_model, array('ip284','ip286'), true) ) { - - # reset Keys on Phone - $max_keys = 10; - for ($i=1; $i <= $max_keys; $i++) { - psetting('memory'.$i.'|path', '/yealink/config/vpPhone/vpPhone.ini'); - psetting('memory'.$i.'|Line', '0'); - psetting('memory'.$i.'|type', ''); - psetting('memory'.$i.'|Value', ''); - psetting('memory'.$i.'|DKtype', '0'); - psetting('memory'.$i.'|PickupValue', ''); - } - - # reset Line Keys on Phone - for ($i=11; $i <= 16; $i++) { - psetting('memory'.$i.'|path', '/yealink/config/vpPhone/vpPhone.ini'); - psetting('memory'.$i.'|Line', $i-10); - psetting('memory'.$i.'|type', ''); - psetting('memory'.$i.'|Value', ''); - psetting('memory'.$i.'|DKtype', '15'); - psetting('memory'.$i.'|PickupValue', ''); - } - - # reset programmable Keys on Phone - //FIXME - - # reset Keys on Expansions Modul ( the correct order 3 2 1) - for ($j=3; $j >= 1; $j--) { - for ($i=0; $i <= 37; $i++) { - psetting('Key'.$i.'|path', '/yealink/config/vpPhone/Ext38_0000000000000'.$j.'.cfg'); - psetting('Key'.$i.'|Line', '0'); - psetting('Key'.$i.'|type', ''); - psetting('Key'.$i.'|Value', ''); - psetting('Key'.$i.'|DKtype', '0'); - psetting('Key'.$i.'|PickupValue', ''); - } - } - - - $softkeys = null; - $GS_Softkeys = gs_get_key_prov_obj( $phone_type ); - if ($GS_Softkeys->set_user( $user['user'] )) { - if ($GS_Softkeys->retrieve_keys( $phone_type, array( - '{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), - '{GS_P_PBX}' => $pbx, - '{GS_P_EXTEN}' => $user_ext, - '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, - '{GS_P_USER}' => $user['user'] - ) )) { - $softkeys = $GS_Softkeys->get_keys(); - } - } - if (! is_array($softkeys)) { - gs_log( GS_LOG_WARNING, 'Failed to get softkeys' ); - } else { - foreach ($softkeys as $key_name => $key_defs) { - if (array_key_exists('slf', $key_defs)) { - $key_def = $key_defs['slf']; - } elseif (array_key_exists('inh', $key_defs)) { - $key_def = $key_defs['inh']; - } else { - continue; - } - $key_idx = (int)lTrim(subStr($key_name,1),'0'); - if ($key_def['function'] === 'f0') continue; - //setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active')); - - # Keys on Phone - if ($key_idx >= 1 && $key_idx <= 10 ) { - psetting('memory'.$key_idx.'|path', '/yealink/config/vpPhone/vpPhone.ini'); - psetting('memory'.$key_idx.'|Line', '0'); - psetting('memory'.$key_idx.'|Value', $key_def['data']); - psetting('memory'.$key_idx.'|DKtype', subStr($key_def['function'],1)); - - # for BLF - if (subStr($key_def['function'],1) == 16 ) { - psetting('memory'.$key_idx.'|type', 'blf'); - psetting('memory'.$key_idx.'|PickupValue', '*81*'.$key_def['data']); - } - } - - # Keys on Expansion Modul - if ($key_idx >= 100 ) { - $key_tmp = (int)lTrim(subStr($key_idx,1),'0'); - psetting('Key'.$key_tmp.'|path', '/yealink/config/vpPhone/Ext38_0000000000000'.subStr($key_idx,0,1).'.cfg'); - psetting('Key'.$key_tmp.'|Line', '0'); - psetting('Key'.$key_tmp.'|Value', $key_def['data']); - psetting('Key'.$key_tmp.'|DKtype', subStr($key_def['function'],1)); - - # for BLF - if (subStr($key_def['function'],1) == 16 ) { - psetting('Key'.$key_tmp.'|type', 'blf'); - psetting('Key'.$key_tmp.'|PickupValue', '*81*'.$key_def['data']); - } - } - } - } - - # XML Browser for Phonebook on Line Key 2 - psetting('memory12|path', '/yealink/config/vpPhone/vpPhone.ini'); - psetting('memory12|Value', $prov_url_yealink.'pb.php?u='.$user_ext); - psetting('memory12|DKtype', '27'); - psetting('memory12|PickupValue', __('Tel.buch')); - psetting('memory12|Label', __('Tel.buch')); - - # XML Browser for Dial-Log on Line Key 3 - psetting('memory13|path', '/yealink/config/vpPhone/vpPhone.ini'); - psetting('memory13|Value', $prov_url_yealink.'dial-log.php?u='.$user_ext); - psetting('memory13|DKtype', '27'); - psetting('memory13|PickupValue', __('Anruf Listen')); - psetting('memory13|Label', __('Anruf Listen')); - -} - -?> \ No newline at end of file diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 6dde6d673..05d2d748d 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -127,7 +127,6 @@ function gs_get_conf( $key, $default=null ) return @defined($key) ? constant($key) : $default; } - $conf = '/etc/gemeinschaft/gemeinschaft.php'; if (! file_exists( $conf )) { trigger_error( "Config file \"$conf\" not found!\n", E_USER_ERROR ); @@ -140,7 +139,6 @@ function gs_get_conf( $key, $default=null ) } } - function _gscnf( $param, $default=null ) { if (@array_key_exists($param, $GLOBALS)) { @@ -332,6 +330,16 @@ function _gscnf( $param, $default=null ) _gscnf( 'TIPTEL_PROV_FW_DEFAULT_IP286' , null ); _gscnf( 'TIPTEL_PROV_KEY_BLACKLIST' , '' ); +_gscnf( 'YEALINK_PROV_ENABLED' , false ); +_gscnf( 'YEALINK_PROV_HTTP_PASS' , '' ); +_gscnf( 'YEALINK_PROV_NTP' , gs_get_conf('GS_PROV_HOST','') ); +_gscnf( 'YEALINK_PROV_FW_UPDATE' , false ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP28XS', null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP280' , null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); +_gscnf( 'YEALINK_PROV_KEY_BLACKLIST' , '' ); + _gscnf( 'CANONIZE_OUTBOUND' , true ); _gscnf( 'CANONIZE_INTL_PREFIX' , '00' ); _gscnf( 'CANONIZE_COUNTRY_CODE' , '49' ); diff --git a/opt/gemeinschaft/inc/gs-fns/gs_prov_params_get.php b/opt/gemeinschaft/inc/gs-fns/gs_prov_params_get.php index d9a65fddd..4e310f7bd 100644 --- a/opt/gemeinschaft/inc/gs-fns/gs_prov_params_get.php +++ b/opt/gemeinschaft/inc/gs-fns/gs_prov_params_get.php @@ -70,8 +70,7 @@ function gs_prov_params_get( $username, $phone_type ) if (! is_array($path)) return new GsError( 'DB error.' ); foreach ($path as $group) { - if ($group['prov_param_profile_id'] > 0) { - + if ($group['prov_param_profile_id'] > 0) { //echo 'Get group\'s prov param profile, id '. $group['prov_param_profile_id'] ."\n"; $rs = $db->execute( 'SELECT `param`, `index`, `value` '. @@ -90,7 +89,31 @@ function gs_prov_params_get( $username, $phone_type ) } } } - + + # get keys for phonetype + if($user['group_id'] < 1) { + $mptt = new YADB_MPTT($db, 'user_groups', 'lft', 'rgt', 'title'); + $group = $mptt->_db_query( 'SELECT * FROM user_groups WHERE `title`=\''. $db->escape($phone_type) .'\'' ); + if (! $group) + return new GsError( 'DB error.' ); + if ($group['prov_param_profile_id'] > 0) { + //echo 'Get group\'s prov param profile, id '. $group['prov_param_profile_id'] ."\n"; + $rs = $db->execute( + 'SELECT `param`, `index`, `value` '. + 'FROM `prov_params` '. + 'WHERE '. + '`profile_id`='. $group['prov_param_profile_id'] .' AND '. + '`phone_type`=\''. $db->escape($phone_type) .'\' '. + 'ORDER BY `param`, `index`' ); + while ($r = $rs->fetchRow()) { + $r['_set_by'] = 'g'; + $r['_setter'] = $user['group_id']; + + $params[$r['param']][$r['index']] = $r['value']; + } + } + } + return $params; } From 30f4fb5da4809c6db2d3378280feffd5fbd26a3d Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:24:16 +0100 Subject: [PATCH 04/42] yealink changes --- etc/asterisk/asterisk.conf | 2 +- etc/gemeinschaft/gemeinschaft.php | 8 ++++---- .../htdocs/gui/mod/prov_phones.php | 4 +++- .../lib/utf8-normalize/gs_utf_normal.php | 19 +++++++++---------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/etc/asterisk/asterisk.conf b/etc/asterisk/asterisk.conf index 33fe71975..391c7f148 100644 --- a/etc/asterisk/asterisk.conf +++ b/etc/asterisk/asterisk.conf @@ -32,7 +32,7 @@ astetcdir => /opt/gemeinschaft/etc/asterisk astmoddir => /usr/lib/asterisk/modules astvarlibdir => /var/lib/asterisk -astdatadir => /var/lib/asterisk +astdatadir => /usr/share/asterisk astagidir => /var/lib/asterisk/agi-bin astspooldir => /var/spool/asterisk astrundir => /var/run/asterisk diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index 870bd5540..c7ffadcb6 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -58,16 +58,16 @@ //----------------------[ Master ]----------------------// -$DB_MASTER_HOST = '127.0.0.1'; +$DB_MASTER_HOST = '192.168.1.130'; $DB_MASTER_USER = 'gemeinschaft'; -$DB_MASTER_PWD = '9ad951b941bb68cf6b4625f44c1a40'; +$DB_MASTER_PWD = ''; $DB_MASTER_DB = 'asterisk'; //----------------------[ Slave ]-----------------------// $DB_SLAVE_HOST = '127.0.0.1'; $DB_SLAVE_USER = 'gemeinschaft'; -$DB_SLAVE_PWD = '9ad951b941bb68cf6b4625f44c1a40'; +$DB_SLAVE_PWD = ''; $DB_SLAVE_DB = 'asterisk'; //--------------------[ CDR Master ]--------------------// @@ -224,7 +224,7 @@ * PROVISIONING ***********************************************************/ -$PROV_HOST = '192.168.178.22'; +$PROV_HOST = '192.168.1.130'; //$PROV_PORT = 0; # 0 for default port for $PROV_SCHEME //$PROV_SCHEME = 'http'; # without "://" $PROV_PATH = '/gemeinschaft/prov/'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php index 7e97753c0..cbcf3fdfe 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php @@ -99,8 +99,10 @@ function _mac_addr_display( $mac ) $phone_types['tiptel-ip280' ] = 'Tiptel IP 280'; $phone_types['tiptel-ip284' ] = 'Tiptel IP 284'; $phone_types['tiptel-ip286' ] = 'Tiptel IP 286'; +} +if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { $phone_types['yealink-sip-t46G' ] = 'Yealink SIP T46G'; - $phone_types['yealink-sip-t48G' ] = 'Yealink SIP T48G'; + $phone_types['yealink-sip-t48G' ] = 'Yealink SIP T48G'; } if (gs_get_conf('GS_POLYCOM_PROV_ENABLED')) { $phone_types['polycom-spip-300'] = 'Polycom SoundPoint IP 300'; diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index 9588b678d..002ab1502 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -61,16 +61,15 @@ function hexUnicodeToUtf8( $hexcp ) # style \uXXXX sequences function utf8_to_unicode_uhex( $str ) { - return $str; - //return preg_replace( - // '/[\x{00}-\x{1F}\x{7F}-\x{7FFFFFFF}]/uSe', - // 'sPrintF("\\u%04x", utf8ToCodepoint("$0"))', - // str_replace( - // array( '\\' , "\x08", "\x0C", "\n" , "\r" , "\t" ), - // array( '\\\\', '\\b' , '\\f' , '\\n', '\\r', '\\t' ), - // $str - // ) - // ); + return preg_replace( + '/[\x{00}-\x{1F}\x{7F}-\x{7FFFFFFF}]/uSe', + 'sPrintF("\\u%04x", utf8ToCodepoint("$0"))', + str_replace( + array( '\\' , "\x08", "\x0C", "\n" , "\r" , "\t" ), + array( '\\\\', '\\b' , '\\f' , '\\n', '\\r', '\\t' ), + $str + ) + ); } # quotes a string according to RFC 4627 (JSON) From fe88c3a67effae27963f0803ad728efdadcec63a Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:24:54 +0100 Subject: [PATCH 05/42] yealink changes --- opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index 002ab1502..db8921858 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -112,4 +112,4 @@ function _gs_utf8_get_map() } -?> + From a27c5861926936c4ec14fe8b6201f972c60f2e14 Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:25:19 +0100 Subject: [PATCH 06/42] yealink changes --- opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php | 1 - 1 file changed, 1 deletion(-) diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index db8921858..a787f4306 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -112,4 +112,3 @@ function _gs_utf8_get_map() } - From d22b6c9595dd29f7f19fbfa5ae3a34a96db576d9 Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:25:55 +0100 Subject: [PATCH 07/42] yealink changes --- opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index a787f4306..002ab1502 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -112,3 +112,4 @@ function _gs_utf8_get_map() } +?> From e68ae19131521aea9e5e277b84a918127202fe82 Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:26:21 +0100 Subject: [PATCH 08/42] yealink changes --- opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index 002ab1502..db8921858 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -112,4 +112,4 @@ function _gs_utf8_get_map() } -?> + From f965fb0563a55aa1dc1eb5223f317d7fc546205c Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:26:47 +0100 Subject: [PATCH 09/42] yealink changes --- opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index db8921858..002ab1502 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -112,4 +112,4 @@ function _gs_utf8_get_map() } - +?> From 2b174e3f43f3a84356f457795c5d87b780f66c5f Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:35:52 +0100 Subject: [PATCH 10/42] yealink cleanup --- etc/gemeinschaft/gemeinschaft.php | 5 +++-- opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php | 4 +++- opt/gemeinschaft/inc/conf.php | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index c7ffadcb6..d456d0d04 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -275,6 +275,7 @@ //$PROV_MODELS_ENABLED_AASTRA = '*'; # or '51i,53i,55i,57i' //$PROV_MODELS_ENABLED_GRANDSTREAM = '*'; # or 'bt110,gxp2000,gxp2020', ... //$PROV_MODELS_ENABLED_TIPTEL = '*'; # or 'ip280,ip284,ip286' +//$PROV_MODELS_ENABLED_YEALINK = '*'; # or 'yealink-sip-t46g,yealink-sip-t48g' //$PROV_MODELS_ENABLED_POLYCOM = '*'; # or 'spip-550,spip-670', ... @@ -627,7 +628,7 @@ # does not control where apache, mysql, zaptel etc. put their # lock files -$CALL_INIT_FROM_NET = '192.168.178.0/16, 172.16.0.0/12, 10.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8'; +$CALL_INIT_FROM_NET = '192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8'; # a comma (,) separated list of IP addresses or # / pairs from where calls can be inited # with HTTP GET @@ -759,7 +760,7 @@ ***********************************************************/ $LOG_TO = 'file'; # 'file'|'syslog' -$LOG_LEVEL = 'DEBUG'; # "FATAL"|"WARNING"|"NOTICE"|"DEBUG" +$LOG_LEVEL = 'NOTICE'; # "FATAL"|"WARNING"|"NOTICE"|"DEBUG" # these settings affect only file logging: //$LOG_FILE = '/var/log/gemeinschaft/gs.log'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 7dbf545f5..996ac5c93 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -113,13 +113,15 @@ $phone_types['tiptel-ip284'] = 'Tiptel IP 284'; if (in_array('*', $enabled_models) || in_array('ip286', $enabled_models)) $phone_types['tiptel-ip286'] = 'Tiptel IP 286'; +} +if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + $enabled_models = preg_split('/[,\\s]+/', gs_get_conf('GS_PROV_MODELS_ENABLED_YEALINK')); if (in_array('*', $enabled_models) || in_array('yealink-sip-t46g', $enabled_models)) $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; if (in_array('*', $enabled_models) || in_array('yealink-sip-t48g', $enabled_models)) $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; } - $key_functions_snom = array( 'none' => __('Leer'), # none 'speed' => __('externes Ziel'), # external dest. diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 05d2d748d..62eff33b8 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -243,6 +243,7 @@ function _gscnf( $param, $default=null ) _gscnf( 'PROV_MODELS_ENABLED_AASTRA' , '*' ); # / '51i,53i,55i,57i' _gscnf( 'PROV_MODELS_ENABLED_GRANDSTREAM' , '*' ); # / 'gxp2000,gxp2020'... _gscnf( 'PROV_MODELS_ENABLED_TIPTEL' , '*' ); # / 'ip280,ip284,ip286' +_gscnf( 'PROV_MODELS_ENABLED_YEALINK' , '*' ); # / 'yealink-sip-t46g,yealink-sip-t48g' _gscnf( 'PROV_MODELS_ENABLED_POLYCOM' , '*' ); # / 'spip-550,spip-670', ... _gscnf( 'SNOM_PROV_ENABLED' , false ); From 0da1ab5c18adb36dfdf757b6ad32a3b6f3c4c1a7 Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 10:39:16 +0100 Subject: [PATCH 11/42] yealink cleanup --- opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php index 13210dc8c..c876a9389 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php @@ -65,7 +65,7 @@ $phone_types['aastra-55i'] = 'Aastra 55i'; $phone_types['aastra-57i'] = 'Aastra 57i'; } -if (gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { +if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; } From 3f3ee4ddb92e35057f6f6e488b6037f33bdbd72f Mon Sep 17 00:00:00 2001 From: mirco312312 Date: Sun, 23 Nov 2014 15:01:56 +0100 Subject: [PATCH 12/42] Yealink cleanup --- .../htdocs/prov/yealink/settings.php | 349 +++++++++--------- 1 file changed, 176 insertions(+), 173 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 77fbf975a..320e374e1 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -444,69 +444,183 @@ function psetting( $param, $val='' ) $user_ext = $user['name']; } -##################################################################### -# Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) -##################################################################### +# Phonetype Check +if ( in_array($phone_type, array('yealink-sip-t46g','yealink-sip-t48g'), true) ) { -# Language -##It configures the language of the web user interface. -##Chinese_S is only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. -##Chinese_T is only applicable to SIP-T46G IP phones. -##French, Portuguese and Spanish are not applicable to SIP-T19P and SIP-T21P IP phones. -psetting('lang.wui', 'English'); -##It configures the language of the phone user interface. -##Chinese_S and Chinese_T are only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. -##The default value is English. -psetting('lang.gui', _yealink_astlang_to_yealinklang($user['language'])); - - -# Remote Phonebook -###X ranges from 1 to 5 -###remote_phonebook.data.X.url = -###remote_phonebook.data.X.name = -psetting('remote_phonebook.data.1.url', $prov_url_yealink.'pb.php?u='.$user_ext); -psetting('remote_phonebook.data.1.name', 'Tel.buch'); -###Except T41P/T42G Models -psetting('remote_phonebook.display_name', 'Tel.buch'); - -# Show Remote Phonebook on Home Screen -psetting('programablekey.2.type', '47'); -psetting('programablekey.2.line', '1'); -psetting('programablekey.2.value', ''); -psetting('programablekey.2.label', 'Tel.buch'); - -##It enables or disables the phone to perform a remote phone book search when receiving an incoming call. -##0-Disabled,1-Enabled. -##The default value is 0. -psetting('features.remote_phonebook.enable', '0'); -##It configures the interval (in seconds) for the phone to update the data of the remote phone book from the remote phone book server. -##The default value is 21600.Integer from 3600 to 2592000. -psetting('features.remote_phonebook.flash_time', '21600'); - -# Ringtone -# exp.: tftp://192.168.1.100/Ring9.wav -# http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav -#psetting('ringtone.url', 'http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav'); -#psetting('ringtone.delete', ''); -#Delete all the custom ringtones uploaded through auto provisioning -#psetting('ringtone.delete', 'http://localhost/all'); - -# Security -###Define the login username and password of the user, var and administrator. -###If you change the username of the administrator from "admin" to "admin1", your new administrator's username should be configured as: security.user_name.admin = admin1. -###If you change the password of the administrator from "admin" to "admin1pwd", your new administrator's password should be configured as: security.user_password = admin1:admin1pwd. -###The following examples change the user's username to "user23" and the user's password to "user23pwd". -###security.user_name.user = user23 -###security.user_password = user23:user23pwd -###The following examples change the var's username to "var55" and the var's password to "var55pwd". -###security.user_name.var = var55 -###security.user_password = var55:var55pwd -#psetting('security.user_name.user', ''); -#psetting('security.user_name.admin', ''); -#psetting('security.user_name.var', ''); -psetting('security.user_password', 'admin:'.gs_get_conf('GS_YEALINK_PROV_HTTP_PASS')); + ##################################################################### + # Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) + ##################################################################### + + # Language + ##It configures the language of the web user interface. + ##Chinese_S is only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. + ##Chinese_T is only applicable to SIP-T46G IP phones. + ##French, Portuguese and Spanish are not applicable to SIP-T19P and SIP-T21P IP phones. + psetting('lang.wui', 'English'); + ##It configures the language of the phone user interface. + ##Chinese_S and Chinese_T are only applicable to SIP-T19P, SIP-T21P and SIP-T46G IP phones. + ##The default value is English. + psetting('lang.gui', _yealink_astlang_to_yealinklang($user['language'])); + + + # Remote Phonebook + ###X ranges from 1 to 5 + ###remote_phonebook.data.X.url = + ###remote_phonebook.data.X.name = + psetting('remote_phonebook.data.1.url', $prov_url_yealink.'pb.php?u='.$user_ext); + psetting('remote_phonebook.data.1.name', 'Tel.buch'); + ###Except T41P/T42G Models + psetting('remote_phonebook.display_name', 'Tel.buch'); + + # Show Remote Phonebook on Home Screen + psetting('programablekey.2.type', '47'); + psetting('programablekey.2.line', '1'); + psetting('programablekey.2.value', ''); + psetting('programablekey.2.label', 'Tel.buch'); + + ##It enables or disables the phone to perform a remote phone book search when receiving an incoming call. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.remote_phonebook.enable', '0'); + ##It configures the interval (in seconds) for the phone to update the data of the remote phone book from the remote phone book server. + ##The default value is 21600.Integer from 3600 to 2592000. + psetting('features.remote_phonebook.flash_time', '21600'); + + # Ringtone + # exp.: tftp://192.168.1.100/Ring9.wav + # http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav + #psetting('ringtone.url', 'http://192.168.178.26/gemeinschaft/prov/ringtones/admin-int-fgz-tiptel.wav'); + #psetting('ringtone.delete', ''); + #Delete all the custom ringtones uploaded through auto provisioning + #psetting('ringtone.delete', 'http://localhost/all'); + + # Security + ###Define the login username and password of the user, var and administrator. + ###If you change the username of the administrator from "admin" to "admin1", your new administrator's username should be configured as: security.user_name.admin = admin1. + ###If you change the password of the administrator from "admin" to "admin1pwd", your new administrator's password should be configured as: security.user_password = admin1:admin1pwd. + ###The following examples change the user's username to "user23" and the user's password to "user23pwd". + ###security.user_name.user = user23 + ###security.user_password = user23:user23pwd + ###The following examples change the var's username to "var55" and the var's password to "var55pwd". + ###security.user_name.var = var55 + ###security.user_password = var55:var55pwd + #psetting('security.user_name.user', ''); + #psetting('security.user_name.admin', ''); + #psetting('security.user_name.var', ''); + psetting('security.user_password', 'admin:'.gs_get_conf('GS_YEALINK_PROV_HTTP_PASS')); + + + ##################################################################### + # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) + ##################################################################### + # Account1 Basic Settings + psetting('account.1.enable', '1'); # 0 = disable, 1 = enable + psetting('account.1.label', $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname']); + psetting('account.1.display_name', $user['callerid']); + psetting('account.1.auth_name', $user_ext); + psetting('account.1.user_name', $user_ext); + psetting('account.1.password', $user['secret']); + psetting('account.1.outbound_proxy_enable', '0'); # 0 = disable, 1 = enable + psetting('account.1.outbound_host', ''); + psetting('account.1.outbound_port', '5061'); + ##It configures the local SIP port for account 1. The default value is 5060. + psetting('account.1.sip_listen_port', '5060'); + ##It configures the transport type for account 1. 0-UDP,1-TCP,2-TLS,3-DNS-NAPTR + psetting('account.1.transport', '0'); ##The default value is 0. + + // # Failback + psetting('account.1.sip_server.1.address', $host); + psetting('account.1.sip_server.1.port', '5060'); + + // # Register Advanced + // ##It configures the SIP server type for account X.0-Default,2-BroadSoft,4-Cosmocom,6-UCAP + // ##The default value is 0. + psetting('account.1.sip_server_type', '0'); + + // psetting('account.1.unregister_on_reboot', ''); + // psetting('account.1.sip_trust_ctrl', ''); + // psetting('account.1.proxy_require', ''); + // psetting('account.1.srv_ttl_timer_enable', ''); + // psetting('account.1.register_mac', '1'); # 0 = disable, 1 = enable + // psetting('account.1.register_line', '1'); # 0 = disable, 1 = enable + // psetting('account.1.reg_fail_retry_interval', '30'); # 0 to 1800, default 30 + + // # NAT + // ##It enables or disables the NAT traversal for account X.0-Disabled,1-Enabled + // ##The default value is 0. + // psetting('account.1.nat.nat_traversal', ''); + // ##It configures the IP address or domain name of the STUN server for account X. + // ##The default value is blank. + // psetting('account.1.nat.stun_server', ''); + // ##It configures the port of the STUN server for account X. + // ##The default value is 3478. + // psetting('account.1.nat.stun_port', ''); + // ##It configures the type of keep-alive packets sent by the phone to the NAT device to keep the communication port open so that NAT can continue to function for account X. + // ##The default value is 1. + // psetting('account.1.nat.udp_update_enable', ''); + // ##It configures the keep-alive interval (in seconds) for account X. + // ##The default value is 30.Integer from 15 to 2147483647 + // psetting('account.1.nat.udp_update_time', ''); + // ##It enables or disables NAT Rport feature for account X.0-Disabled,1-Enabled + // ##The default value is 0. + // psetting('account.1.nat.rport', ''); + + // # Pickup + // ##It enables or disables the phone to pick up a call according to the SIP header of dialog-info for account X + // ##0-Disabled,1-Enabled. + // ##The default value is 0. + // Must be DISABLED to work on Asterisk PBX + psetting('account.1.dialoginfo_callpickup', '0'); + // ##It configures the group pickup code for account X. + // ##The default value is blank. + psetting('account.1.group_pickup_code', ''); + // ##It configures the directed pickup code for account X. + // ##The default value is blank. + psetting('account.1.direct_pickup_code', '*81*'); + + # Time + ##It configures the time zone.For more available time zones, refer to Time Zones on page 215. + ##The default value is +8. + psetting('local_time.time_zone', '+'.( ((int)date('Z')) / 3600)); + ##It configures the time zone name.For more available time zone names, refer to Time Zones on page 215. + ##The default time zone name is China(Beijing). + psetting('local_time.ntp_server1', gs_get_conf('GS_YEALINK_PROV_NTP')); + + ####################################################################################### + ## Features Pickup(Except T20P model) ## + ####################################################################################### + ##It enables or disables the phone to display the GPickup soft key when the phone is in the pre-dialing screen. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.pickup.group_pickup_enable', '0'); + + ##It configures the group call pickup code. + ##The default value is blank. + psetting('features.pickup.group_pickup_code', ''); + + ##It enables or disables the phone to display the DPickup soft key when the phone is in the pre-dialing screen. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.pickup.direct_pickup_enable', '1'); + + ##It configures the directed call pickup code. + ##The default value is blank. + psetting('features.pickup.direct_pickup_code', '*81*'); + + ##It enables or disables the phone to display a visual alert when the monitored user receives an incoming call. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.pickup.blf_visual_enable', '1'); + + ##It enables or disables the phone to play an audio alert when the monitored user receives an incoming call. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.pickup.blf_audio_enable', '0'); + + ##################################################################### + # Keys + ##################################################################### -if ( in_array($phone_type, array('yealink-sip-t46g','yealink-sip-t48g'), true) ) { $max_keys = 10; # RESET KEYS @@ -602,120 +716,9 @@ function psetting( $param, $val='' ) # TODO: Programmable Keys # TODO: Keys on Expansion Modul } - } - + } } -##################################################################### -# MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) -##################################################################### -# Account1 Basic Settings -psetting('account.1.enable', '1'); # 0 = disable, 1 = enable -psetting('account.1.label', $user_ext .' '. mb_subStr($user['firstname'],0,1) .'. '. $user['lastname']); -psetting('account.1.display_name', $user['callerid']); -psetting('account.1.auth_name', $user_ext); -psetting('account.1.user_name', $user_ext); -psetting('account.1.password', $user['secret']); -psetting('account.1.outbound_proxy_enable', '0'); # 0 = disable, 1 = enable -psetting('account.1.outbound_host', ''); -psetting('account.1.outbound_port', '5061'); -##It configures the local SIP port for account 1. The default value is 5060. -psetting('account.1.sip_listen_port', '5060'); -##It configures the transport type for account 1. 0-UDP,1-TCP,2-TLS,3-DNS-NAPTR -psetting('account.1.transport', '0'); ##The default value is 0. - -// # Failback -psetting('account.1.sip_server.1.address', $host); -psetting('account.1.sip_server.1.port', '5060'); - -// # Register Advanced -// ##It configures the SIP server type for account X.0-Default,2-BroadSoft,4-Cosmocom,6-UCAP -// ##The default value is 0. -psetting('account.1.sip_server_type', '0'); - -// psetting('account.1.unregister_on_reboot', ''); -// psetting('account.1.sip_trust_ctrl', ''); -// psetting('account.1.proxy_require', ''); -// psetting('account.1.srv_ttl_timer_enable', ''); -// psetting('account.1.register_mac', '1'); # 0 = disable, 1 = enable -// psetting('account.1.register_line', '1'); # 0 = disable, 1 = enable -// psetting('account.1.reg_fail_retry_interval', '30'); # 0 to 1800, default 30 - -// # NAT -// ##It enables or disables the NAT traversal for account X.0-Disabled,1-Enabled -// ##The default value is 0. -// psetting('account.1.nat.nat_traversal', ''); -// ##It configures the IP address or domain name of the STUN server for account X. -// ##The default value is blank. -// psetting('account.1.nat.stun_server', ''); -// ##It configures the port of the STUN server for account X. -// ##The default value is 3478. -// psetting('account.1.nat.stun_port', ''); -// ##It configures the type of keep-alive packets sent by the phone to the NAT device to keep the communication port open so that NAT can continue to function for account X. -// ##The default value is 1. -// psetting('account.1.nat.udp_update_enable', ''); -// ##It configures the keep-alive interval (in seconds) for account X. -// ##The default value is 30.Integer from 15 to 2147483647 -// psetting('account.1.nat.udp_update_time', ''); -// ##It enables or disables NAT Rport feature for account X.0-Disabled,1-Enabled -// ##The default value is 0. -// psetting('account.1.nat.rport', ''); - -// # Pickup -// ##It enables or disables the phone to pick up a call according to the SIP header of dialog-info for account X -// ##0-Disabled,1-Enabled. -// ##The default value is 0. -<<<<<<< HEAD -======= -// Must be DISABLED to work on Asterisk PBX ->>>>>>> abc790b9b6e321c242309513c3fda63ca3175a38 -psetting('account.1.dialoginfo_callpickup', '0'); -// ##It configures the group pickup code for account X. -// ##The default value is blank. -psetting('account.1.group_pickup_code', ''); -// ##It configures the directed pickup code for account X. -// ##The default value is blank. -psetting('account.1.direct_pickup_code', '*81*'); - -# Time -##It configures the time zone.For more available time zones, refer to Time Zones on page 215. -##The default value is +8. -psetting('local_time.time_zone', '+'.( ((int)date('Z')) / 3600)); -##It configures the time zone name.For more available time zone names, refer to Time Zones on page 215. -##The default time zone name is China(Beijing). -psetting('local_time.ntp_server1', gs_get_conf('GS_YEALINK_PROV_NTP')); - -####################################################################################### -## Features Pickup(Except T20P model) ## -####################################################################################### -##It enables or disables the phone to display the GPickup soft key when the phone is in the pre-dialing screen. -##0-Disabled,1-Enabled. -##The default value is 0. -psetting('features.pickup.group_pickup_enable', '0'); - -##It configures the group call pickup code. -##The default value is blank. -psetting('features.pickup.group_pickup_code', ''); - -##It enables or disables the phone to display the DPickup soft key when the phone is in the pre-dialing screen. -##0-Disabled,1-Enabled. -##The default value is 0. -psetting('features.pickup.direct_pickup_enable', '1'); - -##It configures the directed call pickup code. -##The default value is blank. -psetting('features.pickup.direct_pickup_code', '*81*'); - -##It enables or disables the phone to display a visual alert when the monitored user receives an incoming call. -##0-Disabled,1-Enabled. -##The default value is 0. -psetting('features.pickup.blf_visual_enable', '1'); - -##It enables or disables the phone to play an audio alert when the monitored user receives an incoming call. -##0-Disabled,1-Enabled. -##The default value is 0. -psetting('features.pickup.blf_audio_enable', '0'); - ##################################################################### # Override provisioning parameters (group profile) From 9220373cba19f055a2d12f770d9f037bfc692766 Mon Sep 17 00:00:00 2001 From: d-mark Date: Wed, 1 Jul 2015 12:45:16 +0200 Subject: [PATCH 13/42] Added Yealink support in checkcfg ... without phone reboot :) --- .../inc/gs-fns/gs_prov_phone_checkcfg.php | 105 +++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php b/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php index 462378d04..bf7b3df34 100644 --- a/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php +++ b/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php @@ -235,6 +235,9 @@ function _gs_prov_phone_checkcfg_by_ip_do( $ip, $reboot=true ) if (gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { _gs_prov_phone_checkcfg_by_ip_do_tiptel( $ip, $reboot ); } + if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + _gs_prov_phone_checkcfg_by_ip_do_yealink( $ip, $reboot ); + } //return $err == 0; return true; @@ -318,9 +321,69 @@ function _gs_prov_phone_checkcfg_by_ip_do_grandstream( $ip, $reboot=true ) { if (_gs_prov_phone_checkcfg_exclude_ip( $ip )) return; + $db = @gs_db_slave_connect(); + if (! $db) { + gs_log(GS_LOG_WARNING, 'Failed to connect to DB'); + return; + } + + $type = @$db->executeGetOne(' + SELECT + `p`.`type` + FROM + `users` `u` + JOIN + `phones` `p` ON (`p`.`user_id` = `u`.`id`) + WHERE + `u`.`current_ip` = \''. $db->escape($ip) .'\' + '); + + $model = strtoupper( str_replace( 'grandstream-', '', $type ) ); + + if ( preg_match('/^GXP21([0-9]{2})$/', $model) ) { + reboot_grandstream21xx( $ip, $model ); + return; + } + @ exec( '/opt/gemeinschaft/sbin/gs-grandstream-reboot --ip='. qsa($ip) .' >>/dev/null 2>>/dev/null &', $out, $err ); } +function reboot_grandstream21xx($ip_addr, $model) +{ + $socket = fsockopen("$ip_addr","23", $errno, $errstr, 1000); + if (!$socket) { + // echo "$errstr ($errno)
\n"; + exit; + } + read_up_to("Grandstream $model Command Shell Copyright 2011",$socket); + fputs($socket, "admin\r\n"); + read_up_to("$model",$socket); + fputs($socket, "reboot\r\n"); + read_up_to("Rebooting",$socket); + fputs($socket, "exit\r\n"); + read_up_to("endlessssssssss",$socket); //this is just to keep it until reboot command execute + fclose($socket); +} + +function read_up_to($string,$socket) +{ + $max_loop = 30; + $resp = ""; + while (!feof($socket)) + { + if ($max_loop<0) + break; + $max_loop--; + $resp .= fgets($socket, 10); + // echo $resp."
"; + if (strstr($resp,$string)) + { + // echo "found" . $resp . "
"; + break; + } + } +} + function _gs_prov_phone_checkcfg_by_ip_do_polycom( $ip, $reboot=true ) { if (_gs_prov_phone_checkcfg_exclude_ip( $ip )) return; @@ -372,6 +435,25 @@ function _gs_prov_phone_checkcfg_by_ip_do_tiptel( $ip, $reboot=true ) @ exec( '/opt/gemeinschaft/sbin/gs-tiptel-reboot --ip='. qsa($ip) .' >>/dev/null 2>>/dev/null &', $out, $err ); } +function _gs_prov_phone_checkcfg_by_ip_do_yealink( $ip, $reboot=true ) +{ + if (_gs_prov_phone_checkcfg_exclude_ip( $ip )) return; + + $url = 'http://' . qsa($ip) .'/servlet'; + + //open connection + $ch = curl_init(); + + //set the url, number of POST vars, POST data + curl_setopt($ch,CURLOPT_URL,$url); + curl_setopt($ch,CURLOPT_POST,3); + curl_setopt($ch,CURLOPT_POSTFIELDS,'p=settings-autop&q=write&now=true'); + + //execute post + $result = curl_exec($ch); + +} + // PRIVATE: function _gs_prov_phone_checkcfg_by_ext_do( $ext, $reboot=true ) { @@ -548,7 +630,28 @@ function _gs_prov_phone_checkcfg_by_ext_do_aastra( $ext, $reboot=true ) function _gs_prov_phone_checkcfg_by_ext_do_grandstream( $ext, $reboot=true ) { - //FIXME + $db = @gs_db_slave_connect(); + if (! $db) { + gs_log(GS_LOG_WARNING, 'Failed to connect to DB'); + return; + } + + $ip = @$db->executeGetOne( + 'SELECT + `u`.`current_ip` + FROM + `ast_sipfriends` `s` + JOIN + `users` `u` ON (`u`.`id`=`s`.`_user_id`) + WHERE `s`.`name`=\''. $db->escape($ext) .'\'' + ); + + if (! $ip || ! preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $ip)) { + gs_log(GS_LOG_WARNING, 'Bad IP'); + return; + } + + _gs_prov_phone_checkcfg_by_ip_do_grandstream( $ip, $reboot); } function _gs_prov_phone_checkcfg_by_ext_do_polycom( $ext, $reboot=true ) From 88880afabf651ff7d269a2ab358ce7c79bc2388b Mon Sep 17 00:00:00 2001 From: Dirk Markwardt Date: Fri, 31 Jul 2015 18:31:21 +0200 Subject: [PATCH 14/42] Bugfixes and further work on yealink provisioning --- .gitignore | 4 + etc/gemeinschaft/gemeinschaft.php | 4 + .../htdocs/prov/yealink/.htaccess | 11 ++- .../htdocs/prov/yealink/settings.php | 91 ++++++++++++++++++- opt/gemeinschaft/inc/conf.php | 8 +- 5 files changed, 107 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 16acc6448..59c66f8b4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ opt/gemeinschaft/etc/asterisk/extensions.ael *.pyc .gemeinschaft-version *.komodoproject + +# exclude yealink firmware directory +opt/gemeinschaft/htdocs/prov/yealink/fw + diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index d456d0d04..b3efd75ee 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -534,6 +534,10 @@ # 'f20' Private Hold # 'f27' XML Browser +$YEALINK_PROV_FW_DEFAULT_SIP_T46G = ''; +$YEALINK_PROV_FW_DEFAULT_SIP_T48G = ''; + + //-----------------------[ Polycom ]----------------------// diff --git a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess index 01f5f5eea..0577011c6 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess +++ b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess @@ -7,9 +7,16 @@ RewriteEngine on # The phone asks for - # .cfg + # C.cfg # Rewrite requests for .txt - RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + # xx.72 Firmware requests 001565xxxxxxC.cfg + RewriteRule ^(001565[0-9a-f]*)C.cfg$ settings.php?mac=$1 [L] + + + # xx.73 Firmware requests 001565xxxxxx.cfg + RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + + diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 320e374e1..926609a21 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -163,8 +163,10 @@ function _redirect_tiptel() gs_log( GS_LOG_DEBUG, "Yealink model $ua found." ); # find out the type of the phone: -if (preg_match('/SIP-(T46G|T48G)/', @$ua_parts[1], $m)) # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" +if (preg_match('/SIP-(T46G|T48G)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" $phone_model = 'SIP-'.$m[1]; + $phone_model_config = 'SIP_'.$m[1]; +} else $phone_model = 'unknown'; @@ -297,11 +299,11 @@ function psetting( $param, $val='' ) if ($fw_was_upgraded_manually) { gs_log( GS_LOG_DEBUG, "Phone $mac: Firmware was upgraded \"manually\". Not scheduling an upgrade." ); } else { - $fw_default_vers = _yealink_normalize_version(trim(gs_get_conf('GS_YEALINK_PROV_FW_DEFAULT_'.strToUpper($phone_model)))); + $fw_default_vers = _yealink_normalize_version(trim(gs_get_conf('GS_YEALINK_PROV_FW_DEFAULT_'.strToUpper($phone_model_config)))); if (in_array($fw_default_vers, array(null, false,''), true)) { gs_log( GS_LOG_DEBUG, "Phone $mac: No default firmware set in config file" ); } elseif (subStr($fw_default_vers,0,2) === '00') { - gs_log( GS_LOG_DEBUG, "Phone $mac: Bad default firmware set in config file" ); + gs_log( GS_LOG_DEBUG, "Phone $mac: Bad default firmware set in config file: $fw_default_vers" ); } else { if ($fw_vers_nrml != $fw_default_vers) { gs_log( GS_LOG_NOTICE, "Phone $mac: The Firmware version ($fw_vers_nrml) differs from the default version ($fw_default_vers), scheduling an upgrade ..." ); @@ -462,6 +464,9 @@ function psetting( $param, $val='' ) ##The default value is English. psetting('lang.gui', _yealink_astlang_to_yealinklang($user['language'])); + # Network LLDP enable (for identifying IP phone on LLDP-enabled switches) + psetting('network.lldp.enable', '1'); + psetting('network.lldp.packet_interval', '60'); # Remote Phonebook ###X ranges from 1 to 5 @@ -494,6 +499,18 @@ function psetting( $param, $val='' ) #Delete all the custom ringtones uploaded through auto provisioning #psetting('ringtone.delete', 'http://localhost/all'); + # Country Tone + # Custom,Australia,Austria, Brazil,Belgium,China, Czech,Denmark,Finland,France,Germany,Great Britain,Greece,Hungary,Lithuania,India, Italy,Japan,Mexico, New Zealand, + # Netherlands,Norway,Portugal,Spain,Switzerland,Sweden,Russia, UnitedStates, Chile,Czech ETSI + psetting('voice.tone.country', 'Germany'); + + # DND + psetting('features.dnd.enable', '0'); + psetting('features.dnd.on_code', 'dnd-on'); + psetting('features.dnd.off_code', 'dnd-off'); + + + # Security ###Define the login username and password of the user, var and administrator. ###If you change the username of the administrator from "admin" to "admin1", your new administrator's username should be configured as: security.user_name.admin = admin1. @@ -531,12 +548,69 @@ function psetting( $param, $val='' ) // # Failback psetting('account.1.sip_server.1.address', $host); psetting('account.1.sip_server.1.port', '5060'); + psetting('account.1.sip_server.1.expires', '120'); // # Register Advanced // ##It configures the SIP server type for account X.0-Default,2-BroadSoft,4-Cosmocom,6-UCAP // ##The default value is 0. psetting('account.1.sip_server_type', '0'); + psetting('voice_mail.number.1', 'voicemail'); + psetting('account.1.subscribe_mwi', '1'); + psetting('account.1.display_mwi.enable', '1'); + psetting('account.1.subscribe_mwi_to_vm', '1'); + + # Codecs + psetting('account.1.codec.1.enable', '1'); + psetting('account.1.codec.2.enable', '1'); + psetting('account.1.codec.3.enable', '1'); + psetting('account.1.codec.4.enable', '0'); + psetting('account.1.codec.5.enable', '0'); + psetting('account.1.codec.6.enable', '0'); + psetting('account.1.codec.7.enable', '0'); + psetting('account.1.codec.8.enable', '0'); + psetting('account.1.codec.9.enable', '0'); + psetting('account.1.codec.10.enable', '0'); + psetting('account.1.codec.11.enable', '0'); + + psetting('account.1.codec.1.payload_type', 'PCMA'); + psetting('account.1.codec.2.payload_type', 'PCMU'); + psetting('account.1.codec.3.payload_type', 'G722'); + psetting('account.1.codec.4.payload_type', 'G723_53'); + psetting('account.1.codec.5.payload_type', 'G723_63'); + psetting('account.1.codec.6.payload_type', 'G729'); + psetting('account.1.codec.7.payload_type', 'iLBC'); + psetting('account.1.codec.8.payload_type', 'G726-16'); + psetting('account.1.codec.9.payload_type', 'G726-24'); + psetting('account.1.codec.10.payload_type', 'G726-32'); + psetting('account.1.codec.11.payload_type', 'G726-40'); + + psetting('account.1.codec.1.priority', '1'); + psetting('account.1.codec.2.priority', '2'); + psetting('account.1.codec.3.priority', '3'); + psetting('account.1.codec.4.priority', '0'); + psetting('account.1.codec.5.priority', '0'); + psetting('account.1.codec.6.priority', '0'); + psetting('account.1.codec.7.priority', '0'); + psetting('account.1.codec.8.priority', '0'); + psetting('account.1.codec.9.priority', '0'); + psetting('account.1.codec.10.priority', '0'); + psetting('account.1.codec.11.priority', '0'); + + psetting('account.1.codec.1.rtpmap', '8'); # PCMA + psetting('account.1.codec.2.rtpmap', '0'); # PCMU + psetting('account.1.codec.3.rtpmap', '9'); # G722 + psetting('account.1.codec.4.rtpmap', '4'); # G723_53 + psetting('account.1.codec.5.rtpmap', '4'); # G723_63 + psetting('account.1.codec.6.rtpmap', '18'); # G729 + psetting('account.1.codec.7.rtpmap', '106'); # iLBC + psetting('account.1.codec.8.rtpmap', '103'); # G726-16 + psetting('account.1.codec.9.rtpmap', '104'); # G726-24 + psetting('account.1.codec.10.rtpmap', '102'); # G726-32 + psetting('account.1.codec.11.rtpmap', '105'); # G726-40 + + psetting('account.1.ptime', '20'); # 20ms + // psetting('account.1.unregister_on_reboot', ''); // psetting('account.1.sip_trust_ctrl', ''); // psetting('account.1.proxy_require', ''); @@ -581,11 +655,18 @@ function psetting( $param, $val='' ) # Time ##It configures the time zone.For more available time zones, refer to Time Zones on page 215. ##The default value is +8. - psetting('local_time.time_zone', '+'.( ((int)date('Z')) / 3600)); + psetting('local_time.time_zone', '+1'); + psetting('local_time.time_zone_name', 'Germany(Berlin)'); ##It configures the time zone name.For more available time zone names, refer to Time Zones on page 215. ##The default time zone name is China(Beijing). psetting('local_time.ntp_server1', gs_get_conf('GS_YEALINK_PROV_NTP')); - + psetting('local_time.ntp_server2', gs_get_conf('GS_YEALINK_PROV_NTP')); # override default chinese NTP server + ## NTP setting fron DHCP has high priority + psetting('local_time.manual_ntp_srv_prior','0'); + psetting('local_time.interval' , strval(rand(980,1020))); # default 1000 + psetting('local_time.time_format', '1'); + psetting('local_time.date_format', '0'); # WWW MMM DD + ####################################################################################### ## Features Pickup(Except T20P model) ## ####################################################################################### diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 62eff33b8..e87b696d1 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -335,10 +335,10 @@ function _gscnf( $param, $default=null ) _gscnf( 'YEALINK_PROV_HTTP_PASS' , '' ); _gscnf( 'YEALINK_PROV_NTP' , gs_get_conf('GS_PROV_HOST','') ); _gscnf( 'YEALINK_PROV_FW_UPDATE' , false ); -_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP28XS', null ); -_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP280' , null ); -_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); -_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46G', null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T48G' , null ); +//_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); +//_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); _gscnf( 'YEALINK_PROV_KEY_BLACKLIST' , '' ); _gscnf( 'CANONIZE_OUTBOUND' , true ); From 3f1834869183d2102ff642cf7862f8965533063b Mon Sep 17 00:00:00 2001 From: d-mark Date: Wed, 24 Feb 2016 14:44:08 +0100 Subject: [PATCH 15/42] added display of provisioned user on T46G --- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 926609a21..f74e839ac 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -6,7 +6,8 @@ * * Copyright 2010, amooma GmbH, Bachstr. 126, 56566 Neuwied, Germany, * http://www.amooma.de/ -* Sebastian Ertz +* Dirk Markwardt +* Mirco Bartels * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -509,7 +510,8 @@ function psetting( $param, $val='' ) psetting('features.dnd.on_code', 'dnd-on'); psetting('features.dnd.off_code', 'dnd-off'); - + # Display own Extension + psetting('features.show_default_account', '1'); # Security ###Define the login username and password of the user, var and administrator. @@ -665,7 +667,7 @@ function psetting( $param, $val='' ) psetting('local_time.manual_ntp_srv_prior','0'); psetting('local_time.interval' , strval(rand(980,1020))); # default 1000 psetting('local_time.time_format', '1'); - psetting('local_time.date_format', '0'); # WWW MMM DD + psetting('local_time.date_format', '5'); # 0-WWW MMM DD; 1-DD-MMM-YY; 2-YYYY-MM-DD; 3-DD/MM/YYYY; 4-MM/DD/YY; 5-DD MMM YYYY; 6-WWW DD MMM ####################################################################################### ## Features Pickup(Except T20P model) ## From 305064284f2831d3919b68a1af02896c7a144b70 Mon Sep 17 00:00:00 2001 From: d-mark Date: Wed, 24 Feb 2016 14:52:46 +0100 Subject: [PATCH 16/42] added php5-curl package in install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a84b9ad2f..ca6055486 100644 --- a/install.sh +++ b/install.sh @@ -391,7 +391,7 @@ ${APTITUDE_INSTALL} \ sipsak \ mysql-client mysql-server \ apache2 \ - php5-cli libapache2-mod-php5 php5-mysql php5-ldap \ + php5-cli libapache2-mod-php5 php5-mysql php5-ldap php5-curl \ python2.6 \ python-mysqldb \ sox libsox-fmt-all mpg123 From 2104622765e9f5cbbf33c5d7235825b58b951e58 Mon Sep 17 00:00:00 2001 From: d-mark Date: Wed, 24 Feb 2016 14:59:27 +0100 Subject: [PATCH 17/42] added DHCP Readme for Yealink provisioning --- .../htdocs/prov/yealink/readme_dhcp.txt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt diff --git a/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt b/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt new file mode 100644 index 000000000..cc520b7e7 --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt @@ -0,0 +1,24 @@ +Sample DHCP Server Config (edit IPs to fit your needs): + + + +subnet 192.168.x.0 netmask 255.255.255.0 { + range 192.168.x.100 192.168.x.150; + + # Snom-Phones, MAC starts with 00:04:13 + if binary-to-ascii(16, 32, "", substring(hardware, 0, 4)) = "1000413" { + log(info, "request from snom phone, setting proper options."); + # GS3 + option tftp-server-name "http://192.168.x.250"; + option bootfile-name "/gemeinschaft/prov/snom/settings.php?mac={mac}"; + } + + # Yealink-Phones, MAC starts with 00:15:65 + if binary-to-ascii(16, 32, "", substring(hardware, 0, 4)) = "1001565" { + log(info, "request from yealink phone, setting proper options."); + # GS3 + option tftp-server-name "http://192.168.x.250/gemeinschaft/prov/yealink/$MAC.cfg"; + } + +} + From 4f257a157879acbe3164f58fa2f5611eb3ee8542 Mon Sep 17 00:00:00 2001 From: d-mark Date: Fri, 26 Feb 2016 10:32:41 +0100 Subject: [PATCH 18/42] Added Yealink firmware folder and short Readme. --- .gitignore | 4 ++-- opt/gemeinschaft/htdocs/prov/yealink/fw/readme_firmware.txt | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/fw/readme_firmware.txt diff --git a/.gitignore b/.gitignore index 59c66f8b4..bfce84f17 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ opt/gemeinschaft/etc/asterisk/extensions.ael .gemeinschaft-version *.komodoproject -# exclude yealink firmware directory -opt/gemeinschaft/htdocs/prov/yealink/fw +# exclude yealink firmware images +opt/gemeinschaft/htdocs/prov/yealink/fw/*.rom diff --git a/opt/gemeinschaft/htdocs/prov/yealink/fw/readme_firmware.txt b/opt/gemeinschaft/htdocs/prov/yealink/fw/readme_firmware.txt new file mode 100644 index 000000000..e551a374b --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/fw/readme_firmware.txt @@ -0,0 +1,5 @@ +Place Yealink firmware images in this folder. + +Use filename format "aa.bb.cc.dd.rom", e.g. "28.80.00.95.rom" for T46G and +"35.80.00.95.rom" for T48G. + From 413564fc4bcbba8a28cf0134b01f70385600d49a Mon Sep 17 00:00:00 2001 From: Dirk Markwardt Date: Wed, 28 Dec 2016 17:51:51 +0100 Subject: [PATCH 19/42] Ringtone internal/external for Yealink --- .../dialplan-scripts/in-user-get-ringer.agi | 17 +++++++++++++++++ opt/gemeinschaft/htdocs/prov/yealink/pb.php | 4 ++++ .../htdocs/prov/yealink/settings.php | 6 +++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi index c604adf2d..42765fb36 100755 --- a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi +++ b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi @@ -208,6 +208,23 @@ elseif (strToLower(subStr($user['phone_type'],0,6)) === 'tiptel') { } } +} +elseif (strToLower(subStr($user['phone_type'],0,7)) === 'yealink') { + + $ringtones = _get_ringers( $user['id'] ); + + if (@$ringtones['internal']['file'] && @$ringtones['external']['file']) + $ringtones['external']['file'] = null; + + if (array_key_exists('bellcore', $ringtones[$source])) { + if (@$ringtones[$source]['bellcore'] == 1) exit(); + if (@$ringtones[$source]['bellcore'] != 0) { + gs_agi_set_variable( 'ringer', ('Bellcore-dr'. $ringtones[$source]['bellcore'] ) ); + } else { + gs_agi_set_variable( 'ringer', ('Bellcore-dr0') ); + } + } + } else { diff --git a/opt/gemeinschaft/htdocs/prov/yealink/pb.php b/opt/gemeinschaft/htdocs/prov/yealink/pb.php index ed933270d..3497245bf 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/pb.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/pb.php @@ -6,6 +6,10 @@ * * Copyright 2010, amooma GmbH, Bachstr. 126, 56566 Neuwied, Germany, * http://www.amooma.de/ +* Dirk Markwardt +* Mirco Bartels +* +* based on Tiptel by * Sebastian Ertz * * This program is free software; you can redistribute it and/or diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index f74e839ac..cdacb593f 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -9,6 +9,9 @@ * Dirk Markwardt * Mirco Bartels * +* based on Tiptel provisioning by +* Sebastian Ertz +* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -88,6 +91,7 @@ function _settings_err( $msg='' ) exit(1); } +// Tiptel and Yealink share OUI from MAC address. So redirect Tiptel phones to Tiptel provisioning. function _redirect_tiptel() { $prov_url_tiptel = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH.'tiptel/'.$_REQUEST['mac'].'.cfg'; @@ -145,7 +149,7 @@ function _redirect_tiptel() # HTTP_USER_AGENTs # -# yealink SIP-T46G: "Yealink SIP-T46G 28.72.0.25 00:15:65:5b:53:84" +# e.g. yealink SIP-T46G: "Yealink SIP-T46G 28.72.0.25 00:15:65:5b:53:84" # $ua = trim( @$_SERVER['HTTP_USER_AGENT'] ); $ua_parts = explode(' ', $ua); From 18699dd66abca633ddc7fc0fbbcb1415bb740397 Mon Sep 17 00:00:00 2001 From: d-mark Date: Fri, 30 Dec 2016 19:31:22 +0100 Subject: [PATCH 20/42] added support for Yealink T42G, several bugfixes --- .../htdocs/gui/mod/inc_keyprof.php | 37 ++++++++++++++----- .../htdocs/gui/mod/prov_phones.php | 5 ++- .../htdocs/gui/mod/prov_provparams.php | 1 + .../htdocs/prov/yealink/settings.php | 26 +++++++++---- opt/gemeinschaft/inc/conf.php | 3 +- .../lib/utf8-normalize/gs_utf_normal.php | 19 +++++----- 6 files changed, 62 insertions(+), 29 deletions(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 996ac5c93..92e1bc300 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -116,6 +116,8 @@ } if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { $enabled_models = preg_split('/[,\\s]+/', gs_get_conf('GS_PROV_MODELS_ENABLED_YEALINK')); + if (in_array('*', $enabled_models) || in_array('yealink-sip-t42g', $enabled_models)) + $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; if (in_array('*', $enabled_models) || in_array('yealink-sip-t46g', $enabled_models)) $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; if (in_array('*', $enabled_models) || in_array('yealink-sip-t48g', $enabled_models)) @@ -344,7 +346,8 @@ elseif (array_key_exists('tiptel-ip286', $phone_types)) $phone_type = 'tiptel-ip286'; } if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { - if (array_key_exists('yealink-sip-t46g', $phone_types)) $phone_type = 'yealink-sip-t46g'; + if (array_key_exists('yealink-sip-t42g', $phone_types)) $phone_type = 'yealink-sip-t42g'; + elseif (array_key_exists('yealink-sip-t46g', $phone_types)) $phone_type = 'yealink-sip-t46g'; elseif (array_key_exists('yealink-sip-t48g', $phone_types)) $phone_type = 'yealink-sip-t48g'; } } @@ -363,9 +366,9 @@ } elseif (in_array($phone_type, array('tiptel-ip284', 'tiptel-ip286'), true)) { $phone_layout = 'tiptel'; $key_function_none = $key_function_none_tiptel; -} elseif (in_array($phone_type, array('yealink-sip-t46g', 'yealink-sip-t48g'), true)) { +} elseif (in_array($phone_type, array('yealink-sip-t42g', 'yealink-sip-t46g', 'yealink-sip-t48g'), true)) { $phone_layout = 'yealink'; - $key_function_none = $key_function_none_tiptel; + $key_function_none = $key_function_none_yealink; } else { $phone_layout = false; $key_function_none = false; @@ -1309,12 +1312,20 @@ function gs_dlg_abort() } break; case 'yealink': - //if ($show_ext_modules >= 0) { - $key_levels = array( - 0 => array('from'=> 1, 'to'=> 10, 'shifted'=>false, - 'title'=> htmlEnt($phone_type_title)) - ); - //} + switch($phone_type) { + case 'yealink-sip-t46g': + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 27, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; + case 'yealink-sip-t48g': + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 29, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; + } if ($show_ext_modules >= 1) { $key_levels += array( 1 => array('from'=> 100, 'to'=> 118, 'shifted'=>false, @@ -1345,6 +1356,14 @@ function gs_dlg_abort() 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Spalte') .' 2') ); } + switch($phone_type) { + case 'yealink-sip-t42g': + $key_levels[0]['title']= htmlEnt($phone_type_title); + $key_levels[0]['from'] = 1; + $key_levels[0]['to' ] = 15; + break; + } + break; } diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php index cbcf3fdfe..627a68a1c 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php @@ -101,8 +101,9 @@ function _mac_addr_display( $mac ) $phone_types['tiptel-ip286' ] = 'Tiptel IP 286'; } if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { - $phone_types['yealink-sip-t46G' ] = 'Yealink SIP T46G'; - $phone_types['yealink-sip-t48G' ] = 'Yealink SIP T48G'; + $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; + $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; + $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; } if (gs_get_conf('GS_POLYCOM_PROV_ENABLED')) { $phone_types['polycom-spip-300'] = 'Polycom SoundPoint IP 300'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php index c876a9389..1e7811b3d 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php @@ -66,6 +66,7 @@ $phone_types['aastra-57i'] = 'Aastra 57i'; } if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; } diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index cdacb593f..8d993adcd 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -168,7 +168,7 @@ function _redirect_tiptel() gs_log( GS_LOG_DEBUG, "Yealink model $ua found." ); # find out the type of the phone: -if (preg_match('/SIP-(T46G|T48G)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" +if (preg_match('/SIP-(T42G|T46G|T48G)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" $phone_model = 'SIP-'.$m[1]; $phone_model_config = 'SIP_'.$m[1]; } @@ -452,7 +452,7 @@ function psetting( $param, $val='' ) } # Phonetype Check -if ( in_array($phone_type, array('yealink-sip-t46g','yealink-sip-t48g'), true) ) { +if ( in_array($phone_type, array('yealink-sip-t42g','yealink-sip-t46g','yealink-sip-t48g'), true) ) { ##################################################################### # Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) @@ -591,9 +591,9 @@ function psetting( $param, $val='' ) psetting('account.1.codec.10.payload_type', 'G726-32'); psetting('account.1.codec.11.payload_type', 'G726-40'); - psetting('account.1.codec.1.priority', '1'); - psetting('account.1.codec.2.priority', '2'); - psetting('account.1.codec.3.priority', '3'); + psetting('account.1.codec.1.priority', '2'); + psetting('account.1.codec.2.priority', '3'); + psetting('account.1.codec.3.priority', '1'); psetting('account.1.codec.4.priority', '0'); psetting('account.1.codec.5.priority', '0'); psetting('account.1.codec.6.priority', '0'); @@ -697,7 +697,7 @@ function psetting( $param, $val='' ) ##It enables or disables the phone to display a visual alert when the monitored user receives an incoming call. ##0-Disabled,1-Enabled. ##The default value is 0. - psetting('features.pickup.blf_visual_enable', '1'); + psetting('features.pickup.blf_visual_enable', '0'); ##It enables or disables the phone to play an audio alert when the monitored user receives an incoming call. ##0-Disabled,1-Enabled. @@ -708,8 +708,18 @@ function psetting( $param, $val='' ) # Keys ##################################################################### - $max_keys = 10; - + switch ($phone_type) { + case 'yealink-sip-t42g': + $max_keys=15; + break; + case 'yealink-sip-t46g': + $max_keys=27; + break; + case 'yealink-sip-t48g': + $max_keys=29; + break; + } + # RESET KEYS for ($i=1; $i <= $max_keys; $i++) { psetting('linekey.'.$i.'.line', '0'); diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index e87b696d1..e27785ea1 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -335,8 +335,9 @@ function _gscnf( $param, $default=null ) _gscnf( 'YEALINK_PROV_HTTP_PASS' , '' ); _gscnf( 'YEALINK_PROV_NTP' , gs_get_conf('GS_PROV_HOST','') ); _gscnf( 'YEALINK_PROV_FW_UPDATE' , false ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T42G', null ); _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46G', null ); -_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T48G' , null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T48G', null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); _gscnf( 'YEALINK_PROV_KEY_BLACKLIST' , '' ); diff --git a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php index 002ab1502..9588b678d 100644 --- a/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php +++ b/opt/gemeinschaft/lib/utf8-normalize/gs_utf_normal.php @@ -61,15 +61,16 @@ function hexUnicodeToUtf8( $hexcp ) # style \uXXXX sequences function utf8_to_unicode_uhex( $str ) { - return preg_replace( - '/[\x{00}-\x{1F}\x{7F}-\x{7FFFFFFF}]/uSe', - 'sPrintF("\\u%04x", utf8ToCodepoint("$0"))', - str_replace( - array( '\\' , "\x08", "\x0C", "\n" , "\r" , "\t" ), - array( '\\\\', '\\b' , '\\f' , '\\n', '\\r', '\\t' ), - $str - ) - ); + return $str; + //return preg_replace( + // '/[\x{00}-\x{1F}\x{7F}-\x{7FFFFFFF}]/uSe', + // 'sPrintF("\\u%04x", utf8ToCodepoint("$0"))', + // str_replace( + // array( '\\' , "\x08", "\x0C", "\n" , "\r" , "\t" ), + // array( '\\\\', '\\b' , '\\f' , '\\n', '\\r', '\\t' ), + // $str + // ) + // ); } # quotes a string according to RFC 4627 (JSON) From 20b8524aef225f387e447d62c02d2a0d5f8c8f53 Mon Sep 17 00:00:00 2001 From: d-mark Date: Fri, 30 Dec 2016 21:19:25 +0100 Subject: [PATCH 21/42] Yealink reprovisioning via SIP NOTIFY, handset volume --- opt/gemeinschaft/etc/asterisk/sip_notify.conf | 8 +++++++ .../htdocs/prov/yealink/settings.php | 14 +++++++++-- .../inc/gs-fns/gs_prov_phone_checkcfg.php | 24 ++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/opt/gemeinschaft/etc/asterisk/sip_notify.conf b/opt/gemeinschaft/etc/asterisk/sip_notify.conf index ab36a3b0d..ae758bc22 100644 --- a/opt/gemeinschaft/etc/asterisk/sip_notify.conf +++ b/opt/gemeinschaft/etc/asterisk/sip_notify.conf @@ -122,3 +122,11 @@ Content-Length=>0 ;Content-Length=>0 +;------------------------------- Yealink +[yealink-check-cfg] +Event=>check-sync\;reboot=false + +[yealink-check-cfg-reboot] +Event=>check-sync\;reboot=true + + diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 8d993adcd..7a7da7c4d 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -509,6 +509,13 @@ function psetting( $param, $val='' ) # Netherlands,Norway,Portugal,Spain,Switzerland,Sweden,Russia, UnitedStates, Chile,Czech ETSI psetting('voice.tone.country', 'Germany'); + # Sending volume + # integer range from -50 to 50, default is 0 + # handset is a bit quiet, so so raise it up a bit + psetting('voice.handfree_send', '0'); + psetting('voice.handset_send', '10'); + psetting('voice.headset_send', '0'); + # DND psetting('features.dnd.enable', '0'); psetting('features.dnd.on_code', 'dnd-on'); @@ -531,8 +538,11 @@ function psetting( $param, $val='' ) #psetting('security.user_name.admin', ''); #psetting('security.user_name.var', ''); psetting('security.user_password', 'admin:'.gs_get_conf('GS_YEALINK_PROV_HTTP_PASS')); - - + + # Reboot on SIP NOTIFY + # 0=reboot, if additional parameter "reboot=true" was given, 1=reboot always, 2=ignore SIP NOTIFY message + psetting(sip.notify_reboot_enable, '0'); + ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) ##################################################################### diff --git a/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php b/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php index bf7b3df34..5f5bc8f6e 100644 --- a/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php +++ b/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php @@ -439,6 +439,8 @@ function _gs_prov_phone_checkcfg_by_ip_do_yealink( $ip, $reboot=true ) { if (_gs_prov_phone_checkcfg_exclude_ip( $ip )) return; + gs_log(GS_LOG_DEBUG, "Send yealink update config \"$ip\""); + $url = 'http://' . qsa($ip) .'/servlet'; //open connection @@ -516,7 +518,9 @@ function _gs_prov_phone_checkcfg_by_ext_do( $ext, $reboot=true ) if (gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { _gs_prov_phone_checkcfg_by_ext_do_tiptel( $ext, $reboot ); } - + if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + _gs_prov_phone_checkcfg_by_ext_do_yealink( $ext, $reboot ); + } //return $err == 0; return true; } @@ -677,4 +681,22 @@ function _gs_prov_phone_checkcfg_by_ext_do_tiptel( $ext, $reboot=true ) //FIXME } +function _gs_prov_phone_checkcfg_by_ext_do_yealink( $ext, $reboot=true ) +{ + $sip_notify = $reboot ? 'yealink-check-cfg-reboot' : 'yealink-check-cfg'; + @exec( 'sudo asterisk -rx \'sip notify '. $sip_notify .' '. $ext .'\' >>/dev/null 2>>/dev/null &', $out, $err ); + + $hosts = @gs_hosts_get(false); + if (isGsError($hosts)) { + gs_log(GS_LOG_WARNING, 'Failed to get hosts - '. $hosts->getMsg()); + } elseif (! is_array($hosts)) { + gs_log(GS_LOG_WARNING, 'Failed to get hosts'); + } else { + $cmd = 'asterisk -rx \'sip notify '. $sip_notify .' '. $ext .'\''; + foreach ($hosts as $host) { + @exec( 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root '. qsa($host['host']) .' '. qsa($cmd) .' >>/dev/null 2>>/dev/null &' ); + } + } +} + ?> \ No newline at end of file From b715f4e26b99527ec2f78a4bc3b5cc9a5a968aeb Mon Sep 17 00:00:00 2001 From: d-mark Date: Sun, 1 Jan 2017 16:46:42 +0100 Subject: [PATCH 22/42] use group membership of user for dialout by IAXmodem --- etc/gemeinschaft/gemeinschaft.php | 6 +++++- opt/gemeinschaft/dialplan-scripts/out-route.agi | 13 +++++++++++++ opt/gemeinschaft/inc/conf.php | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index b3efd75ee..bab23aba2 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -493,7 +493,7 @@ //-----------------------[ Yealink ]-----------------------// -$YEALINK_PROV_ENABLED = true; # do provisioning for Tiptel? +$YEALINK_PROV_ENABLED = true; # do provisioning for Yealink? $YEALINK_PROV_HTTP_PASS = 'admin'; # e.g. "gEheiM23y89sdo23", default: 'admin' # to password protect the phone's web gui. @@ -534,6 +534,7 @@ # 'f20' Private Hold # 'f27' XML Browser +$YEALINK_PROV_FW_DEFAULT_SIP_T42G = ''; $YEALINK_PROV_FW_DEFAULT_SIP_T46G = ''; $YEALINK_PROV_FW_DEFAULT_SIP_T48G = ''; @@ -724,6 +725,9 @@ //$FAX_INIT_DOCDIR = '/tmp/'; # directory containing fax documents to be used by "send-fax.php" +//$FAX_MAP_IAXMODEM_USER = ""; + # use group membership of user for dialout by IAXmodem + /*********************************************************** * BRANCH OFFICE INTEGRATION (BOI) ***********************************************************/ diff --git a/opt/gemeinschaft/dialplan-scripts/out-route.agi b/opt/gemeinschaft/dialplan-scripts/out-route.agi index c2ed28fc4..dacae1736 100755 --- a/opt/gemeinschaft/dialplan-scripts/out-route.agi +++ b/opt/gemeinschaft/dialplan-scripts/out-route.agi @@ -70,6 +70,19 @@ $user_id = (int)trim($argv[4]); include_once( GS_DIR .'inc/db_connect.php' ); +// Map user for use by IAXmodem if configured +if ($argv[4] == 'IAXmodem') { + # use map user from gemeinschaft.php + + $db = gs_db_slave_connect(); + if (! $db) gs_agi_err( 'DB error' ); + + $user_id = (int)$db->executeGetOne( 'SELECT `id` FROM `users` WHERE `user`=\''. $db->escape(gs_get_conf('GS_FAX_MAP_IAXMODEM_USER')) .'\'' ); + if ($user_id < 1) $user_id=0; +} +else { + $user_id = (int)trim($argv[4]); +} $qualify_cid = true; diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index e27785ea1..7b18b3ae0 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -408,6 +408,7 @@ function _gscnf( $param, $default=null ) _gscnf( 'FAX_HYLAFAX_PASS' , '' ); _gscnf( 'FAX_HYLAFAX_PATH' , '/var/spool/hylafax/' ); _gscnf( 'FAX_INIT_DOCDIR' , '/tmp/' ); +_gscnf( 'FAX_MAP_IAXMODEM_USER' , '' ); _gscnf( 'BOI_ENABLED' , false ); From 1688614a7934ac4ce9dbb7ab11eab998c7ecfb9f Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 31 Jan 2017 17:43:54 +0100 Subject: [PATCH 23/42] added phonebooks to Yealink provisioning, search on phone works best --- .../htdocs/prov/yealink/.htaccess | 10 +- opt/gemeinschaft/htdocs/prov/yealink/pb.php | 330 ------------------ .../htdocs/prov/yealink/pb_on_phone.php | 183 ++++++++++ .../htdocs/prov/yealink/settings.php | 57 ++- 4 files changed, 240 insertions(+), 340 deletions(-) delete mode 100644 opt/gemeinschaft/htdocs/prov/yealink/pb.php create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/pb_on_phone.php diff --git a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess index 0577011c6..c66e2eaec 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess +++ b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess @@ -1,7 +1,7 @@ # Gemeinschaft # $Revision: 1 $ -# Provisioning for Tiptel *requires* mod_rewrite in order to work! +# Provisioning for Tiptel / Yealink *requires* mod_rewrite in order to work! RewriteEngine on @@ -13,10 +13,10 @@ # xx.72 Firmware requests 001565xxxxxxC.cfg RewriteRule ^(001565[0-9a-f]*)C.cfg$ settings.php?mac=$1 [L] + # xx.73 Firmware requests 001565xxxxxx.cfg + RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] - # xx.73 Firmware requests 001565xxxxxx.cfg - RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] - - + # PB + # RewriteRule ^pb.([0-9]*).(imported|prv|gs).([0-9]*).xml$ pb.php?u=$1&t=$2&p=$3 [L] diff --git a/opt/gemeinschaft/htdocs/prov/yealink/pb.php b/opt/gemeinschaft/htdocs/prov/yealink/pb.php deleted file mode 100644 index 3497245bf..000000000 --- a/opt/gemeinschaft/htdocs/prov/yealink/pb.php +++ /dev/null @@ -1,330 +0,0 @@ - -* Mirco Bartels -* -* based on Tiptel by -* Sebastian Ertz -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301, USA. -\*******************************************************************/ - -define( 'GS_VALID', true ); /// this is a parent file -require_once( dirName(__FILE__) .'/../../../inc/conf.php' ); -include_once( GS_DIR .'inc/db_connect.php' ); -include_once( GS_DIR .'inc/gettext.php' ); -include_once( GS_DIR .'inc/string.php' ); -include_once( GS_DIR .'inc/group-fns.php' ); - -header( 'Content-Type: application/xml; charset=utf-8' ); -header( 'Expires: 0' ); -header( 'Pragma: no-cache' ); -header( 'Cache-Control: private, no-cache, must-revalidate' ); -header( 'Vary: *' ); - -function yealinkXmlEsc( $str ) -{ - return htmlEnt( $str ); -} - -function _ob_send() -{ - if (! headers_sent()) { - header( 'Content-Type: application/xml; charset=utf-8' ); - header( 'Content-Length: '. (int)@ob_get_length() ); - } - @ob_end_flush(); - die(); -} - -function _err( $msg='' ) -{ - @ob_end_clean(); - ob_start(); - echo - '', "\n", - '', "\n", - '', yealinkXmlEsc(__('Fehler')), '', "\n", - '', yealinkXmlEsc( __('Fehler') .': '. $msg ), '', "\n", - '', "\n"; - _ob_send(); -} - -function getUserID( $ext ) -{ - global $db; - - if (! preg_match('/^\d+$/', $ext)) - _err( 'Invalid username' ); - - $user_id = (int)$db->executeGetOne( 'SELECT `_user_id` FROM `ast_sipfriends` WHERE `name`=\''. $db->escape($ext) .'\'' ); - if ($user_id < 1) - _err( 'Unknown user' ); - return $user_id; -} - - -if (! gs_get_conf('GS_TIPTEL_PROV_ENABLED')) { - gs_log( GS_LOG_DEBUG, "Yealink provisioning not enabled" ); - _err( 'Not enabled' ); -} - -$type = trim( @$_REQUEST['t'] ); -if (! in_array( $type, array('gs','prv','imported'), true )) { - $type = false; -} -$page = (int)trim( @$_REQUEST['p'] ); -$search = (int)trim( @$_REQUEST['s'] ); -$query = trim( @$_REQUEST['q'] ); - - -$per_page = 10; -$db = gs_db_slave_connect(); - - -/* -$typeToTitle = array( - 'imported' => "Firma (aus LDAP)", - 'gs' => "Firma", # should normally be "Gemeinschaft" - 'prv' => "Pers\xC3\xB6nlich", -); -*/ -$tmp = array( - 15=>array( - 'k' => 'gs' , - 'v' => gs_get_conf('GS_PB_INTERNAL_TITLE', __("Intern")) ), - 25=>array( - 'k' => 'prv', - 'v' => gs_get_conf('GS_PB_PRIVATE_TITLE' , __("Pers\xC3\xB6nlich")) ) -); -if (gs_get_conf('GS_PB_IMPORTED_ENABLED')) { - $pos = (int)gs_get_conf('GS_PB_IMPORTED_ORDER', 9) * 10; - $tmp[$pos] = array( - 'k' => 'imported', - 'v' => gs_get_conf('GS_PB_IMPORTED_TITLE', __("Extern")) - ); -} -kSort($tmp); -foreach ($tmp as $arr) { - $typeToTitle[$arr['k']] = $arr['v']; -} - - -$url_yealink_pb = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH .'yealink/pb.php'; - - - -#################################### SEARCH SCREEN { -if ($search === 1) { - - $user = trim( @$_REQUEST['u'] ); - $user_id = getUserID( $user ); - - ob_start(); - - echo '',"\n"; - echo - '', "\n", - '', yealinkXmlEsc(__('Suchen')), '', "\n", - '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type) ,'', "\n", - '', "\n", - '', yealinkXmlEsc(__('Suche nach')), '', "\n", - 'q',"\n", - '', "\n", - '', "\n"; - - _ob_send(); -} -#################################### SEARCH SCREEN } - - - -#################################### INITIAL SCREEN { -if (! $type) { - - $user = trim( @$_REQUEST['u'] ); - $user_id = getUserID( $user ); - - $user_groups = gs_group_members_groups_get(array($user_id), 'user'); - $permission_groups = gs_group_permissions_get($user_groups, 'phonebook_user'); - $group_members = gs_group_members_get($permission_groups); - - ob_start(); - echo - '', "\n", - '', "\n", - '', yealinkXmlEsc(__('Telefonbuch')) ,'', "\n\n"; - foreach ($typeToTitle as $t => $title) { - $cq = 'SELECT COUNT(*) FROM '; - switch ($t) { - case 'gs' : $cq .= '`users` WHERE `id` IN ('.implode(',',$group_members).') AND `id`!='.$user_id; break; - case 'imported': $cq .= '`pb_ldap`' ; break; - case 'prv' : $cq .= '`pb_prv` WHERE `user_id`='. $user_id ; break; - default : $cq = false; - } - $c = $cq ? (' ('. (int)@$db->executeGetOne( $cq ) .')') : ''; - echo - '', "\n", - '', yealinkXmlEsc($title), $c, '', "\n", - '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$t), '', "\n", - '', "\n\n"; - } - echo '', "\n"; - _ob_send(); - -} -#################################### INITIAL SCREEN } - - - -#################################### PHONEBOOK { -if ($type === 'gs') { - - $user = trim( @ $_REQUEST['u'] ); - $user_id = getUserID( $user ); - - $user_groups = gs_group_members_groups_get(array($user_id), 'user'); - $permission_groups = gs_group_permissions_get($user_groups, 'phonebook_user'); - $group_members = gs_group_members_get($permission_groups); - - $where = ''; - if (strLen($query) > 0) - $where = 'AND (`u`.`lastname` LIKE \'%'. $query .'%\' OR `u`.`firstname` LIKE \'%'. $query .'%\')'; - - $query = -'SELECT SQL_CALC_FOUND_ROWS `u`.`lastname` `ln`, `u`.`firstname` `fn`, `s`.`name` `ext` -FROM - `users` `u` JOIN - `ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`) -WHERE - `u`.`id` IN ('.implode(',',$group_members).') AND - `u`.`id`!='.$user_id.' - '. ($where ? $where : '') .' -ORDER BY `u`.`lastname`, `u`.`firstname` -LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; - -} -elseif ($type === 'prv') { - - $user = trim( @ $_REQUEST['u'] ); - $user_id = getUserID( $user ); - - $where = ''; - if (strLen($query) > 0) - $where = 'AND (`pb`.`lastname` LIKE \'%'. $query .'%\' OR `pb`.`firstname` LIKE \'%'. $query .'%\')'; - - $query = -'SELECT SQL_CALC_FOUND_ROWS `pb`.`lastname` `ln`, `pb`.`firstname` `fn`, `pb`.`number` `ext` -FROM `pb_prv` `pb` -WHERE - `pb`.`user_id`='.$user_id.' - '. ($where ? $where : '') .' -ORDER BY `pb`.`lastname`, `pb`.`firstname` -LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; - -} -elseif ($type === 'imported') { - - $query = -'SELECT SQL_CALC_FOUND_ROWS `lastname` `ln`, `firstname` `fn`, `number` `ext` -FROM `pb_ldap` -ORDER BY `lastname`, `firstname` -LIMIT '. ($page * (int)$per_page) .','. (int)$per_page; - -} - -if (in_array( $type, array('gs','prv','imported'), true )) { - ob_start(); - echo '',"\n"; - - $rs = $db->execute($query); - $num_total = @$db->numFoundRows(); - $num_pages = ceil($num_total / $per_page); - - $page_title = $typeToTitle[$type]; - if ($num_pages > 1) $page_title.= ' '.($page+1).'/'.$num_pages; - - if ( $rs && $rs->numRows() !== 0 ) { - - echo - '', "\n", - '', yealinkXmlEsc( $page_title ), '', "\n"; - while ($r = $rs->fetchRow()) { - $name = $r['ln'] .( strLen($r['fn'])>0 ? (', '.$r['fn']) : '' ); - $number = $r['ext']; - echo - '', - '', yealinkXmlEsc( $name ) ,' (', yealinkXmlEsc( $number ) ,')', - '', $number ,'', - '', "\n"; - } - echo "\n"; - - echo - '', "\n", - '', yealinkXmlEsc(__("Zur\xC3\xBCck")), '', "\n", - 'SoftKey:Exit', "\n", - '', "\n"; - - echo '', "\n"; - if($page > 0) { - echo '', yealinkXmlEsc('<< '.$page), '', "\n"; - echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&p='.($page-1)), '', "\n"; - } else { - echo '', yealinkXmlEsc(__('Suchen')), '', "\n"; - echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&s=1'), '', "\n"; - } - echo '', "\n"; - - echo '', "\n"; - if($page < $num_pages-1 ) { - echo '', yealinkXmlEsc(($page+2).' >>'), '', "\n"; - echo '', yealinkXmlEsc($url_yealink_pb.'?u='.$user.'&t='.$type.'&p='.($page+1)), '', "\n"; - } else { - echo '', "\n"; - echo '', "\n"; - } - echo '', "\n"; - - echo - '', "\n", - '', yealinkXmlEsc(__("W\xC3\xA4hlen")), '', "\n", - 'SoftKey:Dial', "\n", - '', "\n"; - - echo '', "\n"; - - } else { - - echo - '', "\n", - '', yealinkXmlEsc( $typeToTitle[$type] ), '', "\n", - '', yealinkXmlEsc( __("Dieses Telefonbuch enth\xC3\xA4lt keine Eintr\xC3\xA4ge.") ), '', "\n", - '', "\n"; - - } - _ob_send(); -} -#################################### PHONEBOOK } - - -?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/yealink/pb_on_phone.php b/opt/gemeinschaft/htdocs/prov/yealink/pb_on_phone.php new file mode 100644 index 000000000..4db131806 --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/pb_on_phone.php @@ -0,0 +1,183 @@ + +* +* based on Tiptel by +* Sebastian Ertz +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +\*******************************************************************/ + +define( 'GS_VALID', true ); /// this is a parent file + +require_once( dirName(__FILE__) .'/../../../inc/conf.php' ); +//require_once( GS_DIR .'inc/util.php' ); +//require_once( GS_DIR .'inc/gs-lib.php' ); +require_once( GS_DIR .'inc/prov-fns.php' ); +set_error_handler('err_handler_die_on_err'); +require_once( GS_DIR .'inc/string.php' ); +require_once( GS_DIR .'inc/db_connect.php' ); +include_once( GS_DIR .'inc/group-fns.php' ); + +header( 'Expires: 0' ); +header( 'Pragma: no-cache' ); +header( 'Cache-Control: private, no-cache, must-revalidate' ); +header( 'Vary: *' ); + + +function yealinkXmlEsc( $str ) +{ + return htmlEnt( $str ); +} + +function _err( $msg='' ) +{ + @ob_end_clean(); + @ob_start(); + echo '',"\n"; + if (! headers_sent()) { + header( 'Content-Type: text/plain; charset=utf-8' ); + header( 'Content-Length: '. (int)@ob_get_length() ); + } + @ob_end_flush(); + exit(1); +} + +function getUserID( $ext ) +{ + global $db; + + if (! preg_match('/^\d+$/', $ext)) + _err( 'Invalid username' ); + + $user_id = (int)$db->executeGetOne( 'SELECT `_user_id` FROM `ast_sipfriends` WHERE `name`=\''. $db->escape($ext) .'\'' ); + if ($user_id < 1) + _err( 'Unknown user' ); + return $user_id; +} + +if (! gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + gs_log( GS_LOG_DEBUG, "Yealink provisioning not enabled" ); + _err( 'Not enabled' ); +} + + +$type = trim( @$_REQUEST['t'] ); +if (! in_array( $type, array('gs','prv','imported'), true )) { + _err( 'Not allowed' ); +} + + +$mac = strToUpper(trim( @$_REQUEST['m'] )); + +//FIXME - we need authentication here + +$requester = gs_prov_check_trust_requester(); +if (! $requester['allowed']) { + _err( 'No! See log for details.' ); +} + +# connect to db +$db = gs_db_slave_connect(); +if (! $db) { + gs_log( GS_LOG_WARNING, "Phone with MAC \"$mac\" (Yealink) ask for phonebook - Could not connect to DB" ); + _err( 'No! See log for details.' ); +} + + +# get user_id +$user = trim( @$_REQUEST['u'] ); +$user_id = getUserID( $user ); + + +if ($type === 'gs') { # INTERNAL phonebook + $user_groups = gs_group_members_groups_get(array($user_id), 'user'); + $permission_groups = gs_group_permissions_get($user_groups, 'phonebook_user'); + $group_members = gs_group_members_get($permission_groups); + + $pb = array( + 'type' => 'gs', + 'title' => gs_get_conf('GS_PB_INTERNAL_TITLE', __("Intern")), + 'query' => 'SELECT `u`.`lastname` `ln`, `u`.`firstname` `fn`, `s`.`name` `ext` + FROM + `users` `u` JOIN + `ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`) + WHERE + `u`.`id` IN ('.implode(',', $group_members).') AND + `u`.`id`!='.$user_id.' + ORDER BY `u`.`lastname`, `u`.`firstname`' + ); +} +elseif ($type ==='prv') { # PRIVATE phonebook + $pb = array( + 'type' => 'prv', + 'title' => gs_get_conf('GS_PB_PRIVATE_TITLE', __("Pers\xC3\xB6nlich")), + 'query' => 'SELECT `pb`.`lastname` `ln`, `pb`.`firstname` `fn`, `pb`.`number` `ext` + FROM + `pb_prv` `pb` + WHERE `pb`.`user_id`='.$user_id.' + ORDER BY `pb`.`lastname`, `pb`.`firstname`' + ); +} +elseif ($type === 'imported') { # IMPORTED phonebook + if (! gs_get_conf('GS_PB_IMPORTED_ENABLED')) + _err( 'Not allowed' ); + + $pb = array( + 'type' => 'imported', + 'title' => gs_get_conf('GS_PB_IMPORTED_TITLE', __("Extern")), + 'query' => 'SELECT `lastname` `ln`, `firstname` `fn`, `number` `ext` + FROM `pb_ldap` + ORDER BY `lastname`, `firstname`' + ); +} + + +ob_start(); + +echo '' ,"\n"; +echo '' ,"\n"; + +$rs = $db->execute( $pb['query'] ); + +if ( $rs && $rs->numRows() !== 0 ) { + while ($r = $rs->fetchRow()) { + $lastname = $r['ln']; + $firstname = $r['fn']; + $number = $r['ext']; + + echo '' , + ''. yealinkXmlEsc($lastname) .', '. yealinkXmlEsc($firstname) . '', + ''. yealinkXmlEsc($number). "", + '' ,"\n"; + } +} + +echo '' ,"\n"; + +if (! headers_sent()) { + header( 'Content-Type: application/xml' ); + header( 'Content-Length: '. (int)@ob_get_length() ); +} +@ob_end_flush(); + +?> diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 7a7da7c4d..ac59ac8bb 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -477,11 +477,41 @@ function psetting( $param, $val='' ) ###X ranges from 1 to 5 ###remote_phonebook.data.X.url = ###remote_phonebook.data.X.name = - psetting('remote_phonebook.data.1.url', $prov_url_yealink.'pb.php?u='.$user_ext); - psetting('remote_phonebook.data.1.name', 'Tel.buch'); + + $i=1; + # Intern + psetting('remote_phonebook.data.'.$i.'.url', $prov_url_yealink.'pb_on_phone.php?u='.$user_ext.'&t=gs'); + psetting('remote_phonebook.data.'.$i.'.name', 'Intern'); + $i++; + + if (gs_get_conf('GS_PB_IMPORTED_ENABLED')) { + # Firma + psetting('remote_phonebook.data.'.$i.'.url', $prov_url_yealink.'pb_on_phone.php?u='.$user_ext.'&t=imported'); + psetting('remote_phonebook.data.'.$i.'.name', 'Firma'); + $i++; + }; + + # Personal + psetting('remote_phonebook.data.'.$i.'.url', $prov_url_yealink.'pb_on_phone.php?u='.$user_ext.'&t=prv'); + psetting('remote_phonebook.data.'.$i.'.name', 'Persönlich'); + $i++; + + # empty 4 and 5 + psetting('remote_phonebook.data.'.$i.'.url', ''); + psetting('remote_phonebook.data.'.$i.'.name', ''); + $i++; + + psetting('remote_phonebook.data.'.$i.'.url', ''); + psetting('remote_phonebook.data.'.$i.'.name', ''); + ###Except T41P/T42G Models - psetting('remote_phonebook.display_name', 'Tel.buch'); + psetting('remote_phonebook.display_name', 'Telefonbuch'); + ###Super Search recommended by Yealink support + psetting('remote_phonebook.super_search.enable', '1'); + psetting('directory.search_type', '1'); + + # Show Remote Phonebook on Home Screen psetting('programablekey.2.type', '47'); psetting('programablekey.2.line', '1'); @@ -491,10 +521,14 @@ function psetting( $param, $val='' ) ##It enables or disables the phone to perform a remote phone book search when receiving an incoming call. ##0-Disabled,1-Enabled. ##The default value is 0. - psetting('features.remote_phonebook.enable', '0'); + psetting('features.remote_phonebook.enable', '1'); + ##It enables or disables the phone to perform a remote phone book search when accessing. + ##0-Disabled,1-Enabled. + ##The default value is 0. + psetting('features.remote_phonebook.enter_update_enable', '1'); ##It configures the interval (in seconds) for the phone to update the data of the remote phone book from the remote phone book server. ##The default value is 21600.Integer from 3600 to 2592000. - psetting('features.remote_phonebook.flash_time', '21600'); + psetting('features.remote_phonebook.flash_time', '3600'); # Ringtone # exp.: tftp://192.168.1.100/Ring9.wav @@ -543,6 +577,19 @@ function psetting( $param, $val='' ) # 0=reboot, if additional parameter "reboot=true" was given, 1=reboot always, 2=ignore SIP NOTIFY message psetting(sip.notify_reboot_enable, '0'); + + # Transfer + psetting('transfer.blind_tran_on_hook_enable', '1'); + psetting('transfer.on_hook_trans_enable', '1'); + psetting('transfer.semi_attend_tran_enable', '1'); + + # DSS Key press on active call: 0=new call 1=attended transfer 2=blind transfer + psetting('transfer.dsskey_deal_type', '1'); + + # Enables or disables custom soft keys layout feature. + psetting('phone_setting.custom_softkey_enable', '1'); + + ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) ##################################################################### From 5aecaefdfc4c5c6d0257977a4d03f936078aa176 Mon Sep 17 00:00:00 2001 From: d-mark Date: Fri, 17 Feb 2017 19:06:08 +0100 Subject: [PATCH 24/42] Yealink EXP40 support --- .../htdocs/gui/mod/inc_keyprof.php | 24 +++---- .../htdocs/prov/yealink/settings.php | 66 +++++++++++++++++-- 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 92e1bc300..e2f56529e 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -1328,32 +1328,32 @@ function gs_dlg_abort() } if ($show_ext_modules >= 1) { $key_levels += array( - 1 => array('from'=> 100, 'to'=> 118, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Spalte') .' 1') + 1 => array('from'=> 101, 'to'=> 120, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 1') ); $key_levels += array( - 2 => array('from'=> 119, 'to'=> 137, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Spalte') .' 2') + 2 => array('from'=> 121, 'to'=> 140, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 2') ); } if ($show_ext_modules >= 2) { $key_levels += array( - 3 => array('from'=> 200, 'to'=> 218, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Spalte') .' 1') + 3 => array('from'=> 201, 'to'=> 220, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 1') ); $key_levels += array( - 4 => array('from'=> 219, 'to'=> 237, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Spalte') .' 2') + 4 => array('from'=> 221, 'to'=> 240, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 2') ); } if ($show_ext_modules >= 3) { $key_levels += array( - 5 => array('from'=> 300, 'to'=> 318, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Spalte') .' 1') + 5 => array('from'=> 301, 'to'=> 320, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 1') ); $key_levels += array( - 6 => array('from'=> 319, 'to'=> 337, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Spalte') .' 2') + 6 => array('from'=> 321, 'to'=> 340, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 2') ); } switch($phone_type) { diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index ac59ac8bb..6d2e3044e 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -789,7 +789,18 @@ function psetting( $param, $val='' ) } # TODO: RESET PROGRAMMABLE KEYS? - # TODO: RESET EXP KEYS? + # RESET EXP KEYS on EXP40 + if ($phone_type == 'yealink-sip-t46g' || $phone_type == 'yealink-sip-t48g') { + for ($j=1; $j<=6; $j++) { + for ($i=1; $i <= 40; $i++) { + psetting('expansion_module.'.$j.'.key.'.$i.'.line', '0'); + psetting('expansion_module.'.$j.'.key.'.$i.'.value', ''); + psetting('expansion_module.'.$j.'.key.'.$i.'.type', '0'); + psetting('expansion_module.'.$j.'.key.'.$i.'.label', ''); + } + } + } + $softkeys = null; $GS_Softkeys = gs_get_key_prov_obj( $phone_type ); @@ -818,13 +829,16 @@ function psetting( $param, $val='' ) continue; } - $key_idx = (int)lTrim(subStr($key_name,1),'0'); + # $key_name is Fxxyy , where xx is extension module and yy is key index + $key_idx = (int)lTrim(subStr($key_name,3),'0'); + $key_exp = (int)lTrim(subStr($key_name,1,2),'0'); + # gs_log( GS_LOG_DEBUG, 'Softkey '.$key_name.' -> Exp='.$key_exp.' Idx='.$key_idx ); if ($key_def['function'] === 'f0') continue; ####################################################################################### ## Line Keys ## ####################################################################################### - if ($key_idx >= 1 && $key_idx <= $max_keys ) { + if ($key_idx >= 1 && $key_idx <= $max_keys && $key_exp == 0) { gs_log( GS_LOG_DEBUG, 'Set LineKey('.$key_idx.') value=\''.$key_def['data'].'\' type=\''.subStr($key_def['function'],1).'\' label=\''.$key_def['label'].'\'' ); ###It configures the desired line to apply the key feature.Integer from 1 to 6 @@ -866,7 +880,51 @@ function psetting( $param, $val='' ) ###The default value is blank. psetting('linekey.'.$key_idx.'.label', $key_def['label']); } - + ####################################################################################### + ## Expansion Keys ## + ####################################################################################### + else if ($key_idx >= 1 && $key_idx <= 40 && $key_exp >= 1 && $key_exp <=6) { + gs_log( GS_LOG_DEBUG, 'Set ExpKey('.$key_idx.') value=\''.$key_def['data'].'\' type=\''.subStr($key_def['function'],1).'\' label=\''.$key_def['label'].'\'' ); + ###It configures the desired line to apply the key feature.Integer from 1 to 6 + psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.line', 1); + ###It configures the value of the line key feature. + ###For example, when setting the key feature to BLF, it configures the number of the monitored user. + ###The default value is blank. + psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.value', $key_def['data']); + # for BLF + if (subStr($key_def['function'],1) == 16 ) { + ###It configures the pickup code for BLF feature or conference ID followed by the # sign for Meet-Me conference feature. + ###It only applies to BLF and Meet-Me conference features. + ###The default value is blank + psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.pickup_value', '*81*'); + } + ###It configures the key feature for the line key X. + #The valid types are: + #0-NA 1-Conference 2-Forward 3-Transfer 4-Hold 5-DND 7-Call Return 8-SMS 9-Directed Pickup + #10-Call Park 11-DTMF 12-Voice Mail 13-Speed Dial 14-Intercom 15-Line 16-BLF 17-URL 18-Group Listening + #20-Private Hold 22-XML Group 23-Group Pickup 24-Multicast Paging 25-Record 27-XML Browser + #34-Hot Desking 35-URL Record 38-LDAP 39-BLF List + #40-Prefix 41-Zero Touch 42-ACD 45-Local Group 46-Network Group 49-Custom Button + #50-Keypad Lock 55-Meet-Me Conference 56-Retrieve Park 57-Hoteling 58-ACD Grace 59-Sisp Code + #60-Emergency 61-Directory + #---- + #0-NA £¨Only for T41/T42/T46) + #22-XML Group (Not support T20) + #38-LDAP (Not support T20) + #46-Network Group (Not support T20) + #8-SMS (Only support T21/T46/T22/T26/T28) + #17-URL (Only support T41/T42/T46) + #49-Custom Button (Only support T20/T22/T26/T28) + psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.type', subStr($key_def['function'],1)); + ###It configures the desired local group/XML group/network group for the line key X. + ###It only applies to the Local Group, XML Group and Network Group features. + ###XML Group and Network Group features are not applicable to SIP-T20P IP phones. + // psetting('linekey.'.$key_idx.'.xml_phonebook', '0'); + ###It configures the label displayed on the LCD screen for each line key. + ###The default value is blank. + psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.label', $key_def['label']); + + } # TODO: Programmable Keys # TODO: Keys on Expansion Modul } From 9a72a1b7fe430777238ffe054459d537c7afe33a Mon Sep 17 00:00:00 2001 From: Sebastian Ertz Date: Mon, 20 Feb 2017 11:14:24 +0100 Subject: [PATCH 25/42] syntax fehler beseitigt --- opt/gemeinschaft/htdocs/prov/snom/settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/snom/settings.php b/opt/gemeinschaft/htdocs/prov/snom/settings.php index 7ba644d66..04f57d26e 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/settings.php +++ b/opt/gemeinschaft/htdocs/prov/snom/settings.php @@ -725,8 +725,8 @@ function _settings_out() } } psetting('dnd_mode' , $dnd_mode, true); -psetting('dnd_on_code' , 'dnd-on@'. $host)); -psetting('dnd_off_code' , 'dnd-off@'. $host)); +psetting('dnd_on_code' , 'dnd-on@'. $host); +psetting('dnd_off_code' , 'dnd-off@'. $host); psetting('preselection_nr' , ''); From 7adcc2604b228fda4920958e05fc67dea496dc51 Mon Sep 17 00:00:00 2001 From: Sebastian Ertz Date: Mon, 20 Feb 2017 10:06:05 +0100 Subject: [PATCH 26/42] Add Provisioning for SNOM D305, D315, D375 --- .../htdocs/gui/mod/inc_keyprof.php | 29 +++++++++++++++++-- .../htdocs/gui/mod/prov_phones.php | 3 ++ .../htdocs/prov/snom/settings.php | 19 +++++++++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 32ef66661..ddcfe6b24 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -69,6 +69,12 @@ $phone_types['snom-710'] = 'Snom 710'; if (in_array('*', $enabled_models) || in_array('715', $enabled_models)) $phone_types['snom-715'] = 'Snom 715'; + if (in_array('*', $enabled_models) || in_array('d305', $enabled_models)) + $phone_types['snom-d305'] = 'Snom D305'; + if (in_array('*', $enabled_models) || in_array('d315', $enabled_models)) + $phone_types['snom-d315'] = 'Snom D315'; + if (in_array('*', $enabled_models) || in_array('d375', $enabled_models)) + $phone_types['snom-d375'] = 'Snom D375'; } /* # Maybe there will be some reason for enabling keys on Snom M3 phones in future. @@ -285,6 +291,9 @@ elseif (array_key_exists('snom-710', $phone_types)) $phone_type = 'snom-710'; elseif (array_key_exists('snom-715', $phone_types)) $phone_type = 'snom-715'; elseif (array_key_exists('snom-821', $phone_types)) $phone_type = 'snom-821'; + elseif (array_key_exists('snom-d305', $phone_types)) $phone_type = 'snom-d305'; + elseif (array_key_exists('snom-d315', $phone_types)) $phone_type = 'snom-d315'; + elseif (array_key_exists('snom-d375', $phone_types)) $phone_type = 'snom-d375'; } else if (gs_get_conf('GS_SIEMENS_PROV_ENABLED')) { if (array_key_exists('siemens-os20', $phone_types)) $phone_type = 'siemens-os20'; @@ -308,7 +317,7 @@ elseif (array_key_exists('tiptel-ip286', $phone_types)) $phone_type = 'tiptel-ip286'; } } -if (in_array($phone_type, array('snom-300', 'snom-320', 'snom-360', 'snom-370', 'snom-870', 'snom-760', 'snom-720', 'snom-725', 'snom-710', 'snom-715', 'snom-821'), true)) { +if (in_array($phone_type, array('snom-300', 'snom-320', 'snom-360', 'snom-370', 'snom-870', 'snom-760', 'snom-720', 'snom-725', 'snom-710', 'snom-715', 'snom-821', 'snom-d305', 'snom-d315', 'snom-d375'), true)) { $phone_layout = 'snom'; $key_function_none = $key_function_none_snom; } elseif (in_array($phone_type, array('siemens-os20', 'siemens-os40', 'siemens-os60', 'siemens-os80'), true)) { @@ -1035,6 +1044,16 @@ function gs_dlg_abort() //$key_levels[0]['to' ] = 15; break; } + switch ($phone_type) { + case 'snom-d305': + case 'snom-d315': + $key_levels = array( + 0 => array('from'> 0, + 'to' => 1, 'shifted'=>false, + 'title' => htmlEnt($phone_type_title)) + ); + break; + } break; case 'siemens': //if ($show_ext_modules >= 0) { @@ -1331,6 +1350,10 @@ function gs_dlg_abort() switch ($key_level_idx) { case 0: $left = 0; $right = 11; break; } + case ('snom-d305' || 'snom-d315'): + switch ($key_level_idx) { + case 0: $left = 0; $right = 1; break; + } default: switch ($key_level_idx) { case 0: $left = 0; $right = 6; break; @@ -1345,7 +1368,7 @@ function gs_dlg_abort() for ($i=$key_level_info['from']; $i<=$key_level_info['to']; ++$i) { if ($phone_layout === 'snom') { - if ($phone_type === 'snom-760' || $phone_type === 'snom-870' || $phone_type == 'snom-720' || $phone_type == 'snom-725' || $phone_type == 'snom-710' || $phone_type == 'snom-715' || $phone_type == 'snom-821') { + if ($phone_type === 'snom-760' || $phone_type === 'snom-870' || $phone_type == 'snom-720' || $phone_type == 'snom-725' || $phone_type == 'snom-710' || $phone_type == 'snom-715' || $phone_type == 'snom-821' || $phone_type == 'snom-d305' || $phone_type == 'snom-d315') { $knum = $i; $knump = str_pad($knum, 3, '0', STR_PAD_LEFT); }else { @@ -1435,7 +1458,7 @@ function gs_dlg_abort() echo ''active')); setting('fkey', 5, 'keyevent F_MUTE', array('context'=>'active')); } +if ($phone_model == 'd305' || $phone_model == 'd315') { + psetting('status_msgs_that_are_blocked', ''); + psetting('dkey_fkey1', 'url '. $prov_url_snom .'dial-log.php?user=$user_name1', array('context'=>'active')); + psetting('dkey_fkey2', 'url '. $prov_url_snom .'pb.php?m=$mac&u=$user_name1', array('context'=>'active')); + psetting('gui_fkey1', 'keyevent F_CALL_LIST'); + psetting('gui_fkey2', 'keyevent F_ADR_BOOK'); + psetting('gui_fkey3', 'keyevent F_SETTINGS'); + setting('fkey', 2, 'url '. $prov_url_snom .'pb.php?m=$mac&u=$user_name1', array('context'=>'active')); + setting('fkey', 3, 'keyevent F_TRANSFER', array('context'=>'active')); + setting('fkey', 4, 'keyevent F_MUTE', array('context'=>'active')); +} if (($phone_model == '710') || ($phone_model == '715')) { psetting('dkey_fkey1', 'url '. $prov_url_snom .'dial-log.php?user=$user_name1', array('context'=>'active')); psetting('dkey_fkey2', 'url '. $prov_url_snom .'pb.php?m=$mac&u=$user_name1', array('context'=>'active')); From ff3e4c2ac3dc827d7f6a992af92ef0e209c549a2 Mon Sep 17 00:00:00 2001 From: d-mark Date: Thu, 23 Feb 2017 20:06:10 +0100 Subject: [PATCH 27/42] added GS server side Dial log for Yealink --- .../htdocs/prov/yealink/dial-log.php | 234 ++++++++++++++++++ .../htdocs/prov/yealink/settings.php | 14 ++ 2 files changed, 248 insertions(+) create mode 100644 opt/gemeinschaft/htdocs/prov/yealink/dial-log.php diff --git a/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php b/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php new file mode 100644 index 000000000..995d92f3e --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php @@ -0,0 +1,234 @@ + +* +* based on Snom by +* Stefan Wintermeyer +* Philipp Kempgen +* Peter Kozak +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301, USA. +\*******************************************************************/ + +# caution: earlier versions of Snom firmware do not like +# indented XML + +define( 'GS_VALID', true ); /// this is a parent file +require_once( dirName(__FILE__) .'/../../../inc/conf.php' ); +include_once( GS_DIR .'inc/db_connect.php' ); +include_once( GS_DIR .'inc/gettext.php' ); +include_once( GS_DIR .'inc/langhelper.php' ); +require_once( GS_DIR .'inc/string.php' ); + +header( 'Expires: 0' ); +header( 'Pragma: no-cache' ); +header( 'Cache-Control: private, no-cache, must-revalidate' ); +header( 'Vary: *' ); + +function yealinkXmlEsc( $str ) +{ + return htmlEnt( $str ); +} + +function _ob_send() +{ + if (! headers_sent()) { + header( 'Content-Type: application/xml' ); + header( 'Content-Length: '. (int)@ob_get_length() ); + } + @ob_end_flush(); + die(); +} + +function _err( $msg='' ) +{ + @ob_end_clean(); + ob_start(); + echo + '', "\n", + '', "\n", + '', __('Fehler'), '', "\n", + '', yealinkXmlEsc( __('Fehler') .': '. $msg ), '', "\n", + '', "\n"; + _ob_send(); +} + + +if (! gs_get_conf('GS_YEALINK_PROV_ENABLED')) { + gs_log( GS_LOG_DEBUG, "Yealink provisioning not enabled" ); + _err( 'Not enabled.' ); +} + + +$user = trim( @ $_REQUEST['user'] ); +if (! preg_match('/^\d+$/', $user)) + _err( 'Not a valid SIP user.' ); + +$mac = preg_replace('/[^\dA-Z]/', '', strToUpper(trim( @$_REQUEST['mac'] ))); + +$type = trim( @ $_REQUEST['type'] ); +if (! in_array( $type, array('in','out','missed','queue'), true )) + $type = false; + +$db = gs_db_slave_connect(); + +# get user_id +# +$user_id = (int)$db->executeGetOne( 'SELECT `_user_id` FROM `ast_sipfriends` WHERE `name`=\''. $db->escape($user) .'\'' ); +if ($user_id < 1) + _err( 'Unknown user.' ); + + +# $remote_addr = @$_SERVER['REMOTE_ADDR']; +#$remote_addr_check = $db->executeGetOne( 'SELECT `current_ip` FROM `users` WHERE `id`='. $user_id ); +#if ($remote_addr != $remote_addr_check) _err( 'Not authorized' ); + +unset($remote_addr_check); +unset($remote_addr); +unset($user_id_check); + +// setup i18n stuff +gs_setlang( gs_get_lang_user($db, $user, GS_LANG_FORMAT_GS) ); +gs_loadtextdomain( 'gemeinschaft-gui' ); +gs_settextdomain( 'gemeinschaft-gui' ); + +$typeToTitle = array( + 'out' => __("Gew\xC3\xA4hlt"), + 'missed' => __("Verpasst"), + 'in' => __("Angenommen"), + 'queue' => __("Warteschlangen") +); + +ob_start(); + + +$url_yealink_dl = GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH .'yealink/dial-log.php'; + +#################################### INITIAL SCREEN { +if (! $type) { + + # delete outdated entries + # + $db->execute( 'DELETE FROM `dial_log` WHERE `user_id`='. $user_id .' AND `timestamp`<'. (time()-(int)GS_PROV_DIAL_LOG_LIFE) ); + + + + echo '', "\n"; + echo + '', "\n", + '', __('Anruflisten') ,'', "\n"; + + foreach ($typeToTitle as $t => $title) { + + $num_calls = (int)$db->executeGetOne( 'SELECT COUNT(*) FROM `dial_log` WHERE `user_id`='. $user_id .' AND `type`=\''. $t .'\'' ); + //if ($num_calls > 0) { + echo + "\n", + '', "\n", + '', yealinkXmlEsc( $title ) ,'', "\n", + '', $url_yealink_dl ,'?user=',$user, '&mac=',$mac, '&type=',$t, '', "\n", + '', "\n"; + //} + } + + echo + "\n", + ''; + +} +#################################### INITIAL SCREEN } + + + +#################################### DIAL LOG { +else { + + echo '', "\n"; + if ($type === 'queue'){ + $query = + 'SELECT + `timestamp` `ts`, `number`, `remote_name`, `remote_user_id` + FROM `dial_log` + WHERE + `user_id`='. $user_id .' AND + `type`=\''. $type .'\' + ORDER BY `ts` DESC + LIMIT 20'; + } else { + $query = + 'SELECT + MAX(`timestamp`) `ts`, `number`, `remote_name`, `remote_user_id`, + COUNT(*) `num_calls` + FROM `dial_log` + WHERE + `user_id`='. $user_id .' AND + `type`=\''. $type .'\' + GROUP BY `number` + ORDER BY `ts` DESC + LIMIT 20'; + } + $rs = $db->execute( $query ); + + echo + '', + '', yealinkXmlEsc( $typeToTitle[$type] ) , + ($rs->numRows() == 0 ? ' ('.yealinkXmlEsc(__('keine')).')' : '') , + '', "\n"; + + while ($r = $rs->fetchRow()) { + + $entry_name = $r['number']; + if ($r['remote_name'] != '') { + $entry_name .= ' '. $r['remote_name']; + } + if (date('dm') == date('dm', (int)$r['ts'])) + $when = date('H:i', (int)$r['ts']); + else + $when = date('d.m.', (int)$r['ts']); + $entry_name = $when .' '. $entry_name; + if ($r['num_calls'] > 1) { + $entry_name .= ' ('. $r['num_calls'] .')'; + } + echo + "\n", + '', "\n", + '', yealinkXmlEsc( $entry_name ) ,'', "\n", + '', yealinkXmlEsc( $r['number'] ) ,'', "\n", + '', "\n"; + + } + + echo + "\n", + ''; + +} +#################################### DIAL LOG } + + +_ob_send(); + +?> diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 6d2e3044e..fae60ef43 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -789,6 +789,20 @@ function psetting( $param, $val='' ) } # TODO: RESET PROGRAMMABLE KEYS? + # Programable Key 1 (default "History") > GS History + # Programable Key 5 (UP Key)(default "History") > GS History + # Programable Key 6 (DOWN Key)(default "Phonebook") > XML Phonebook + psetting('programablekey.1.type', '27'); # XML Browser + psetting('programablekey.1.value', $prov_url_yealink.'dial-log.php?user='.$user_ext ); + psetting('programablekey.1.label', 'Anrufliste'); + psetting('programablekey.5.type', '27'); # XML Browser + psetting('programablekey.5.value', $prov_url_yealink.'dial-log.php?user='.$user_ext ); + psetting('programablekey.5.label', 'Anrufliste'); + + psetting('programablekey.6.type', '47'); # XML Phonebook + psetting('programablekey.6.value', '' ); + psetting('programablekey.6.label', 'Tel.Buch'); + # RESET EXP KEYS on EXP40 if ($phone_type == 'yealink-sip-t46g' || $phone_type == 'yealink-sip-t48g') { for ($j=1; $j<=6; $j++) { From 04cdcd0c0807c94e2e4fbd20300a1e3f84201b9e Mon Sep 17 00:00:00 2001 From: d-mark Date: Fri, 24 Feb 2017 19:30:45 +0100 Subject: [PATCH 28/42] added some settings, especially XML push server --- .../htdocs/prov/yealink/settings.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index fae60ef43..f59957166 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -589,6 +589,14 @@ function psetting( $param, $val='' ) # Enables or disables custom soft keys layout feature. psetting('phone_setting.custom_softkey_enable', '1'); + # DSS extended key length + psetting('features.config_dsskey_length', '1'); + + # blf_and_callpark_idle_led_enable + psetting('features.blf_and_callpark_idle_led_enable', '1'); + + # IP for XML push + psetting('push_xml.server', GS_PROV_HOST ); ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) @@ -714,6 +722,13 @@ function psetting( $param, $val='' ) // ##It configures the directed pickup code for account X. // ##The default value is blank. psetting('account.1.direct_pickup_code', '*81*'); + + + # DTMF 0=Inband 1=RFC2833 2=SIP INFO 3=RFC2833+SIP INFO + psetting('account.1.dtmf.type', '1'); + + # DTMF Info Type 1=DTMF-Relay 2=DTMF 3=Telephone-Event + psetting('account.1.dtmf.info_type', '1'); # Time ##It configures the time zone.For more available time zones, refer to Time Zones on page 215. @@ -762,7 +777,7 @@ function psetting( $param, $val='' ) psetting('features.pickup.blf_audio_enable', '0'); ##################################################################### - # Keys + # Keys and Device specific settings ##################################################################### switch ($phone_type) { @@ -771,9 +786,11 @@ function psetting( $param, $val='' ) break; case 'yealink-sip-t46g': $max_keys=27; + psetting('screensaver.wait_time', '21600'); break; case 'yealink-sip-t48g': $max_keys=29; + psetting('screensaver.wait_time', '21600'); break; } From b4295abd435e544dcf797183fd0ccaacd387873d Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 28 Feb 2017 15:23:46 +0100 Subject: [PATCH 29/42] speed up yealink provisioning by only settings params for configured EXT40 modules --- opt/gemeinschaft/htdocs/prov/yealink/dial-log.php | 6 +++--- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php b/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php index 995d92f3e..cbac12a33 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/dial-log.php @@ -98,9 +98,9 @@ function _err( $msg='' ) _err( 'Unknown user.' ); -# $remote_addr = @$_SERVER['REMOTE_ADDR']; -#$remote_addr_check = $db->executeGetOne( 'SELECT `current_ip` FROM `users` WHERE `id`='. $user_id ); -#if ($remote_addr != $remote_addr_check) _err( 'Not authorized' ); +$remote_addr = @$_SERVER['REMOTE_ADDR']; +$remote_addr_check = $db->executeGetOne( 'SELECT `current_ip` FROM `users` WHERE `id`='. $user_id ); +if ($remote_addr != $remote_addr_check) _err( 'Not authorized' ); unset($remote_addr_check); unset($remote_addr); diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index f59957166..d28a804c6 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -504,7 +504,6 @@ function psetting( $param, $val='' ) psetting('remote_phonebook.data.'.$i.'.url', ''); psetting('remote_phonebook.data.'.$i.'.name', ''); - ###Except T41P/T42G Models psetting('remote_phonebook.display_name', 'Telefonbuch'); ###Super Search recommended by Yealink support @@ -595,9 +594,6 @@ function psetting( $param, $val='' ) # blf_and_callpark_idle_led_enable psetting('features.blf_and_callpark_idle_led_enable', '1'); - # IP for XML push - psetting('push_xml.server', GS_PROV_HOST ); - ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) ##################################################################### @@ -820,9 +816,15 @@ function psetting( $param, $val='' ) psetting('programablekey.6.value', '' ); psetting('programablekey.6.label', 'Tel.Buch'); + # max 6 EXP40 Modules allowed + # get max configured EXP40 count to speed up provisioning + $max_ext_modules = (int)$db->executeGetOne( 'SELECT `g`.`show_ext_modules` FROM `users` `u` JOIN `user_groups` `g` ON (`g`.`id`=`u`.`group_id`) WHERE `u`.`id`='.$user_id ); + if ($max_ext_modules >6) { $max_ext_modules=6; } + + # RESET EXP KEYS on EXP40 if ($phone_type == 'yealink-sip-t46g' || $phone_type == 'yealink-sip-t48g') { - for ($j=1; $j<=6; $j++) { + for ($j=1; $j<=$max_ext_modules; $j++) { for ($i=1; $i <= 40; $i++) { psetting('expansion_module.'.$j.'.key.'.$i.'.line', '0'); psetting('expansion_module.'.$j.'.key.'.$i.'.value', ''); From c7599b041b8e2197838187a85bbcd849302e617f Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 28 Feb 2017 15:56:11 +0100 Subject: [PATCH 30/42] Yealink prov: add XML push server = IP of GS and action URI IP to any --- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index d28a804c6..86d1cf1d7 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -594,6 +594,12 @@ function psetting( $param, $val='' ) # blf_and_callpark_idle_led_enable psetting('features.blf_and_callpark_idle_led_enable', '1'); + # push XML server + psetting('push_xml.server', $host); + + # features.action_uri_limit_ip + psetting('features.action_uri_limit_ip', 'any'); + ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) ##################################################################### From 60e98ead23a972cf6d181065557e373ec88b7878 Mon Sep 17 00:00:00 2001 From: d-mark Date: Wed, 5 Apr 2017 20:05:06 +0200 Subject: [PATCH 31/42] Yealink add custom ringtone --- opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi | 8 ++++---- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi index 42765fb36..40e5ac88c 100755 --- a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi +++ b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi @@ -213,10 +213,10 @@ elseif (strToLower(subStr($user['phone_type'],0,7)) === 'yealink') { $ringtones = _get_ringers( $user['id'] ); - if (@$ringtones['internal']['file'] && @$ringtones['external']['file']) - $ringtones['external']['file'] = null; - - if (array_key_exists('bellcore', $ringtones[$source])) { + if (@$ringtones[$source]['file']) { + gs_agi_set_variable( 'ringer', ('<'. GS_PROV_SCHEME .'://'. GS_PROV_HOST . (GS_PROV_PORT ? ':'.GS_PROV_PORT : '') . GS_PROV_PATH .'ringtones/'. $ringtones[$source]['file'] .'-tiptel.wav>') ); + } elseif (array_key_exists('bellcore', $ringtones[$source])) { + if (@$ringtones[$source]['bellcore'] == 1) exit(); if (@$ringtones[$source]['bellcore'] != 0) { gs_agi_set_variable( 'ringer', ('Bellcore-dr'. $ringtones[$source]['bellcore'] ) ); diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 86d1cf1d7..f5f4c309b 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -731,6 +731,9 @@ function psetting( $param, $val='' ) # DTMF Info Type 1=DTMF-Relay 2=DTMF 3=Telephone-Event psetting('account.1.dtmf.info_type', '1'); + + # allow alert info URL + psetting('account.1.alert_info_url_enable', '1'); # Time ##It configures the time zone.For more available time zones, refer to Time Zones on page 215. From b9f72133e1cdb6da8982a62df06599b5c47eb3e4 Mon Sep 17 00:00:00 2001 From: d-mark Date: Mon, 24 Jul 2017 15:50:25 +0200 Subject: [PATCH 32/42] added support for Yealink T42S and T46S --- etc/gemeinschaft/gemeinschaft.php | 3 ++- opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php | 12 ++++++++++-- opt/gemeinschaft/htdocs/gui/mod/prov_phones.php | 2 ++ .../htdocs/gui/mod/prov_provparams.php | 2 ++ opt/gemeinschaft/htdocs/prov/yealink/settings.php | 15 +++++++++++---- opt/gemeinschaft/inc/conf.php | 2 ++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index bab23aba2..2a9311fac 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -538,7 +538,8 @@ $YEALINK_PROV_FW_DEFAULT_SIP_T46G = ''; $YEALINK_PROV_FW_DEFAULT_SIP_T48G = ''; - +$YEALINK_PROV_FW_DEFAULT_SIP_T42S = ''; +$YEALINK_PROV_FW_DEFAULT_SIP_T46S = ''; //-----------------------[ Polycom ]----------------------// diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index e2f56529e..0ff1ef7cf 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -122,7 +122,11 @@ $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; if (in_array('*', $enabled_models) || in_array('yealink-sip-t48g', $enabled_models)) $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; -} + if (in_array('*', $enabled_models) || in_array('yealink-sip-t42s', $enabled_models)) + $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; + if (in_array('*', $enabled_models) || in_array('yealink-sip-t46s', $enabled_models)) + $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; + } $key_functions_snom = array( 'none' => __('Leer'), # none @@ -349,6 +353,8 @@ if (array_key_exists('yealink-sip-t42g', $phone_types)) $phone_type = 'yealink-sip-t42g'; elseif (array_key_exists('yealink-sip-t46g', $phone_types)) $phone_type = 'yealink-sip-t46g'; elseif (array_key_exists('yealink-sip-t48g', $phone_types)) $phone_type = 'yealink-sip-t48g'; + elseif (array_key_exists('yealink-sip-t42s', $phone_types)) $phone_type = 'yealink-sip-t42s'; + elseif (array_key_exists('yealink-sip-t46s', $phone_types)) $phone_type = 'yealink-sip-t46s'; } } if (in_array($phone_type, array('snom-300', 'snom-320', 'snom-360', 'snom-370', 'snom-870', 'snom-760', 'snom-720', 'snom-725', 'snom-710', 'snom-715', 'snom-821'), true)) { @@ -366,7 +372,7 @@ } elseif (in_array($phone_type, array('tiptel-ip284', 'tiptel-ip286'), true)) { $phone_layout = 'tiptel'; $key_function_none = $key_function_none_tiptel; -} elseif (in_array($phone_type, array('yealink-sip-t42g', 'yealink-sip-t46g', 'yealink-sip-t48g'), true)) { +} elseif (in_array($phone_type, array('yealink-sip-t42g', 'yealink-sip-t46g', 'yealink-sip-t48g', 'yealink-sip-t42s', 'yealink-sip-t46s'), true)) { $phone_layout = 'yealink'; $key_function_none = $key_function_none_yealink; } else { @@ -1314,6 +1320,7 @@ function gs_dlg_abort() case 'yealink': switch($phone_type) { case 'yealink-sip-t46g': + case 'yealink-sip-t46s': $key_levels = array( 0 => array('from'=> 1, 'to'=> 27, 'shifted'=>false, 'title'=> htmlEnt($phone_type_title)) @@ -1358,6 +1365,7 @@ function gs_dlg_abort() } switch($phone_type) { case 'yealink-sip-t42g': + case 'yealink-sip-t42s': $key_levels[0]['title']= htmlEnt($phone_type_title); $key_levels[0]['from'] = 1; $key_levels[0]['to' ] = 15; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php index 627a68a1c..d0e9ef722 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php @@ -104,6 +104,8 @@ function _mac_addr_display( $mac ) $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; + $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; + $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; } if (gs_get_conf('GS_POLYCOM_PROV_ENABLED')) { $phone_types['polycom-spip-300'] = 'Polycom SoundPoint IP 300'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php index 1e7811b3d..564e570c6 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php @@ -69,6 +69,8 @@ $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; + $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; + $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; } if (gs_get_conf('GS_GRANDSTREAM_PROV_ENABLED')) { $phone_types['grandstream-ht287' ] = 'Grandstream HT 287'; diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index f5f4c309b..3f9612cb9 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -168,7 +168,7 @@ function _redirect_tiptel() gs_log( GS_LOG_DEBUG, "Yealink model $ua found." ); # find out the type of the phone: -if (preg_match('/SIP-(T42G|T46G|T48G)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" +if (preg_match('/SIP-(T42G|T46G|T48G|T42S|T46S)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" $phone_model = 'SIP-'.$m[1]; $phone_model_config = 'SIP_'.$m[1]; } @@ -452,7 +452,7 @@ function psetting( $param, $val='' ) } # Phonetype Check -if ( in_array($phone_type, array('yealink-sip-t42g','yealink-sip-t46g','yealink-sip-t48g'), true) ) { +if ( in_array($phone_type, array('yealink-sip-t42g','yealink-sip-t46g','yealink-sip-t48g','yealink-sip-t42s','yealink-sip-t46s'), true) ) { ##################################################################### # Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) @@ -797,7 +797,14 @@ function psetting( $param, $val='' ) $max_keys=29; psetting('screensaver.wait_time', '21600'); break; - } + case 'yealink-sip-t42s': + $max_keys=15; + break; + case 'yealink-sip-t46s': + $max_keys=27; + psetting('screensaver.wait_time', '21600'); + break; + } # RESET KEYS for ($i=1; $i <= $max_keys; $i++) { @@ -832,7 +839,7 @@ function psetting( $param, $val='' ) # RESET EXP KEYS on EXP40 - if ($phone_type == 'yealink-sip-t46g' || $phone_type == 'yealink-sip-t48g') { + if ($phone_type == 'yealink-sip-t46g' || $phone_type == 'yealink-sip-t48g' || $phone_type == 'yealink-sip-t46s') { for ($j=1; $j<=$max_ext_modules; $j++) { for ($i=1; $i <= 40; $i++) { psetting('expansion_module.'.$j.'.key.'.$i.'.line', '0'); diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 7b18b3ae0..31b4d7e07 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -338,6 +338,8 @@ function _gscnf( $param, $default=null ) _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T42G', null ); _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46G', null ); _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T48G', null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T42S', null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46S', null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); _gscnf( 'YEALINK_PROV_KEY_BLACKLIST' , '' ); From 02ffde2ca16ffba08981fc9edbe8f7ad9b1ad6d2 Mon Sep 17 00:00:00 2001 From: d-mark Date: Mon, 24 Jul 2017 15:58:21 +0200 Subject: [PATCH 33/42] fixed syntax error --- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 3f9612cb9..fd79c125c 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -574,7 +574,7 @@ function psetting( $param, $val='' ) # Reboot on SIP NOTIFY # 0=reboot, if additional parameter "reboot=true" was given, 1=reboot always, 2=ignore SIP NOTIFY message - psetting(sip.notify_reboot_enable, '0'); + psetting('sip.notify_reboot_enable', '0'); # Transfer From 3998cc2846739c7e6d46d6a17f2dfe38e9655093 Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 15 Aug 2017 16:21:07 +0200 Subject: [PATCH 34/42] Bugfix Yealink Support T4xS Key assignment --- .../htdocs/gui/mod/inc_keyprof.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 0ff1ef7cf..05f2f09b5 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -1320,7 +1320,12 @@ function gs_dlg_abort() case 'yealink': switch($phone_type) { case 'yealink-sip-t46g': - case 'yealink-sip-t46s': + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 27, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; + case 'yealink-sip-t46s': $key_levels = array( 0 => array('from'=> 1, 'to'=> 27, 'shifted'=>false, 'title'=> htmlEnt($phone_type_title)) @@ -1332,6 +1337,20 @@ function gs_dlg_abort() 'title'=> htmlEnt($phone_type_title)) ); break; + case 'yealink-sip-t42g': + $show_ext_modules=0; + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 15, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; + case 'yealink-sip-t42s': + $show_ext_modules=0; + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 15, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; } if ($show_ext_modules >= 1) { $key_levels += array( @@ -1363,14 +1382,7 @@ function gs_dlg_abort() 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 2') ); } - switch($phone_type) { - case 'yealink-sip-t42g': - case 'yealink-sip-t42s': - $key_levels[0]['title']= htmlEnt($phone_type_title); - $key_levels[0]['from'] = 1; - $key_levels[0]['to' ] = 15; - break; - } + break; } From 6971ad01fccbc3396dcd0e9a5294157e011751c6 Mon Sep 17 00:00:00 2001 From: d-mark Date: Sat, 2 Dec 2017 17:44:30 +0100 Subject: [PATCH 35/42] fix update of CID info to RPID-PAI-FROM --- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index fd79c125c..3daed4687 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -735,6 +735,9 @@ function psetting( $param, $val='' ) # allow alert info URL psetting('account.1.alert_info_url_enable', '1'); + # CID Source. 0-FROM 1-PAI 2-PAI-FROM 3-RPID-PAI-FROM 4-PAI-RPID-FROM 5-RPID-FROM + psetting('account.1.cid_source', '3'); + # Time ##It configures the time zone.For more available time zones, refer to Time Zones on page 215. ##The default value is +8. From f2c00125629d57a4db2e1745c532ad5bb046d6ec Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 30 Jan 2018 15:50:02 +0100 Subject: [PATCH 36/42] RTCP-XR settings added (enabled) --- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 3daed4687..70f54de9c 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -600,6 +600,14 @@ function psetting( $param, $val='' ) # features.action_uri_limit_ip psetting('features.action_uri_limit_ip', 'any'); + # RTCP-XR features + psetting('phone_setting.vq_rtcpxr.session_report.enable', '1'); + psetting('phone_setting.vq_rtcpxr.interval_report.enable', '1'); + psetting('phone_setting.vq_rtcpxr_interval_period', '20'); + psetting('phone_setting.vq_rtcpxr.states_show_on_web.enable', '1'); + psetting('voice.rtcp_xr.enable', '1'); + + ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) ##################################################################### From 09816feed1ca1ef283d5f6584601f487912a7550 Mon Sep 17 00:00:00 2001 From: d-mark Date: Mon, 5 Nov 2018 19:29:22 +0100 Subject: [PATCH 37/42] Yealink - disabled new warning display, bugfixes + asterisk patches in install.sh --- install.sh | 49 +++++++++++++++++-- .../htdocs/prov/yealink/settings.php | 2 + 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index ca6055486..9e4b96faa 100644 --- a/install.sh +++ b/install.sh @@ -219,7 +219,7 @@ ${APTITUDE_INSTALL} \ vim less git linux-headers-$(uname -r) \ gcc make gcc make ncurses-dev zlib1g-dev \ g++ libxml2-dev doxygen libmysql++-dev libcrypto++-dev libssl-dev \ - libportaudio2 portaudio19-dev libasound-dev + libportaudio2 portaudio19-dev libasound-dev lame # now that we have vim, enable syntax highlighting by default: if ( which vim 1>>/dev/null 2>>/dev/null ); then @@ -302,6 +302,24 @@ sleep 3 # sed -i -r -e 's/^(RAMRUN=)no/\1yes/' /etc/default/rcS || true +# install libjansson-dev, sqlite3, libsqlite-dev +# +echo "" +echo "***" +echo "*** Installing libjansson-dev, sqlite3, libsqlite3-dev ..." +echo "***" +if ( ! which libjansson-dev 1>>/dev/null 2>>/dev/null ); then + ${APTITUDE_INSTALL} libjansson-dev +fi +if ( ! which sqlite3 1>>/dev/null 2>>/dev/null ); then + ${APTITUDE_INSTALL} sqlite3 +fi +if ( ! which libsqlite3-dev 1>>/dev/null 2>>/dev/null ); then + ${APTITUDE_INSTALL} libsqlite3-dev +fi +if ( ! which uuid-dev 1>>/dev/null 2>>/dev/null ); then + ${APTITUDE_INSTALL} uuid-dev +fi # install dahdi # @@ -319,14 +337,37 @@ make config # generate /etc/dahdi/system.conf: dahdi_genconf || true +# install asterisk +# +echo "" +echo "***" +echo "*** Installing Asterisk ..." +echo "***" cd /usr/local/src/ -$DOWNLOAD "http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz" -tar -xvzf asterisk-13-current.tar.gz -cd $(tar -tzf asterisk-13-current.tar.gz | head -n 1 | cut -d '/' -f1) +$DOWNLOAD "http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/asterisk-13.15.1.tar.gz" +$DOWNLOAD "https://issues.asterisk.org/jira/secure/attachment/55471/asterisk-13.13.1-one-way-audio.patch" +tar -xvzf asterisk-13.15.1.tar.gz +cd $(tar -tzf asterisk-13.15.1.tar.gz | head -n 1 | cut -d '/' -f1) + +# patch asterisk +# +echo "" +echo "***" +echo "*** Patching Asterisk ..." +echo "***" +# Patch against 1-way-audio when transcoding +patch -p0 < ../asterisk-13.13.1-one-way-audio.patch + +# read -p "Patching completed, Press enter to continue" + ./configure make menuselect.makeopts menuselect/menuselect --enable res_config_mysql menuselect.makeopts menuselect/menuselect --enable cdr_mysql menuselect.makeopts +menuselect/menuselect --enable app_meetme menuselect.makeopts +menuselect/menuselect --enable app_setcallerid menuselect.makeopts +# read -p "Setting asterisk options completed, Press enter to continue" + make make install make samples diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 70f54de9c..2a3e31008 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -607,6 +607,8 @@ function psetting( $param, $val='' ) psetting('phone_setting.vq_rtcpxr.states_show_on_web.enable', '1'); psetting('voice.rtcp_xr.enable', '1'); + # Disable Warnings Display (Default Password set, Network, ...) + psetting('phone_setting.warnings_display.mode', '0'); ##################################################################### # MAC-specific provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) From 50b4e96cbdcd224d98435b962dbc6bf7b0fc04d7 Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 6 Nov 2018 13:51:04 +0100 Subject: [PATCH 38/42] G.722 Codec added in SIP and IAX gateways --- opt/gemeinschaft/htdocs/gui/mod/routing_gws-iax.php | 3 ++- opt/gemeinschaft/htdocs/gui/mod/routing_gws-sip.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/opt/gemeinschaft/htdocs/gui/mod/routing_gws-iax.php b/opt/gemeinschaft/htdocs/gui/mod/routing_gws-iax.php index fddd1fc5b..03eadc247 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/routing_gws-iax.php +++ b/opt/gemeinschaft/htdocs/gui/mod/routing_gws-iax.php @@ -447,6 +447,7 @@ function confirm_delete() { echo '', __('Codecs') ,':',"\n"; echo '',"\n"; $codecs = array( + 'g722' => 'G.722', 'alaw' => 'G.711a', 'ulaw' => 'G.711u', 'gsm' => 'GSM' @@ -456,7 +457,7 @@ function confirm_delete() { echo '',"\n"; - echo '',"\n"; + echo '
',"\n"; } echo '   (', htmlEnt(__('Standard')) ,': ', htmlEnt('G.711a') ,')',"\n"; echo '',"\n"; diff --git a/opt/gemeinschaft/htdocs/gui/mod/routing_gws-sip.php b/opt/gemeinschaft/htdocs/gui/mod/routing_gws-sip.php index f09a6f983..61590cf45 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/routing_gws-sip.php +++ b/opt/gemeinschaft/htdocs/gui/mod/routing_gws-sip.php @@ -457,6 +457,7 @@ function confirm_delete() { echo '', __('Codecs') ,':',"\n"; echo '',"\n"; $codecs = array( + 'g722' => 'G.722', 'alaw' => 'G.711a', 'ulaw' => 'G.711u', 'gsm' => 'GSM', @@ -469,7 +470,7 @@ function confirm_delete() { echo '',"\n"; - echo '',"\n"; + echo '
',"\n"; } echo '   (', htmlEnt(__('Standard')) ,': ', htmlEnt('G.711a') ,')',"\n"; echo '',"\n"; From 056a1fe64cba64ba814ec5a394ea4b49c8716bfe Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 6 Nov 2018 18:08:16 +0100 Subject: [PATCH 39/42] newer Yealink phones have another MAC vendor ID --- opt/gemeinschaft/htdocs/prov/yealink/.htaccess | 7 +++++-- opt/gemeinschaft/htdocs/prov/yealink/settings.php | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess index c66e2eaec..67cfae2d1 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess +++ b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess @@ -13,8 +13,11 @@ # xx.72 Firmware requests 001565xxxxxxC.cfg RewriteRule ^(001565[0-9a-f]*)C.cfg$ settings.php?mac=$1 [L] - # xx.73 Firmware requests 001565xxxxxx.cfg - RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + # xx.73 Firmware requests 001565xxxxxx.cfg + RewriteRule ^(001565[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + + # newer Yealink phones have 805ec0xxxxxx.cfg + RewriteRule ^(805ec0[0-9a-f]*).cfg$ settings.php?mac=$1 [L] # PB # RewriteRule ^pb.([0-9]*).(imported|prv|gs).([0-9]*).xml$ pb.php?u=$1&t=$2&p=$3 [L] diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index 2a3e31008..a26ea57e4 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -141,7 +141,7 @@ function _redirect_tiptel() # make sure the phone is a Yealink: # -if (subStr($mac,0,6) !== '001565') { +if ((subStr($mac,0,6) !== '001565') && (subStr($mac,0,6) !== '805EC0')) { gs_log( GS_LOG_NOTICE, "Yealink provisioning: MAC address \"$mac\" is not a Yealink phone" ); # don't explain this to the users _settings_err( 'No! See log for details.' ); @@ -809,7 +809,7 @@ function psetting( $param, $val='' ) case 'yealink-sip-t48g': $max_keys=29; psetting('screensaver.wait_time', '21600'); - break; + break; case 'yealink-sip-t42s': $max_keys=15; break; @@ -860,7 +860,7 @@ function psetting( $param, $val='' ) psetting('expansion_module.'.$j.'.key.'.$i.'.type', '0'); psetting('expansion_module.'.$j.'.key.'.$i.'.label', ''); } - } + } } @@ -985,7 +985,7 @@ function psetting( $param, $val='' ) ###It configures the label displayed on the LCD screen for each line key. ###The default value is blank. psetting('expansion_module.'.$key_exp.'.key.'.$key_idx.'.label', $key_def['label']); - + } # TODO: Programmable Keys # TODO: Keys on Expansion Modul From f9ecb07a11484888ceec3d251b1038f4a45e48b6 Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 20 Nov 2018 18:31:33 +0100 Subject: [PATCH 40/42] use G722 codec in SIP and IAX nodes with higher prio than alaw if activated --- opt/gemeinschaft/etc/asterisk/iax-nodes.conf.php | 1 + opt/gemeinschaft/etc/asterisk/sip-nodes.conf.php | 1 + 2 files changed, 2 insertions(+) diff --git a/opt/gemeinschaft/etc/asterisk/iax-nodes.conf.php b/opt/gemeinschaft/etc/asterisk/iax-nodes.conf.php index 70ef9ffce..a91af7fac 100755 --- a/opt/gemeinschaft/etc/asterisk/iax-nodes.conf.php +++ b/opt/gemeinschaft/etc/asterisk/iax-nodes.conf.php @@ -134,6 +134,7 @@ $params['permit' ] = null; $codecs_allow = array(); + $codecs_allow['g722' ] = false; $codecs_allow['alaw' ] = true; $codecs_allow['ulaw' ] = false; diff --git a/opt/gemeinschaft/etc/asterisk/sip-nodes.conf.php b/opt/gemeinschaft/etc/asterisk/sip-nodes.conf.php index 85d9a3568..71cab40e2 100755 --- a/opt/gemeinschaft/etc/asterisk/sip-nodes.conf.php +++ b/opt/gemeinschaft/etc/asterisk/sip-nodes.conf.php @@ -138,6 +138,7 @@ $params['permit' ] = null; $codecs_allow = array(); + $codecs_allow['g722' ] = false; $codecs_allow['alaw' ] = true; $codecs_allow['ulaw' ] = false; From def9af686bd04e68298d2ba4cd358069f266da8b Mon Sep 17 00:00:00 2001 From: d-mark Date: Tue, 20 Nov 2018 18:40:58 +0100 Subject: [PATCH 41/42] show login source IP and telephone type in admin users module --- .../htdocs/gui/mod/admin_users.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/opt/gemeinschaft/htdocs/gui/mod/admin_users.php b/opt/gemeinschaft/htdocs/gui/mod/admin_users.php index f6aa2d8ef..54d35bae0 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/admin_users.php +++ b/opt/gemeinschaft/htdocs/gui/mod/admin_users.php @@ -36,6 +36,8 @@ include_once( GS_DIR .'inc/gs-fns/gs_user_external_number_del.php' ); include_once( GS_DIR .'inc/gs-fns/gs_pickupgroup_user_add.php' ); include_once( GS_DIR .'inc/gs-fns/gs_callblocking_set.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_user_ip_by_ext.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_user_phonemodel_get.php' ); include_once( GS_DIR .'inc/group-fns.php' ); require_once( GS_DIR .'inc/boi-soap/boi-api.php' ); include_once( GS_DIR .'lib/utf8-normalize/gs_utf_normal.php' ); @@ -1028,6 +1030,24 @@ function count_users_logged_in( $DB ) { ← + + : + + + + +   + + + + : + + + + +   + + From 049403b0fbdfe450b40084d4a9f1e7585079fe9c Mon Sep 17 00:00:00 2001 From: d-mark Date: Thu, 18 Aug 2022 19:09:16 +0200 Subject: [PATCH 42/42] Added support for Yealink T46U + EXT43 --- etc/gemeinschaft/gemeinschaft.php | 1 + .../htdocs/gui/mod/inc_keyprof.php | 116 +++++++++++++----- .../htdocs/gui/mod/prov_phones.php | 3 +- .../htdocs/gui/mod/prov_provparams.php | 1 + .../htdocs/prov/yealink/.htaccess | 3 + .../htdocs/prov/yealink/readme_dhcp.txt | 12 ++ .../htdocs/prov/yealink/settings.php | 26 +++- opt/gemeinschaft/inc/conf.php | 1 + 8 files changed, 129 insertions(+), 34 deletions(-) diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index 2a9311fac..d35c4d7a7 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -540,6 +540,7 @@ $YEALINK_PROV_FW_DEFAULT_SIP_T42S = ''; $YEALINK_PROV_FW_DEFAULT_SIP_T46S = ''; +$YEALINK_PROV_FW_DEFAULT_SIP_T46U = ''; //-----------------------[ Polycom ]----------------------// diff --git a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php index 9e1126188..e2205af8b 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php +++ b/opt/gemeinschaft/htdocs/gui/mod/inc_keyprof.php @@ -132,6 +132,8 @@ $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; if (in_array('*', $enabled_models) || in_array('yealink-sip-t46s', $enabled_models)) $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; + if (in_array('*', $enabled_models) || in_array('yealink-sip-t46u', $enabled_models)) + $phone_types['yealink-sip-t46u' ] = 'Yealink SIP T46U'; } $key_functions_snom = array( @@ -364,6 +366,7 @@ elseif (array_key_exists('yealink-sip-t48g', $phone_types)) $phone_type = 'yealink-sip-t48g'; elseif (array_key_exists('yealink-sip-t42s', $phone_types)) $phone_type = 'yealink-sip-t42s'; elseif (array_key_exists('yealink-sip-t46s', $phone_types)) $phone_type = 'yealink-sip-t46s'; + elseif (array_key_exists('yealink-sip-t46u', $phone_types)) $phone_type = 'yealink-sip-t46u'; } } if (in_array($phone_type, array('snom-300', 'snom-320', 'snom-360', 'snom-370', 'snom-870', 'snom-760', 'snom-720', 'snom-725', 'snom-710', 'snom-715', 'snom-821', 'snom-d305', 'snom-d315', 'snom-d375'), true)) { @@ -381,7 +384,7 @@ } elseif (in_array($phone_type, array('tiptel-ip284', 'tiptel-ip286'), true)) { $phone_layout = 'tiptel'; $key_function_none = $key_function_none_tiptel; -} elseif (in_array($phone_type, array('yealink-sip-t42g', 'yealink-sip-t46g', 'yealink-sip-t48g', 'yealink-sip-t42s', 'yealink-sip-t46s'), true)) { +} elseif (in_array($phone_type, array('yealink-sip-t42g', 'yealink-sip-t46g', 'yealink-sip-t48g', 'yealink-sip-t42s', 'yealink-sip-t46s', 'yealink-sip-t46u'), true)) { $phone_layout = 'yealink'; $key_function_none = $key_function_none_yealink; } else { @@ -1350,6 +1353,12 @@ function gs_dlg_abort() 'title'=> htmlEnt($phone_type_title)) ); break; + case 'yealink-sip-t46u': + $key_levels = array( + 0 => array('from'=> 1, 'to'=> 27, 'shifted'=>false, + 'title'=> htmlEnt($phone_type_title)) + ); + break; case 'yealink-sip-t48g': $key_levels = array( 0 => array('from'=> 1, 'to'=> 29, 'shifted'=>false, @@ -1371,37 +1380,84 @@ function gs_dlg_abort() ); break; } - if ($show_ext_modules >= 1) { - $key_levels += array( - 1 => array('from'=> 101, 'to'=> 120, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 1') - ); - $key_levels += array( - 2 => array('from'=> 121, 'to'=> 140, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 2') - ); - } - if ($show_ext_modules >= 2) { - $key_levels += array( - 3 => array('from'=> 201, 'to'=> 220, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 1') - ); - $key_levels += array( - 4 => array('from'=> 221, 'to'=> 240, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 2') - ); + // EXT43 with 3 layers + if ($phone_type == 'yealink-sip-t46u') { + if ($show_ext_modules >= 1) { + $key_levels += array( + 1 => array('from'=> 101, 'to'=> 120, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 1') + ); + $key_levels += array( + 2 => array('from'=> 121, 'to'=> 140, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 2') + ); + $key_levels += array( + 3 => array('from'=> 141, 'to'=> 160, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 3') + ); + } + if ($show_ext_modules >= 2) { + $key_levels += array( + 4 => array('from'=> 201, 'to'=> 220, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 1') + ); + $key_levels += array( + 5 => array('from'=> 221, 'to'=> 240, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 2') + ); + $key_levels += array( + 6 => array('from'=> 241, 'to'=> 260, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 3') + ); + } + if ($show_ext_modules >= 3) { + $key_levels += array( + 7 => array('from'=> 301, 'to'=> 320, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 1') + ); + $key_levels += array( + 8 => array('from'=> 321, 'to'=> 340, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 2') + ); + $key_levels += array( + 9 => array('from'=> 341, 'to'=> 360, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 3') + ); + } } - if ($show_ext_modules >= 3) { - $key_levels += array( - 5 => array('from'=> 301, 'to'=> 320, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 1') - ); - $key_levels += array( - 6 => array('from'=> 321, 'to'=> 340, 'shifted'=>false, - 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 2') - ); + // EXT40 with 2 layers + else { + if ($show_ext_modules >= 1) { + $key_levels += array( + 1 => array('from'=> 101, 'to'=> 120, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 1') + ); + $key_levels += array( + 2 => array('from'=> 121, 'to'=> 140, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 1 '. __('Ebene') .' 2') + ); + } + if ($show_ext_modules >= 2) { + $key_levels += array( + 3 => array('from'=> 201, 'to'=> 220, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 1') + ); + $key_levels += array( + 4 => array('from'=> 221, 'to'=> 240, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 2 '. __('Ebene') .' 2') + ); + } + if ($show_ext_modules >= 3) { + $key_levels += array( + 5 => array('from'=> 301, 'to'=> 320, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 1') + ); + $key_levels += array( + 6 => array('from'=> 321, 'to'=> 340, 'shifted'=>false, + 'title'=> __('Erweiterungs-Modul') .' 3 '. __('Ebene') .' 2') + ); + } } - break; } diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php index 613ed06f7..53d2614b8 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_phones.php @@ -106,9 +106,10 @@ function _mac_addr_display( $mac ) if (gs_get_conf('GS_YEALINK_PROV_ENABLED')) { $phone_types['yealink-sip-t42g' ] = 'Yealink SIP T42G'; $phone_types['yealink-sip-t46g' ] = 'Yealink SIP T46G'; - $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; + $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; + $phone_types['yealink-sip-t46u' ] = 'Yealink SIP T46U'; } if (gs_get_conf('GS_POLYCOM_PROV_ENABLED')) { $phone_types['polycom-spip-300'] = 'Polycom SoundPoint IP 300'; diff --git a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php index 564e570c6..904bbd03e 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php +++ b/opt/gemeinschaft/htdocs/gui/mod/prov_provparams.php @@ -71,6 +71,7 @@ $phone_types['yealink-sip-t48g' ] = 'Yealink SIP T48G'; $phone_types['yealink-sip-t42s' ] = 'Yealink SIP T42S'; $phone_types['yealink-sip-t46s' ] = 'Yealink SIP T46S'; + $phone_types['yealink-sip-t46u' ] = 'Yealink SIP T46U'; } if (gs_get_conf('GS_GRANDSTREAM_PROV_ENABLED')) { $phone_types['grandstream-ht287' ] = 'Grandstream HT 287'; diff --git a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess index 67cfae2d1..25444214d 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/.htaccess +++ b/opt/gemeinschaft/htdocs/prov/yealink/.htaccess @@ -19,6 +19,9 @@ # newer Yealink phones have 805ec0xxxxxx.cfg RewriteRule ^(805ec0[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + # even newer Yealink phones have 805e0cxxxxxx.cfg + RewriteRule ^(805e0c[0-9a-f]*).cfg$ settings.php?mac=$1 [L] + # PB # RewriteRule ^pb.([0-9]*).(imported|prv|gs).([0-9]*).xml$ pb.php?u=$1&t=$2&p=$3 [L] diff --git a/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt b/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt index cc520b7e7..5f98db5f1 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt +++ b/opt/gemeinschaft/htdocs/prov/yealink/readme_dhcp.txt @@ -19,6 +19,18 @@ subnet 192.168.x.0 netmask 255.255.255.0 { # GS3 option tftp-server-name "http://192.168.x.250/gemeinschaft/prov/yealink/$MAC.cfg"; } + # Yealink-Phones, MAC starts with 80:5e:c0 + if binary-to-ascii(16, 32, "", substring(hardware, 0, 4)) = "1805ec0" { + log(info, "request from yealink phone, setting proper options."); + # GS3 + option tftp-server-name "http://192.168.9.1/gemeinschaft/prov/yealink/$MAC.cfg"; + } + # Yealink-Phones, MAC starts with 80:5e:0c + if binary-to-ascii(16, 32, "", substring(hardware, 0, 4)) = "1805e0c" { + log(info, "request from yealink phone, setting proper options."); + # GS3 + option tftp-server-name "http://192.168.9.1/gemeinschaft/prov/yealink/$MAC.cfg"; + } } diff --git a/opt/gemeinschaft/htdocs/prov/yealink/settings.php b/opt/gemeinschaft/htdocs/prov/yealink/settings.php index a26ea57e4..37c8bec1e 100644 --- a/opt/gemeinschaft/htdocs/prov/yealink/settings.php +++ b/opt/gemeinschaft/htdocs/prov/yealink/settings.php @@ -141,7 +141,7 @@ function _redirect_tiptel() # make sure the phone is a Yealink: # -if ((subStr($mac,0,6) !== '001565') && (subStr($mac,0,6) !== '805EC0')) { +if ((subStr($mac,0,6) !== '001565') && (subStr($mac,0,6) !== '805EC0') && (subStr($mac,0,6) !== '805E0C')) { gs_log( GS_LOG_NOTICE, "Yealink provisioning: MAC address \"$mac\" is not a Yealink phone" ); # don't explain this to the users _settings_err( 'No! See log for details.' ); @@ -168,7 +168,7 @@ function _redirect_tiptel() gs_log( GS_LOG_DEBUG, "Yealink model $ua found." ); # find out the type of the phone: -if (preg_match('/SIP-(T42G|T46G|T48G|T42S|T46S)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" +if (preg_match('/SIP-(T42G|T46G|T48G|T42S|T46S|T46U)/', @$ua_parts[1], $m)) { # e.g. "SIP-T46G", "SIP-T48G" or "SIP-T22P" $phone_model = 'SIP-'.$m[1]; $phone_model_config = 'SIP_'.$m[1]; } @@ -452,7 +452,7 @@ function psetting( $param, $val='' ) } # Phonetype Check -if ( in_array($phone_type, array('yealink-sip-t42g','yealink-sip-t46g','yealink-sip-t48g','yealink-sip-t42s','yealink-sip-t46s'), true) ) { +if ( in_array($phone_type, array('yealink-sip-t42g','yealink-sip-t46g','yealink-sip-t48g','yealink-sip-t42s','yealink-sip-t46s','yealink-sip-t46u'), true) ) { ##################################################################### # Common provisioning parameters (applicable to SIP-T28P/T26P/T22P/T20P/T21P/T19P/T46G/T42G/T41P IP phones running firmware version 72 or later) @@ -817,6 +817,10 @@ function psetting( $param, $val='' ) $max_keys=27; psetting('screensaver.wait_time', '21600'); break; + case 'yealink-sip-t46u': + $max_keys=27; + psetting('screensaver.wait_time', '21600'); + break; } # RESET KEYS @@ -862,6 +866,22 @@ function psetting( $param, $val='' ) } } } + + # RESET EXP KEYS on EXP43 + if ($phone_type == 'yealink-sip-t46u') { + # max 3 EXP43 Modules allowed + # get max configured EXP43 count to speed up provisioning + if ($max_ext_modules >3) { $max_ext_modules=3; } + + for ($j=1; $j<=$max_ext_modules; $j++) { + for ($i=1; $i <= 60; $i++) { + psetting('expansion_module.'.$j.'.key.'.$i.'.line', '0'); + psetting('expansion_module.'.$j.'.key.'.$i.'.value', ''); + psetting('expansion_module.'.$j.'.key.'.$i.'.type', '0'); + psetting('expansion_module.'.$j.'.key.'.$i.'.label', ''); + } + } + } $softkeys = null; diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 31b4d7e07..5afa37b4a 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -340,6 +340,7 @@ function _gscnf( $param, $default=null ) _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T48G', null ); _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T42S', null ); _gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46S', null ); +_gscnf( 'YEALINK_PROV_FW_DEFAULT_SIP_T46U', null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP284' , null ); //_gscnf( 'YEALINK_PROV_FW_DEFAULT_IP286' , null ); _gscnf( 'YEALINK_PROV_KEY_BLACKLIST' , '' );