diff --git a/etc/gemeinschaft/gemeinschaft.php b/etc/gemeinschaft/gemeinschaft.php index 5172c270e..80db494b9 100644 --- a/etc/gemeinschaft/gemeinschaft.php +++ b/etc/gemeinschaft/gemeinschaft.php @@ -296,6 +296,10 @@ $SNOM_PROV_PB_NUM_RESULTS = 15; # number of results in phonebook search on Snom phone +$SNOM_PROV_SIP_INFO = false; + # Use Sip-Info to reprovision the phone after changes. + # The phone does not have to reboot for this. + # Before you do firmware updates be sure to read # doc/other/snom-and-cisco-switches.txt # Set $LOG_LEVEL to "NOTICE" or even "DEBUG" and diff --git a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi index c604adf2d..04c54bd68 100755 --- a/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi +++ b/opt/gemeinschaft/dialplan-scripts/in-user-get-ringer.agi @@ -133,13 +133,8 @@ if (strToLower(subStr($user['phone_type'],0,4)) === 'snom') { 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'] .'-snom.wav>') ); - } elseif (array_key_exists('bellcore', $ringtones[$source])) { - if (@$ringtones[$source]['bellcore'] == 1) exit(); - if (@$ringtones[$source]['bellcore'] != 0) { - gs_agi_set_variable( 'ringer', ('') ); - } else { - gs_agi_set_variable( 'ringer', ('') ); - } + } else { + gs_agi_set_variable( 'ringer', (';info=alert-' . $source . ';x-line-id=0') ); } } @@ -215,4 +210,4 @@ else { } -?> \ No newline at end of file +?> diff --git a/opt/gemeinschaft/dialplan-scripts/out-route.agi b/opt/gemeinschaft/dialplan-scripts/out-route.agi index c2ed28fc4..1a95313ba 100755 --- a/opt/gemeinschaft/dialplan-scripts/out-route.agi +++ b/opt/gemeinschaft/dialplan-scripts/out-route.agi @@ -33,6 +33,7 @@ require_once( GS_DIR .'inc/agi-fns.php' ); require_once( GS_DIR .'inc/pcre_check.php' ); include_once( GS_DIR .'inc/group-fns.php' ); include_once( GS_DIR .'inc/get-listen-to-ids.php' ); +include_once( GS_DIR .'inc/nobody-extensions.php' ); ini_set('implicit_flush', 1); ob_implicit_flush(1); @@ -194,10 +195,14 @@ foreach ($gate_grps as $ggrp_id) { if ($qualify_cid && ! in_array(strToLower($out_cid_num), array('anonymous', 'unknown', ''), true)) # no action for "anonymous" { - $user_cid_override = $db->executeGetOne( - 'SELECT `cid_ext` '. - 'FROM `gate_cids` '. - 'WHERE `grp_id` = '.$ggrp_id.' AND `cid_int` = \''.$db->escape($out_cid_num).'\'' ); + if (gs_is_nobody_extension($out_cid_num)) { + $user_cid_override = 0; + } else { + $user_cid_override = $db->executeGetOne( + 'SELECT `cid_ext` '. + 'FROM `gate_cids` '. + 'WHERE `grp_id` = '.$ggrp_id.' AND `cid_int` = \''.$db->escape($out_cid_num).'\'' ); + } if ($user_cid_override !== false) { gs_agi_verbose( '### Overriding caller ID "'.$out_cid_num.'" -> "'.$user_cid_override.'" for gategroup ID: '. $ggrp_id ); $out_cid_num = preg_replace('/[^0-9+a-zA-Z\-_.]/', '', $user_cid_override); diff --git a/opt/gemeinschaft/htdocs/gui/mod/calls_queue.php b/opt/gemeinschaft/htdocs/gui/mod/calls_queue.php index b2a31978c..5ca7f65e9 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/calls_queue.php +++ b/opt/gemeinschaft/htdocs/gui/mod/calls_queue.php @@ -60,12 +60,13 @@ $rs = $DB->execute( 'SELECT SQL_CALC_FOUND_ROWS `d`.`timestamp` `ts`, `d`.`number`, `d`.`remote_name`, - `u`.`id` `r_uid`, `u`.`lastname` `r_ln`, `u`.`firstname` `r_fn` + `u`.`id` `r_uid`, `u`.`lastname` `r_ln`, `u`.`firstname` `r_fn`, + `s`.`callerid` FROM `dial_log` `d` LEFT JOIN - `users` `u` ON (`u`.`id`=`d`.`remote_user_id`) + `users` `u` ON (`u`.`id`=`d`.`remote_user_id`) LEFT JOIN + `ast_sipfriends` `s` ON (`d`.`user_id` = `s`.`_user_id`) WHERE - `d`.`user_id`='. (int)@$_SESSION['sudo_user']['info']['id'] .' AND `d`.`type`=\''. $DB->escape($type) .'\' AND `d`.`timestamp`>'. (time()-GS_PROV_DIAL_LOG_LIFE) .' AND `d`.`number` <> \''. $DB->escape( @$_SESSION['sudo_user']['info']['ext'] ) .'\' @@ -83,6 +84,7 @@ + @@ -131,6 +133,7 @@ if ($r['r_fn'] != '') $name .= ', ' . $r['r_fn']; } echo '', htmlEnt($name), ''; + echo '', htmlEnt($r['callerid']), ''; echo '', date_human($r['ts']), ''; diff --git a/opt/gemeinschaft/htdocs/gui/mod/home_home.php b/opt/gemeinschaft/htdocs/gui/mod/home_home.php index db74df080..b837ff317 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/home_home.php +++ b/opt/gemeinschaft/htdocs/gui/mod/home_home.php @@ -38,6 +38,11 @@ if (! @$_SESSION['sudo_user']['info']['host_is_foreign']) { + if ($action === 'checkcfg') { + + gs_prov_phone_checkcfg_by_ext( $_SESSION['sudo_user']['info']['ext'], false ); + + } if ($action === 'reboot') { gs_prov_phone_checkcfg_by_ext( $_SESSION['sudo_user']['info']['ext'], true ); @@ -374,11 +379,30 @@
-
+ + + + + +
+
+ + + +
+ +
+

diff --git a/opt/gemeinschaft/htdocs/gui/mod/ringtones_ringtones.php b/opt/gemeinschaft/htdocs/gui/mod/ringtones_ringtones.php index 09886c05a..ffa39afb9 100644 --- a/opt/gemeinschaft/htdocs/gui/mod/ringtones_ringtones.php +++ b/opt/gemeinschaft/htdocs/gui/mod/ringtones_ringtones.php @@ -263,7 +263,7 @@ ?>

[1] - Für das Snom kann nur entweder für interne oder für externe Anrufe eine eigene Klingeltondatei eingestellt sein, nicht für beides. Die Länge wird auf wenige Sekunden begrenzt.'); ?> +

-* 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. -\*******************************************************************/ - -/* -URL PARAMETERS: - user= Benutzername - to= Zielrufnummer - - optional: - from= Ausgangsnummer - cidnum= Caller-ID-Nummer - /callerid= - clir=1 zur Rufnummernunterdrueckung - prv=1 fuer Privatgespraech -*/ - - -define( 'GS_VALID', true ); /// this is a parent file -require_once( dirName(__FILE__) .'/../../inc/conf.php' ); -require_once( GS_DIR .'inc/netmask.php' ); -require_once( GS_DIR .'inc/gs-lib.php' ); -include_once( GS_DIR .'inc/gs-fns/gs_user_get.php' ); -include_once( GS_DIR .'inc/gs-fns/gs_user_external_numbers_get.php' ); -require_once( GS_DIR .'inc/get-listen-to-ids.php' ); -require_once( GS_DIR .'inc/remote-exec.php' ); -require_once( GS_DIR .'inc/quote_shell_arg.php' ); -require_once( GS_DIR .'inc/canonization.php' ); - -header( 'Content-Type: text/plain; charset=utf-8' ); -header( 'Pragma: no-cache' ); -header( 'Cache-Control: private, no-cache, must-revalidate' ); -header( 'Expires: 0' ); -header( 'Vary: *' ); - - -function die_not_allowed( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 403 Forbidden', true, 403 ); - header( 'Status: 403 Forbidden' , true, 403 ); - } - die( $msg ); -} -function die_invalid( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 400 Bad Request', true, 400 ); - header( 'Status: 400 Bad Request' , true, 400 ); - } - die( $msg ); -} -function die_ok( $msg ) { - if (! headers_sent()) { - //header( 'HTTP/1.0 204 No Content', true, 204 ); - //header( 'Status: 204 No Content' , true, 204 ); - header( 'HTTP/1.0 200 OK', true, 200 ); - header( 'Status: 200 OK' , true, 200 ); - } - die( $msg ); -} -function die_error( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 500 Internal Server Error', true, 500 ); - header( 'Status: 500 Internal Server Error' , true, 500 ); - } - die( $msg ); -} - -function _normalize_number( $number ) { - $intl_prfx = gs_get_conf('GS_CANONIZE_INTL_PREFIX', '00'); - $number = preg_replace('/^\+/', $intl_prfx, trim($number)); - $number = preg_replace('/[^\d*#]/', '', $number); - return $number; -} - -function _pack_int( $int ) { - $str = base64_encode(pack('N', $int )); - return preg_replace('/[^a-z0-9]/i', '', $str); -} - - - -$remote_ip = @$_SERVER['REMOTE_ADDR']; - -$networks = explode(',', GS_CALL_INIT_FROM_NET); -$allowed = false; -foreach ($networks as $net) { - if (ip_addr_in_network( $remote_ip, trim($net) )) { - $allowed = true; - $net = trim($net); - break; - } -} -if ($allowed) { - gs_log( GS_LOG_DEBUG, "IP $remote_ip is in $net => allowed to init call" ); -} else { - gs_log( GS_LOG_NOTICE, "IP $remote_ip is not in GS_CALL_INIT_FROM_NET => not allowed to init call" ); - die_not_allowed( 'You are not allowed to init a call.' ); -} - - - -##################################################################### -# user -##################################################################### - -if (! isSet( $_REQUEST['user'] )) { - gs_log( GS_LOG_NOTICE, 'No user code specified. Use user=' ); - die_invalid( 'No user code specified. Use user=' ); -} -$user_code = trim( $_REQUEST['user'] ); - -if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) { - # hack to compare user names as if they were integers - # padded to 6 digits - $user_code = lTrim($user_code, '0'); - if (strLen($user_code) < 6) - $user_code = str_pad($user_code, 6, '0', STR_PAD_LEFT); -} - -$user = @gs_user_get( $user_code ); -if (isGsError( $user )) { - gs_log( GS_LOG_NOTICE, $user->getMsg() ); - die_invalid( $user->getMsg() ); -} -if ($user['nobody_index'] > 0) { - gs_log( GS_LOG_NOTICE, 'Nobody user. Not allowed to init a call.' ); - die_not_allowed( 'Nobody user. Not allowed to init a call.' ); -} - -$db = gs_db_master_connect(); -if (! $db) { - gs_log( GS_LOG_NOTICE, 'Could not connect to database.' ); - die_error( 'Could not connect to database.' ); -} - -$is_foreign = (bool)(int)$db->executeGetOne( 'SELECT `is_foreign` FROM `hosts` WHERE `id`='. $user['host_id'] ); - -$user_ext_obj = new CanonicalPhoneNumber( gs_get_conf('GS_CANONIZE_LOCAL_BRANCH') . $user['ext'] ); - -$user_external_numbers = null; - - - -##################################################################### -# from number -##################################################################### - -if (! isSet( $_REQUEST['from'] )) { - $from_num = null; # i.e. use default -} else { - $from_num = _normalize_number( $_REQUEST['from'] ); -} -if ($from_num === $user['ext']) { - $from_num = null; -} else { - $from_num_obj = new CanonicalPhoneNumber( $from_num ); - if ($from_num_obj->intl === $user_ext_obj->intl) { - $from_num = null; - } - unset($from_num_obj); # from_num might be modified later -} -if ($from_num) { - # get external numbers - $user_external_numbers = @gs_user_external_numbers_get( $user_code ); - if (isGsError($user_external_numbers)) { - gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); - $user_external_numbers = array(); - } - if (! is_array($user_external_numbers)) { - $user_external_numbers = array(); - } - - # check if number in external numbers - if (! in_array($from_num, $user_external_numbers, true)) { - $from_num_obj = new CanonicalPhoneNumber( $from_num ); - if ($from_num_obj->errt != '' && $from_num_obj->errt !== 'self') { - gs_log( GS_LOG_WARNING, 'Problem with phone number "'. $from_num .'" ('. $from_num_obj->errt .').' ); - $in_external_numbers = false; - } else { - if (in_array($from_num_obj->intl, $user_external_numbers, true)) { - $in_external_numbers = true; - } else { - $in_external_numbers = false; - if (count($user_external_numbers) > 0) { - foreach ($user_external_numbers as $user_external_number) { - $tmp = new CanonicalPhoneNumber( $user_external_number ); - if ($tmp->intl === $from_num_obj->intl) { - //gs_log( GS_LOG_DEBUG, 'Number "'. $tmp->intl .'" equals "'. $from_num .'"' ); - $in_external_numbers = true; - break; - } - } - unset($tmp); - } - } - } - if (! $in_external_numbers) { - gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $from_num .'" in external numbers. Falling back to default number "'. $user['ext'] .'".' ); - $from_num = null; - } - unset($in_external_numbers); - unset($from_num_obj); - } -} -$from_num_effective = ($from_num - ? $from_num - : gs_get_conf('GS_CANONIZE_NATL_PREFIX') . - gs_get_conf('GS_CANONIZE_AREA_CODE') . - gs_get_conf('GS_CANONIZE_LOCAL_BRANCH') . - $user['ext'] - ); -$from_num_effective_obj = new CanonicalPhoneNumber( $from_num_effective ); - - - -##################################################################### -# cidnum -##################################################################### - -if (isSet( $_REQUEST['cidnum'] )) { - $cidnum = _normalize_number( $_REQUEST['cidnum'] ); -} elseif (isSet( $_REQUEST['callerid'] )) { - $cidnum = _normalize_number( $_REQUEST['callerid'] ); -} else { - $cidnum = null; # i.e. use the default -} - -if ($cidnum === $user['ext']) { - $cidnum = null; -} else { - $cidnum_obj = new CanonicalPhoneNumber( $cidnum ); - if ($cidnum_obj->intl === $user_ext_obj->intl) { - $cidnum = null; - } - unset($cidnum_obj); # cidnum might be modified later -} -if ($cidnum) { -if (! $is_foreign) { - # get external numbers - if (! is_array($user_external_numbers)) { - $user_external_numbers = @gs_user_external_numbers_get( $user_code ); - if (isGsError($user_external_numbers)) { - gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); - $user_external_numbers = array(); - } - if (! is_array($user_external_numbers)) { - $user_external_numbers = array(); - } - } - - # check if number in external numbers - if (! in_array($cidnum, $user_external_numbers, true)) { - $cidnum_obj = new CanonicalPhoneNumber( $cidnum ); - if ($cidnum_obj->errt != '' && $cidnum_obj->errt !== 'self') { - gs_log( GS_LOG_WARNING, 'Problem with phone number "'. $cidnum .'" ('. $cidnum_obj->errt .').' ); - $in_external_numbers = false; - } else { - if (in_array($cidnum_obj->intl, $user_external_numbers, true)) { - $in_external_numbers = true; - } else { - $in_external_numbers = false; - if (count($user_external_numbers) > 0) { - foreach ($user_external_numbers as $user_external_number) { - $tmp = new CanonicalPhoneNumber( $user_external_number ); - if ($tmp->intl === $cidnum_obj->intl) { - //gs_log( GS_LOG_DEBUG, 'Number "'. $tmp->intl .'" equals "'. $cidnum .'"' ); - $in_external_numbers = true; - break; - } - } - unset($tmp); - } - } - } - if (! $in_external_numbers) { - gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $cidnum .'" in external numbers. Falling back to default number (from=) as CIDnum.' ); - $cidnum = null; - } - unset($in_external_numbers); - unset($cidnum_obj); - } -}/* else { - # user on a foreign host - # as it's not us to initiate the call we don't care to check the cidnum -}*/ -} - - - -##################################################################### -# to number -##################################################################### - -if (! isSet( $_REQUEST['to'] )) { - gs_log( GS_LOG_NOTICE, 'No phone number specified. Use to=' ); - die_invalid( 'No phone number specified. Use to=' ); -} -$to_num = _normalize_number( $_REQUEST['to'] ); -$to_num_obj = new CanonicalPhoneNumber( $to_num ); - -$from_equals_to = false; -if ($to_num === $from_num_effective) { - $from_equals_to = true; -} else { - if ($to_num_obj->intl === $from_num_effective_obj->intl) { - $from_equals_to = true; - } -} -if ($from_equals_to) { - # from_num and to_num must not be the same - would probably result - # in voicemail picking up the phone - gs_log( GS_LOG_NOTICE, 'Won\'t make a call when from and to numbers are equal ('. $to_num .').' ); - die_invalid( 'Can\'t make a call from "'. $from_num_effective .'" to "'. $to_num .'".' ); -} - - - -##################################################################### -# CLIR -##################################################################### - -if (! isSet( $_REQUEST['clir'] )) { - $clir = false; -} else { - $clir = strToLower(trim( $_REQUEST['clir'] )); - $clir = ($clir > 0 || $clir==='yes' || $clir==='true'); -} - - -##################################################################### -# private call -##################################################################### - -if (! isSet( $_REQUEST['prv'] )) { - $prv = false; -} else { - $prv = strToLower(trim( $_REQUEST['prv'] )); - $prv = ($prv > 0 || $prv==='yes' || $prv==='true'); -} -$prvPrefix = $prv ? '*7*' : ''; - - - -##################################################################### -# init call -##################################################################### - -gs_log( GS_LOG_DEBUG, "Init call - user: $user_code, from: ". ($from_num ? $from_num : 'default ('.$from_num_effective.')') .", to: $to_num, clir: ". ($clir ? 'yes':'no') ); - -if (! $clir) { - $firstname_abbr = mb_subStr($user['firstname'],0,1); - $firstname_abbr = ($firstname_abbr != '') ? $firstname_abbr .'. ' : ''; - if (! $cidnum) - $callerid = $firstname_abbr . $user['lastname'] .' <'. $from_num_effective .'>'; - else - $callerid = $firstname_abbr . $user['lastname'] .' <'. ($cidnum ? $cidnum : $from_num_effective) .'>'; -} else { - $callerid = 'Anonymous '; -} - - -if (! $is_foreign) { - - //FIXME? - is this code correct for numbers in the same area? - $to_num = (subStr($to_num_obj->dial,0,1) === '0') # intl. or natl. - ? '0'.$to_num_obj->dial # Amtsholung - : $to_num_obj->dial; - $from_num_dial = (subStr($from_num_effective_obj->dial,0,1) === '0') # intl. or natl. - ? '0'.$from_num_effective_obj->dial # Amtsholung - : $from_num_effective_obj->dial; - - $call - //= "Channel: Local/". $from_num_dial ."\n" - = "Channel: Local/urldial-". $from_num_dial ."@to-internal-users-self\n" - . "MaxRetries: 0\n" - . "WaitTime: 15\n" - . "Context: urldial\n" - . "Extension: $prvPrefix$to_num\n" - . "Callerid: Rufaufbau \n" - . "Setvar: __user_id=". $user['id'] ."\n" - . "Setvar: __user_name=". $user['ext'] ."\n" - . "Setvar: CHANNEL(language)=". gs_get_conf('GS_INTL_ASTERISK_LANG','de') ."\n" - . "Setvar: __is_callfile_origin=1\n" # no forwards and no mailbox on origin side - . "Setvar: __saved_callerid=". $callerid ."\n" - . "Setvar: __callfile_from_user=". $user['ext'] ."\n" - ; - //echo $call; - - $filename = '/tmp/gs-'. $user['id'] .'-'. _pack_int(time()) . rand(100,999) .'.call'; - $cf = @fOpen( $filename, 'wb' ); - if (! $cf) { - gs_log( GS_LOG_WARNING, 'Failed to write call file "'. $filename .'"' ); - die_error( 'Failed to write call file.' ); - } - @fWrite( $cf, $call, strLen($call) ); - @fClose( $cf ); - @chmod( $filename, 00666 ); - - $spoolfile = '/var/spool/asterisk/outgoing/'. baseName($filename); - - if (! gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) { - $our_host_ids = @gs_get_listen_to_ids(); - if (! is_array($our_host_ids)) $our_host_ids = array(); - $user_is_on_this_host = in_array( $user['host_id'], $our_host_ids ); - } else { - $user_is_on_this_host = true; - } - - if ($user_is_on_this_host) { - - # the Asterisk of this user and the web server both run on this host - - //$ok = @rename( $filename, $spoolfile ); - $err=0; $out=array(); - @exec( 'sudo mv '. qsa($filename) .' '. qsa($spoolfile) .' 1>>/dev/null 2>>/dev/null', $out, $err ); - if ($err != 0) { - @unlink( $filename ); - gs_log( GS_LOG_WARNING, 'Failed to move call file "'. $filename .'" to "'. '/var/spool/asterisk/outgoing/'. baseName($filename) .'"' ); - die_error( 'Failed to move call file.' ); - } - - } - else { - - $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes '. qsa( $filename ) .' '. qsa( 'root@'. $user['host'] .':'. $filename ); - //echo $cmd, "\n"; - @exec( $cmd .' 1>>/dev/null 2>>/dev/null', $out, $err ); - @unlink( $filename ); - if ($err != 0) { - gs_log( GS_LOG_WARNING, 'Failed to scp call file "'. $filename .'" to '. $user['host'] ); - die_error( 'Failed to scp call file.' ); - } - //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo! - $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root '. qsa( $user['host'] ) .' '. qsa( 'mv '. qsa( $filename ) .' '. qsa( $spoolfile ) ); - //echo $cmd, "\n"; - @exec( $cmd .' 1>>/dev/null 2>>/dev/null', $out, $err ); - if ($err != 0) { - gs_log( GS_LOG_WARNING, 'Failed to mv call file "'. $filename .'" on '. $user['host'] .' to "'. $spoolfile .'"' ); - die_error( 'Failed to mv call file on remote host.' ); - } - - } - -} -else { - - include_once( GS_DIR .'inc/boi-soap/boi-api.php' ); - $api = gs_host_get_api( $user['host_id'] ); - switch ($api) { - case 'm01': - case 'm02': - if (! extension_loaded('soap')) { - gs_log( GS_LOG_NOTICE, 'Failed to initiate call on foreign host (SoapClient not available).' ); - die_error( 'Failed to initiate call on foreign host (SoapClient not available).' ); - } else { - include_once( GS_DIR .'inc/boi-soap/boi-soap.php' ); - $ok = gs_boi_call_init( $api, $user['host'], $user_code, $to_num_obj->norm, $from_num_effective_obj->norm, $cidnum, $clir, $prv ); - if (! $ok) { - gs_log( GS_LOG_NOTICE, 'Failed to initiate call on foreign host (SOAP error).' ); - die_error( 'Failed to initiate call on foreign host (SOAP error).' ); - } - gs_log( GS_LOG_DEBUG, "OK. Calling ". $to_num_obj->norm ." from ". $from_num_effective_obj->norm ." (user $user_code) on host ". $user['host'] ."..." ); - die_ok( "OK. Calling ". $to_num_obj->norm ." from ". $from_num_effective_obj->norm ." (user $user_code) on host ". $user['host'] ."..." ); - } - break; - - case '': - # host does not provide any API - gs_log( GS_LOG_WARNING, 'Failed initiate call on foreign host '.$user['host'].' without any API' ); - die_error( 'Failed initiate call on foreign host '.$user['host'].' without any API' ); - break; - - default: - gs_log( GS_LOG_WARNING, 'Failed to initiate call on foreign host '. $user['host'] .' - invalid API "'.$api.'"' ); - die_error( 'Failed to initiate call on foreign host '. $user['host'] .' - invalid API "'.$api.'"'); - } - -} - - -gs_log( GS_LOG_DEBUG, "OK. Calling $to_num from ". $from_num_effective_obj->dial ." ..." ); -die_ok( "OK. Calling $to_num from ". $from_num_effective_obj->dial ." ..." ); - - -?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/call-init-2.php b/opt/gemeinschaft/htdocs/prov/call-init-2.php new file mode 120000 index 000000000..7e7c3d86c --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/call-init-2.php @@ -0,0 +1 @@ +call-init-direct.php \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/call-init-direct.php b/opt/gemeinschaft/htdocs/prov/call-init-direct.php new file mode 100644 index 000000000..2d6146c69 --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/call-init-direct.php @@ -0,0 +1,302 @@ + +* 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. +\*******************************************************************/ + +# +# custom call-init script to work with snom dialbox +# + +/* +URL PARAMETERS: + user= Benutzername + to= Zielrufnummer +*/ + + +define( 'GS_VALID', true ); /// this is a parent file +require_once( dirName(__FILE__) .'/../../inc/conf.php' ); +require_once( GS_DIR .'inc/netmask.php' ); +require_once( GS_DIR .'inc/gs-lib.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_hosts_get.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_user_get.php' ); +include_once( GS_DIR .'inc/gs-fns/gs_user_external_numbers_get.php' ); +require_once( GS_DIR .'inc/get-listen-to-ids.php' ); +require_once( GS_DIR .'inc/remote-exec.php' ); +require_once( GS_DIR .'inc/quote_shell_arg.php' ); + +header( 'Content-Type: text/plain; charset=utf-8' ); +header( 'Pragma: no-cache' ); +header( 'Cache-Control: private, no-cache, must-revalidate' ); +header( 'Expires: 0' ); +header( 'Vary: *' ); + + +function die_not_allowed( $msg ) { + if (! headers_sent()) { + header( 'HTTP/1.0 403 Forbidden', true, 403 ); + header( 'Status: 403 Forbidden' , true, 403 ); + } + die( $msg ); +} +function die_invalid( $msg ) { + if (! headers_sent()) { + header( 'HTTP/1.0 400 Bad Request', true, 400 ); + header( 'Status: 400 Bad Request' , true, 400 ); + } + die( $msg ); +} +function die_ok( $msg ) { + if (! headers_sent()) { + //header( 'HTTP/1.0 204 No Content', true, 204 ); + //header( 'Status: 204 No Content' , true, 204 ); + header( 'HTTP/1.0 200 OK', true, 200 ); + header( 'Status: 200 OK' , true, 200 ); + } + die( $msg ); +} +function die_error( $msg ) { + if (! headers_sent()) { + header( 'HTTP/1.0 500 Internal Server Error', true, 500 ); + header( 'Status: 500 Internal Server Error' , true, 500 ); + } + die( $msg ); +} + +function _normalize_number( $number ) { + $intl_prfx = gs_get_conf('GS_CANONIZE_INTL_PREFIX', '00'); + $number = preg_replace('/^\+/', $intl_prfx, trim($number)); + $number = preg_replace('/[^\d*#]/', '', $number); + return $number; +} + +function _pack_int( $int ) { + $str = base64_encode(pack('N', $int )); + return preg_replace('/[^a-z\d]/i', '', $str); +} + + + +$remote_ip = @$_SERVER['REMOTE_ADDR']; + +$networks = explode(',', GS_CALL_INIT_FROM_NET); +$allowed = false; +foreach ($networks as $net) { + if (ip_addr_in_network( $remote_ip, trim($net) )) { + $allowed = true; + $net = trim($net); + break; + } +} +if ($allowed) { + gs_log( GS_LOG_DEBUG, "IP $remote_ip is in $net => allowed to init call" ); +} else { + gs_log( GS_LOG_NOTICE, "IP $remote_ip is not in GS_CALL_INIT_FROM_NET => not allowed to init call" ); + die_not_allowed( 'You are not allowed to init a call.' ); +} + +gs_log( GS_LOG_WARNING, 'Using legacy call-init script!' ); + + +# user +# +if (! isSet( $_REQUEST['user'] )) + die_invalid( 'No user code specified. Use user=' ); +$user_code = trim( $_REQUEST['user'] ); + +if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) { + # hack to compare user names as if they were integers + # padded to 6 digits + $user_code = lTrim($user_code, '0'); + if (strLen($user_code) < 6) + $user_code = str_pad($user_code, 6, '0', STR_PAD_LEFT); +} + +$is_LVM_agenturmitarbeiter = + (gs_get_conf('GS_LVM_CALL_INIT_USERS_500000') && $user_code >= '500000'); + +if (! $is_LVM_agenturmitarbeiter) { + $user = @ gs_user_get( $user_code ); + if (isGsError( $user )) + die_invalid( $user->getMsg() ); + if ($user['nobody_index'] > 0) + die_not_allowed( 'Nobody user. Not allowed to init a call.' ); +} else { + $user = array( + 'id' => 0, + 'user' => $user_code, + 'pin' => null, + 'lastname' => '(Agenturmitarbeiter)', + 'firstname' => '', + 'honorific' => '', + 'nobody_index'=> null, + 'ext' => '', + 'callerid' => 'Anonymous ', + 'mailbox' => '', + 'host_id' => 0, + 'host' => '0.0.0.0' + ); +} + + +# from number +# +if (! isSet( $_REQUEST['from'] )) { + $from_num = null; # i.e. use default +} else { + $from_num = _normalize_number( $_REQUEST['from'] ); +} +if ($from_num === $user['ext']) { + $from_num = null; +} +if ($from_num) { + if (! $is_LVM_agenturmitarbeiter) { + $user_external_numbers = @gs_user_external_numbers_get( $user_code ); + if (isGsError($user_external_numbers)) { + gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); + $user_external_numbers = array(); + } + if (! is_array($user_external_numbers)) { + $user_external_numbers = array(); + } + if (! in_array($from_num, $user_external_numbers, true)) { + gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $from_num .'" in external numbers. Falling back to default number "'. $user['ext'] .'".' ); + $from_num = null; + } + } else { + $user_external_numbers = array(); + } +} else { + if ($is_LVM_agenturmitarbeiter) { + die_invalid( 'LVM Agenturmitarbeiter - must use from=' ); + } +} +$from_num_effective = ($from_num ? $from_num : $user['ext']); + + +# cidnum +# +if (isSet( $_REQUEST['cidnum'] )) { + $cidnum = _normalize_number( $_REQUEST['cidnum'] ); +} elseif (isSet( $_REQUEST['callerid'] )) { + $cidnum = _normalize_number( $_REQUEST['callerid'] ); +} else { + $cidnum = null; # i.e. use the default +} + +if ($cidnum === $user['ext']) { + $cidnum = null; +} +if ($cidnum) { + if (! $is_LVM_agenturmitarbeiter) { + if (! is_array($user_external_numbers)) { + # we might already have that + $user_external_numbers = @gs_user_external_numbers_get( $user_code ); + if (isGsError($user_external_numbers)) { + gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); + $user_external_numbers = array(); + } + if (! is_array($user_external_numbers)) { + $user_external_numbers = array(); + } + } + if (! in_array($cidnum, $user_external_numbers, true)) { + gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $cidnum .'" in external numbers. Falling back to default number (from=) as CIDnum.' ); + $cidnum = null; + } + } else { + $cidnum = null; + } +} + + + +# to number +# +if (! isSet( $_REQUEST['to'] )) + die_invalid( 'No phone number specified. Use to=' ); +$to_num = _normalize_number( $_REQUEST['to'] ); + +if ( ( $from_num && $to_num === $from_num ) +|| (! $from_num && $to_num === $user['ext']) ) +{ + # from_num and to_num must not be the same - would probably result + # in voicemail picking up the phone + gs_log( GS_LOG_NOTICE, 'Won\'t make a call when from and to numbers are equal ('. $to_num .').' ); + die_invalid( 'Can\'t make a call from "'. $from_num_effective .'" to "'. $to_num .'".' ); +} + + +# CLIR +# +if (! isSet( $_REQUEST['clir'] )) { + $clir = false; +} else { + $clir = strToLower(trim( $_REQUEST['clir'] )); + $clir = ($clir > 0 || $clir==='yes' || $clir==='true'); +} + +# private call +# +if (! isSet( $_REQUEST['prv'] )) { + $prv = false; +} else { + $prv = strToLower(trim( $_REQUEST['prv'] )); + $prv = ($prv > 0 || $prv==='yes' || $prv==='true'); +} +$prvPrefix = $prv ? '*7*' : ''; + + + + +gs_log( GS_LOG_DEBUG, "Init call - user: $user_code, from: ". ($from_num ? $from_num : 'default ('.$from_num_effective.')') .", to: $to_num, clir: ". ($clir ? 'yes':'no') ); + +if (! $clir) { + if (! $is_LVM_agenturmitarbeiter) { + $firstname_abbr = mb_subStr($user['firstname'],0,1); + $firstname_abbr = ($firstname_abbr != '') ? $firstname_abbr .'. ' : ''; + if (! $cidnum) + $callerid = $firstname_abbr . $user['lastname'] .' <'. $from_num_effective .'>'; + else + $callerid = $firstname_abbr . $user['lastname'] .' <'. ($cidnum ? $cidnum : $from_num_effective) .'>'; + } else { + $callerid = 'Agenturmitarbeiter '; + } +} else { + $callerid = 'Anonymous '; +} + +$db = gs_db_slave_connect(); +$phone_ip_addr = $db->executeGetOne('SELECT `current_ip` FROM `users` WHERE `id`=' . $user['id'] ); + +$dialbox_url = 'http://' . $phone_ip_addr . '/?NUMBER=' . $to_num . '&DIAL=true'; +gs_log( GS_LOG_DEBUG, "Init call - calling " . $dialbox_url ); +file_get_contents($dialbox_url); + +die_ok( "OK. Calling $to_num from $from_num_effective ..." ); + + +?> diff --git a/opt/gemeinschaft/htdocs/prov/call-init.php b/opt/gemeinschaft/htdocs/prov/call-init.php deleted file mode 100644 index e170a8e7e..000000000 --- a/opt/gemeinschaft/htdocs/prov/call-init.php +++ /dev/null @@ -1,400 +0,0 @@ - -* 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. -\*******************************************************************/ - -# -# legacy call-init script ! -# - -/* -URL PARAMETERS: - user= Benutzername - to= Zielrufnummer - - optional: - from= Ausgangsnummer - cidnum= Caller-ID-Nummer - /callerid= - clir=1 zur Rufnummernunterdrueckung - prv=1 fuer Privatgespraech -*/ - - -define( 'GS_VALID', true ); /// this is a parent file -require_once( dirName(__FILE__) .'/../../inc/conf.php' ); -require_once( GS_DIR .'inc/netmask.php' ); -require_once( GS_DIR .'inc/gs-lib.php' ); -include_once( GS_DIR .'inc/gs-fns/gs_hosts_get.php' ); -include_once( GS_DIR .'inc/gs-fns/gs_user_get.php' ); -include_once( GS_DIR .'inc/gs-fns/gs_user_external_numbers_get.php' ); -require_once( GS_DIR .'inc/get-listen-to-ids.php' ); -require_once( GS_DIR .'inc/remote-exec.php' ); -require_once( GS_DIR .'inc/quote_shell_arg.php' ); - -header( 'Content-Type: text/plain; charset=utf-8' ); -header( 'Pragma: no-cache' ); -header( 'Cache-Control: private, no-cache, must-revalidate' ); -header( 'Expires: 0' ); -header( 'Vary: *' ); - - -function die_not_allowed( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 403 Forbidden', true, 403 ); - header( 'Status: 403 Forbidden' , true, 403 ); - } - die( $msg ); -} -function die_invalid( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 400 Bad Request', true, 400 ); - header( 'Status: 400 Bad Request' , true, 400 ); - } - die( $msg ); -} -function die_ok( $msg ) { - if (! headers_sent()) { - //header( 'HTTP/1.0 204 No Content', true, 204 ); - //header( 'Status: 204 No Content' , true, 204 ); - header( 'HTTP/1.0 200 OK', true, 200 ); - header( 'Status: 200 OK' , true, 200 ); - } - die( $msg ); -} -function die_error( $msg ) { - if (! headers_sent()) { - header( 'HTTP/1.0 500 Internal Server Error', true, 500 ); - header( 'Status: 500 Internal Server Error' , true, 500 ); - } - die( $msg ); -} - -function _normalize_number( $number ) { - $intl_prfx = gs_get_conf('GS_CANONIZE_INTL_PREFIX', '00'); - $number = preg_replace('/^\+/', $intl_prfx, trim($number)); - $number = preg_replace('/[^\d*#]/', '', $number); - return $number; -} - -function _pack_int( $int ) { - $str = base64_encode(pack('N', $int )); - return preg_replace('/[^a-z\d]/i', '', $str); -} - - - -$remote_ip = @$_SERVER['REMOTE_ADDR']; - -$networks = explode(',', GS_CALL_INIT_FROM_NET); -$allowed = false; -foreach ($networks as $net) { - if (ip_addr_in_network( $remote_ip, trim($net) )) { - $allowed = true; - $net = trim($net); - break; - } -} -if ($allowed) { - gs_log( GS_LOG_DEBUG, "IP $remote_ip is in $net => allowed to init call" ); -} else { - gs_log( GS_LOG_NOTICE, "IP $remote_ip is not in GS_CALL_INIT_FROM_NET => not allowed to init call" ); - die_not_allowed( 'You are not allowed to init a call.' ); -} - -gs_log( GS_LOG_WARNING, 'Using legacy call-init script!' ); - - -# user -# -if (! isSet( $_REQUEST['user'] )) - die_invalid( 'No user code specified. Use user=' ); -$user_code = trim( $_REQUEST['user'] ); - -if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) { - # hack to compare user names as if they were integers - # padded to 6 digits - $user_code = lTrim($user_code, '0'); - if (strLen($user_code) < 6) - $user_code = str_pad($user_code, 6, '0', STR_PAD_LEFT); -} - -$is_LVM_agenturmitarbeiter = - (gs_get_conf('GS_LVM_CALL_INIT_USERS_500000') && $user_code >= '500000'); - -if (! $is_LVM_agenturmitarbeiter) { - $user = @ gs_user_get( $user_code ); - if (isGsError( $user )) - die_invalid( $user->getMsg() ); - if ($user['nobody_index'] > 0) - die_not_allowed( 'Nobody user. Not allowed to init a call.' ); -} else { - $user = array( - 'id' => 0, - 'user' => $user_code, - 'pin' => null, - 'lastname' => '(Agenturmitarbeiter)', - 'firstname' => '', - 'honorific' => '', - 'nobody_index'=> null, - 'ext' => '', - 'callerid' => 'Anonymous ', - 'mailbox' => '', - 'host_id' => 0, - 'host' => '0.0.0.0' - ); -} - - -# from number -# -if (! isSet( $_REQUEST['from'] )) { - $from_num = null; # i.e. use default -} else { - $from_num = _normalize_number( $_REQUEST['from'] ); -} -if ($from_num === $user['ext']) { - $from_num = null; -} -if ($from_num) { - if (! $is_LVM_agenturmitarbeiter) { - $user_external_numbers = @gs_user_external_numbers_get( $user_code ); - if (isGsError($user_external_numbers)) { - gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); - $user_external_numbers = array(); - } - if (! is_array($user_external_numbers)) { - $user_external_numbers = array(); - } - if (! in_array($from_num, $user_external_numbers, true)) { - gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $from_num .'" in external numbers. Falling back to default number "'. $user['ext'] .'".' ); - $from_num = null; - } - } else { - $user_external_numbers = array(); - } -} else { - if ($is_LVM_agenturmitarbeiter) { - die_invalid( 'LVM Agenturmitarbeiter - must use from=' ); - } -} -$from_num_effective = ($from_num ? $from_num : $user['ext']); - - -# cidnum -# -if (isSet( $_REQUEST['cidnum'] )) { - $cidnum = _normalize_number( $_REQUEST['cidnum'] ); -} elseif (isSet( $_REQUEST['callerid'] )) { - $cidnum = _normalize_number( $_REQUEST['callerid'] ); -} else { - $cidnum = null; # i.e. use the default -} - -if ($cidnum === $user['ext']) { - $cidnum = null; -} -if ($cidnum) { - if (! $is_LVM_agenturmitarbeiter) { - if (! is_array($user_external_numbers)) { - # we might already have that - $user_external_numbers = @gs_user_external_numbers_get( $user_code ); - if (isGsError($user_external_numbers)) { - gs_log( GS_LOG_WARNING, $user_external_numbers->getMsg() ); - $user_external_numbers = array(); - } - if (! is_array($user_external_numbers)) { - $user_external_numbers = array(); - } - } - if (! in_array($cidnum, $user_external_numbers, true)) { - gs_log( GS_LOG_WARNING, 'User '. $user_code .' does not have "'. $cidnum .'" in external numbers. Falling back to default number (from=) as CIDnum.' ); - $cidnum = null; - } - } else { - $cidnum = null; - } -} - - - -# to number -# -if (! isSet( $_REQUEST['to'] )) - die_invalid( 'No phone number specified. Use to=' ); -$to_num = _normalize_number( $_REQUEST['to'] ); - -if ( ( $from_num && $to_num === $from_num ) -|| (! $from_num && $to_num === $user['ext']) ) -{ - # from_num and to_num must not be the same - would probably result - # in voicemail picking up the phone - gs_log( GS_LOG_NOTICE, 'Won\'t make a call when from and to numbers are equal ('. $to_num .').' ); - die_invalid( 'Can\'t make a call from "'. $from_num_effective .'" to "'. $to_num .'".' ); -} - - -# CLIR -# -if (! isSet( $_REQUEST['clir'] )) { - $clir = false; -} else { - $clir = strToLower(trim( $_REQUEST['clir'] )); - $clir = ($clir > 0 || $clir==='yes' || $clir==='true'); -} - -# private call -# -if (! isSet( $_REQUEST['prv'] )) { - $prv = false; -} else { - $prv = strToLower(trim( $_REQUEST['prv'] )); - $prv = ($prv > 0 || $prv==='yes' || $prv==='true'); -} -$prvPrefix = $prv ? '*7*' : ''; - - - - -gs_log( GS_LOG_DEBUG, "Init call - user: $user_code, from: ". ($from_num ? $from_num : 'default ('.$from_num_effective.')') .", to: $to_num, clir: ". ($clir ? 'yes':'no') ); - -if (! $clir) { - if (! $is_LVM_agenturmitarbeiter) { - $firstname_abbr = mb_subStr($user['firstname'],0,1); - $firstname_abbr = ($firstname_abbr != '') ? $firstname_abbr .'. ' : ''; - if (! $cidnum) - $callerid = $firstname_abbr . $user['lastname'] .' <'. $from_num_effective .'>'; - else - $callerid = $firstname_abbr . $user['lastname'] .' <'. ($cidnum ? $cidnum : $from_num_effective) .'>'; - } else { - $callerid = 'Agenturmitarbeiter '; - } -} else { - $callerid = 'Anonymous '; -} - -/* -$call = "Channel: Local/". $from_num_effective ."\n" - . "MaxRetries: 0\n" - //. "RetryTime: 5\n" - . "WaitTime: 15\n" - . "Context: from-internal-users\n" - . "Extension: $prvPrefix$to_num\n" - . "Callerid: $callerid\n" - . "Setvar: __user_id=". $user['id'] ."\n" - . "Setvar: __user_name=". $user['ext'] ."\n" - . "Setvar: CHANNEL(language)=". gs_get_conf('GS_INTL_ASTERISK_LANG','de') ."\n" - . "Setvar: __is_callcompletion=1\n" # prevent vm from answering - . "Setvar: __saved_callerid=$callerid\n" # always useful to know the orgin -; -*/ -$call = "Channel: Local/". $from_num_effective ."\n" - . "MaxRetries: 0\n" - //. "RetryTime: 5\n" - . "WaitTime: 15\n" - . "Context: urldial\n" - . "Extension: $prvPrefix$to_num\n" - . "Callerid: PBX \n" - . "Setvar: __user_id=". $user['id'] ."\n" - . "Setvar: __user_name=". $user['ext'] ."\n" - . "Setvar: CHANNEL(language)=". gs_get_conf('GS_INTL_ASTERISK_LANG','de') ."\n" - . "Setvar: __is_callfile_origin=1\n" # no forwards and no mailbox on origin side - . "Setvar: __saved_callerid=". $callerid ."\n" - . "Setvar: __callfile_from_user=". $user['ext'] ."\n" -; - -//echo $call; - -$filename = '/tmp/gs-'. $user['id'] .'-'. _pack_int(time()) . rand(100,999) .'.call'; -$cf = @fOpen( $filename, 'wb' ); -if (! $cf) { - gs_log( GS_LOG_WARNING, 'Failed to write call file "'. $filename .'"' ); - die_error( 'Failed to write call file.' ); -} -@fWrite( $cf, $call, strLen($call) ); -@fClose( $cf ); -@chmod( $filename, 00666 ); - -$spoolfile = '/var/spool/asterisk/outgoing/'. baseName($filename); - - -if (! gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) { - $our_host_ids = @gs_get_listen_to_ids(); - if (! is_array($our_host_ids)) $our_host_ids = array(); - $user_is_on_this_host = in_array( $user['host_id'], $our_host_ids ); -} else { - $user_is_on_this_host = true; -} - -if ($is_LVM_agenturmitarbeiter) { - $hosts = gs_hosts_get(); - if (isGsError($hosts) || ! is_array($hosts) || count($hosts)<1) - die_error( 'Could not get hosts.' ); - //$host = $hosts[rand(0,count($hosts)-1)]; - $host = $hosts[0]; - $user['host_id'] = $host['id']; - $user['host'] = $host['host']; -} - -if ($user_is_on_this_host) { - - # the Asterisk of this user and the web server both run on this host - - //$ok = @rename( $filename, $spoolfile ); - $err=0; $out=array(); - @exec( 'sudo mv '. qsa($filename) .' '. qsa($spoolfile) .' 1>>/dev/null 2>>/dev/null', $out, $err ); - if ($err != 0) { - @unlink( $filename ); - gs_log( GS_LOG_WARNING, 'Failed to move call file "'. $filename .'" to "'. '/var/spool/asterisk/outgoing/'. baseName($filename) .'"' ); - die_error( 'Failed to move call file.' ); - } - -} -else { - - $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes '. qsa( $filename ) .' '. qsa( 'root@'. $user['host'] .':'. $filename ); - //echo $cmd, "\n"; - @exec( $cmd .' 1>>/dev/null 2>>/dev/null', $out, $err ); - @unlink( $filename ); - if ($err != 0) { - gs_log( GS_LOG_WARNING, 'Failed to scp call file "'. $filename .'" to '. $user['host'] ); - die_error( 'Failed to scp call file.' ); - } - //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo! - $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root '. qsa( $user['host'] ) .' '. qsa( 'mv '. qsa( $filename ) .' '. qsa( $spoolfile ) ); - //echo $cmd, "\n"; - @exec( $cmd .' 1>>/dev/null 2>>/dev/null', $out, $err ); - if ($err != 0) { - gs_log( GS_LOG_WARNING, 'Failed to mv call file "'. $filename .'" on '. $user['host'] .' to "'. $spoolfile .'"' ); - die_error( 'Failed to mv call file on remote host.' ); - } - -} - -die_ok( "OK. Calling $to_num from $from_num_effective ..." ); - - -?> \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/call-init.php b/opt/gemeinschaft/htdocs/prov/call-init.php new file mode 120000 index 000000000..7e7c3d86c --- /dev/null +++ b/opt/gemeinschaft/htdocs/prov/call-init.php @@ -0,0 +1 @@ +call-init-direct.php \ No newline at end of file diff --git a/opt/gemeinschaft/htdocs/prov/snom/dial-log.php b/opt/gemeinschaft/htdocs/prov/snom/dial-log.php index 4ea1a8295..e09789afd 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/dial-log.php +++ b/opt/gemeinschaft/htdocs/prov/snom/dial-log.php @@ -176,11 +176,12 @@ function _err( $msg='' ) if ($type === 'queue'){ $query = 'SELECT - `timestamp` `ts`, `number`, `remote_name`, `remote_user_id` - FROM `dial_log` + `d`.`timestamp` `ts`, `d`.`number`, `d`.`remote_name`, `d`.`remote_user_id`, + `s`.`name` `int_user` + FROM `dial_log` `d` LEFT JOIN + `ast_sipfriends` `s` ON (`d`.`user_id` = `s`.`_user_id`) WHERE - `user_id`='. $user_id .' AND - `type`=\''. $type .'\' + `d`.`type`=\''. $type .'\' ORDER BY `ts` DESC LIMIT 20'; } else { @@ -206,18 +207,27 @@ function _err( $msg='' ) 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'] .')'; + + if($type == 'queue') { + $entry_name = $r['remote_name']; + $entry_name = $r['int_user'] . ' <- ' . $entry_name; + $entry_name = $when .' '. $entry_name; + $entry_name = $entry_name . ' ' . $r['number']; + } else { + $entry_name = $r['number']; + if ($r['remote_name'] != '') { + $entry_name .= ' '. $r['remote_name']; + } + $entry_name = $when .' '. $entry_name; + if ($r['num_calls'] > 1) { + $entry_name .= ' ('. $r['num_calls'] .')'; + } } + echo "\n", '', "\n", diff --git a/opt/gemeinschaft/htdocs/prov/snom/pb.php b/opt/gemeinschaft/htdocs/prov/snom/pb.php index fc83adb56..38876ef4f 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/pb.php +++ b/opt/gemeinschaft/htdocs/prov/snom/pb.php @@ -325,7 +325,7 @@ function defineBackKey() echo '', "\n", - '', snomXmlEsc( $typeToTitle[$type] ), '', "\n", + '', snomXmlEsc( $typeToTitle[$type] . ': ' . $keys ), '', "\n", 'Prompt', "\n"; while ($r = $rs->fetchRow()) { $name = $r['ln'] .( strLen($r['fn'])>0 ? (', '.$r['fn']) : '' ); diff --git a/opt/gemeinschaft/htdocs/prov/snom/settings.php b/opt/gemeinschaft/htdocs/prov/snom/settings.php index 603eac0e5..c470d71ae 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/settings.php +++ b/opt/gemeinschaft/htdocs/prov/snom/settings.php @@ -156,6 +156,7 @@ function _settings_err( $msg='' ) 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/gs-fns/gs_ringtones_get.php' ); $settings = array(); @@ -1078,10 +1079,25 @@ function _settings_out() setting('user_ringer', 1 , 'Ringer1'); # Ringer[1-10] / Silent / Custom # Alert-Info-Klingeltoene: -psetting('alert_internal_ring_sound', 'Ringer2'); # Alert-Info: alert-internal -psetting('alert_external_ring_sound', 'Ringer3'); # Alert-Info: alert-external + +$ringtones = gs_ringtones_get($user['user']); + +$bellcore_internal = 2; +if (array_key_exists('bellcore', $ringtones['internal'])) { + $bellcore_internal = $ringtones['internal']['bellcore']; +} + +$bellcore_external = 3; +if (array_key_exists('bellcore', $ringtones['external'])) { + $bellcore_external = $ringtones['external']['bellcore']; +} +psetting('alert_internal_ring_sound', 'Ringer' . $bellcore_internal); # Alert-Info: alert-internal +psetting('alert_external_ring_sound', 'Ringer' . $bellcore_external); # Alert-Info: alert-external psetting('alert_group_ring_sound' , 'Ringer4'); # Alert-Info: alert-group +unset($bellcore_internal); +unset($bellcore_external); + # Adressbuchklingeltoene (wir benutzen nicht das Telefon-interne Telefonbuch, diese Einstellungen werden also nicht benutzt): psetting('friends_ring_sound' , 'Ringer1'); psetting('family_ring_sound' , 'Ringer1'); diff --git a/opt/gemeinschaft/htdocs/prov/snom/sw/.gitignore b/opt/gemeinschaft/htdocs/prov/snom/sw/.gitignore index a8a0dcec4..6bc87cdac 100644 --- a/opt/gemeinschaft/htdocs/prov/snom/sw/.gitignore +++ b/opt/gemeinschaft/htdocs/prov/snom/sw/.gitignore @@ -1 +1,2 @@ *.bin +lang* diff --git a/opt/gemeinschaft/inc/conf.php b/opt/gemeinschaft/inc/conf.php index 50b00defb..e851b234e 100644 --- a/opt/gemeinschaft/inc/conf.php +++ b/opt/gemeinschaft/inc/conf.php @@ -251,6 +251,7 @@ function _gscnf( $param, $default=null ) _gscnf( 'SNOM_PROV_HTTP_USER' , '' ); _gscnf( 'SNOM_PROV_HTTP_PASS' , '' ); _gscnf( 'SNOM_PROV_PB_NUM_RESULTS' , 15 ); +_gscnf( 'SNOM_PROV_SIP_INFO' , false ); _gscnf( 'SNOM_PROV_FW_UPDATE' , false ); //_gscnf( 'SNOM_PROV_FW_BETA' , false ); _gscnf( 'SNOM_PROV_FW_6TO7' , false ); @@ -435,4 +436,4 @@ function _gscnf( $param, $default=null ) include_once( GS_DIR .'inc/gettext.php' ); -?> \ No newline at end of file +?> 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..3365f6310 100644 --- a/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php +++ b/opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php @@ -145,7 +145,7 @@ function gs_prov_phone_checkcfg_all( $reboot=true ) gs_log(GS_LOG_DEBUG, 'phone_checkcfg all phones'); $rs = $db->execute( -'SELECT `s`.`name`, `u`.`current_ip` `ip` +'SELECT `s`.`name` `ext`, `u`.`current_ip` `ip` FROM `users` `u` JOIN `ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`)' @@ -153,7 +153,7 @@ function gs_prov_phone_checkcfg_all( $reboot=true ) while ($r = $rs->fetchRow()) { if ($r['ip']) _gs_prov_phone_checkcfg_by_ip_do( $r['ip'], $reboot ); - _gs_prov_phone_checkcfg_by_ext_do( $ext, $reboot ); + _gs_prov_phone_checkcfg_by_ext_do( $r['ext'], $reboot ); } return true; } @@ -245,9 +245,22 @@ function _gs_prov_phone_checkcfg_by_ip_do_snom( $ip, $reboot=true ) { if (_gs_prov_phone_checkcfg_exclude_ip( $ip )) return; - @ exec( 'wget -O /dev/null -o /dev/null -b --tries=3 --timeout=8 --retry-connrefused -q --user='. qsa(gs_get_conf('GS_SNOM_PROV_HTTP_USER','')) .' --password='. qsa(gs_get_conf('GS_SNOM_PROV_HTTP_PASS','')) .' '. qsa('http://'. $ip .'/confirm.htm?REBOOT=yes') . ' >>/dev/null 2>>/dev/null &', $out, $err ); - // Actually the value after REBOOT= does not matter. - // Is there a check-sync URL *without* reboot? + if (!gs_get_conf('GS_SNOM_PROV_SIP_INFO') || $reboot) { + @ exec( 'wget -O /dev/null -o /dev/null -b --tries=3 --timeout=8 --retry-connrefused -q --user='. qsa(gs_get_conf('GS_SNOM_PROV_HTTP_USER','')) .' --password='. qsa(gs_get_conf('GS_SNOM_PROV_HTTP_PASS','')) .' '. qsa('http://'. $ip .'/confirm.htm?REBOOT=yes') . ' >>/dev/null 2>>/dev/null &', $out, $err ); + // Actually the value after REBOOT= does not matter. + } else { + $socket = @fsockopen("udp://".$ip, 5060, $errno, $errstr, 2); + + $message = 'NOTIFY sip:1234@' . $ip . ' SIP/2.0' . "\n" . + 'To: sip:1234@' . $ip . "\n" . + 'From: gemeinschaft@' . GS_PROV_HOST . "\n" . + 'CSeq: 10 NOTIFY' . "\n" . + 'Call-ID: 1234@' . GS_PROV_HOST . "\n" . + 'Event: check-sync;reboot=false'; + + fwrite($socket, $message); + fclose($socket); + } } // REALLY PRIVATE! CAREFUL WITH PARAMS - NO VALIDATION! @@ -574,4 +587,4 @@ function _gs_prov_phone_checkcfg_by_ext_do_tiptel( $ext, $reboot=true ) //FIXME } -?> \ No newline at end of file +?> diff --git a/opt/gemeinschaft/inc/nobody-extensions.php b/opt/gemeinschaft/inc/nobody-extensions.php index 3bfcfd710..cc3813894 100644 --- a/opt/gemeinschaft/inc/nobody-extensions.php +++ b/opt/gemeinschaft/inc/nobody-extensions.php @@ -58,5 +58,11 @@ function gs_nobody_index_to_extension( $index, $at_boi_host=false ) return (string)( $start + (int)$index ); } +function gs_is_nobody_extension( $ext, $at_boi_host=false ) +{ + $nobody_rxpattern = '/' . preg_replace('/[^\d]/', '\d', gs_conf_nobody_pattern($at_boi_host)) . '/'; + + return (int)preg_match($nobody_rxpattern, (string)$ext); +} -?> \ No newline at end of file +?> diff --git a/opt/gemeinschaft/scripts/gs-prov-phone-checkcfg b/opt/gemeinschaft/scripts/gs-prov-phone-checkcfg index c6a1c3dbb..4a9083dd5 100755 --- a/opt/gemeinschaft/scripts/gs-prov-phone-checkcfg +++ b/opt/gemeinschaft/scripts/gs-prov-phone-checkcfg @@ -38,20 +38,16 @@ include_once( GS_DIR .'inc/gs-fns/gs_prov_phone_checkcfg.php' ); /*********************************************************** * the shell parameters ***********************************************************/ -/* $usage = 'Reboots a phone by user code, extension, IP addr. or all phones Usage: '. baseName(__FILE__) .' ( --user= | --ext= | --ip= | --all=yes ) --reboot=yes|no'; -*/ -$usage = 'Reboots a phone by user code, extension, IP addr. or all phones -Usage: '. baseName(__FILE__) .' ( --user= | --ext= | --ip= | --all=yes )'; $opts = @getOptsNoMultiples( '', array( 'user=', 'ext=', 'ip=', - 'all='/*, - 'reboot='*/ + 'all=', + 'reboot=' ), $usage ); @@ -62,13 +58,12 @@ if (! isSet( $opts['user'] ) ) { gs_script_invalid_usage( $usage ); } -/* + if (! isSet( $opts['reboot'] )) { echo "Use --reboot=yes|no\n"; gs_script_invalid_usage( $usage ); } -*/ -$opts['reboot'] = 'yes'; + if (count($opts) > 2) { echo "Use only one of the parameters!\n"; gs_script_invalid_usage( $usage ); @@ -101,4 +96,4 @@ if (! $ret) else echo "Done.\n"; -?> \ No newline at end of file +?>