diff --git a/LANG_www/agc_br/manager_send.php b/LANG_www/agc_br/manager_send.php index 2f8f8d65..8ab685e6 100644 --- a/LANG_www/agc_br/manager_send.php +++ b/LANG_www/agc_br/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel não é válido or queryCID $queryCID não é válido or filename: $filename não é válido, $ACTION comando não inserido\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel não é válido or exten $exten não é válido or filename: $filename não é válido, $ACTION comando não inserido\n"; diff --git a/LANG_www/agc_br/vdc_db_query.php b/LANG_www/agc_br/vdc_db_query.php index 57c2e6ae..7678cb84 100644 --- a/LANG_www/agc_br/vdc_db_query.php +++ b/LANG_www/agc_br/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_br/vicidial.php b/LANG_www/agc_br/vicidial.php index cb2d5c17..220c69dc 100644 --- a/LANG_www/agc_br/vicidial.php +++ b/LANG_www/agc_br/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_segundos > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_de/manager_send.php b/LANG_www/agc_de/manager_send.php index 70b82fc4..5f3dc010 100644 --- a/LANG_www/agc_de/manager_send.php +++ b/LANG_www/agc_de/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanal $channel ist unzulässig or queryCID $queryCID ist unzulässig or filename: $filename ist unzulässig, $ACTION Befehl nicht abgesetzt\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanal $channel ist unzulässig or exten $exten ist unzulässig or filename: $filename ist unzulässig, $ACTION Befehl nicht abgesetzt\n"; diff --git a/LANG_www/agc_de/vdc_db_query.php b/LANG_www/agc_de/vdc_db_query.php index 7fba8117..84ea8b9a 100644 --- a/LANG_www/agc_de/vdc_db_query.php +++ b/LANG_www/agc_de/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_de/vicidial.php b/LANG_www/agc_de/vicidial.php index 93aac712..2b7b2090 100644 --- a/LANG_www/agc_de/vicidial.php +++ b/LANG_www/agc_de/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_Sekunden > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_el/manager_send.php b/LANG_www/agc_el/manager_send.php index c198d62c..24fca6b6 100644 --- a/LANG_www/agc_el/manager_send.php +++ b/LANG_www/agc_el/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Κανάλι $channel δεν ισχύει or queryCID $queryCID δεν ισχύει or filename: $filename δεν ισχύει, $ACTION εντολή που δεν έγινε εισαγωγή\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Κανάλι $channel δεν ισχύει or exten $exten δεν ισχύει or filename: $filename δεν ισχύει, $ACTION εντολή που δεν έγινε εισαγωγή\n"; diff --git a/LANG_www/agc_el/vdc_db_query.php b/LANG_www/agc_el/vdc_db_query.php index cd2326f8..da76780e 100644 --- a/LANG_www/agc_el/vdc_db_query.php +++ b/LANG_www/agc_el/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_el/vicidial.php b/LANG_www/agc_el/vicidial.php index acf7cf79..f6c6fa05 100644 --- a/LANG_www/agc_el/vicidial.php +++ b/LANG_www/agc_el/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_δευτερόλεπτα > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_es/manager_send.php b/LANG_www/agc_es/manager_send.php index 03c7e29e..4692fd1d 100644 --- a/LANG_www/agc_es/manager_send.php +++ b/LANG_www/agc_es/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel No es válido or queryCID $queryCID No es válido or filename: $filename No es válido, $ACTION comando no insertado\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel No es válido or exten $exten No es válido or filename: $filename No es válido, $ACTION comando no insertado\n"; diff --git a/LANG_www/agc_es/vdc_db_query.php b/LANG_www/agc_es/vdc_db_query.php index a0b7f4f8..f8d37fff 100644 --- a/LANG_www/agc_es/vdc_db_query.php +++ b/LANG_www/agc_es/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_es/vicidial.php b/LANG_www/agc_es/vicidial.php index 5af8345c..67c2cf71 100644 --- a/LANG_www/agc_es/vicidial.php +++ b/LANG_www/agc_es/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_segundos > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_fr/manager_send.php b/LANG_www/agc_fr/manager_send.php index 38f6eed9..87bee166 100644 --- a/LANG_www/agc_fr/manager_send.php +++ b/LANG_www/agc_fr/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel est invalide or queryCID $queryCID est invalide or filename: $filename est invalide, $ACTION commande non insérée\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Canal $channel est invalide or exten $exten est invalide or filename: $filename est invalide, $ACTION commande non insérée\n"; diff --git a/LANG_www/agc_fr/vdc_db_query.php b/LANG_www/agc_fr/vdc_db_query.php index a272b6b3..076c9e82 100644 --- a/LANG_www/agc_fr/vdc_db_query.php +++ b/LANG_www/agc_fr/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_fr/vicidial.php b/LANG_www/agc_fr/vicidial.php index f6bbd929..a26aa6cb 100644 --- a/LANG_www/agc_fr/vicidial.php +++ b/LANG_www/agc_fr/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_secondes > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_it/manager_send.php b/LANG_www/agc_it/manager_send.php index c26c98e8..f500624c 100644 --- a/LANG_www/agc_it/manager_send.php +++ b/LANG_www/agc_it/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Canale $channel non e` valido or queryCID $queryCID non e` valido or filename: $filename non e` valido, $ACTION comando non inserito\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Canale $channel non e` valido or exten $exten non e` valido or filename: $filename non e` valido, $ACTION comando non inserito\n"; diff --git a/LANG_www/agc_it/vdc_db_query.php b/LANG_www/agc_it/vdc_db_query.php index 70d4881d..335754a8 100644 --- a/LANG_www/agc_it/vdc_db_query.php +++ b/LANG_www/agc_it/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_it/vicidial.php b/LANG_www/agc_it/vicidial.php index abe62e6b..2f8ab753 100644 --- a/LANG_www/agc_it/vicidial.php +++ b/LANG_www/agc_it/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_secondi > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_pl/manager_send.php b/LANG_www/agc_pl/manager_send.php index 671667ae..0c726592 100644 --- a/LANG_www/agc_pl/manager_send.php +++ b/LANG_www/agc_pl/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanał $channel nie jest prawidłowy or queryCID $queryCID nie jest prawidłowy or filename: $filename nie jest prawidłowy, $ACTION komenda nie wstawiona\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanał $channel nie jest prawidłowy or exten $exten nie jest prawidłowy or filename: $filename nie jest prawidłowy, $ACTION komenda nie wstawiona\n"; diff --git a/LANG_www/agc_pl/vdc_db_query.php b/LANG_www/agc_pl/vdc_db_query.php index 075e3051..402964be 100644 --- a/LANG_www/agc_pl/vdc_db_query.php +++ b/LANG_www/agc_pl/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_pl/vicidial.php b/LANG_www/agc_pl/vicidial.php index 118cbaa2..f391fdfb 100644 --- a/LANG_www/agc_pl/vicidial.php +++ b/LANG_www/agc_pl/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_sekundy > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_pt/manager_send.php b/LANG_www/agc_pt/manager_send.php index 9d4bcb03..197d34a7 100644 --- a/LANG_www/agc_pt/manager_send.php +++ b/LANG_www/agc_pt/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Canaleta $channel é inválido or queryCID $queryCID é inválido or filename: $filename é inválido, $ACTION comando não introduzido\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Canaleta $channel é inválido or exten $exten é inválido or filename: $filename é inválido, $ACTION comando não introduzido\n"; diff --git a/LANG_www/agc_pt/vdc_db_query.php b/LANG_www/agc_pt/vdc_db_query.php index af8986d9..4f44bc3e 100644 --- a/LANG_www/agc_pt/vdc_db_query.php +++ b/LANG_www/agc_pt/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_pt/vicidial.php b/LANG_www/agc_pt/vicidial.php index 35900fed..b7be80da 100644 --- a/LANG_www/agc_pt/vicidial.php +++ b/LANG_www/agc_pt/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_segundos > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/agc_ru/active_list_refresh.php b/LANG_www/agc_ru/active_list_refresh.php new file mode 100644 index 00000000..252bd19f --- /dev/null +++ b/LANG_www/agc_ru/active_list_refresh.php @@ -0,0 +1,482 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to serve updates of the live data to the display scripts +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ADD - ('1','2','3','4','5') +# - $order - ('asc','desc') +# - $format - ('text','table','menu','selectlist','textarea') +# - $bgcolor - ('#123456','white','black','etc...') +# - $txtcolor - ('#654321','black','white','etc...') +# - $txtsize - ('1','2','3','etc...') +# - $selectsize - ('2','3','4','etc...') +# - $selectfontsize - ('8','10','12','etc...') +# - $selectedext - ('cc100') +# - $selectedtrunk - ('Zap/25-1') +# - $selectedlocal - ('SIP/cc100') +# - $textareaheight - ('8','10','12','etc...') +# - $textareawidth - ('8','10','12','etc...') +# - $field_name - ('extension','busyext','extension_xfer','etc...') +# +# +# changes +# 50323-1147 - First build of script +# 50401-1132 - small formatting changes +# 50502-1402 - added field_name as modifiable variable +# 50503-1213 - added session_name checking for extra security +# 50503-1311 - added conferences list +# 50610-1155 - Added NULL check on MySQL results to reduced errors +# 50711-1209 - removed HTTP authentication in favor of user/pass vars +# 60421-1155 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1118 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ADD"])) {$ADD=$_GET["ADD"];} + elseif (isset($_POST["ADD"])) {$ADD=$_POST["ADD"];} +if (isset($_GET["order"])) {$order=$_GET["order"];} + elseif (isset($_POST["order"])) {$order=$_POST["order"];} +if (isset($_GET["bgcolor"])) {$bgcolor=$_GET["bgcolor"];} + elseif (isset($_POST["bgcolor"])) {$bgcolor=$_POST["bgcolor"];} +if (isset($_GET["txtcolor"])) {$txtcolor=$_GET["txtcolor"];} + elseif (isset($_POST["txtcolor"])) {$txtcolor=$_POST["txtcolor"];} +if (isset($_GET["txtsize"])) {$txtsize=$_GET["txtsize"];} + elseif (isset($_POST["txtsize"])) {$txtsize=$_POST["txtsize"];} +if (isset($_GET["selectsize"])) {$selectsize=$_GET["selectsize"];} + elseif (isset($_POST["selectsize"])) {$selectsize=$_POST["selectsize"];} +if (isset($_GET["selectfontsize"])) {$selectfontsize=$_GET["selectfontsize"];} + elseif (isset($_POST["selectfontsize"])) {$selectfontsize=$_POST["selectfontsize"];} +if (isset($_GET["selectedext"])) {$selectedext=$_GET["selectedext"];} + elseif (isset($_POST["selectedext"])) {$selectedext=$_POST["selectedext"];} +if (isset($_GET["selectedtrunk"])) {$selectedtrunk=$_GET["selectedtrunk"];} + elseif (isset($_POST["selectedtrunk"])) {$selectedtrunk=$_POST["selectedtrunk"];} +if (isset($_GET["selectedlocal"])) {$selectedlocal=$_GET["selectedlocal"];} + elseif (isset($_POST["selectedlocal"])) {$selectedlocal=$_POST["selectedlocal"];} +if (isset($_GET["textareaheight"])) {$textareaheight=$_GET["textareaheight"];} + elseif (isset($_POST["textareaheight"])) {$textareaheight=$_POST["textareaheight"];} +if (isset($_GET["textareawidth"])) {$textareawidth=$_GET["textareawidth"];} + elseif (isset($_POST["textareawidth"])) {$textareawidth=$_POST["textareawidth"];} +if (isset($_GET["field_name"])) {$field_name=$_GET["field_name"];} + elseif (isset($_POST["field_name"])) {$field_name=$_POST["field_name"];} + +### security strip all non-alphanumeric characters out of the variables ### + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $ADD=ereg_replace("[^0-9]","",$ADD); + $order=ereg_replace("[^0-9a-zA-Z]","",$order); + $format=ereg_replace("[^0-9a-zA-Z]","",$format); + $bgcolor=ereg_replace("[^\#0-9a-zA-Z]","",$bgcolor); + $txtcolor=ereg_replace("[^\#0-9a-zA-Z]","",$txtcolor); + $txtsize=ereg_replace("[^0-9a-zA-Z]","",$txtsize); + $selectsize=ereg_replace("[^0-9a-zA-Z]","",$selectsize); + $selectfontsize=ereg_replace("[^0-9a-zA-Z]","",$selectfontsize); + $selectedext=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedext); + $selectedtrunk=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedtrunk); + $selectedlocal=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$selectedlocal); + $textareaheight=ereg_replace("[^0-9a-zA-Z]","",$textareaheight); + $textareawidth=ereg_replace("[^0-9a-zA-Z]","",$textareawidth); + $field_name=ereg_replace("[^ \#\*\:\/\@\.\-\_0-9a-zA-Z]","",$field_name); + +# default optional vars if not set +if (!isset($ADD)) {$ADD="1";} +if (!isset($order)) {$order='desc';} +if (!isset($format)) {$format="text";} +if (!isset($bgcolor)) {$bgcolor='white';} +if (!isset($txtcolor)) {$txtcolor='black';} +if (!isset($txtsize)) {$txtsize='2';} +if (!isset($selectsize)) {$selectsize='4';} +if (!isset($selectfontsize)) {$selectfontsize='10';} +if (!isset($textareaheight)) {$textareaheight='10';} +if (!isset($textareawidth)) {$textareawidth='20';} + +$version = '0.0.8'; +$build = '60619-1118'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='table') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Показывать Списки: "; +if ($ADD==1) {echo "Активные расширения";} +if ($ADD==2) {echo "Занятые Расширения";} +if ($ADD==3) {echo "Внешние Линии";} +if ($ADD==4) {echo "Локальные Расширения";} +if ($ADD==5) {echo "Конференции";} +if ($ADD==99999) {echo "ПОМОЩЬ";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ADD=1 display all live extensions on a server +###################### +if ($ADD==1) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'extension';} + if ($format=='table') {echo "\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + +###################### +# ADD=2 display all busy extensions on a server +###################### +if ($ADD==2) +{ + if (!$field_name) {$field_name = 'busyext';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=3 display all busy outside lines(trunks) on a server +###################### +if ($ADD==3) +{ + if (!$field_name) {$field_name = 'trunk';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=4 display all busy Local lines on a server +###################### +if ($ADD==4) +{ + if (!$field_name) {$field_name = 'local';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + +###################### +# ADD=5 display all agc-usable conferences on a server +###################### +if ($ADD==5) +{ + $pt='pt'; + if (!$field_name) {$field_name = 'conferences';} + if ($format=='table') {echo "
\n";} + if ($format=='menu') {echo "\n"; + } + if ($format=='textarea') + { + echo "\n";} +} + + + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='table') {echo "\n";} +if ($format=='table') {echo "\n\n\n";} + +exit; + +?> + + + + + diff --git a/LANG_www/agc_ru/astguiclient.php b/LANG_www/agc_ru/astguiclient.php new file mode 100644 index 00000000..9212cffa --- /dev/null +++ b/LANG_www/agc_ru/astguiclient.php @@ -0,0 +1,2905 @@ + LICENSE: AGPLv2 +# +# make sure you have added a user to the vicidial_users MySQL table with at least +# user_level 1 or greater to access this page. Also you need to have the login +# and pass of a phone listed in the asterisk.phones table. The page grabs the +# server info and other details from this login and pass +# +# Other scripts that this application depends on: +# - active_list_refresh.php: displays active/live channels and phones +# - manager_send.php: sends Actions to be executed on Asterisk servers +# - live_exten_check.php: checks to see if user's phone is on a live call +# - call_log_display.php: retrieves log of inbound and outbound calls +# - voicemail_check.php: retrieves counts of new and old messages +# - inbound_popup.php: opens upon live_inbound call coming in +# - conf_exten_check.php: checks to see if and calls are in a specific conf +# - park_calls_display.php: retrieves list of parked calls +# - vdc_db_query.php: Changes values in the DB for non-calling records +# +# CHANGES +# 50215-1356 - Proof-of-concept test of XMLHttpRequest for astGUIclient web +# 50323-1411 - First build version display-only +# 50331-1040 - Second-build, added phone login and hangup/hijack display +# 50401-1006 - Trunk/Local Hangup functions enabled +# 50404-1056 - Trunk/Local Hijack functions enabled +# 50404-1459 - Simple live calls display and grabs updated time from server +# 50405-1221 - Reorganized the display and layers, added some images +# 50406-1005 - Added In/Out call log display to MAIN panel +# 50407-1254 - Start/Stop Recording on live calls enabled +# 50422-1101 - Activated Check Voicemail button and new/old messages count +# 50428-1449 - Added dial from log and basic live_inbound call popup +# 50429-1455 - Modified inbound popup code for IE and to add more functions +# 50502-1442 - Added basic method to transfer live calls somewhere else +# 50503-1205 - Added web_client_sessions entry for more security of subscripts +# 50503-1537 - Added basic conferences display +# 50509-1132 - Added conference connected list and hangup/xfer for them +# 50511-1129 - Added registration of conference rooms and added manual dial +# 50523-1342 - Added Conference recording and send DTMF +# 50523-1622 - Added Local Dial window frame for calling local extensions +# 50524-1456 - Added ability to park call and display number of parked calls +# 50524-1600 - Added ability to display and pickup/hangup/xfer parked calls +# 50525-1224 - Added ability to place outbound call from within conferene +# 50531-1225 - Added ability to do dual transfers to meetme rooms from Main +# 50711-1229 - removed HTTP authentication in favor of user/pass vars +# 50711-1610 - Added Zap monitoring to Trunk/Local Action screens +# 50804-1604 - Minor bug fix in inbound_popup functions +# 50818-1715 - Added pretty login section +# 50913-1137 - Added custom outbound_cid from phones table +# 51110-1430 - Fixed non-standard http port issue +# 60103-1421 - Added code for favorite extensions chooser +# 60104-1347 - Added basic layout for favorites editing frame +# 60105-1124 - Finished Favorites frame and added DB submission +# 60112-1622 - Several formatting changes +# 60421-1357 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1103 - Added variable filters to close security holes for login form +# 60829-1528 - Made compatible with WeBRooTWritablE setting in dbconnect.php +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +$version = '2.0.1'; +$build = '60829-1528'; + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + + +if ($force_logout) +{ + if( (strlen($_SERVER['user'])>0) or (strlen($_SERVER['pass'])>0) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + } + echo "Вы вышли из системы. Спасибо\n"; + exit; +} + +$StarTtime = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd-His"); + $month_old = mktime(0, 0, 0, date("m"), date("d")-7, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + +$US='_'; +$CL=':'; +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./astguiclient_auth_entries.txt", "a");} +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = $agcPAGE; +$agcDIR = eregi_replace('astguiclient.php','',$agcDIR); + + if( (strlen($user)<2) or (strlen($pass)<2) or (!$auth) or ($relogin == 'YES') ) + { + header ("Content-type: text/html; charset=utf-8"); + + echo "web-клиент astGUIclient: Логин\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин
 
Логин Пользователя:
Пароль Пользователя:
Логин Телефона:
Пароль Телефона:

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + + if($auth>0) + { + $office_no=strtoupper($user); + $password=strtoupper($pass); + $stmt="SELECT full_name,user_level from vicidial_users where user='$user' and pass='$pass'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname=$row[0]; + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIНАБОР НОМЕРА|GOOD|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "VICIНАБОР НОМЕРА|FAIL|$date|$user|$pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + } + } + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web-клиент astGUIclient: Логин Телефона\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Russian
\n"; +echo "
\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Логин Телефона
 
Логин Телефона:
Пароль Телефона:

ВЕРСИЯ: $version       СБОРКА: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +$authphone=0; +$stmt="SELECT count(*) from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web-клиент astGUIclient: Логин Телефона\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин Телефона
 
Извините, но ваш логин и пароль телефона не активен в этой системе. Пожалуйста, попробуйте еще раз:
 
Логин Телефона:
Пароль Телефона:

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { + echo "web-клиент astGUIclient\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $phone_login=$row[6]; + $phone_pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $CaLLerID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + + $local_web_callerID_URL_enc = rawurlencode($local_web_callerID_URL); + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtime$US$session_ext$session_rand"; + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'agc';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','agc','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="SELECT count(*) from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_present=$row[0]; + if ($favorites_present > 0) + { + $stmt="SELECT extensions_list from phone_favorites where extension='$extension' and server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favorites_list=$row[0]; + $h=0; + $favorites_listX = eregi_replace("'",'',$favorites_list); + $favorites = explode(',',$favorites_listX); + $favorites_count = count($favorites); + $favorites_listX=''; + + $o=0; + while ($favorites_count > $o) + { + $stmt="SELECT fullname,protocol from phones where extension = '$favorites[$o]' and server_ip='$server_ip';"; + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $favorites_names[$o] = $rowx[0]; + $favorites_listX .= "$rowx[1]/$favorites[$o],"; + $o++; + } + + echo "\n"; + echo "\n"; + } + else + { + echo "\n"; + } + +### gather phone extensions and fullnames for favorites editor ### + $stmt="SELECT extension,fullname from phones where server_ip = '$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $exten_ct = mysql_num_rows($rslt); + $favlistCT=0; + $nofavlistCT=0; + while ($favlistCT < $exten_ct) + { + $row=mysql_fetch_row($rslt); + $favlist[$favlistCT]= "$row[0] - $row[1]"; + $favlistCT++; + } + + } +} + + +?> + + + + + + +\n"; + + +?> + +
+ + + + + + + + + +
+ + +ВЫХОД
\n"; ?> +
Главная ПанельПанель Активных ЛинийПанель КонференцийПроверьте Голосовую почтуЖивой Вызов
+
+ + +

Logout
+
+ + +
TRUNK РАЗЪЕДИНЕНИЕ

+ Active Trunks Menu
+ Hangup Trunk   |   + Hijack Trunk   |   + Listen Trunk   |   + Обновление   |   + Вернуться к Главному Окну +
+
+ + +
ЛОКАЛЬНВЙ РАЗЪЕДИНЕНИЕ

+ Активное Локальное Меню
+ Hangup Local   |   + Hijack Local   |   + Listen Local   |   + Обновление   |   + Вернуться к Главному Окну +
+
+ + + + + + + +
ПЕРЕВОД ЖИВОГО ВЫЗОВА
Канал в который будет переведен: Канал
Расширения:
Меню Расширений
+
+ Отправить в выбранное расширение

+ Отправить в выбранный vmail box

+ Отправить в этот номер:


+ Обновление


+ Вернуться к Главному Окну

+
Конференции:
(кликните на номере ниже, чтобы отправить в конференцию)
Отправить также мой канал
Меню Конференций
+
+ + + + + +
ЛОКАЛЬНОЕ Расширение Набора номера
Телефонный вызов от: Канал
Расширения:
Меню Расширений
+
+ Вызов в выбранное расширение

+ Вызов в выбранный vmail box

+ Обновление


+ Вернуться к Главному Окну

+
+
+ + +
ПАРКОВАТЬ ВЫЗОВ:
+ Вернуться к Главному Окну

+
+
+ + + + + + + + + + + + + + + +
  +
VOICEMAIL     НОВЫЙ:     СТАРЫЙ:             РУЧНОЙ НАБОР НОМЕРА       НАБОР НОМЕРА
ПАРКОВАТЬ ВЫЗОВ: 0                ЛОКАЛЬНЫЕ РАСШИРЕНИЯ НАБОРА НОМЕРА
ИСХОДЯЩИЕ ВЫЗОВЫ:
ВХОДЯЩИЕ ВЫЗОВЫ:
Версия web-клиента astGUIclient : СБОРКА:
+ + + + $h) + { + if (strlen($favorites[$h])>1) + { + echo "\n"; + } + $h++; + } +?> + +
ИЗБРАННОЕ       редактировать
$favorites[$h] - $favorites_names[$h]
 
+
+ + + + + + + +
ИЗБРАННОЕ

 
ПОДТВЕРДИТЕ ИЗМЕНЕНИЕ ИЗБРАННОГО - требование для выхода из системы
ВЕРНУТЬСЯ К ГЛАВНОМУ ОКНУ - игнорирует сделанные изменения
+
+ +
+ + + + + + + + + + + + + +
+STOP | СТАРТ     Норма обновлений: 1000 ms Быстрее | Медленее

+
Инициализация..
+
Активные Расширения
+ОБНОВИТЬ | +ПОРЯДОК | +
Внешние Линии
+ОБНОВИТЬ | +ПОРЯДОК | +
Локальные Расширения
+ОБНОВИТЬ | +ПОРЯДОК | +
+ Данные Идут Сюда

+
+ Данные Идут Сюда

Trunk Action +
+ Данные Идут Сюда

Local Action +
+
+ + + + +
+ + +Список Конференций + + + +
+Для информации о конференции кликните на номер конференции слева +
+ + + + + + + + + + + + + + + + + + diff --git a/LANG_www/agc_ru/call_log_display.php b/LANG_www/agc_ru/call_log_display.php new file mode 100644 index 00000000..8fcd83fd --- /dev/null +++ b/LANG_www/agc_ru/call_log_display.php @@ -0,0 +1,196 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send the inbound and outbound calls for a specific phone +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# - $in_limit - ('10','20','50','100',...) +# - $out_limit - ('10','20','50','100',...) +# +# +# changes +# 50406-1013 - First build of script +# 50407-1452 - Added definable limits +# 50503-1236 - added session_name checking for extra security +# 50610-1158 - Added NULL check on MySQL results to reduced errors +# 50711-1202 - removed HTTP authentication in favor of user/pass vars +# 60323-1550 - added option for showing different number dialed in log +# 60421-1401 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1202 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($in_limit)) {$in_limit="100";} +if (!isset($out_limit)) {$out_limit="100";} +$number_dialed = 'number_dialed'; +#$number_dialed = 'extension'; + +$version = '0.0.8'; +$build = '60619-1202'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Показать Логи Вызовов"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten это неправильно или протокол $protocol это неправильно\n"; + exit; + } + else + { + ##### print outbound calls from the call_log table + $stmt="SELECT uniqueid,start_time,$number_dialed,length_in_sec FROM call_log where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\" order by start_time desc limit $out_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$out_calls_count = mysql_num_rows($rslt);} + echo "$out_calls_count|"; + $loop_count=0; + while ($out_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[3] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + + if ($number_dialed == 'extension') {$row[2] = substr($row[2],-10);} + echo "$row[0] ~$row[1] ~$row[2] ~$call_time_MS|"; + } + echo "\n"; + + ##### print inbound calls from the live_inbound_log table + $stmt="SELECT call_log.uniqueid,live_inbound_log.start_time,live_inbound_log.extension,caller_id,length_in_sec from live_inbound_log,call_log where phone_ext='$exten' and live_inbound_log.server_ip = '$server_ip' and call_log.uniqueid=live_inbound_log.uniqueid order by start_time desc limit $in_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$in_calls_count = mysql_num_rows($rslt);} + echo "$in_calls_count|"; + $loop_count=0; + while ($in_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + + $call_time_M = ($row[4] / 60); + $call_time_M = round($call_time_M, 2); + $call_time_M_int = intval("$call_time_M"); + $call_time_SEC = ($call_time_M - $call_time_M_int); + $call_time_SEC = ($call_time_SEC * 60); + $call_time_SEC = round($call_time_SEC, 0); + if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";} + $call_time_MS = "$call_time_M_int:$call_time_SEC"; + $callerIDnum = $row[3]; $callerIDname = $row[3]; + $callerIDnum = preg_replace("/.*<|>.*/","",$callerIDnum); + $callerIDname = preg_replace("/\"| <\d*>/","",$callerIDname); + + echo "$row[0] ~$row[1] ~$row[2] ~$callerIDnum ~$callerIDname ~$call_time_MS|"; + } + echo "\n"; + + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_ru/conf_exten_check.php b/LANG_www/agc_ru/conf_exten_check.php new file mode 100644 index 00000000..468f0477 --- /dev/null +++ b/LANG_www/agc_ru/conf_exten_check.php @@ -0,0 +1,514 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('refresh','register') +# - $client - ('agc','vdc') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $campagentstdisp - ('YES',...) +# + +# changes +# 50509-1054 - First build of script +# 50511-1112 - Added ability to register a conference room +# 50610-1159 - Added NULL check on MySQL results to reduced errors +# 50706-1429 - script changed to not use HTTP login vars, user/pass instead +# 50706-1525 - Added date-time display for vicidial client display +# 50816-1500 - Added random update to vicidial_live_agents table for vdc users +# 51121-1353 - Altered echo statements for several small PHP speed optimizations +# 60410-1424 - Added ability to grab calls-being-placed and agent status +# 60421-1405 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1201 - Added variable filters to close security holes for login form +# 61128-2255 - Added update for manual dial vicidial_live_agents +# 70319-1542 - Added agent disabled display function +# 71122-0205 - Added vicidial_live_agent status output +# 80424-0442 - Added non_latin lookup from system_settings +# 80519-1425 - Added calls-in-queue tally +# 80703-1106 - Added API functionality for Hangup and Dispo +# 81104-0229 - Added mysql error logging capability +# 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries +# 90102-1402 - Added check for system and database time synchronization +# 90120-1720 - Added compatibility for API pause/resume and dial a number +# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours +# + +$version = '2.0.5-18'; +$build = '90307-1855'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=17; +$one_mysql_log=0; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["client"])) {$client=$_GET["client"];} + elseif (isset($_POST["client"])) {$client=$_POST["client"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campagentstdisp"])) {$campagentstdisp=$_GET["campagentstdisp"];} + elseif (isset($_POST["campagentstdisp"])) {$campagentstdisp=$_POST["campagentstdisp"];} + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) +{ +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +} + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($client)) {$client="agc";} + +$Alogin='N'; +$RingCalls='N'; +$DiaLCalls='N'; + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$FILE_TIME = date("Ymd_His"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$random = (rand(1000000, 9999999) + 10000000); + + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03002',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Conf Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + if ($ACTION == 'refresh') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($conf_exten)<1) + { + $channel_live=0; + echo "Conf Exten $conf_exten это неправильно\n"; + exit; + } + else + { + + if ($client == 'vdc') + { + $Acount=0; + $AexternalDEAD=0; + + ### see if the agent has a record in the vicidial_live_agents table + $stmt="SELECT count(*) from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Acount=$row[0]; + + if ($Acount > 0) + { + $stmt="SELECT status from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03004',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Astatus=$row[0]; + } + # ### find out if external table shows agent should be disabled + # $stmt="SELECT count(*) from another_table where user='$user' and status='DEAD';"; + # if ($DB) {echo "|$stmt|\n";} + # $rslt=mysql_query($stmt, $link); + # $row=mysql_fetch_row($rslt); + # $AexternalDEAD=$row[0]; + + if ($auto_dial_level > 0) + { + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03005',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 5) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9305$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + if ($campagentstdisp == 'YES') + { + ### grab the status of this agent to display + $stmt="SELECT status,campaign_id,closer_campaigns from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03006',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $Alogin=$row[0]; + $Acampaign=$row[1]; + $AccampSQL=$row[2]; + $AccampSQL = ereg_replace(' -','', $AccampSQL); + $AccampSQL = ereg_replace(' ',"','", $AccampSQL); + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status IN('LIVE') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03007',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $RingCalls=$row[0]; + if ($RingCalls > 0) {$RingCalls = "Звонки в очереди: $RingCalls";} + else {$RingCalls = "Звонки в очереди: $RingCalls";} + + ### grab the number of calls being placed from this server and campaign + $stmt="SELECT count(*) from vicidial_auto_calls where status NOT IN('XFER') and ( (campaign_id='$Acampaign') or (campaign_id IN('$AccampSQL')) );"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $DiaLCalls=$row[0]; + + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + } + } + else + { + $Alogin='N'; + $RingCalls='N'; + $DiaLCalls='N'; + + ### update the vicidial_live_agents every second with a new random number so it is shown to be alive + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03009',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 5) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9309$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + } + + ### grab the API hangup and API dispo fields in vicidial_live_agents + $stmt="SELECT external_hangup,external_status,external_pause,external_dial from vicidial_live_agents where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03010',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $external_hangup = $row[0]; + $external_status = $row[1]; + $external_pause = $row[2]; + $external_dial = $row[3]; + if (strlen($external_status)<1) {$external_status = '::::::::::';} + + $web_epoch = date("U"); + $stmt="select UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03014',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $server_epoch = $row[0]; + $db_epoch = $row[1]; + $time_diff = ($server_epoch - $db_epoch); + $web_diff = ($db_epoch - $web_epoch); + + + ##### grab the shift information the agent + $stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + $VU_agent_shift_enforcement_override = $row[1]; + + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $shift_enforcement = $row[0]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[1]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + + ### CHECK TO SEE IF AGENT IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR + $Ashift_logout=0; + if ( ( (ereg("ALL",$shift_enforcement)) and (!ereg("OFF|СТАРТ",$VU_agent_shift_enforcement_override)) ) or (ereg("ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if (strlen($LOGgroup_shiftsSQL) < 3) + {$Ashift_logout++;} + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ($shift_ok < 1) + {$Ashift_logout++;} + } + } + + + if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (eregi("0$",$StarTtime)) ) + {$Alogin='TIME_SYNC';} + if ($Acount < 1) + {$Alogin='DEAD_VLA';} + if ($AexternalDEAD > 0) + {$Alogin='DEAD_EXTERNAL';} + if ($Ashift_logout > 0) + {$Alogin='SHIFT_ВЫХОД';} + + echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Статус: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . "|\n"; + + } + $total_conf=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03011',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$sip_list = mysql_num_rows($rslt);} + # echo "$sip_list|"; + $loop_count=0; + while ($sip_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $КаналA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03012',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + # echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; $total_conf++; + $row=mysql_fetch_row($rslt); + $КаналA[$total_conf] = "$row[0]"; + if ($format=='debug') {echo "\n";} + } + } + $channels_list = ($channels_list + $sip_list); + echo "$channels_list|"; + + $counter=0; + $countecho=''; + while($total_conf > $counter) + { + $counter++; + $countecho = "$countecho$КаналA[$counter] ~"; + # echo "$КаналA[$counter] ~"; + } + + echo "$countecho\n"; + } + + if ($ACTION == 'register') + { + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($exten)<1) ) + { + $channel_live=0; + echo "Conf Exten $conf_exten это неправильно or Exten $exten это неправильно\n"; + exit; + } + else + { + $stmt="UPDATE conferences set extension='$exten' where server_ip = '$server_ip' and conf_exten = '$conf_exten';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03013',$user,$server_ip,$session_name,$one_mysql_log);} + } + echo "Конференция $conf_exten был зарегистрирован на $exten\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) +{ +$NOW_TIME = date("Y-m-d H:i:s"); +# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); +$errno=''; $error=''; +if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|conf_check |$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_ru/dbconnect.php b/LANG_www/agc_ru/dbconnect.php new file mode 100644 index 00000000..723d3c59 --- /dev/null +++ b/LANG_www/agc_ru/dbconnect.php @@ -0,0 +1,58 @@ + LICENSE: AGPLv2 +# +if ( file_exists("/etc/astguiclient.conf") ) +{ +$DBCagc = file("/etc/astguiclient.conf"); +foreach ($DBCagc as $DBCline) + { + $DBCline = preg_replace("/ |>|\n|\r|\t|\#.*|;.*/","",$DBCline); + if (ereg("^PATHlogs", $DBCline)) + {$PATHlogs = $DBCline; $PATHlogs = preg_replace("/.*=/","",$PATHlogs);} + if (ereg("^PATHweb", $DBCline)) + {$WeBServeRRooT = $DBCline; $WeBServeRRooT = preg_replace("/.*=/","",$WeBServeRRooT);} + if (ereg("^VARDB_server", $DBCline)) + {$VARDB_server = $DBCline; $VARDB_server = preg_replace("/.*=/","",$VARDB_server);} + if (ereg("^VARDB_database", $DBCline)) + {$VARDB_database = $DBCline; $VARDB_database = preg_replace("/.*=/","",$VARDB_database);} + if (ereg("^VARDB_user", $DBCline)) + {$VARDB_user = $DBCline; $VARDB_user = preg_replace("/.*=/","",$VARDB_user);} + if (ereg("^VARDB_pass", $DBCline)) + {$VARDB_pass = $DBCline; $VARDB_pass = preg_replace("/.*=/","",$VARDB_pass);} + if (ereg("^VARDB_port", $DBCline)) + {$VARDB_port = $DBCline; $VARDB_port = preg_replace("/.*=/","",$VARDB_port);} + } + +} +else +{ +#defaults for DB connection +$VARDB_server = 'localhost'; +$VARDB_user = 'cron'; +$VARDB_pass = '1234'; +$VARDB_database = '1234'; +$WeBServeRRooT = '/usr/local/apache2/htdocs'; +} + +$link=mysql_connect("$VARDB_server", "$VARDB_user", "$VARDB_pass"); +if (!$link) { + die('MySQL connect ERROR: ' . mysql_error()); +} +mysql_select_db("$VARDB_database",$link); + +$local_DEF = 'Local/'; +$conf_silent_prefix = '7'; +$local_AMP = '@'; +$ext_context = 'demo'; +$recording_exten = '8309'; +$WeBRooTWritablE = '1'; +$non_latin = '0'; # set to 1 for UTF rules, overridden by system_settings +$flag_channels=0; +$flag_string = 'VICIast20'; + +?> diff --git a/LANG_www/agc_ru/inbound_popup.php b/LANG_www/agc_ru/inbound_popup.php new file mode 100644 index 00000000..2c08e788 --- /dev/null +++ b/LANG_www/agc_ru/inbound_popup.php @@ -0,0 +1,351 @@ + LICENSE: AGPLv2 +# +# This script is designed to open up when a live_inbound call comes in giving the user +# options of what to do with the call or options to lookup the callerID on various web sites +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $uniqueid - ('1234567890.123456',...) +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $vmail_box - ('101','1234',...) +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $voicemail_dump_exten - ('85026666666666') +# - $local_web_callerID_URL_enc - ( rawurlencoded custom callerid lookup URL) +# +# +# changes +# 50428-1500 - First build of script display only +# 50429-1241 - some formatting, hangup and Vmail redirect, 30s timeout on actions, and CID web lookup links +# 50503-1244 - added session_name checking for extra security +# 50711-1203 - removed HTTP authentication in favor of user/pass vars +# 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["voicemail_dump_exten"])) {$voicemail_dump_exten=$_GET["voicemail_dump_exten"];} + elseif (isset($_POST["voicemail_dump_exten"])) {$voicemail_dump_exten=$_POST["voicemail_dump_exten"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_GET["local_web_callerID_URL_enc"];} + elseif (isset($_POST["local_web_callerID_URL_enc"])) {$local_web_callerID_URL_enc=$_POST["local_web_callerID_URL_enc"];} +if (isset($_GET["local_web_callerID_URL_enc"])) {$local_web_callerID_URL = rawurldecode($local_web_callerID_URL_enc);} + else {$local_web_callerID_URL = '';} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.6'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +$DO = '-1'; +if ( (eregi("^Zap",$channel)) and (!eregi("-",$channel)) ) {$channel = "$channel$DO";} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +$forever_stop=0; +$user_abb = "$user$user$user$user"; +while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + +echo "\n"; +echo "\n"; +echo "\n"; +?> + + +ЖИВОЙ ВХОДЯЩИЙ ВЫЗОВ"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "

ЖИВОЙ ВХОДЯЩИЙ ВЫЗОВ

\n"; +echo "$NOW_TIME

\n"; +} + + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if (strlen($uniqueid)<9) + { + $channel_live=0; + echo "Uniqueid $uniqueid это неправильно\n"; + exit; + } + else + { + $stmt="SELECT * FROM live_inbound where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $channels_list = mysql_num_rows($rslt); + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); +# echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; +# Zap/73|"V.I.C.I. MARKET" <7275338730>|2005-04-28 14:01:21|7274514936|Inbound direct to Matt||||| + if ($format=='debug') {echo "\n";} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Канал: $row[1]
ВызывающийID: $row[3]
\n"; + + $phone = eregi_replace(".*\<","",$row[3]); + $phone = eregi_replace("\>.*","",$phone); + $NPA = substr($phone, 0, 3); + $NXX = substr($phone, 3, 3); + $XXXX = substr($phone, 6, 4); + $D='-'; + echo "GOOGLE - \n"; + echo "ANYWHO - \n"; + echo "SWITCHBOARD - \n"; + echo "VERIZON - \n"; + echo "WHITEPAGES - \n"; + echo "411.COM - \n"; + echo "411.COM - \n"; + + $local_web_callerID_QUERY_STRING =''; + $local_web_callerID_QUERY_STRING.="?callerID_areacode=$NPA"; + $local_web_callerID_QUERY_STRING.="&callerID_prefix=$NXX"; + $local_web_callerID_QUERY_STRING.="&callerID_last4=$XXXX"; + $local_web_callerID_QUERY_STRING.="&callerID_Time=$row[6]"; + $local_web_callerID_QUERY_STRING.="&callerID_Канал=$row[1]"; + $local_web_callerID_QUERY_STRING.="&callerID_uniqueID=$row[0]"; + $local_web_callerID_QUERY_STRING.="&callerID_phone_ext=$row[5]"; + $local_web_callerID_QUERY_STRING.="&callerID_server_ip=$row[2]"; + $local_web_callerID_QUERY_STRING.="&callerID_extension=$row[4]"; + $local_web_callerID_QUERY_STRING.="&callerID_inbound_number=$row[8]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_a=$row[9]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_b=$row[10]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_c=$row[11]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_d=$row[12]"; + $local_web_callerID_QUERY_STRING.="&callerID_comment_e=$row[13]"; + echo "ПОЛЬЗОВАТЕЛЬСКИЙ - \n"; + + echo "
Набранный Номер: $row[8]
Примечания:$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|
\n"; + echo "РАЗЪЕДИНЕНИЕ - \n"; + echo "ПОСЛАТЬ В МОЙ VOICEMAIL\n"; + echo "
\n"; + + + $stmt="UPDATE live_inbound set acknowledged='Y' where server_ip = '$server_ip' and uniqueid = '$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + + } + + + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_ru/live_exten_check.php b/LANG_www/agc_ru/live_exten_check.php new file mode 100644 index 00000000..87f5e96b --- /dev/null +++ b/LANG_www/agc_ru/live_exten_check.php @@ -0,0 +1,278 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send whether the client channel is live and to what channel it is connected +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# +# +# changes +# 50404-1249 - First build of script +# 50406-1402 - added connected trunk lookup +# 50428-1452 - added live_inbound check for exten on 2nd line of output +# 50503-1233 - added session_name checking for extra security +# 50524-1429 - added parked calls count +# 50610-1204 - Added NULL check on MySQL results to reduced errors +# 50711-1204 - removed HTTP authentication in favor of user/pass vars +# 60103-1541 - added favorite extens status display +# 60421-1359 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1203 - Added variable filters to close security holes for login form +# 60825-1029 - Fixed translation variable issue ChannelA +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["favorites_count"])) {$favorites_count=$_GET["favorites_count"];} + elseif (isset($_POST["favorites_count"])) {$favorites_count=$_POST["favorites_count"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '2.0.1'; +$build = '60825-1029'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Live Extension Check"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + +echo "DateTime: $NOW_TIME|"; +echo "UnixTime: $StarTtime|"; + +$stmt="SELECT count(*) FROM parked_channels where server_ip = '$server_ip';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +echo "$row[0]|"; + + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten это неправильно или протокол $protocol это неправильно\n"; + exit; + } + else + { + $stmt="SELECT channel,extension FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$channels_list = mysql_num_rows($rslt);} + echo "$channels_list|"; + $loop_count=0; + while ($channels_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + $ChanneLA[$loop_count] = "$row[0]"; + $ChanneLB[$loop_count] = "$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + $counter=0; + while($loop_count > $counter) + { + $counter++; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "КаналA: $ChanneLA[$counter] ~"; + echo "КаналB: $ChanneLB[$counter] ~"; + echo "КаналBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel_data = '$ChanneLA[$counter]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "КаналA: $ChanneLA[$counter] ~"; + echo "КаналB: $ChanneLB[$counter] ~"; + echo "КаналBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "КаналA: $ChanneLA[$counter] ~"; + echo "КаналB: $ChanneLB[$counter] ~"; + echo "КаналBtrunk: $row[0]|"; + } + else + { + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and channel LIKE \"$ChanneLB[$counter]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($rslt) {$trunk_count = mysql_num_rows($rslt);} + if ($trunk_count>0) + { + $row=mysql_fetch_row($rslt); + echo "Conversation: $counter ~"; + echo "КаналA: $ChanneLA[$counter] ~"; + echo "КаналB: $ChanneLB[$counter] ~"; + echo "КаналBtrunk: $row[0]|"; + } + else + { + echo "Conversation: $counter ~"; + echo "КаналA: $ChanneLA[$counter] ~"; + echo "КаналB: $ChanneLB[$counter] ~"; + echo "КаналBtrunk: $ChanneLA[$counter]|"; + } + } + } + } + } + +echo "\n"; + +### check for live_inbound entry +$stmt="select * from live_inbound where server_ip = '$server_ip' and phone_ext = '$exten' and acknowledged='N';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); +if ($rslt) {$channels_list = mysql_num_rows($rslt);} + if ($channels_list>0) + { + $row=mysql_fetch_row($rslt); + $LIuniqueid = "$row[0]"; + $LIchannel = "$row[1]"; + $LIcallerid = "$row[3]"; + $LIdatetime = "$row[6]"; + echo "$LIuniqueid|$LIchannel|$LIcallerid|$LIdatetime|$row[8]|$row[9]|$row[10]|$row[11]|$row[12]|$row[13]|"; + if ($format=='debug') {echo "\n";} + } + +echo "\n"; + + +### if favorites are present do a lookup to see if any are active +if ($favorites_count > 0) + { + $favorites = explode(',',$favorites_list); + $h=0; + $favs_print=''; + while ($favorites_count > $h) + { + $fav_extension = explode('/',$favorites[$h]); + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$favorites[$h]%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $favs_print .= "$fav_extension[1]: $row[0] ~"; + $h++; + } + echo "$favs_print\n"; + } + +if ($format=='debug') {echo "\n";} + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_ru/manager_send.php b/LANG_www/agc_ru/manager_send.php new file mode 100644 index 00000000..c6d0fff1 --- /dev/null +++ b/LANG_www/agc_ru/manager_send.php @@ -0,0 +1,1943 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $ACTION - ('Originate','Redirect','Hangup','Command','Monitor','StopMonitor','SysCIDOriginate','RedirectName','RedirectNameVmail','MonitorConf','StopMonitorConf','RedirectXtra','RedirectXtraCX','RedirectVD','HangupConfDial','VolumeControl','OriginateVDRelogin') +# - $queryCID - ('CN012345678901234567',...) +# - $format - ('text','debug') +# - $channel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $exten - ('1234','913125551212',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $filename - ('20050406-125623_44444',...) +# - $extenName - ('phone100',...) +# - $parkedby - ('phone100',...) +# - $extrachannel - ('Zap/41-1','SIP/test101-1jut','IAX2/iaxy@iaxy',...) +# - $auto_dial_level - ('0','1','1.1',...) +# - $campaign - ('CLOSER','TESTCAMP',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('1234',...) +# - $seconds - ('32',...) +# - $outbound_cid - ('3125551212','0000000000',...) +# - $agent_log_id - ('123456',...) +# - $call_server_ip - ('10.10.10.15',...) +# - $CalLCID - ('VD01234567890123456',...) +# - $stage - ('UP','DOWN','2NDXfeR') +# - $session_id - ('8600051') +# - $FROMvdc - ('YES','NO') +# - $agentchannel - ('SIP/cc101-g7yr','Zap/1-1',...) +# - $usegroupalias - ('0','1') +# - $account - ('DEFAULT',...) +# - $agent_dialed_number - ('1','') +# - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# +# CHANGELOG: +# 50401-1002 - First build of script, Hangup function only +# 50404-1045 - Redirect basic function enabled +# 50406-1522 - Monitor basic function enabled +# 50407-1647 - Monitor and StopMonitor full functions enabled +# 50422-1120 - basic Originate function enabled +# 50428-1451 - basic SysCIDOriginate function enabled for checking voicemail +# 50502-1539 - basic RedirectName and RedirectNameVmail added +# 50503-1227 - added session_name checking for extra security +# 50523-1341 - added Conference call start/stop recording +# 50523-1421 - added OriginateName and OriginateNameVmail for local calls +# 50524-1602 - added RedirectToPark and RedirectFromPark +# 50531-1203 - added RedirecXtra for dual channel redirection +# 50630-1100 - script changed to not use HTTP login vars, user/pass instead +# 50804-1148 - Added RedirectVD for VICIDIAL blind redirection with logging +# 50815-1204 - Added NEXTAVAILABLE to RedirectXtra function +# 50903-2343 - Added HangupConfDial function to hangup in-dial channels in conf +# 50913-1057 - Added outbound_cid set if present to originate call +# 51020-1556 - Added agent_log_id framework for detailed agent activity logging +# 51118-1204 - Fixed Blind transfer bug from VICIDIAL when in manual dial mode +# 51129-1014 - Added ability to accept calls from other VICIDIAL servers +# 51129-1253 - Fixed Hangups of other agents channels in VICIDIAL AD +# 60310-2022 - Fixed NEXTAVAILABLE bug in leave-3way-call redirect function +# 60421-1413 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1158 - Added variable filters to close security holes for login form +# 60809-1544 - Added direct transfers to leave-3ways in consultative transfers +# 61004-1526 - Added parsing of volume control command and lookup or number +# 61130-1617 - Added lead_id to MonitorConf for recording_log +# 61201-1115 - Added user to MonitorConf for recording_log +# 70111-1600 - added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70226-1251 - Added Mute/UnMute to conference volume control +# 70320-1502 - Added option to allow retry of leave-3way-call and debug logging +# 70322-1636 - Added sipsak display ability +# 80331-1433 - Added second transfer try for VICIDIAL transfers on manual dial calls +# 80402-0121 - Fixes for manual dial transfers on some systems +# 80424-0442 - Added non_latin lookup from system_settings +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80915-1755 - Rewrote leave-3way functions for external calling +# 81011-1404 - Fixed bugs in leave3way when transferring a manual dial call +# 81020-1459 - Fixed bugs in queue_log logging +# 81104-0203 - Added mysql error logging capability +# 90303-1144 - Fixed manual dial live hangup bug +# 90304-1334 - Added account and usegroupalias and user campaign/in-group specific variables +# 90305-1040 - Added agent_dialed_number and type for user_call_log feature +# + +$version = '2.0.5-38'; +$build = '90305-1040'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=83; +$one_mysql_log=0; + +require("dbconnect.php"); + +### These are variable assignments for PHP globals off +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["queryCID"])) {$queryCID=$_GET["queryCID"];} + elseif (isset($_POST["queryCID"])) {$queryCID=$_POST["queryCID"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["filename"])) {$filename=$_GET["filename"];} + elseif (isset($_POST["filename"])) {$filename=$_POST["filename"];} +if (isset($_GET["extenName"])) {$extenName=$_GET["extenName"];} + elseif (isset($_POST["extenName"])) {$extenName=$_POST["extenName"];} +if (isset($_GET["parkedby"])) {$parkedby=$_GET["parkedby"];} + elseif (isset($_POST["parkedby"])) {$parkedby=$_POST["parkedby"];} +if (isset($_GET["extrachannel"])) {$extrachannel=$_GET["extrachannel"];} + elseif (isset($_POST["extrachannel"])) {$extrachannel=$_POST["extrachannel"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["secondS"])) {$secondS=$_GET["secondS"];} + elseif (isset($_POST["secondS"])) {$secondS=$_POST["secondS"];} +if (isset($_GET["outbound_cid"])) {$outbound_cid=$_GET["outbound_cid"];} + elseif (isset($_POST["outbound_cid"])) {$outbound_cid=$_POST["outbound_cid"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["call_server_ip"])) {$call_server_ip=$_GET["call_server_ip"];} + elseif (isset($_POST["call_server_ip"])) {$call_server_ip=$_POST["call_server_ip"];} +if (isset($_GET["CalLCID"])) {$CalLCID=$_GET["CalLCID"];} + elseif (isset($_POST["CalLCID"])) {$CalLCID=$_POST["CalLCID"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["enable_sipsak_messages"])) {$enable_sipsak_messages=$_GET["enable_sipsak_messages"];} + elseif (isset($_POST["enable_sipsak_messages"])) {$enable_sipsak_messages=$_POST["enable_sipsak_messages"];} +if (isset($_GET["allow_sipsak_messages"])) {$allow_sipsak_messages=$_GET["allow_sipsak_messages"];} + elseif (isset($_POST["allow_sipsak_messages"])) {$allow_sipsak_messages=$_POST["allow_sipsak_messages"];} +if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];} + elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];} +if (isset($_GET["FROMvdc"])) {$FROMvdc=$_GET["FROMvdc"];} + elseif (isset($_POST["FROMvdc"])) {$FROMvdc=$_POST["FROMvdc"];} +if (isset($_GET["agentchannel"])) {$agentchannel=$_GET["agentchannel"];} + elseif (isset($_POST["agentchannel"])) {$agentchannel=$_POST["agentchannel"];} +if (isset($_GET["usegroupalias"])) {$usegroupalias=$_GET["usegroupalias"];} + elseif (isset($_POST["usegroupalias"])) {$usegroupalias=$_POST["usegroupalias"];} +if (isset($_GET["account"])) {$account=$_GET["account"];} + elseif (isset($_POST["account"])) {$account=$_POST["account"];} +if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_dialed_number"];} + elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} +if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} + elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) +{ +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$secondS = ereg_replace("[^0-9]","",$secondS); +} + +# default optional vars if not set +if (!isset($ACTION)) {$ACTION="Originate";} +if (!isset($format)) {$format="alert";} +if (!isset($ext_priority)) {$ext_priority="1";} + +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$NOWnum = date("YmdHis"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +$stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02002',$user,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Отослать Менеджеру: "; +if ($ACTION=="Originate") {echo "Originate";} +if ($ACTION=="Redirect") {echo "Redirect";} +if ($ACTION=="RedirectName") {echo "RedirectName";} +if ($ACTION=="Hangup") {echo "Hangup";} +if ($ACTION=="Command") {echo "Command";} +if ($ACTION==99999) {echo "ПОМОЩЬ";} +echo "\n"; +echo "\n"; +echo "\n"; +} + + + + + +###################### +# ACTION=SysCIDOriginate - insert Originate Manager statement allowing small CIDs for system calls +###################### +if ($ACTION=="SysCIDOriginate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<1) ) + { + echo "Exten $exten это неправильно or queryCID $queryCID это неправильно, Originate команда не введена\n"; + } + else + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02004',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Originate посылать команду для Exten $exten Канал $channel на $server_ip\n"; + } +} + + + +###################### +# ACTION=Originate, OriginateName, OriginateNameVmail - insert Originate Manager statement +###################### +if ($ACTION=="OriginateName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "extenName $extenName должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nOriginateName Action не послано\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02005',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "extenName $extenName должен быть установлен\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nOriginateNameVmail Action не послано\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02006',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Originate"; + } + } +} + +if ($ACTION=="OriginateVDRelogin") +{ + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $CIDdate = date("ymdHis"); + $DS='-'; + $SIPSAK_prefix = 'LIN-'; + print "\n"; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$campaign\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + $queryCID = "$SIPSAK_prefix$campaign$DS$CIDdate"; + + } + $ACTION="Originate"; +} + +if ($ACTION=="Originate") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($ext_context)<1) or (strlen($queryCID)<10) ) + { + echo "Exten $exten это неправильно or queryCID $queryCID это неправильно, Originate команда не введена\n"; + } + else + { + if (strlen($outbound_cid)>1) + {$outCID = "\"$queryCID\" <$outbound_cid>";} + else + {$outCID = "$queryCID";} + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $outCID','$account','$variable','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02007',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Originate посылать команду для Exten $exten Канал $channel на $server_ip |$account|$variable|\n"; + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$exten','$channel','0','$outbound_cid','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00192',$user,$server_ip,$session_name,$one_mysql_log);} + } + } +} + + + +###################### +# ACTION=HangupConfDial - find the Local channel that is in the conference and needs to be hung up +###################### +if ($ACTION=="HangupConfDial") +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "conference $exten это неправильно or ext_context $ext_context or queryCID $queryCID это неправильно, Hangup команда не введена\n"; + } + else + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$exten$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02008',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02009',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $ACTION="Hangup"; + $queryCID = eregi_replace("^.","G",$queryCID); # GTvdcW... + } + } +} + + + +###################### +# ACTION=Hangup - insert Hangup Manager statement +###################### +if ($ACTION=="Hangup") +{ +$stmt="UPDATE vicidial_live_agents SET external_hangup='0' where user='$user';"; + if ($format=='debug') {echo "\n";} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02010',$user,$server_ip,$session_name,$one_mysql_log);} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) ) + { + $channel_live=0; + echo "Канал $channel это неправильно or queryCID $queryCID это неправильно, Hangup команда не введена\n"; + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + +# $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $row=mysql_fetch_row($rslt); +# if ($row[0]==0) +# { +# $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; +# if ($format=='debug') {echo "\n";} +# $rslt=mysql_query($stmt, $link); +# $rowx=mysql_fetch_row($rslt); +# if ($rowx[0]==0) +# { +# $channel_live=0; +# echo "Channel $channel is not live on $call_server_ip, Hangup command not inserted\n"; +# } +# } + if ( ($auto_dial_level > 0) and (strlen($CalLCID)>2) and (strlen($exten)>2) and ($secondS > 0)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where channel='$channel' and callerid='$CalLCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02011',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + echo "Call $CalLCID $channel это не активно на $call_server_ip, Checking Live Канал...\n"; + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension LIKE \"%$exten\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02012',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $channel_live=0; + echo "Канал $channel это не активно на $call_server_ip, Hangup команда не введена $rowx[0]\n$stmt\n"; + } + else + { + echo "$stmt\n"; + } + } + } + if ( ($auto_dial_level < 1) and (strlen($stage)>2) and (strlen($channel)>2) and (strlen($exten)>2) ) + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel' and extension NOT LIKE \"%$exten%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02083',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $channel_live=0; + echo "Канал $channel in use by another agent на $call_server_ip, Hangup команда не введена $rowx[0]\n$stmt\n"; + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|MDCHU|$user|$channel|$call_server_ip|$exten|\n"); + fclose($fp); + } + } + else + { + echo "$stmt\n"; + } + } + + if ($channel_live==1) + { + if ( (strlen($CalLCID)>15) and ($secondS > 0)) + { + $stmt="SELECT count(*) FROM vicidial_auto_calls where callerid='$CalLCID';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02013',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($format=='debug') {echo "\n";} + if ($rowx[0] > 0) + { + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02014',$user,$server_ip,$session_name,$one_mysql_log);} + if ($format=='debug') {echo "\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='CONNECT';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02015',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_cn_ct = mysql_num_rows($rslt); + if ($VAC_cn_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_connect = $row[0]; + } + if ($format=='debug') {echo "\n";} + if ($caller_connect > 0) + { + ### grab call lead information needed for QM logging + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where callerid='$CalLCID' order by call_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02016',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + if ($format=='debug') {echo "\n";} + + $CLstage = preg_replace("/.*-/",'',$CLstage); + if (strlen($CLstage) < 1) {$CLstage=0;} + + $stmt="SELECT count(*) from queue_log where call_id='$CalLCID' and verb='COMPLETECALLER' and queue='$CLcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02017',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_complete = $row[0]; + } + if ($format=='debug') {echo "\n";} + + if ($caller_complete < 1) + { + $time_id=0; + $stmt="SELECT time_id from queue_log where call_id='$CalLCID' and verb='ENTERQUEUE' and queue='$CLcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02018',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_eq_ct = mysql_num_rows($rslt); + if ($VAC_eq_ct > 0) + { + $row=mysql_fetch_row($rslt); + $time_id = $row[0]; + } + $StarTtime = date("U"); + if ($time_id > 100000) + {$secondS = ($StarTtime - $time_id);} + + if ($format=='debug') {echo "\n";} + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CalLCID',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$secondS',data3='1',serverid='$queuemetrics_log_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'02019',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + if ($format=='debug') {echo "\n";} + } + } + } + } + } + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Hangup','$queryCID','Channel: $channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02020',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Hangup посылать команду для Канал $channel на $call_server_ip\n"; + } + } +} + + + +###################### +# ACTION=Redirect, RedirectName, RedirectNameVmail, RedirectToPark, RedirectFromPark, RedirectVD, RedirectXtra, RedirectXtraCX +# - insert Redirect Manager statement using extensions name +###################### +if ($ACTION=="RedirectVD") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($campaign)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($uniqueid)<2) or (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "auto_dial_level $auto_dial_level должен быть установлен\n"; + echo "campaign $campaign должен быть установлен\n"; + echo "uniqueid $uniqueid должен быть установлен\n"; + echo "lead_id $lead_id должен быть установлен\n"; + echo "\nRedirectVD Action не послано\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "select count(*) from vicidial_campaigns where campaign_id='$campaign' and campaign_allow_inbound='Y';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02021',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where lead_id='$lead_id' order by start_epoch desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02022',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_log set end_epoch='$StarTtime', length_in_sec='$secondS',status='XFER' where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02023',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02024',$user,$server_ip,$session_name,$one_mysql_log);} + } + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectToPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($parkedby)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "extenName $extenName должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "parkedby $parkedby должен быть установлен\n"; + echo "\nRedirectToPark Action не послано\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "INSERT INTO parked_channels values('$channel','$server_ip','','$extenName','$parkedby','$NOW_TIME');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02025',$user,$server_ip,$session_name,$one_mysql_log);} + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectFromPark") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirectFromPark Action не послано\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt = "DELETE FROM parked_channels where server_ip='$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02026',$user,$server_ip,$session_name,$one_mysql_log);} + $ACTION="Redirect"; + } +} + +if ($ACTION=="RedirectName") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "extenName $extenName должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirectName Action не послано\n"; + } + else + { + $stmt="SELECT dialplan_number FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02027',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + $ACTION="Redirect"; + } + } +} + +if ($ACTION=="RedirectNameVmail") +{ + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($extenName)<1) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "extenName $extenName должен быть установлен\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirectNameVmail Action не послано\n"; + } + else + { + $stmt="SELECT voicemail_id FROM phones where server_ip = '$server_ip' and extension='$extenName';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02028',$user,$server_ip,$session_name,$one_mysql_log);} + $name_count = mysql_num_rows($rslt); + if ($name_count>0) + { + $row=mysql_fetch_row($rslt); + $exten = "$exten$row[0]"; + $ACTION="Redirect"; + } + } +} + + + + + + +if ($ACTION=="RedirectXtraCXNeW") +{ + $DBout=''; + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!ereg("NEXTAVAILABLE",$exten)) ) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "ExtraКанал $extrachannel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirect Action не послано\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); + fclose($fp); + } + } + } + else + { + if (ereg("NEXTAVAILABLE",$exten)) + { + $stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 1) + { + $stmtB="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtB, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'02030',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtC="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtC, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + + if ( (ereg("^8300",$extension)) and ($protocol == 'Local') ) + { + $extension = "$extension$user"; + } + + $stmtD="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtD, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtD,'02032',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtE="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtE, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);} + + $queryCID = "CXAR24$NOWnum"; + $stmtF="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtF, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtF,'02034',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmtG="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtG, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtG,'02035',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($auto_dial_level < 1) + { + $stmtH = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtH, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtH,'02036',$user,$server_ip,$session_name,$one_mysql_log);} + } + + // $fp = fopen ("./vicidial_debug_3way.txt", "a"); + // fwrite ($fp, "$NOW_TIME|$filename|\n|$stmtA|\n|$stmtB|\n|$stmtC|\n|$stmtD|\n|$stmtE|\n|$stmtF|\n|$stmtG|\n|$stmtH|\n\n"); + // fclose($fp); + + echo "NeWSessioN|$exten|\n"; + echo "|$stmtG|\n"; + + exit; + } + else + { + $channel_liveX=0; + echo "Cannot find empty vicidial_conference на $server_ip, Redirect команда не введена\n|$stmt|"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Не могу найти свободную конференцию на $server_ip";} + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02037',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02038',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Канал $channel это не активно на $call_server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02039',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02040',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Канал $channel это не активно на $server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + $stmt="SELECT count(*) FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02041',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] < 1) + { + $channel_liveY=0; + echo "No Local agent to send call to, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "No Local agent to send call to";} + } + else + { + $stmt="SELECT server_ip,conf_exten,user FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02042',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $dest_server_ip = $rowx[0]; + $dest_session_id = $rowx[1]; + $dest_user = $rowx[2]; + $S='*'; + + $D_s_ip = explode('.', $dest_server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$dest_session_id$S$lead_id$S$dest_user$S$phone_code$S$phone_number$S$campaign$S"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02043',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','$queryCID','Channel: $extrachannel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02044',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtraCX посылать команду для Канал $channel на $call_server_ip and \nHungup $extrachannel на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel на $call_server_ip, Hungup $extrachannel на $server_ip";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Changed to Redirect: $channel на $server_ip";} + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + + } +} + + + + + + + + + + +if ($ACTION=="RedirectXtraNeW") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!ereg("NEXTAVAILABLE",$exten)) ) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "ExtraКанал $extrachannel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "session_id $session_id должен быть установлен\n"; + echo "\nRedirect Action не послано\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|$session_id|\n"); + fclose($fp); + } + } + } + else + { + if (ereg("NEXTAVAILABLE",$exten)) + { + $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 1) + { + $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02046',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $exten = $row[0]; + + $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02048',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);} + + $queryCID = "CXAR23$NOWnum"; + $stmtB="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $agentchannel','Context: $ext_context','Exten: $exten','Priority: 1','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmtB, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02050',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_live_agents set conf_exten='$exten' where server_ip='$server_ip' and user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02051',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($auto_dial_level < 1) + { + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and callerid LIKE \"M%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02052',$user,$server_ip,$session_name,$one_mysql_log);} + } + + echo "NeWSessioN|$exten|\n"; + echo "|$stmtB|\n"; + + exit; + } + else + { + $channel_liveX=0; + echo "Cannot find empty vicidial_conference на $server_ip, Redirect команда не введена\n|$stmt|"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Не могу найти свободную конференцию на $server_ip";} + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02053',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02054',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Канал $channel это не активно на $call_server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02055',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02056',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Канал $channel это не активно на $server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02057',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtra посылать команду для Канал $channel and \nExtraКанал $extrachannel\n to $exten на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel and $extrachannel to $exten на $server_ip";} + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02058',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02059',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "RedirectXtra посылать команду для Канал $channel на $call_server_ip and \nExtraКанал $extrachannel\n to $exten на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel/$call_server_ip and $extrachannel/$server_ip to $exten";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + + } + } +} + + + + + + + +/* +if ($ACTION=="RedirectXtraCX") +{ + $DBout=''; + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "ExtraКанал $extrachannel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirect Action не послано\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); + fclose($fp); + } + } + } + else + { + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Канал $channel это не активно на $call_server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Канал $channel это не активно на $server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + $stmt="SELECT count(*) FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0] < 1) + { + $channel_liveY=0; + echo "No Local agent to send call to, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "No Local agent to send call to";} + } + else + { + $stmt="SELECT server_ip,conf_exten,user FROM vicidial_live_agents where lead_id='$lead_id' and user!='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + $dest_server_ip = $rowx[0]; + $dest_session_id = $rowx[1]; + $dest_user = $rowx[2]; + $S='*'; + + $D_s_ip = explode('.', $dest_server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$dest_session_id$S$lead_id$S$dest_user$S$phone_code$S$phone_number$S$campaign$S"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','$queryCID','Channel: $extrachannel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtraCX посылать команду для Канал $channel на $call_server_ip and \nHungup $extrachannel на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel на $call_server_ip, Hungup $extrachannel на $server_ip";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Changed to Redirect: $channel на $server_ip";} + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + + } +} + + + +###### BEGIN OLD LEAVE-3-WAY FOR EXTERNAL CALLS - DEPRICATED AND WILL BE DELETED SOON ##### +if ($ACTION=="RedirectXtra") +{ + if ($channel=="$extrachannel") + {$ACTION="Redirect";} + else + { + $row=''; $rowx=''; + $channel_liveX=1; + $channel_liveY=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($extrachannel)<3) ) + { + $channel_liveX=0; + $channel_liveY=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "ExtraКанал $extrachannel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirect Action не послано\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n"); + fclose($fp); + } + } + } + else + { + if (ereg("NEXTAVAILABLE",$exten)) + { + $stmt="SELECT conf_exten FROM conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if (strlen($row[0]) > 3) + { + $stmt="UPDATE conferences set extension='$user' where server_ip='$server_ip' and conf_exten='$row[0]';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $exten = $row[0]; + } + else + { + $channel_liveX=0; + echo "Не могу найти свободную конференцию на $server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Не могу найти свободную конференцию на $server_ip";} + } + } + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + + $stmt="SELECT count(*) FROM live_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveX=0; + echo "Канал $channel это не активно на $call_server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $call_server_ip";} + } + } + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + if ( ($row[0]==0) && (!ereg("SECOND",$filename)) ) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_liveY=0; + echo "Канал $channel это не активно на $server_ip, Redirect команда не введена\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel это не активно на $server_ip";} + } + } + if ( ($channel_liveX==1) && ($channel_liveY==1) ) + { + if ( ($server_ip=="$call_server_ip") or (strlen($call_server_ip)<7) ) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','ExtraChannel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra посылать команду для Канал $channel and \nExtraКанал $extrachannel\n to $exten на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel and $extrachannel to $exten на $server_ip";} + } + else + { + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $dest_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S$exten"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$call_server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $dest_dialstring','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $extrachannel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + + echo "RedirectXtra посылать команду для Канал $channel на $call_server_ip and \nExtraКанал $extrachannel\n to $exten на $server_ip\n"; + if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel/$call_server_ip and $extrachannel/$server_ip to $exten";} + } + } + else + { + if ($channel_liveX==1) + {$ACTION="Redirect"; $server_ip = $call_server_ip;} + if ($channel_liveY==1) + {$ACTION="Redirect"; $channel=$extrachannel;} + + } + + if (ereg("SECOND|FIRST|DEBUG",$filename)) + { + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$DBout|\n"); + fclose($fp); + } + } + + } + } +} +###### END OLD LEAVE-3-WAY FOR EXTERNAL CALLS - DEPRICATED AND WILL BE DELETED SOON ##### +*/ + +if ($ACTION=="Redirect") +{ + ### for manual dial VICIНАБОР НОМЕРА calls send the second attempt to transfer the call + if ($stage=="2NDXfeR") + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $hangup_channel_prefix = "$local_DEF$session_id$local_AMP$ext_context"; + + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02060',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row > 0) + { + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$hangup_channel_prefix%\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02061',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + $channel=$rowx[0]; + $channel = eregi_replace("1$","2",$channel); + $queryCID = eregi_replace("^.","Q",$queryCID); + } + } + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($exten)<1) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) ) + { + $channel_live=0; + echo "Одна из этих переменных это неправильно:\n"; + echo "Канал $channel должно быть больше чем 2 символа\n"; + echo "queryCID $queryCID должно быть больше чем 14 символов\n"; + echo "exten $exten должен быть установлен\n"; + echo "ext_context $ext_context должен быть установлен\n"; + echo "ext_priority $ext_priority должен быть установлен\n"; + echo "\nRedirect Action не послано\n"; + } + else + { + if (strlen($call_server_ip)>6) {$server_ip = $call_server_ip;} + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02062',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02063',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Канал $channel это не активно на $server_ip, Redirect команда не введена\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Redirect','$queryCID','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','CallerID: $queryCID','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02064',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "Redirect посылать команду для Канал $channel на $server_ip\n"; + } + } +} + + + +###################### +# ACTION=Monitor or Stop Monitor - insert Monitor/StopMonitor Manager statement to start recording on a channel +###################### +if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) +{ + if ($ACTION=="StopMonitor") + {$SQLfile = "";} + else + {$SQLfile = "File: $filename";} + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) + { + $channel_live=0; + echo "Канал $channel это неправильно or queryCID $queryCID это неправильно or filename: $filename это неправильно, $ACTION команда не введена\n"; + } + else + { + $stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02065',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0]==0) + { + $stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$channel';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02066',$user,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + if ($rowx[0]==0) + { + $channel_live=0; + echo "Канал $channel это не активно на $server_ip, $ACTION команда не введена\n"; + } + } + if ($channel_live==1) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','$ACTION','$queryCID','Channel: $channel','$SQLfile','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02067',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($ACTION=="Monitor") + { + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02068',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT recording_id FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02069',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + } + else + { + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02070',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02071',$user,$server_ip,$session_name,$one_mysql_log);} + } + + } + echo "$ACTION посылать команду для Канал $channel на $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n"; + } + } +} + + + + + + +###################### +# ACTION=MonitorConf or StopMonitorConf - insert Monitor/StopMonitor Manager statement to start recording on a conference +###################### +if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) +{ + $row=''; $rowx=''; + $channel_live=1; + $uniqueidSQL=''; + + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) + { + $channel_live=0; + echo "Канал $channel это неправильно or exten $exten это неправильно or filename: $filename это неправильно, $ACTION команда не введена\n"; + } + else + { + + $VDvicidial_id=''; + + if ($ACTION=="MonitorConf") + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02072',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02073',$user,$server_ip,$session_name,$one_mysql_log);} + $RLaffected_rows = mysql_affected_rows($link); + if ($RLaffected_rows > 0) + { + $recording_id = mysql_insert_id($link); + } + + if ($FROMvdc=='YES') + { + ##### get call type from vicidial_live_agents table + $VLA_inOUT='NONE'; + $stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02074',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLA_inOUT_ct = mysql_num_rows($rslt); + if ($VLA_inOUT_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLA_inOUT = $row[0]; + } + if ($VLA_inOUT == 'INBOUND') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ##### look for the vicidial ID in the vicidial_closer_log table + $stmt="SELECT closecallid FROM vicidial_closer_log where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + } + else + { + ##### look for the vicidial ID in the vicidial_log table + $stmt="SELECT uniqueid FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + } + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02075',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDvicidial_id = $row[0]; + + $stmt = "UPDATE recording_log SET vicidial_id='$VDvicidial_id' where recording_id='$recording_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02076',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + } + + ##### StopMonitorConf steps ##### + else + { + if ($uniqueid=='IN') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ### find the value to put in the vicidial_id field if this was an inbound call + $stmt="SELECT closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02077',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueidSQL = ",vicidial_id='$row[0]'"; + } + } + else + { + if (strlen($uniqueid) > 8) + {$uniqueidSQL = ",vicidial_id='$uniqueid'";} + } + + $stmt="SELECT recording_id,start_epoch FROM recording_log where filename='$filename'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02078',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $rec_count = mysql_num_rows($rslt); + if ($rec_count>0) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $uniqueidSQL where filename='$filename'"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02079',$user,$server_ip,$session_name,$one_mysql_log);} + } + + # find and hang up all recordings going на in this conference # and extension = '$exten' + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02080',$user,$server_ip,$session_name,$one_mysql_log);} + # $rec_count = intval(mysql_num_rows($rslt) / 2); + $rec_count = mysql_num_rows($rslt); + $h=0; + while ($rec_count>$h) + { + $rowx=mysql_fetch_row($rslt); + $HUchannel[$h] = $rowx[0]; + $h++; + } + $i=0; + while ($h>$i) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02081',$user,$server_ip,$session_name,$one_mysql_log);} + $i++; + } + + } + echo "$ACTION посылать команду для Канал $channel на $server_ip\nFilename: $filename\nRecorDing_ID: $recording_id\n ЗАПИСЬ МОЖЕТ ПРОДОЛЖАТЬСЯ ДО 60 МИН.\n"; + } +} + + + + + +###################### +# ACTION=VolumeControl - raise or lower the volume of a meetme participant +###################### +if ($ACTION=="VolumeControl") +{ + if ( (strlen($exten)<1) or (strlen($channel)<1) or (strlen($stage)<1) or (strlen($queryCID)<1) ) + { + echo "Конференция $exten, Stage $stage это неправильно or queryCID $queryCID это неправильно, Originate команда не введена\n"; + } + else + { + $participant_number='XXYYXXYYXXYYXX'; + if (eregi('UP',$stage)) {$vol_prefix='4';} + if (eregi('DOWN',$stage)) {$vol_prefix='3';} + if (eregi('UNMUTE',$stage)) {$vol_prefix='2';} + if (eregi('MUTING',$stage)) {$vol_prefix='1';} + $local_DEF = 'Local/'; + $local_AMP = '@'; + $volume_local_channel = "$local_DEF$participant_number$vol_prefix$exten$local_AMP$ext_context"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $volume_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02082',$user,$server_ip,$session_name,$one_mysql_log);} + echo "Volume посылать команду для Конференция $exten, Stage $stage Канал $channel на $server_ip\n"; + } +} + + + + + + + + + + + + +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +if ($format=='debug') {echo "\n";} +if ($format=='debug') {echo "\n\n\n";} + +exit; + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) +{ +$NOW_TIME = date("Y-m-d H:i:s"); +# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); +$errno=''; $error=''; +if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|manager_send|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_ru/park_calls_display.php b/LANG_www/agc_ru/park_calls_display.php new file mode 100644 index 00000000..0885af0e --- /dev/null +++ b/LANG_www/agc_ru/park_calls_display.php @@ -0,0 +1,146 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send the details on the parked calls on the server +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $exten - ('cc101','testphone','49-1','1234','913125551212',...) +# - $protocol - ('SIP','Zap','IAX2',...) +# +# +# changes +# 50524-1515 - First build of script +# 50711-1208 - removed HTTP authentication in favor of user/pass vars +# 60421-1111 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1205 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} +if (!isset($park_limit)) {$park_limit="1000";} + +$version = '0.0.4'; +$build = '60619-1205'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0) ) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Показать Паркованные Вызовы"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($exten)<1) or (strlen($protocol)<3) ) + { + $channel_live=0; + echo "Exten $exten это неправильно или протокол $protocol это неправильно\n"; + exit; + } + else + { + ##### print parked calls from the parked_channels table + $stmt="SELECT * from parked_channels where server_ip = '$server_ip' order by parked_time limit $park_limit;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $park_calls_count = mysql_num_rows($rslt); + echo "$park_calls_count\n"; + $loop_count=0; + while ($park_calls_count>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0] ~$row[2] ~$row[3] ~$row[4] ~$row[5]|"; + } + echo "\n"; + } + + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_ru/timeclock.php b/LANG_www/agc_ru/timeclock.php new file mode 100644 index 00000000..6889cded --- /dev/null +++ b/LANG_www/agc_ru/timeclock.php @@ -0,0 +1,455 @@ + LICENSE: AGPLv2 +# +# CHANGELOG +# 80523-0134 - First Build +# 80524-0225 - Changed event_date to DATETIME, added timestamp field and tcid_link field +# 80525-2351 - Added an audit log that is not to be editable +# 80602-0641 - Fixed status update bug +# + +$version = '2.0.5-4'; +$build = '80602-0641'; + +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); + $last_action_date = $NOW_TIME; + +$US='_'; +$CL=':'; +$AT='@'; +$DS='-'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('timeclock.php','',$agcPAGE); + + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["commit"])) {$commit=$_GET["commit"];} + elseif (isset($_POST["commit"])) {$commit=$_POST["commit"];} +if (isset($_GET["referrer"])) {$referrer=$_GET["referrer"];} + elseif (isset($_POST["referrer"])) {$referrer=$_POST["referrer"];} +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} + +if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } +if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^\,0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign=ereg_replace("[^0-9a-zA-Z_]","",$VD_campaign); + $user=ereg_replace("[^0-9a-zA-Z]","",$user); + $pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + $stage=ereg_replace("[^0-9a-zA-Z]","",$stage); + $commit=ereg_replace("[^0-9a-zA-Z]","",$commit); + $referrer=ereg_replace("[^0-9a-zA-Z]","",$referrer); + +require("dbconnect.php"); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,admin_home_url FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $welcomeURL = $row[1]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +if ( ($stage == 'login') or ($stage == 'logout') ) + { + ### see if user/pass exist for this user in vicidial_users table + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $valid_user=$row[0]; + print "\n"; + + if ($valid_user < 1) + { + ### NOT A VALID USER/PASS + $VDdisplayMESSAGE = "Пользователя и пароль, которые вы вступили, не действующих в системе
Пожалуйста, повторите попытку:"; + + echo"\n"; + echo"VICIНАБОР НОМЕРА:Timeclock\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Timeclock
 
Логин Пользователя:
Пароль Пользователя:
 

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + else + { + ### VALID USER/PASS, CONTINUE + + ### get name and group for this user + $stmt="SELECT full_name,user_group from vicidial_users where user='$user' and pass='$pass';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $full_name = $row[0]; + $user_group = $row[1]; + print "\n"; + + ### get vicidial_timeclock_status record count for this user + $stmt="SELECT count(*) from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $vts_count = $row[0]; + + $last_action_sec=99; + + if ($vts_count > 0) + { + ### vicidial_timeclock_status record found, grab status and date of last activity + $stmt="SELECT status,event_epoch from vicidial_timeclock_status where user='$user';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $status = $row[0]; + $event_epoch = $row[1]; + $last_action_date = date("Y-m-d H:i:s", $event_epoch); + $last_action_sec = ($StarTtimE - $event_epoch); + if ($last_action_sec > 0) + { + $totTIME_H = ($last_action_sec / 3600); + $totTIME_H_int = round($totTIME_H, 2); + $totTIME_H_int = intval("$totTIME_H"); + $totTIME_M = ($totTIME_H - $totTIME_H_int); + $totTIME_M = ($totTIME_M * 60); + $totTIME_M_int = round($totTIME_M, 2); + $totTIME_M_int = intval("$totTIME_M"); + $totTIME_S = ($totTIME_M - $totTIME_M_int); + $totTIME_S = ($totTIME_S * 60); + $totTIME_S = round($totTIME_S, 0); + if (strlen($totTIME_H_int) < 1) {$totTIME_H_int = "0";} + if ($totTIME_M_int < 10) {$totTIME_M_int = "0$totTIME_M_int";} + if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";} + $totTIME_HMS = "$totTIME_H_int:$totTIME_M_int:$totTIME_S"; + } + else + { + $totTIME_HMS='0:00:00'; + } + + print "\n"; + } + else + { + ### No vicidial_timeclock_status record found, insert one + $stmt="INSERT INTO vicidial_timeclock_status set status='СТАРТ', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $status='СТАРТ'; + $totTIME_HMS='0:00:00'; + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + if ( ($last_action_sec < 30) and ($status != 'СТАРТ') ) + { + ### You cannot log in or out within 30 секунды of your last login/logout + $VDdisplayMESSAGE = "Вы не можете войти или в течение 30 секунд после вашего последнего входа в систему или Logout"; + + echo"\n"; + echo"VICIНАБОР НОМЕРА:Timeclock\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Timeclock
 
Логин Пользователя:
Пароль Пользователя:
 

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + if ($commit == 'YES') + { + if ( ( ($status=='AUTOВЫХОД') or ($status=='СТАРТ') or ($status=='ВЫХОД') ) and ($stage=='login') ) + { + $VDdisplayMESSAGE = "You have now logged-in"; + $LOGtimeMESSAGE = "You logged in at $NOW_TIME"; + + ### Add a record to the timeclock log + $stmt="INSERT INTO vicidial_timeclock_log set event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "\n"; + + ### Update the user's timeclock status record + $stmt="UPDATE vicidial_timeclock_status set status='LOGIN', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Add a record to the timeclock audit log + $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='LOGIN', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + + if ( ($status=='LOGIN') and ($stage=='logout') ) + { + $VDdisplayMESSAGE = "Вы уже зарегистрированы отказа"; + $LOGtimeMESSAGE = "Вы вошли на$NOW_TIME
Количество раз, когда вы были зарегистрированы в:$totTIME_HMS"; + + ### Add a record to the timeclock log + $stmt="INSERT INTO vicidial_timeclock_log set event='ВЫХОД', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + $timeclock_id = mysql_insert_id($link); + print "\n"; + + ### Update last login record in the timeclock log + $stmt="UPDATE vicidial_timeclock_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Update the user's timeclock status record + $stmt="UPDATE vicidial_timeclock_status set status='ВЫХОД', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip' where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Add a record to the timeclock audit log + $stmt="INSERT INTO vicidial_timeclock_audit_log set timeclock_id='$timeclock_id', event='ВЫХОД', user='$user', user_group='$user_group', event_epoch='$StarTtimE', ip_address='$ip', login_sec='$last_action_sec', event_date='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + + ### Update last login record in the timeclock audit log + $stmt="UPDATE vicidial_timeclock_audit_log set login_sec='$last_action_sec',tcid_link='$timeclock_id' where event='LOGIN' and user='$user' order by timeclock_id desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + + if ( ( ( ($status=='AUTOВЫХОД') or ($status=='СТАРТ') or ($status=='ВЫХОД') ) and ($stage=='logout') ) or ( ($status=='LOGIN') and ($stage=='login') ) ) + {echo "ОШИБКА: timeclock вход вход уже сделал:$status|$stage"; exit;} + + if ($referrer=='agent') + {$BACKlink = "BACK TO Агент Логин экрана";} + if ($referrer=='admin') + {$BACKlink = "BACK TO администрации";} + if ($referrer=='welcome') + {$BACKlink = "BACK приветствовать экрана";} + + echo"\n"; + echo"VICIНАБОР НОМЕРА:Timeclock\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Timeclock
 
$LOGtimeMESSAGE
 
$BACKlink
 

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + + + + if ( ($status=='AUTOВЫХОД') or ($status=='СТАРТ') or ($status=='ВЫХОД') ) + { + $VDdisplayMESSAGE = "Время с момента вашего последнего входа в:$totTIME_HMS"; + $log_action = 'login'; + $button_name = 'LOGIN'; + $LOGtimeMESSAGE = "Вы последнего зарегистрированного по адресу:$last_action_date

Нажмите кнопку Вход для входа в"; + } + if ($status=='LOGIN') + { + $VDdisplayMESSAGE = "Количество раз, когда вы вышли в:$totTIME_HMS"; + $log_action = 'logout'; + $button_name = 'ВЫХОД'; + $LOGtimeMESSAGE = "Вы вошли в по адресу: $last_action_date
Количество раз, когда вы вышли в:$totTIME_HMS

Нажмите ВЫХОД для входа из"; + } + + echo"\n"; + echo"VICIНАБОР НОМЕРА:Timeclock\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Timeclock
 
$LOGtimeMESSAGE
 
 

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + + exit; + } + + + + } + +else + { + echo"\n"; + echo"VICIНАБОР НОМЕРА:Timeclock\n"; + echo"\n"; + echo"\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Timeclock
 
Логин Пользователя:
Пароль Пользователя:
 

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_ru/vdc_db_query.php b/LANG_www/agc_ru/vdc_db_query.php new file mode 100644 index 00000000..adb94bc7 --- /dev/null +++ b/LANG_www/agc_ru/vdc_db_query.php @@ -0,0 +1,3978 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to send whether the meetme conference has live channels connected and which they are +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $ACTION - ('regCLOSER','manDiaLnextCALL','manDiaLskip','manDiaLonly','manDiaLlookCALL','manDiaLlogCALL','userLOGout','updateDISPO','VDADpause','VDADready','VDADcheckINCOMING','UpdatEFavoritEs','CalLBacKLisT','CalLBacKCounT','PauseCodeSubmit','LogiNCamPaigns','alt_phone_change','AlertControl') +# - $stage - ('start','finish','lookup','new') +# - $closer_choice - ('CL_TESTCAMP_L CL_OUT123_L -') +# - $conf_exten - ('8600011',...) +# - $exten - ('123test',...) +# - $ext_context - ('default','demo',...) +# - $ext_priority - ('1','2',...) +# - $campaign - ('testcamp',...) +# - $dial_timeout - ('60','26',...) +# - $dial_prefix - ('9','8',...) +# - $campaign_cid - ('3125551212','0000000000',...) +# - $MDnextCID - ('M06301413000000002',...) +# - $uniqueid - ('1120232758.2406800',...) +# - $lead_id - ('36524',...) +# - $list_id - ('101','123456',...) +# - $length_in_sec - ('12',...) +# - $phone_code - ('1',...) +# - $phone_number - ('3125551212',...) +# - $channel - ('Zap/12-1',...) +# - $start_epoch - ('1120236911',...) +# - $vendor_lead_code - ('1234test',...) +# - $title - ('Mr.',...) +# - $first_name - ('Bob',...) +# - $middle_initial - ('L',...) +# - $last_name - ('Wilson',...) +# - $address1 - ('1324 Main St.',...) +# - $address2 - ('Apt. 12',...) +# - $address3 - ('co Robert Wilson',...) +# - $city - ('Chicago',...) +# - $state - ('IL',...) +# - $province - ('NA',...) +# - $postal_code - ('60054',...) +# - $country_code - ('USA',...) +# - $gender - ('M',...) +# - $date_of_birth - ('1970-01-01',...) +# - $alt_phone - ('3125551213',...) +# - $email - ('bob@bob.com',...) +# - $security_phrase - ('Hello',...) +# - $comments - ('Good Customer',...) +# - $auto_dial_level - ('0','1','1.2',...) +# - $VDstop_rec_after_each_call - ('0','1') +# - $conf_silent_prefix - ('7','8','5',...) +# - $extension - ('123','user123','25-1',...) +# - $protocol - ('Zap','SIP','IAX2',...) +# - $user_abb - ('1234','6666',...) +# - $preview - ('YES','NO',...) +# - $called_count - ('0','1','2',...) +# - $agent_log_id - ('123456',...) +# - $agent_log - ('NO',...) +# - $favorites_list - (",'cc160','cc100'",...) +# - $CallBackDatETimE - ('2006-04-21 14:30:00',...) +# - $recipient - ('ANYONE,'USERONLY') +# - $callback_id - ('12345','12346',...) +# - $use_internal_dnc - ('Y','N') +# - $use_campaign_dnc - ('Y','N') +# - $omit_phone_code - ('Y','N') +# - $no_delete_sessions - ('0','1') +# - $LogouTKicKAlL - ('0','1'); +# - $closer_blended = ('0','1'); +# - $inOUT = ('IN','OUT'); +# - $manual_dial_filter = ('NONE','CAMPLISTS','DNC','CAMPLISTS_DNC') +# - $agentchannel = ('Zap/1-1','SIP/testing-6ry4i3',...) +# - $conf_dialed = ('0','1') +# - $leaving_threeway = ('0','1') +# - $blind_transfer = ('0','1') +# - $usegroupalias - ('0','1') +# - $account - ('DEFAULT',...) +# - $agent_dialed_number - ('1','') +# - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') +# +# CHANGELOG: +# 50629-1044 - First build of script +# 50630-1422 - Added manual dial action and MD channel lookup +# 50701-1451 - Added dial log for start and end of vicidial calls +# 50705-1239 - Added call disposition update +# 50804-1627 - Fixed updateDispo to update vicidial_log entry +# 50816-1605 - Added VDADpause/ready for auto dialing +# 50816-1811 - Added basic autodial call pickup functions +# 50817-1005 - Altered logging functions to accomodate auto_dialing +# 50818-1305 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1411 - Added hangup of agent phone after Logout +# 50901-1315 - Fixed CLOSER IN-GROUP Web Form bug +# 50902-1507 - Fixed CLOSER log length_in_sec bug +# 50902-1730 - Added functions for manual preview dialing and revert +# 50913-1214 - Added agent random update to leadupdate +# 51020-1421 - Added agent_log_id framework for detailed agent activity logging +# 51021-1717 - Allows for multi-line comments (changes \n to !N in database) +# 51111-1046 - Added vicidial_agent_log lead_id earlier for manual dial +# 51121-1445 - Altered echo statements for several small PHP speed optimizations +# 51122-1328 - Fixed UserLogout issue not removing conference reservation +# 51129-1012 - Added ability to accept calls from other VICIDIAL servers +# 51129-1729 - Changed manual dial to use the '/n' flag for calls +# 51221-1154 - Added SCRIPT id lookup and sending to vicidial.php for display +# 60105-1059 - Added Updating of astguiclient favorites in the DB +# 60208-1617 - Added dtmf buttons output per call +# 60213-1521 - Added closer_campaigns update to vicidial_users +# 60215-1036 - Added Callback date-time entry into vicidial_callbacks table +# 60413-1541 - Added USERONLY Callback listings output - CalLBacKLisT +# - Added USERONLY Callback count output - CalLBacKCounT +# 60414-1140 - Added Callback lead lookup for manual dialing +# 60419-1517 - After CALLBK is sent to agent, update callback record to INACTIVE +# 60421-1419 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60427-1236 - Fixed closer_choice error for CLOSER campaigns +# 60609-1148 - Added ability to check for manual dial numbers in DNC +# 60619-1117 - Added variable filters to close security holes for login form +# 60623-1414 - Fixed variable filter for phone_code and fixed manual dial logic +# 60821-1600 - Added ability to omit the phone code on vicidial lead dialing +# 60821-1647 - Added ability to not delete sessions at logout +# 60906-1124 - Added lookup and sending of callback data for CALLBK calls +# 61128-2229 - Added vicidial_live_agents and vicidial_auto_calls manual dial entries +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70115-1733 - Added alt_dial functionality in auto-dial modes +# 70118-1501 - Added user_group to vicidial_log,_agent_log,_closer_log,_callbacks +# 70123-1357 - Fixed bug that would not update vicidial_closer_log status to dispo +# 70202-1438 - Added pause code submit function +# 70203-0930 - Added dialed_number to lead info output +# 70203-1030 - Added dialed_label to lead info output +# 70206-1126 - Added INBOUND status for inbound/closer calls in vicidial_live_agents +# 70212-1253 - Fixed small issue with CXFER +# 70213-1431 - Added QueueMetrics PAUSE/UNPAUSE/AGENTLOGIN/AGENTLOGOFF actions +# 70214-1231 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1210 - Added queuemetrics COMPLETEAGENT action +# 70216-1051 - Fixed double call complete queuemetrics logging +# 70222-1616 - Changed queue_log PAUSE/UNPAUSE to PAUSEALL/UNPAUSEALL +# 70309-1034 - Allow amphersands and questions marks in comments to pass through +# 70313-1052 - Allow pound signs(hash) in comments to pass through +# 70319-1544 - Added agent disable update customer data function +# 70322-1545 - Added sipsak display ability +# 70413-1253 - Fixed bug for outbound call time in CLOSER-type blended campaigns +# 70424-1100 - Fixed bug for fronter/closer calls that would delete vdac records +# 70802-1729 - Fixed bugs with pause_sec and wait_sec under certain call handling +# 70828-1443 - Added source_id to output of SCRIPTtab-IFRAME and WEBFORM +# 71029-1855 - removed campaign_id naming restrictions for CLOSER-type campaigns +# 71030-2047 - added hopper priority for auto alt dial entries +# 71116-1011 - added calls_today count updating of the vicidial_live_agents upon INCALL +# 71120-1520 - added LogiNCamPaigns to show only allowed campaigns for agents upon login +# 71125-1751 - Added inbound-group default inbound group sending to vicidial.php +# 71129-2025 - restricted callbacks count and list to campaign only +# 71223-0318 - changed logging of closer calls +# 71226-1117 - added option to kick all calls from conference upon logout +# 80116-1032 - added user_closer_log logging in regCLOSER +# 80125-1213 - fixed vicidial_log bug when call is from closer +# 80317-2051 - Added in-group recording settings +# 80402-0121 - Fixes for manual dial transfers on some systems, removed /n persist flag +# 80424-0442 - Added non_latin lookup from system_settings +# 80430-1006 - Added term_reason for vicidial_log and vicidial_closer_log +# 80430-1957 - Changed to leave lead_id in vicidial_live_agents record until after dispo +# 80630-2153 - Added queue_log logging for Manual dial calls +# 80703-0139 - Added alter customer phone permissions +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80713-0624 - Added vicidial_list.last_local_call_time field +# 80717-1604 - Modified logging function to use inOUT to determine call direction and place to log +# 80719-1147 - Changed recording conf prefix +# 80815-1019 - Added manual dial list restriction option +# 80831-0545 - Added extended alt dial number info display support +# 80909-1710 - Added support for campaign-specific DNC lists +# 81010-1048 - Added support for hangup of all channels except for agent channel after attempting a 3way call +# 81011-1404 - Fixed bugs in leave3way when transferring a manual dial call +# 81020-1459 - Fixed bugs in queue_log logging +# 81104-0134 - Added mysql error logging capability +# 81104-1617 - Added multi-retry for some vicidial_live_agents table MySQL queries +# 81106-0410 - Added force_timeclock_login option to LoginCampaigns function +# 81107-0424 - Added carryover of script and presets for in-group calls from campaign settings +# 81110-0058 - Changed Pause time to start new vicidial_agent_log on every pause +# 81110-1512 - Added hangup_all_non_reserved to fix non-Hangup bug +# 81111-1630 - Added another hangup fix for non-hangup +# 81114-0126 - More vicidial_agent_log bug fixes +# 81119-1809 - webform backslash fix +# 81124-2212 - Fixes blind transfer bug +# 81126-1522 - Fixed callback comments bug +# 81211-0420 - Fixed Manual dial agent_log bug +# 90120-1718 - Added external pause and dial option +# 90126-1759 - Fixed QM section that wasn't qualified and added agent alert option +# 90128-0231 - Added vendor_lead_code to manual dial lead lookup +# 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups +# 90305-1041 - Added agent_dialed_number and type for user_call_log feature +# 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time +# + +$version = '2.0.5-104'; +$build = '90320-0306'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=194; +$one_mysql_log=0; + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["ACTION"])) {$ACTION=$_GET["ACTION"];} + elseif (isset($_POST["ACTION"])) {$ACTION=$_POST["ACTION"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["closer_choice"])) {$closer_choice=$_GET["closer_choice"];} + elseif (isset($_POST["closer_choice"])) {$closer_choice=$_POST["closer_choice"];} +if (isset($_GET["conf_exten"])) {$conf_exten=$_GET["conf_exten"];} + elseif (isset($_POST["conf_exten"])) {$conf_exten=$_POST["conf_exten"];} +if (isset($_GET["exten"])) {$exten=$_GET["exten"];} + elseif (isset($_POST["exten"])) {$exten=$_POST["exten"];} +if (isset($_GET["ext_context"])) {$ext_context=$_GET["ext_context"];} + elseif (isset($_POST["ext_context"])) {$ext_context=$_POST["ext_context"];} +if (isset($_GET["ext_priority"])) {$ext_priority=$_GET["ext_priority"];} + elseif (isset($_POST["ext_priority"])) {$ext_priority=$_POST["ext_priority"];} +if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];} + elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];} +if (isset($_GET["dial_timeout"])) {$dial_timeout=$_GET["dial_timeout"];} + elseif (isset($_POST["dial_timeout"])) {$dial_timeout=$_POST["dial_timeout"];} +if (isset($_GET["dial_prefix"])) {$dial_prefix=$_GET["dial_prefix"];} + elseif (isset($_POST["dial_prefix"])) {$dial_prefix=$_POST["dial_prefix"];} +if (isset($_GET["campaign_cid"])) {$campaign_cid=$_GET["campaign_cid"];} + elseif (isset($_POST["campaign_cid"])) {$campaign_cid=$_POST["campaign_cid"];} +if (isset($_GET["MDnextCID"])) {$MDnextCID=$_GET["MDnextCID"];} + elseif (isset($_POST["MDnextCID"])) {$MDnextCID=$_POST["MDnextCID"];} +if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];} + elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];} +if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} + elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];} +if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];} + elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];} +if (isset($_GET["length_in_sec"])) {$length_in_sec=$_GET["length_in_sec"];} + elseif (isset($_POST["length_in_sec"])) {$length_in_sec=$_POST["length_in_sec"];} +if (isset($_GET["phone_code"])) {$phone_code=$_GET["phone_code"];} + elseif (isset($_POST["phone_code"])) {$phone_code=$_POST["phone_code"];} +if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];} + elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];} +if (isset($_GET["channel"])) {$channel=$_GET["channel"];} + elseif (isset($_POST["channel"])) {$channel=$_POST["channel"];} +if (isset($_GET["start_epoch"])) {$start_epoch=$_GET["start_epoch"];} + elseif (isset($_POST["start_epoch"])) {$start_epoch=$_POST["start_epoch"];} +if (isset($_GET["dispo_choice"])) {$dispo_choice=$_GET["dispo_choice"];} + elseif (isset($_POST["dispo_choice"])) {$dispo_choice=$_POST["dispo_choice"];} +if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];} + elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];} +if (isset($_GET["title"])) {$title=$_GET["title"];} + elseif (isset($_POST["title"])) {$title=$_POST["title"];} +if (isset($_GET["first_name"])) {$first_name=$_GET["first_name"];} + elseif (isset($_POST["first_name"])) {$first_name=$_POST["first_name"];} +if (isset($_GET["middle_initial"])) {$middle_initial=$_GET["middle_initial"];} + elseif (isset($_POST["middle_initial"])) {$middle_initial=$_POST["middle_initial"];} +if (isset($_GET["last_name"])) {$last_name=$_GET["last_name"];} + elseif (isset($_POST["last_name"])) {$last_name=$_POST["last_name"];} +if (isset($_GET["address1"])) {$address1=$_GET["address1"];} + elseif (isset($_POST["address1"])) {$address1=$_POST["address1"];} +if (isset($_GET["address2"])) {$address2=$_GET["address2"];} + elseif (isset($_POST["address2"])) {$address2=$_POST["address2"];} +if (isset($_GET["address3"])) {$address3=$_GET["address3"];} + elseif (isset($_POST["address3"])) {$address3=$_POST["address3"];} +if (isset($_GET["city"])) {$city=$_GET["city"];} + elseif (isset($_POST["city"])) {$city=$_POST["city"];} +if (isset($_GET["state"])) {$state=$_GET["state"];} + elseif (isset($_POST["state"])) {$state=$_POST["state"];} +if (isset($_GET["province"])) {$province=$_GET["province"];} + elseif (isset($_POST["province"])) {$province=$_POST["province"];} +if (isset($_GET["postal_code"])) {$postal_code=$_GET["postal_code"];} + elseif (isset($_POST["postal_code"])) {$postal_code=$_POST["postal_code"];} +if (isset($_GET["country_code"])) {$country_code=$_GET["country_code"];} + elseif (isset($_POST["country_code"])) {$country_code=$_POST["country_code"];} +if (isset($_GET["gender"])) {$gender=$_GET["gender"];} + elseif (isset($_POST["gender"])) {$gender=$_POST["gender"];} +if (isset($_GET["date_of_birth"])) {$date_of_birth=$_GET["date_of_birth"];} + elseif (isset($_POST["date_of_birth"])) {$date_of_birth=$_POST["date_of_birth"];} +if (isset($_GET["alt_phone"])) {$alt_phone=$_GET["alt_phone"];} + elseif (isset($_POST["alt_phone"])) {$alt_phone=$_POST["alt_phone"];} +if (isset($_GET["email"])) {$email=$_GET["email"];} + elseif (isset($_POST["email"])) {$email=$_POST["email"];} +if (isset($_GET["security_phrase"])) {$security_phrase=$_GET["security_phrase"];} + elseif (isset($_POST["security_phrase"])) {$security_phrase=$_POST["security_phrase"];} +if (isset($_GET["comments"])) {$comments=$_GET["comments"];} + elseif (isset($_POST["comments"])) {$comments=$_POST["comments"];} +if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];} + elseif (isset($_POST["auto_dial_level"])) {$auto_dial_level=$_POST["auto_dial_level"];} +if (isset($_GET["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_GET["VDstop_rec_after_each_call"];} + elseif (isset($_POST["VDstop_rec_after_each_call"])) {$VDstop_rec_after_each_call=$_POST["VDstop_rec_after_each_call"];} +if (isset($_GET["conf_silent_prefix"])) {$conf_silent_prefix=$_GET["conf_silent_prefix"];} + elseif (isset($_POST["conf_silent_prefix"])) {$conf_silent_prefix=$_POST["conf_silent_prefix"];} +if (isset($_GET["extension"])) {$extension=$_GET["extension"];} + elseif (isset($_POST["extension"])) {$extension=$_POST["extension"];} +if (isset($_GET["protocol"])) {$protocol=$_GET["protocol"];} + elseif (isset($_POST["protocol"])) {$protocol=$_POST["protocol"];} +if (isset($_GET["user_abb"])) {$user_abb=$_GET["user_abb"];} + elseif (isset($_POST["user_abb"])) {$user_abb=$_POST["user_abb"];} +if (isset($_GET["preview"])) {$preview=$_GET["preview"];} + elseif (isset($_POST["preview"])) {$preview=$_POST["preview"];} +if (isset($_GET["called_count"])) {$called_count=$_GET["called_count"];} + elseif (isset($_POST["called_count"])) {$called_count=$_POST["called_count"];} +if (isset($_GET["agent_log_id"])) {$agent_log_id=$_GET["agent_log_id"];} + elseif (isset($_POST["agent_log_id"])) {$agent_log_id=$_POST["agent_log_id"];} +if (isset($_GET["agent_log"])) {$agent_log=$_GET["agent_log"];} + elseif (isset($_POST["agent_log"])) {$agent_log=$_POST["agent_log"];} +if (isset($_GET["favorites_list"])) {$favorites_list=$_GET["favorites_list"];} + elseif (isset($_POST["favorites_list"])) {$favorites_list=$_POST["favorites_list"];} +if (isset($_GET["CallBackDatETimE"])) {$CallBackDatETimE=$_GET["CallBackDatETimE"];} + elseif (isset($_POST["CallBackDatETimE"])) {$CallBackDatETimE=$_POST["CallBackDatETimE"];} +if (isset($_GET["recipient"])) {$recipient=$_GET["recipient"];} + elseif (isset($_POST["recipient"])) {$recipient=$_POST["recipient"];} +if (isset($_GET["callback_id"])) {$callback_id=$_GET["callback_id"];} + elseif (isset($_POST["callback_id"])) {$callback_id=$_POST["callback_id"];} +if (isset($_GET["use_internal_dnc"])) {$use_internal_dnc=$_GET["use_internal_dnc"];} + elseif (isset($_POST["use_internal_dnc"])) {$use_internal_dnc=$_POST["use_internal_dnc"];} +if (isset($_GET["use_campaign_dnc"])) {$use_campaign_dnc=$_GET["use_campaign_dnc"];} + elseif (isset($_POST["use_campaign_dnc"])) {$use_campaign_dnc=$_POST["use_campaign_dnc"];} +if (isset($_GET["omit_phone_code"])) {$omit_phone_code=$_GET["omit_phone_code"];} + elseif (isset($_POST["omit_phone_code"])) {$omit_phone_code=$_POST["omit_phone_code"];} +if (isset($_GET["phone_ip"])) {$phone_ip=$_GET["phone_ip"];} + elseif (isset($_POST["phone_ip"])) {$phone_ip=$_POST["phone_ip"];} +if (isset($_GET["enable_sipsak_messages"])) {$enable_sipsak_messages=$_GET["enable_sipsak_messages"];} + elseif (isset($_POST["enable_sipsak_messages"])) {$enable_sipsak_messages=$_POST["enable_sipsak_messages"];} +if (isset($_GET["status"])) {$status=$_GET["status"];} + elseif (isset($_POST["status"])) {$status=$_POST["status"];} +if (isset($_GET["LogouTKicKAlL"])) {$LogouTKicKAlL=$_GET["LogouTKicKAlL"];} + elseif (isset($_POST["LogouTKicKAlL"])) {$LogouTKicKAlL=$_POST["LogouTKicKAlL"];} +if (isset($_GET["closer_blended"])) {$closer_blended=$_GET["closer_blended"];} + elseif (isset($_POST["closer_blended"])) {$closer_blended=$_POST["closer_blended"];} +if (isset($_GET["inOUT"])) {$inOUT=$_GET["inOUT"];} + elseif (isset($_POST["inOUT"])) {$inOUT=$_POST["inOUT"];} +if (isset($_GET["manual_dial_filter"])) {$manual_dial_filter=$_GET["manual_dial_filter"];} + elseif (isset($_POST["manual_dial_filter"])) {$manual_dial_filter=$_POST["manual_dial_filter"];} +if (isset($_GET["alt_dial"])) {$alt_dial=$_GET["alt_dial"];} + elseif (isset($_POST["alt_dial"])) {$alt_dial=$_POST["alt_dial"];} +if (isset($_GET["agentchannel"])) {$agentchannel=$_GET["agentchannel"];} + elseif (isset($_POST["agentchannel"])) {$agentchannel=$_POST["agentchannel"];} +if (isset($_GET["conf_dialed"])) {$conf_dialed=$_GET["conf_dialed"];} + elseif (isset($_POST["conf_dialed"])) {$conf_dialed=$_POST["conf_dialed"];} +if (isset($_GET["leaving_threeway"])) {$leaving_threeway=$_GET["leaving_threeway"];} + elseif (isset($_POST["leaving_threeway"])) {$leaving_threeway=$_POST["leaving_threeway"];} +if (isset($_GET["hangup_all_non_reserved"])) {$hangup_all_non_reserved=$_GET["hangup_all_non_reserved"];} + elseif (isset($_POST["hangup_all_non_reserved"])) {$hangup_all_non_reserved=$_POST["hangup_all_non_reserved"];} +if (isset($_GET["blind_transfer"])) {$blind_transfer=$_GET["blind_transfer"];} + elseif (isset($_POST["blind_transfer"])) {$blind_transfer=$_POST["blind_transfer"];} +if (isset($_GET["usegroupalias"])) {$usegroupalias=$_GET["usegroupalias"];} + elseif (isset($_POST["usegroupalias"])) {$usegroupalias=$_POST["usegroupalias"];} +if (isset($_GET["account"])) {$account=$_GET["account"];} + elseif (isset($_POST["account"])) {$account=$_POST["account"];} +if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_dialed_number"];} + elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} +if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} + elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 + +$txt = '.txt'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$CIDdate = date("mdHis"); +$ENTRYdate = date("YmdHis"); +$MT[0]=''; +$agents='@agents'; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,timeclock_end_of_day FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $timeclock_end_of_day = $row[1]; + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ($non_latin < 1) +{ +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); +$length_in_sec = ereg_replace("[^0-9]","",$length_in_sec); +$phone_code = ereg_replace("[^0-9]","",$phone_code); +$phone_number = ereg_replace("[^0-9]","",$phone_number); +} + +# default optional vars if not set +if (!isset($format)) {$format="text";} + if ($format == 'debug') {$DB=1;} +if (!isset($ACTION)) {$ACTION="refresh";} +if (!isset($query_date)) {$query_date = $NOW_DATE;} + +if ($ACTION == 'LogiNCamPaigns') + { + $skip_user_validation=1; + } +else + { + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00002',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00003',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } +} + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "VICIDiaL Скрипт Запроса Базы Данных"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + + +################################################################################ +### LogiNCamPaigns - generates an HTML SELECT list of allowed campaigns for a +### specific agent on the login screen +################################################################################ +if ($ACTION == 'LogiNCamPaigns') + { + if ( (strlen($user)<1) ) + { + echo "\n"; + exit; + } + else + { + $stmt="SELECT user_group,user_level,agent_shift_enforcement_override,shift_override_flag from vicidial_users where user='$user' and pass='$pass'"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00004',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + $VU_user_level = $row[1]; + $VU_agent_shift_enforcement_override = $row[2]; + $VU_shift_override_flag = $row[3]; + + $LOGallowed_campaignsSQL=''; + + $stmt="SELECT allowed_campaigns,forced_timeclock_login,shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00005',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $forced_timeclock_login = $row[1]; + $shift_enforcement = $row[2]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[3]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + if ( (!eregi("ALL-CAMPAIGNS",$row[0])) ) + { + $LOGallowed_campaignsSQL = eregi_replace(' -','',$row[0]); + $LOGallowed_campaignsSQL = eregi_replace(' ',"','",$LOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$LOGallowed_campaignsSQL')"; + } + + $show_campaign_list=1; + ### CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + if ( (ereg('Y',$forced_timeclock_login)) or ( (ereg('ADMIN_EXEMPT',$forced_timeclock_login)) and ($VU_user_level < 8) ) ) + { + $last_agent_event=''; + $HHMM = date("Hi"); + $HHteod = substr($timeclock_end_of_day,0,2); + $MMteod = substr($timeclock_end_of_day,2,2); + + if ($HHMM < $timeclock_end_of_day) + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d")-1, date("Y"));} + else + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d"), date("Y"));} + + $EoDdate = date("Y-m-d H:i:s", $EoD); + + ##### grab timeclock logged-in time for each user ##### + $stmt="SELECT event from vicidial_timeclock_log where user='$user' and event_epoch >= '$EoD' order by timeclock_id desc limit 1;"; + if ($DB>0) {echo "|$stmt|";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00184',$user,$server_ip,$session_name,$one_mysql_log);} + $events_to_parse = mysql_num_rows($rslt); + if ($events_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $last_agent_event = $rowx[0]; + } + if ( (strlen($last_agent_event)<2) or (ereg('ВЫХОД',$last_agent_event)) ) + {$show_campaign_list=0;} + } + } + + ### CHECK TO SEE IF AGENT IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR + if ( ( (ereg("СТАРТ|ALL",$shift_enforcement)) and (!ereg("OFF",$VU_agent_shift_enforcement_override)) ) or (ereg("СТАРТ|ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if ( (strlen($LOGgroup_shiftsSQL) < 3) and ($VU_shift_override_flag < 1) ) + { + $VDdisplayMESSAGE = "ОШИБКА: Есть сдвиги не включена для пользователя группы\n"; + $VDloginDISPLAY=1; + } + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00193',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDdisplayMESSAGE = "ОШИБКА: Вы не можете войти в вашу за переход\n"; + $VDloginDISPLAY=1; + } + } + if ($VDloginDISPLAY > 0) + { + $loginDATE = date("Ymd"); + $VDdisplayMESSAGE.= "

МЕНЕДЖЕР Переопределить:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "Manager Логин:
\n"; + $VDdisplayMESSAGE.= "Manager Пароль:
\n"; + $VDdisplayMESSAGE.= "




\n"; + echo "$VDdisplayMESSAGE"; + exit; + } + } + + if ($show_campaign_list > 0) + { + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00006',$user,$server_ip,$session_name,$one_mysql_log);} + $camps_to_print = mysql_num_rows($rslt); + + echo "\n"; + } + else + { + echo "\n"; + } + exit; + } + + + +################################################################################ +### regCLOSER - update the vicidial_live_agents table to reflect the closer +### inbound choices made upon login +################################################################################ +if ($ACTION == 'regCLOSER') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($closer_choice)<1) || (strlen($user)<1) ) + { + $channel_live=0; + echo "Выбор Группы $closer_choice это неправильно\n"; + exit; + } + else + { + if ($closer_choice == "MGRLOCK-") + { + $stmt="SELECT closer_campaigns FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00007',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $closer_choice =$row[0]; + + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00008',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="UPDATE vicidial_live_agents set closer_campaigns='$closer_choice' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00009',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_users set closer_campaigns='$closer_choice' where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00010',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="INSERT INTO vicidial_user_closer_log set user='$user',campaign_id='$campaign',event_date='$NOW_TIME',blended='$closer_blended',closer_campaigns='$closer_choice';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00011',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="DELETE FROM vicidial_live_inbound_agents where user='$user';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00012',$user,$server_ip,$session_name,$one_mysql_log);} + + $in_groups_pre = preg_replace('/-$/','',$closer_choice); + $in_groups = explode(" ",$in_groups_pre); + $in_groups_ct = count($in_groups); + $k=1; + while ($k < $in_groups_ct) + { + if (strlen($in_groups[$k])>1) + { + $stmt="SELECT group_weight,calls_today FROM vicidial_inbound_group_agents where user='$user' and group_id='$in_groups[$k]';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00013',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $viga_ct = mysql_num_rows($rslt); + if ($viga_ct > 0) + { + $row=mysql_fetch_row($rslt); + $group_weight = $row[0]; + $calls_today = $row[1]; + } + else + { + $group_weight = 0; + $calls_today = 0; + } + $stmt="INSERT INTO vicidial_live_inbound_agents set user='$user',group_id='$in_groups[$k]',group_weight='$group_weight',calls_today='$calls_today',last_call_time='$NOW_TIME',last_call_finish='$NOW_TIME';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} + } + $k++; + } + + } + echo "Closer In Выбор Группы $closer_choice был зарегистрован пользователем $user\n"; +} + + +################################################################################ +### manDiaLnextCALL - for manual VICIDiaL dialing this will grab the next lead +### in the campaign, reserve it, send data back to client and +### place the call by inserting into vicidial_manager +################################################################################ +if ($ACTION == 'manDiaLnextCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) ) + { + $channel_live=0; + echo "ПУСТОЙ КОНТЕЙНЕР\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context это неправильно\n"; + exit; + } + else + { + + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00015',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### check if this is a callback, if it is, skip the grabbing of a new lead and mark the callback as INACTIVE + if ( (strlen($callback_id)>0) and (strlen($lead_id)>0) ) + { + $affected_rows=1; + $CBleadIDset=1; + + $stmt = "UPDATE vicidial_callbacks set status='INACTIVE' where callback_id='$callback_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00016',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + if (strlen($phone_number)>3) + { + if (ereg("DNC",$manual_dial_filter)) + { + $stmt="SELECT count(*) FROM vicidial_dnc where phone_number='$phone_number';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00017',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC НОМЕР\n"; + exit; + } + $stmt="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$phone_number' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00018',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + echo "DNC НОМЕР\n"; + exit; + } + } + if (ereg("CAMPLISTS",$manual_dial_filter)) + { + $stmt="SELECT list_id,active from vicidial_lists where campaign_id='$campaign'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00019',$user,$server_ip,$session_name,$one_mysql_log);} + $lists_to_parse = mysql_num_rows($rslt); + $camp_lists=''; + $o=0; + while ($lists_to_parse > $o) + { + $rowx=mysql_fetch_row($rslt); + if (ereg("Y", $rowx[1])) {$active_lists++; $camp_lists .= "'$rowx[0]',";} + if (ereg("N", $rowx[1])) {$inactive_lists++;} + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + + $stmt="SELECT count(*) FROM vicidial_list where phone_number='$phone_number' and list_id IN($camp_lists);"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00020',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + + if ($row[0] < 1) + { + echo "НОМЕР NOT IN CAMPLISTS\n"; + exit; + } + } + if ($stage=='lookup') + { + if (strlen($vendor_lead_code)>0) + { + $stmt="SELECT lead_id FROM vicidial_list where vendor_lead_code='$vendor_lead_code' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + if ( ($man_leadID_ct > 0) and (strlen($phone_number) > 5) ) + {$override_phone++;} + } + else + { + $stmt="SELECT lead_id FROM vicidial_list where phone_number='$phone_number' order by modify_date desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00021',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $man_leadID_ct = mysql_num_rows($rslt); + } + if ($man_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $affected_rows=1; + $lead_id =$row[0]; + $CBleadIDset=1; + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME',vendor_lead_code='$vendor_lead_code';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00022',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id($link); + $CBleadIDset=1; + } + } + else + { + ### insert a new lead in the system with this phone number + $stmt = "INSERT INTO vicidial_list SET phone_code='$phone_code',phone_number='$phone_number',list_id='$list_id',status='QUEUE',user='$user',called_since_last_reset='Y',entry_date='$ENTRYdate',last_local_call_time='$NOW_TIME';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00023',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $lead_id = mysql_insert_id($link); + $CBleadIDset=1; + } + } + else + { + ### grab the next lead in the hopper for this campaign and reserve it for the user + $stmt = "UPDATE vicidial_hopper set status='QUEUE', user='$user' where campaign_id='$campaign' and status='READY' order by priority desc,hopper_id LIMIT 1"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00024',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + } + + if ($affected_rows > 0) + { + if (!$CBleadIDset) + { + ##### grab the lead_id of the reserved user in vicidial_hopper + $stmt="SELECT lead_id FROM vicidial_hopper where campaign_id='$campaign' and status='QUEUE' and user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00025',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $hopper_leadID_ct = mysql_num_rows($rslt); + if ($hopper_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + } + } + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00026',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $source_id = trim("$row[6]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $called_since_last_reset = trim("$row[9]"); + $phone_code = trim("$row[10]"); + if ($override_phone < 1) + {$phone_number = trim("$row[11]");} + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = stripslashes(trim("$row[29]")); + $called_count = trim("$row[30]"); + } + + $called_count++; + + ##### check if system is set to generate logfile for transfers + $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00027',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_xfer_log_ct = mysql_num_rows($rslt); + if ($enable_agc_xfer_log_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_agc_xfer_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_xfer_log > 0) ) + { + # generate callerID for unique identifier in xfer_log file + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + + # DATETIME|campaign|lead_id|phone_number|user|type + # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|M + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|M|$MqueryCID|\n"); + fclose($fp); + } + + ##### if lead is a callback, grab the callback comments + $CBentry_time = ''; + $CBcallback_time = ''; + $CBuser = ''; + $CBcomments = ''; + if (ereg("CALLBK",$dispo)) + { + $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00028',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBentry_time = trim("$row[0]"); + $CBcallback_time = trim("$row[1]"); + $CBuser = trim("$row[2]"); + $CBcomments = trim("$row[3]"); + } + } + + $stmt = "SELECT local_gmt FROM servers where active='Y' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00029',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $server_ct = mysql_num_rows($rslt); + if ($server_ct > 0) + { + $row=mysql_fetch_row($rslt); + $local_gmt = $row[0]; + } + $LLCT_DATE_offset = ($local_gmt - $gmt_offset_now); + $LLCT_DATE = date("Y-m-d H:i:s", mktime(date("H")-$LLCT_DATE_offset,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if (ereg('Y',$called_since_last_reset)) + { + $called_since_last_reset = ereg_replace('Y','',$called_since_last_reset); + if (strlen($called_since_last_reset) < 1) {$called_since_last_reset = 0;} + $called_since_last_reset++; + $called_since_last_reset = "Y$called_since_last_reset"; + } + else {$called_since_last_reset = 'Y';} + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', called_since_last_reset='$called_since_last_reset', called_count='$called_count',user='$user',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00030',$user,$server_ip,$session_name,$one_mysql_log);} + + if (!$CBleadIDset) + { + ### delete the lead from the hopper + $stmt = "DELETE FROM vicidial_hopper where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00031',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="UPDATE vicidial_agent_log set lead_id='$lead_id',comments='MANUAL' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00032',$user,$server_ip,$session_name,$one_mysql_log);} + + ### if preview dialing, do not send the call + if ( (strlen($preview)<1) || ($preview == 'NO') ) + { + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + # $Local_persist = '/n'; + $Local_persist = ''; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + ### whether to omit phone_code or not + if (eregi('Y',$omit_phone_code)) + {$Ndialstring = "$Local_out_prefix$phone_number";} + else + {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','$account','$variable','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00033',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00034',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00035',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update calls_today count in vicidial_campaign_agents + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00036',$user,$server_ip,$session_name,$one_mysql_log);} + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00191',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00037',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # UNПАУЗПАALL + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00038',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # ENTERQUEUE + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='ENTERQUEUE',data2='$phone_number',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00039',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # CONNECT + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00040',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $MqueryCID . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + $LeaD_InfO .= $CBentry_time . "\n"; + $LeaD_InfO .= $CBcallback_time . "\n"; + $LeaD_InfO .= $CBuser . "\n"; + $LeaD_InfO .= $CBcomments . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= "MAIN\n"; + $LeaD_InfO .= $source_id . "\n"; + + echo $LeaD_InfO; + + } + else + { + echo "ПУСТОЙ КОНТЕЙНЕР\n"; + } + } +} + + +################################################################################ +### alt_phone_change - change alt phone numbers to active and inactive +### +################################################################################ +if ($ACTION == 'alt_phone_change') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) || (strlen($phone_number)<1) ) + { + $channel_live=0; + echo "АЛЬТ. ТЕЛЕФОН НОМЕР СТАТУС NOT CHANGED\n"; + echo "$phone_number $stage $lead_id or $called_count это неправильно\n"; + exit; + } + else + { + $stmt = "UPDATE vicidial_list_alt_phones set active='$stage' where lead_id='$lead_id' and phone_number='$phone_number' and alt_phone_count='$called_count';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00041',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "АЛЬТ. ТЕЛЕФОН НОМЕР СТАТУС CHANGED\n"; + } +} + + +################################################################################ +### AlertControl - change the agent alert setting in vicidial_users +### +################################################################################ +if ($ACTION == 'AlertControl') +{ + if (strlen($stage)<1) + { + $channel_live=0; + echo "AGENT ALERT SETTING NOT CHANGED\n"; + echo "$stage это неправильно\n"; + exit; + } + else + { + if (ereg('ON',$stage)) {$stage = '1';} + else {$stage = '0';} + + $stmt = "UPDATE vicidial_users set alert_enabled='$stage' where user='$user' and pass='$pass';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'000185',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "AGENT ALERT SETTING CHANGED $stage\n"; + } +} + + +################################################################################ +### manDiaLskip - for manual VICIDiaL dialing this skips the lead that was +### previewed in the step above and puts it back in orig status +################################################################################ +if ($ACTION == 'manDiaLskip') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($stage)<1) || (strlen($called_count)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "LEAD NOT REVERTED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context это неправильно\n"; + exit; + } + else + { + $called_count = ($called_count - 1); + ### flag the lead as called and change it's status to INCALL + $stmt = "UPDATE vicidial_list set status='$stage', called_count='$called_count',user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00042',$user,$server_ip,$session_name,$one_mysql_log);} + + + echo "LEAD REVERTED\n"; + } +} + + +################################################################################ +### manDiaLonly - for manual VICIDiaL dialing this sends the call that was +### previewed in the step above +################################################################################ +if ($ACTION == 'manDiaLonly') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($conf_exten)<1) || (strlen($campaign)<1) || (strlen($ext_context)<1) || (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo " ВЫЗОВ NOT PLACED\n"; + echo "Conf Exten $conf_exten or campaign $campaign or ext_context $ext_context это неправильно\n"; + exit; + } + else + { + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00043',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### prepare variables to place manual call from VICIDiaL + $CCID_on=0; $CCID=''; + $local_DEF = 'Local/'; + $local_AMP = '@'; + $Local_out_prefix = '9'; + $Local_dial_timeout = '60'; + $Local_persist = '/n'; + if ($dial_timeout > 4) {$Local_dial_timeout = $dial_timeout;} + $Local_dial_timeout = ($Local_dial_timeout * 1000); + if (strlen($dial_prefix) > 0) {$Local_out_prefix = "$dial_prefix";} + if (strlen($campaign_cid) > 6) {$CCID = "$campaign_cid"; $CCID_on++;} + if (eregi("x",$dial_prefix)) {$Local_out_prefix = '';} + + $PADlead_id = sprintf("%09s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 0, -1);} + + # Create unique calleridname to track the call: MmmddhhmmssLLLLLLLLL + $MqueryCID = "M$CIDdate$PADlead_id"; + if ($CCID_on) {$CIDstring = "\"$MqueryCID\" <$CCID>";} + else {$CIDstring = "$MqueryCID";} + + if ( ($usegroupalias > 0) and (strlen($account)>1) ) + { + $RAWaccount = $account; + $account = "Account: $account"; + $variable = "Variable: usegroupalias=1"; + } + else + {$account=''; $variable='';} + + ### whether to omit phone_code or not + if (eregi('Y',$omit_phone_code)) + {$Ndialstring = "$Local_out_prefix$phone_number";} + else + {$Ndialstring = "$Local_out_prefix$phone_code$phone_number";} + ### insert the call action into the vicidial_manager table to initiate the call + # $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $conf_exten','Context: $ext_context','Channel: $local_DEF$Local_out_prefix$phone_code$phone_number$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','');"; + $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$MqueryCID','Exten: $Ndialstring','Context: $ext_context','Channel: $local_DEF$conf_exten$local_AMP$ext_context$Local_persist','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','$account','$variable','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00044',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type) values('$server_ip','$campaign','XFER','$lead_id','$MqueryCID','$phone_code','$phone_number','$NOW_TIME','OUT')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00045',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00046',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9046$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00047',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "$MqueryCID\n"; + + if ($agent_dialed_number > 0) + { + $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$user','$NOW_TIME','$agent_dialed_type','$server_ip','$phone_number','$Ndialstring','$lead_id','$CCID','$RAWaccount')"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00192',$user,$server_ip,$session_name,$one_mysql_log);} + } + + + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00048',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # UNПАУЗПАALL + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='UNПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00049',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # ENTERQUEUE + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='NONE',verb='ENTERQUEUE',data2='$phone_number',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00050',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + # CONNECT + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MqueryCID',queue='$campaign',agent='Agent/$user',verb='CONNECT',data1='0',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00051',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + } +} + + +################################################################################ +### manDiaLlookCALL - for manual VICIDiaL dialing this will attempt to look up +### the trunk channel that the call was placed on +################################################################################ +if ($ACTION == 'manDiaLlookCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; +if (strlen($MDnextCID)<18) + { + echo "NO\n"; + echo "MDnextCID $MDnextCID это неправильно\n"; + exit; + } +else + { + ##### look for the channel in the UPDATED vicidial_manager record of the call initiation + $stmt="SELECT uniqueid,channel FROM vicidial_manager where callerid='$MDnextCID' and server_ip='$server_ip' and status IN('UPDATED','DEAD') LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00052',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $uniqueid =$row[0]; + $channel =$row[1]; + echo "$uniqueid\n$channel"; + + $wait_sec=0; + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00053',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',wait_epoch='$StarTtime',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00054',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="UPDATE vicidial_auto_calls set uniqueid='$uniqueid',channel='$channel' where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00055',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + echo "NO\n"; + } + } +} + + + +################################################################################ +### manDiaLlogCALL - for manual VICIDiaL logging of calls places record in +### vicidial_log and then sends process to call_log entry +################################################################################ +if ($ACTION == 'manDiaLlogCaLL') +{ + $MT[0]=''; + $row=''; $rowx=''; + $vidSQL=''; + $VDterm_reason=''; + +if ($stage == "start") + { + if ( (strlen($uniqueid)<1) || (strlen($lead_id)<1) || (strlen($list_id)<1) || (strlen($phone_number)<1) || (strlen($campaign)<1) ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|VL_LOG_0|$uniqueid|$lead_id|$user|$list_id|$campaign|$start_epoch|$phone_number|$agent_log_id|\n"); + fclose($fp); + + echo "LOG НЕ ВВЕДЕН\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id or list_id: $list_id or phone_number: $phone_number or campaign: $campaign это неправильно\n"; + exit; + } + else + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00056',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','INCALL','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Введенный: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOG НЕ ВВЕДЕН\n"; + } + + $stmt = "UPDATE vicidial_auto_calls SET uniqueid='$uniqueid' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00058',$user,$server_ip,$session_name,$one_mysql_log);} + + # ##### insert log into call_log for manual VICIDiaL call + # $stmt = "INSERT INTO call_log (uniqueid,channel,server_ip,extension,number_dialed,caller_code,start_time,start_epoch) values('$uniqueid','$channel','$server_ip','$exten','$phone_code$phone_number','MD $user $lead_id','$NOW_TIME','$StarTtime')"; + # if ($DB) {echo "$stmt\n";} + # $rslt=mysql_query($stmt, $link); + # $affected_rows = mysql_affected_rows($link); + + # if ($affected_rows > 0) + # { + # echo "CALL_LOG Введенный: $uniqueid|$channel|$NOW_TIME"; + # } + # else + # { + # echo "LOG НЕ ВВЕДЕН\n"; + # } + } + } + +if ($stage == "end") + { + ##### get call type from vicidial_live_agents table + $VLA_inOUT='NONE'; + $stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00059',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLA_inOUT_ct = mysql_num_rows($rslt); + if ($VLA_inOUT_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLA_inOUT = $row[0]; + } + + if ( (strlen($uniqueid)<1) and ($VLA_inOUT == 'INBOUND') ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_0|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$start_epoch|$phone_number|$agent_log_id|\n"); + fclose($fp); + $uniqueid='6666.1'; + } + if ( (strlen($uniqueid)<1) or (strlen($lead_id)<1) ) + { + echo "LOG НЕ ВВЕДЕН\n"; + echo "uniqueid $uniqueid or lead_id: $lead_id это неправильно\n"; + exit; + } + else + { + $term_reason='NONE'; + if ($start_epoch < 1000) + { + if ($VLA_inOUT == 'INBOUND') + { + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + ##### look for the start epoch in the vicidial_closer_log table + $stmt="SELECT start_epoch,term_reason,closecallid,campaign_id FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + $VDIDselect = "VDCL_LID $lead_id $phone_number $user $four_hours_ago"; + } + else + { + ##### look for the start epoch in the vicidial_log table + $stmt="SELECT start_epoch,term_reason,uniqueid,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; + } + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00060',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch = $row[0]; + $VDterm_reason = $row[1]; + $VDvicidial_id = $row[2]; + $VDcampaign_id = $row[3]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + + if ( ($length_in_sec < 1) and ($VLA_inOUT == 'INBOUND') ) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_1|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|\n"); + fclose($fp); + + ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log + $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00061',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VM_mancall_ct = mysql_num_rows($rslt); + if ($VM_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $start_epoch = $row[0]; + $VDterm_reason = $row[1]; + $VDcampaign_id = $row[2]; + $length_in_sec = ($StarTtime - $start_epoch); + } + else + { + $length_in_sec = 0; + } + } + } + else {$length_in_sec = ($StarTtime - $start_epoch);} + + if (strlen($VDcampaign_id)<1) {$VDcampaign_id = $campaign;} + + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if ($VLA_inOUT == 'INBOUND') + { + $stmt = "UPDATE vicidial_closer_log set end_epoch='$StarTtime', length_in_sec='$length_in_sec' where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00062',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_2|$uniqueid|$lead_id|$user|$inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$start_epoch|\n"); + fclose($fp); + } + } + + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00063',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + } + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + + if ($auto_dial_level > 0) + { + ### check to see if campaign has alt_dial enabled + $stmt="SELECT auto_alt_dial FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00064',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_alt_dial =$row[0]; + } + else {$auto_alt_dial = 'NONE';} + if (eregi("(ALT_ONLY|ADDR3_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED|EXTENDED_ONLY)",$auto_alt_dial)) + { + ### check to see if lead should be alt_dialed + if (strlen($alt_dial)<2) {$alt_dial = 'NONE';} + + if ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("(ALT_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED)",$auto_alt_dial)) ) + { + $alt_dial_skip=0; + $stmt="SELECT alt_phone,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00065',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_phone = $row[0]; + $alt_phone = eregi_replace("[^0-9]","",$alt_phone); + $gmt_offset_now = $row[1]; + $state = $row[2]; + } + else {$alt_phone = '';} + if (strlen($alt_phone)>5) + { + if (ereg("Y",$use_internal_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$alt_phone';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00066',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if (ereg("Y",$use_campaign_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$alt_phone' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00067',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + ### insert record into vicidial_hopper for alt_phone call attempt + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ALT',user='',priority='25';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00068',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {$alt_dial_skip=1;} + } + else + {$alt_dial_skip=1;} + if ($alt_dial_skip > 0) + {$alt_dial='ALT';} + } + + if ( ( (eregi("(ALT)",$alt_dial)) and (eregi("ALT_AND_ADDR3",$auto_alt_dial)) ) or ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("ADDR3_ONLY",$auto_alt_dial)) ) ) + { + $addr3_dial_skip=0; + $stmt="SELECT address3,gmt_offset_now,state FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00069',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_mancall_ct = mysql_num_rows($rslt); + if ($VAC_mancall_ct > 0) + { + $row=mysql_fetch_row($rslt); + $address3 = $row[0]; + $address3 = eregi_replace("[^0-9]","",$address3); + $gmt_offset_now = $row[1]; + $state = $row[2]; + } + else {$address3 = '';} + if (strlen($address3)>5) + { + if (ereg("Y",$use_internal_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$address3';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00070',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if (ereg("Y",$use_campaign_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$address3' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00071',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + ### insert record into vicidial_hopper for address3 call attempt + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$list_id',gmt_offset_now='$gmt_offset_now',state='$state',alt_dial='ADDR3',user='',priority='20';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00072',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + {$addr3_dial_skip=1;} + } + else + {$addr3_dial_skip=1;} + if ($addr3_dial_skip > 0) + {$alt_dial='ADDR3';} + } + + # $fp = fopen ("./alt_multi_log.txt", "a"); + # fwrite ($fp, "$NOW_TIME|PRE-X|$campaign|$lead_id|$phone_number|$user|$Ctype|$callerid|$uniqueid|$stmt|$auto_alt_dial|$alt_dial\n"); + # fclose($fp); + + if ( ( ( (eregi("(NONE|MAIN)",$alt_dial)) and (eregi("EXTENDED_ONLY",$auto_alt_dial)) ) or ( (eregi("(ALT)",$alt_dial)) and (eregi("(ALT_AND_EXTENDED)",$auto_alt_dial)) ) or ( (eregi("(ADDR3)",$alt_dial)) and (eregi("(ADDR3_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED)",$auto_alt_dial)) ) or ( (eregi("(X)",$alt_dial)) and (eregi("EXTENDED",$auto_alt_dial)) ) ) and (!eregi("LAST",$alt_dial)) ) + { + if (eregi("(ADDR3)",$alt_dial)) {$Xlast=0;} + else + {$Xlast = ereg_replace("[^0-9]","",$alt_dial);} + if (strlen($Xlast)<1) + {$Xlast=0;} + $VD_altdialx=''; + + $stmt="SELECT gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00073',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VL_deailts_ct = mysql_num_rows($rslt); + if ($VL_deailts_ct > 0) + { + $row=mysql_fetch_row($rslt); + $EA_gmt_offset_now = $row[0]; + $EA_state = $row[1]; + $EA_list_id = $row[2]; + } + $alt_dial_phones_count=0; + $stmt="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00074',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_ct = mysql_num_rows($rslt); + if ($VLAP_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_dial_phones_count = $row[0]; + } + while ( ($alt_dial_phones_count > 0) and ($alt_dial_phones_count > $Xlast) ) + { + $Xlast++; + $stmt="SELECT alt_phone_id,phone_number,active FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Xlast';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00075',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_detail_ct = mysql_num_rows($rslt); + if ($VLAP_detail_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_altdial_id = $row[0]; + $VD_altdial_phone = $row[1]; + $VD_altdial_active = $row[2]; + } + else + {$Xlast=9999999999;} + + if (ereg("Y",$VD_altdial_active)) + { + if (ereg("Y",$use_internal_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00076',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_dnc_ct = mysql_num_rows($rslt); + if ($VLAP_dnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = $row[0]; + } + } + else {$VD_alt_dnc_count=0;} + if (ereg("Y",$use_campaign_dnc)) + { + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00077',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLAP_cdnc_ct = mysql_num_rows($rslt); + if ($VLAP_cdnc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VD_alt_dnc_count = ($VD_alt_dnc_count + $row[0]); + } + } + if ($VD_alt_dnc_count < 1) + { + if ($alt_dial_phones_count == $Xlast) + {$Xlast = 'LAST';} + $stmt = "INSERT INTO vicidial_hopper SET lead_id='$lead_id',campaign_id='$campaign',status='HOLD',list_id='$EA_list_id',gmt_offset_now='$EA_gmt_offset_now',state='$EA_state',alt_dial='X$Xlast',user='',priority='15';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00078',$user,$server_ip,$session_name,$one_mysql_log);} + $Xlast=9999999999; + } + } + } + } + } + + if ($enable_queuemetrics_logging > 0) + { + ### grab call lead information needed for QM logging + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id' order by call_time limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00079',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + + $CLstage = preg_replace("/.*-/",'',$CLstage); + if (strlen($CLstage) < 1) {$CLstage=0;} + + $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETECALLER' and queue='$VDcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00080',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $caller_complete = $row[0]; + } + + if ($caller_complete < 1) + { + $term_reason='AGENT'; + } + else + { + $term_reason='CALLER'; + } + + } + + ### delete call record from vicidial_auto_calls + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00081',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00082',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9082$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + if ($enable_queuemetrics_logging > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='ПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00083',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + else + { + if ($enable_queuemetrics_logging > 0) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id' order by call_time desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00084',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + + $CLstage = preg_replace("/XFER|CLOSER|-/",'',$CLstage); + if ($CLstage < 0.25) {$CLstage=0;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00085',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + + # $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$campaign' and uniqueid='$uniqueid';"; + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and callerid LIKE \"M%\";"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00086',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00087',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9087$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + if ($enable_queuemetrics_logging > 0) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='ПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00088',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + + if ( ($VLA_inOUT == 'AUTO') or ($VLA_inOUT == 'MANUAL') ) + { + $SQLterm = "term_reason='$term_reason',"; + + if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT term_reason,uniqueid from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00089',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; + } + if (ereg("CALLER",$VDterm_reason)) + { + $SQLterm = ""; + } + else + { + $SQLterm = "term_reason='AGENT',"; + } + } + + ### check to see if the vicidial_log record exists, if not, insert it + $stmt="SELECT count(*) from vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00186',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_vld_ct = mysql_num_rows($rslt); + if ($VAC_vld_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VLD_count = $row[0]; + if ($VLD_count < 1) + { + ##### insert log into vicidial_log for manual VICIDiaL call + $stmt="INSERT INTO vicidial_log (uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,comments,processed,user_group,alt_dial) values('$uniqueid','$lead_id','$list_id','$campaign','$NOW_TIME','$StarTtime','DONEM','$phone_code','$phone_number','$user','MANUAL','N','$user_group','$alt_dial');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00057',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "VICIDiaL_LOG Введенный: $uniqueid|$channel|$NOW_TIME\n"; + echo "$StarTtime\n"; + } + else + { + echo "LOG НЕ ВВЕДЕН\n"; + } + } + } + + ##### update the duration and end time in the vicidial_log table + $stmt="UPDATE vicidial_log set $SQLterm end_epoch='$StarTtime', length_in_sec='$length_in_sec' where uniqueid='$uniqueid' and lead_id='$lead_id' and user='$user' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00090',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + + if ($affected_rows > 0) + { + echo "$uniqueid\n$channel\n"; + } + else + { + echo "LOG НЕ ВВЕДЕН\n\n"; + } + } + else + { + $SQLterm = "term_reason='$term_reason'"; + $QL_term=''; + + if ( (ereg("NONE",$term_reason)) or (ereg("NONE",$VDterm_reason)) or (strlen($VDterm_reason) < 1) ) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT term_reason,closecallid from vicidial_closer_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00091',$user,$server_ip,$session_name,$one_mysql_log);} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDterm_reason = $row[0]; + $VDvicidial_id = $row[1]; + $VDIDselect = "VDCL_LID4HOUR $lead_id $four_hours_ago"; + } + if (ereg("CALLER",$VDterm_reason)) + { + $SQLterm = ""; + } + else + { + $SQLterm = "term_reason='AGENT'"; + $QL_term = 'COMPLETEAGENT'; + } + } + + if (strlen($SQLterm) > 0) + { + ##### update the duration and end time in the vicidial_log table + $stmt="UPDATE vicidial_closer_log set $SQLterm where lead_id='$lead_id' and call_date > \"$four_hours_ago\" order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00092',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + } + + if ($enable_queuemetrics_logging > 0) + { + if ( (strlen($QL_term) > 0) and ($leaving_threeway > 0) ) + { + $stmt="SELECT count(*) from queue_log where call_id='$MDnextCID' and verb='COMPLETEAGENT' and queue='$VDcampaign_id';"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00093',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VAC_cc_ct = mysql_num_rows($rslt); + if ($VAC_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $agent_complete = $row[0]; + } + if ($agent_complete < 1) + { + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00094',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + } + } + } + } + } + + echo $VDstop_rec_after_each_call . '|' . $extension . '|' . $conf_silent_prefix . '|' . $conf_exten . '|' . $user_abb . "|\n"; + + ##### if VICIDiaL call and hangup_after_each_call activated, find all recording + ##### channels and hang them up while entering info into recording_log and + ##### returning filename/recordingID + if ($VDstop_rec_after_each_call == 1) + { + $local_DEF = 'Local/'; + $local_AMP = '@'; + $total_rec=0; + $total_hangup=0; + $loop_count=0; + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00095',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + else + { + # if (preg_match("/$agentchannel/i",$row[0])) + if ( ($agentchannel == "$row[0]") or (ereg('ASTblind',$row[0])) ) + { + $donothing=1; + } + else + { + $hangup_channels[$total_hangup] = "$row[0]"; + $total_hangup++; + } + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + $loop_count=0; + $stmt="SELECT channel FROM live_channels where server_ip = '$server_ip' and extension = '$conf_exten' order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00184',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$rec_list = mysql_num_rows($rslt);} + while ($rec_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + if (preg_match("/Local\/$conf_silent_prefix$conf_exten\@/i",$row[0])) + { + $rec_channels[$total_rec] = "$row[0]"; + $total_rec++; + } + else + { + # if (preg_match("/$agentchannel/i",$row[0])) + if ( ($agentchannel == "$row[0]") or (ereg('ASTblind',$row[0])) ) + { + $donothing=1; + } + else + { + $hangup_channels[$total_hangup] = "$row[0]"; + $total_hangup++; + } + } + if ($format=='debug') {echo "\n";} + $loop_count++; + } + + + ### if a conference call or 3way call was attempted, then hangup all channels except for the agentchannel + if ( ( ($conf_dialed > 0) or ($hangup_all_non_reserved > 0) ) and ($leaving_threeway < 1) and ($blind_transfer < 1) ) + { + $loop_count=0; + while($loop_count < $total_hangup) + { + if (strlen($hangup_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','CH12346$StarTtime$loop_count','Channel: $hangup_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00096',$user,$server_ip,$session_name,$one_mysql_log);} + } + $loop_count++; + } + } + + $total_recFN=0; + $loop_count=0; + $filename=$MT; # not necessary : and cmd_line_f LIKE \"%_$user_abb\" + $stmt="SELECT cmd_line_f FROM vicidial_manager where server_ip='$server_ip' and action='Originate' and cmd_line_b = 'Channel: $local_DEF$conf_silent_prefix$conf_exten$local_AMP$ext_context' order by entry_date desc limit $total_rec;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00097',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$recFN_list = mysql_num_rows($rslt);} + while ($recFN_list>$loop_count) + { + $row=mysql_fetch_row($rslt); + $filename[$total_recFN] = preg_replace("/Callerid: /i","",$row[0]); + if ($format=='debug') {echo "\n";} + $total_recFN++; + $loop_count++; + } + + $loop_count=0; + while($loop_count < $total_rec) + { + if (strlen($rec_channels[$loop_count])>5) + { + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$loop_count','Channel: $rec_channels[$loop_count]','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00098',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "REC_STOP|$rec_channels[$loop_count]|$filename[$loop_count]|"; + if (strlen($filename)>2) + { + $stmt="SELECT recording_id,start_epoch,vicidial_id,lead_id FROM recording_log where filename='$filename[$loop_count]'"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00099',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) {$fn_count = mysql_num_rows($rslt);} + if ($fn_count) + { + $row=mysql_fetch_row($rslt); + $recording_id = $row[0]; + $start_time = $row[1]; + $vicidial_id = $row[2]; + $RClead_id = $row[3]; + + if ( (strlen($RClead_id)<1) or ($RClead_id < 1) or ($RClead_id=='NULL') ) + {$lidSQL = ",lead_id='$lead_id'";} + if (strlen($vicidial_id)<1) + {$vidSQL = ",vicidial_id='$VDvicidial_id'";} + else + { + if ( (ereg('.',$vicidial_id)) and ($VLA_inOUT == 'INBOUND') ) + { + if (!ereg('.',$VDvicidial_id)) + {$vidSQL = ",vicidial_id='$VDvicidial_id'";} + + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND_LOG_3|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$vicidial_id|$start_epoch|$recording_id|\n"); + fclose($fp); + } + } + $length_in_sec = ($StarTtime - $start_time); + $length_in_min = ($length_in_sec / 60); + $length_in_min = sprintf("%8.2f", $length_in_min); + + $stmt="UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' $vidSQL $lidSQL where filename='$filename[$loop_count]' and end_epoch is NULL;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00100',$user,$server_ip,$session_name,$one_mysql_log);} + + echo "$recording_id|$length_in_min|"; + + # $fp = fopen ("./recording_debug_$NOW_DATE$txt", "a"); + # fwrite ($fp, "$NOW_TIME|ЗАПИСЬ_LOG|$filename[$loop_count]|$uniqueid|$lead_id|$user|$inOUT|$VLA_inOUT|$length_in_sec|$VDterm_reason|$VDvicidial_id|$VDvicidial_id|$vicidial_id|$start_epoch|$recording_id|$VDIDselect|\n"); + # fclose($fp); + } + else {echo "||";} + } + else {echo "||";} + echo "\n"; + } + $loop_count++; + } + } + + + $talk_sec=0; + $talk_epochSQL=''; + $StarTtime = date("U"); + $stmt = "select talk_epoch,talk_sec,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00101',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ( (eregi("NULL",$row[0])) or ($row[0] < 1000) ) + { + $talk_epochSQL=",talk_epoch='$StarTtime'"; + $row[0]=$row[2]; + } + $talk_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set talk_sec='$talk_sec',dispo_epoch='$StarTtime' $talk_epochSQL where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00102',$user,$server_ip,$session_name,$one_mysql_log);} + + } +} + + +################################################################################ +### VDADREcheckINCOMING - for auto-dial VICIDiaL dialing this will recheck for +### calls to see if the channel has updated +################################################################################ +if ($ACTION == 'VDADREcheckINCOMING') +{ + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) || (strlen($lead_id)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Кампания $campaign это неправильно\n"; + echo "lead_id $lead_id это неправильно\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00103',$user,$server_ip,$session_name,$one_mysql_log);} + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + } + } +} + + +################################################################################ +### VDADcheckINCOMING - for auto-dial VICIDiaL dialing this will check for calls +### in the vicidial_live_agents table in QUEUE status, then +### lookup the lead info and pass it back to vicidial.php +################################################################################ +if ($ACTION == 'VDADcheckINCOMING') +{ + $VDCL_ingroup_recording_override = ''; + $VDCL_ingroup_rec_filename = ''; + $Ctype = 'A'; + $MT[0]=''; + $row=''; $rowx=''; + $channel_live=1; + $alt_phone_code=''; + $alt_phone_number=''; + $alt_phone_note=''; + $alt_phone_active=''; + $alt_phone_count=''; + + if ( (strlen($campaign)<1) || (strlen($server_ip)<1) ) + { + $channel_live=0; + echo "0\n"; + echo "Кампания $campaign это неправильно\n"; + exit; + } + else + { + ### grab the call and lead info from the vicidial_live_agents table + $stmt = "SELECT lead_id,uniqueid,callerid,channel,call_server_ip,comments FROM vicidial_live_agents where server_ip = '$server_ip' and user='$user' and campaign_id='$campaign' and status='QUEUE';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00104',$user,$server_ip,$session_name,$one_mysql_log);} + $queue_leadID_ct = mysql_num_rows($rslt); + + if ($queue_leadID_ct > 0) + { + $row=mysql_fetch_row($rslt); + $lead_id =$row[0]; + $uniqueid =$row[1]; + $callerid =$row[2]; + $channel =$row[3]; + $call_server_ip =$row[4]; + $VLAcomments=$row[5]; + + if (strlen($call_server_ip)<7) {$call_server_ip = $server_ip;} + echo "1\n" . $lead_id . '|' . $uniqueid . '|' . $callerid . '|' . $channel . '|' . $call_server_ip . "|\n"; + + ##### grab number of calls today in this campaign and increment + $stmt="SELECT calls_today FROM vicidial_live_agents WHERE user='$user' and campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00105',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_cc_ct = mysql_num_rows($rslt); + if ($vla_cc_ct > 0) + { + $row=mysql_fetch_row($rslt); + $calls_today =$row[0]; + } + else + {$calls_today ='0';} + $calls_today++; + + ### update the agent status to INCALL in vicidial_live_agents + $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00106',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9106$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt = "UPDATE vicidial_campaign_agents set calls_today='$calls_today' where user='$user' and campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00107',$user,$server_ip,$session_name,$one_mysql_log);} + + ##### grab the data from vicidial_list for the lead_id + $stmt="SELECT * FROM vicidial_list where lead_id='$lead_id' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00108',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $list_lead_ct = mysql_num_rows($rslt); + if ($list_lead_ct > 0) + { + $row=mysql_fetch_row($rslt); + # $lead_id = trim("$row[0]"); + $dispo = trim("$row[3]"); + $tsr = trim("$row[4]"); + $vendor_id = trim("$row[5]"); + $source_id = trim("$row[6]"); + $list_id = trim("$row[7]"); + $gmt_offset_now = trim("$row[8]"); + $phone_code = trim("$row[10]"); + $phone_number = trim("$row[11]"); + $title = trim("$row[12]"); + $first_name = trim("$row[13]"); + $middle_initial = trim("$row[14]"); + $last_name = trim("$row[15]"); + $address1 = trim("$row[16]"); + $address2 = trim("$row[17]"); + $address3 = trim("$row[18]"); + $city = trim("$row[19]"); + $state = trim("$row[20]"); + $province = trim("$row[21]"); + $postal_code = trim("$row[22]"); + $country_code = trim("$row[23]"); + $gender = trim("$row[24]"); + $date_of_birth = trim("$row[25]"); + $alt_phone = trim("$row[26]"); + $email = trim("$row[27]"); + $security = trim("$row[28]"); + $comments = stripslashes(trim("$row[29]")); + $called_count = trim("$row[30]"); + } + + ##### if lead is a callback, grab the callback comments + $CBentry_time = ''; + $CBcallback_time = ''; + $CBuser = ''; + $CBcomments = ''; + if (ereg("CALLBK",$dispo)) + { + $stmt="SELECT entry_time,callback_time,user,comments FROM vicidial_callbacks where lead_id='$lead_id' order by callback_id desc LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00109',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $cb_record_ct = mysql_num_rows($rslt); + if ($cb_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $CBentry_time = trim("$row[0]"); + $CBcallback_time = trim("$row[1]"); + $CBuser = trim("$row[2]"); + $CBcomments = trim("$row[3]"); + } + } + + ### update the lead status to INCALL + $stmt = "UPDATE vicidial_list set status='INCALL', user='$user' where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00110',$user,$server_ip,$session_name,$one_mysql_log);} + + ### update the log status to INCALL + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00111',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + + $stmt = "select campaign_id,phone_number,alt_dial,call_type from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00112',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($VDAC_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + $dialed_number =$row[1]; + $dialed_label =$row[2]; + $call_type =$row[3]; + } + else + { + $dialed_number = $phone_number; + $dialed_label = 'MAIN'; + if (preg_match('/^M|^V/',$callerid)) + { + $call_type = 'OUT'; + $VDADchannel_group = $campaign; + } + else + { + $call_type = 'IN'; + $stmt = "select campaign_id from vicidial_closer_log where lead_id = '$lead_id' order by call_date desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00183',$user,$server_ip,$session_name,$one_mysql_log);} + $VDCL_mvac_ct = mysql_num_rows($rslt); + if ($VDCL_mvac_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDADchannel_group =$row[0]; + } + } + if ($WeBRooTWritablE > 0) + { + $fp = fopen ("./vicidial_debug.txt", "a"); + fwrite ($fp, "$NOW_TIME|INBND|$callerid|$user|$user_group|$list_id|$lead_id|$phone_number|$uniqueid|$VDADchannel_group|$call_type|\n"); + fclose($fp); + } + } + + if ( ($call_type=='OUT') or ($call_type=='OUTBALANCE') ) + { + $stmt = "UPDATE vicidial_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00113',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00114',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_campaign_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + $VDCL_default_xfer_group = $row[6]; + if (strlen($VDCL_default_xfer_group)<2) {$VDCL_default_xfer_group='X';} + } + echo "|||||$VDCL_campaign_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|X|X||||\n|\n"; + + $stmt = "select phone_number,alt_dial from vicidial_auto_calls where callerid = '$callerid' order by call_time desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00115',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAC_cid_ct = mysql_num_rows($rslt); + if ($VDAC_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dialed_number =$row[0]; + $dialed_label =$row[1]; + } + else + { + $dialed_number = $phone_number; + $dialed_label = 'MAIN'; + } + if (ereg('X',$dialed_label)) + { + if (ereg('LAST',$dialed_label)) + { + $stmt = "SELECT phone_code,phone_number,alt_phone_note,active,alt_phone_count FROM vicidial_list_alt_phones where lead_id='$lead_id' order by alt_phone_count desc limit 1;"; + } + else + { + $Talt_dial = ereg_replace("[^0-9]","",$dialed_label); + $stmt = "SELECT phone_code,phone_number,alt_phone_note,active,alt_phone_count FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Talt_dial';"; + } + + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00116',$user,$server_ip,$session_name,$one_mysql_log);} + $VLAP_ct = mysql_num_rows($rslt); + if ($VLAP_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alt_phone_code = $row[0]; + $alt_phone_number = $row[1]; + $alt_phone_note = $row[2]; + $alt_phone_active = $row[3]; + $alt_phone_count = $row[4]; + } + } + } + else + { + ### update the vicidial_closer_log user to INCALL + $stmt = "UPDATE vicidial_closer_log set user='$user', comments='AUTO', list_id='$list_id', status='INCALL', user_group='$user_group' where lead_id='$lead_id' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00117',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "select count(*) from vicidial_log where lead_id='$lead_id' and uniqueid='$uniqueid';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00118',$user,$server_ip,$session_name,$one_mysql_log);} + $VDL_cid_ct = mysql_num_rows($rslt); + if ($VDL_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_front_VDlog =$row[0]; + } + + $stmt = "select group_name,group_color,web_form_address,fronter_display,ingroup_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_xfer_group,ingroup_recording_override,ingroup_rec_filename,default_group_alias from vicidial_inbound_groups where group_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00119',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_name = $row[0]; + $VDCL_group_color = $row[1]; + $VDCL_group_web = stripslashes($row[2]); + $VDCL_fronter_display = $row[3]; + $VDCL_ingroup_script = $row[4]; + $VDCL_get_call_launch = $row[5]; + $VDCL_xferconf_a_dtmf = $row[6]; + $VDCL_xferconf_a_number = $row[7]; + $VDCL_xferconf_b_dtmf = $row[8]; + $VDCL_xferconf_b_number = $row[9]; + $VDCL_default_xfer_group = $row[10]; + $VDCL_ingroup_recording_override = $row[11]; + $VDCL_ingroup_rec_filename = $row[12]; + $VDCL_default_group_alias = $row[13]; + + + $stmt = "select campaign_script,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00181',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ( ( (ereg('NONE',$VDCL_ingroup_script)) and (strlen($VDCL_ingroup_script) < 5) ) or (strlen($VDCL_ingroup_script) < 1) ) + {$VDCL_ingroup_script = $row[0];} + if (strlen($VDCL_xferconf_a_dtmf) < 1) + {$VDCL_xferconf_a_dtmf = $row[1];} + if (strlen($VDCL_xferconf_a_number) < 1) + {$VDCL_xferconf_a_number = $row[2];} + if (strlen($VDCL_xferconf_b_dtmf) < 1) + {$VDCL_xferconf_b_dtmf = $row[3];} + if (strlen($VDCL_xferconf_b_number) < 1) + {$VDCL_xferconf_b_number = $row[4];} + if (strlen($VDCL_default_group_alias) < 1) + {$VDCL_default_group_alias = $row[5];} + } + + $stmt = "select group_web_vars from vicidial_inbound_group_agents where group_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00188',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidgwv_ct = mysql_num_rows($rslt); + if ($VDIG_cidgwv_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + + if (strlen($VDCL_group_web_vars) < 1) + { + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$campaign' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00189',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + ### update the comments in vicidial_live_agents record + $stmt = "UPDATE vicidial_live_agents set comments='INBOUND' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00120',$user,$server_ip,$session_name,$one_mysql_log);} + + $Ctype = 'I'; + } + else + { + $stmt = "select campaign_script,get_call_launch,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,default_group_alias from vicidial_campaigns where campaign_id='$VDADchannel_group';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00121',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cid_ct = mysql_num_rows($rslt); + if ($VDIG_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_ingroup_script = $row[0]; + $VDCL_get_call_launch = $row[1]; + $VDCL_xferconf_a_dtmf = $row[2]; + $VDCL_xferconf_a_number = $row[3]; + $VDCL_xferconf_b_dtmf = $row[4]; + $VDCL_xferconf_b_number = $row[5]; + $VDCL_default_group_alias = $row[6]; + } + + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$VDADchannel_group' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00190',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_group_web_vars = $row[0]; + } + } + + $VDCL_caller_id_number=''; + if (strlen($VDCL_default_group_alias)>1) + { + $stmt = "select caller_id_number from groups_alias where group_alias_id='$VDCL_default_group_alias';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00187',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidnum_ct = mysql_num_rows($rslt); + if ($VDIG_cidnum_ct > 0) + { + $row=mysql_fetch_row($rslt); + $VDCL_caller_id_number = $row[0]; + } + } + + ### if web form is set then send на to vicidial.php for override of WEB_FORM address + if ( (strlen($VDCL_group_web)>5) or (strlen($VDCL_group_name)>0) ) {echo "$VDCL_group_web|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|\n";} + else {echo "X|$VDCL_group_name|$VDCL_group_color|$VDCL_fronter_display|$VDADchannel_group|$VDCL_ingroup_script|$VDCL_get_call_launch|$VDCL_xferconf_a_dtmf|$VDCL_xferconf_a_number|$VDCL_xferconf_b_dtmf|$VDCL_xferconf_b_number|$VDCL_default_xfer_group|$VDCL_ingroup_recording_override|$VDCL_ingroup_rec_filename|$VDCL_default_group_alias|$VDCL_caller_id_number|$VDCL_group_web_vars|\n";} + + $stmt = "SELECT full_name from vicidial_users where user='$tsr';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00122',$user,$server_ip,$session_name,$one_mysql_log);} + $VDU_cid_ct = mysql_num_rows($rslt); + if ($VDU_cid_ct > 0) + { + $row=mysql_fetch_row($rslt); + $fronter_full_name = $row[0]; + echo $fronter_full_name . '|' . $tsr . "\n"; + } + else {echo '|' . $tsr . "\n";} + } + + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + + $LeaD_InfO = $callerid . "\n"; + $LeaD_InfO .= $lead_id . "\n"; + $LeaD_InfO .= $dispo . "\n"; + $LeaD_InfO .= $tsr . "\n"; + $LeaD_InfO .= $vendor_id . "\n"; + $LeaD_InfO .= $list_id . "\n"; + $LeaD_InfO .= $gmt_offset_now . "\n"; + $LeaD_InfO .= $phone_code . "\n"; + $LeaD_InfO .= $phone_number . "\n"; + $LeaD_InfO .= $title . "\n"; + $LeaD_InfO .= $first_name . "\n"; + $LeaD_InfO .= $middle_initial . "\n"; + $LeaD_InfO .= $last_name . "\n"; + $LeaD_InfO .= $address1 . "\n"; + $LeaD_InfO .= $address2 . "\n"; + $LeaD_InfO .= $address3 . "\n"; + $LeaD_InfO .= $city . "\n"; + $LeaD_InfO .= $state . "\n"; + $LeaD_InfO .= $province . "\n"; + $LeaD_InfO .= $postal_code . "\n"; + $LeaD_InfO .= $country_code . "\n"; + $LeaD_InfO .= $gender . "\n"; + $LeaD_InfO .= $date_of_birth . "\n"; + $LeaD_InfO .= $alt_phone . "\n"; + $LeaD_InfO .= $email . "\n"; + $LeaD_InfO .= $security . "\n"; + $LeaD_InfO .= $comments . "\n"; + $LeaD_InfO .= $called_count . "\n"; + $LeaD_InfO .= $CBentry_time . "\n"; + $LeaD_InfO .= $CBcallback_time . "\n"; + $LeaD_InfO .= $CBuser . "\n"; + $LeaD_InfO .= $CBcomments . "\n"; + $LeaD_InfO .= $dialed_number . "\n"; + $LeaD_InfO .= $dialed_label . "\n"; + $LeaD_InfO .= $source_id . "\n"; + $LeaD_InfO .= $alt_phone_code . "\n"; + $LeaD_InfO .= $alt_phone_number . "\n"; + $LeaD_InfO .= $alt_phone_note . "\n"; + $LeaD_InfO .= $alt_phone_active . "\n"; + $LeaD_InfO .= $alt_phone_count . "\n"; + + echo $LeaD_InfO; + + + + $wait_sec=0; + $StarTtime = date("U"); + $stmt = "select wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00123',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $wait_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec',talk_epoch='$StarTtime',lead_id='$lead_id' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00124',$user,$server_ip,$session_name,$one_mysql_log);} + + ### If ВЫЗОВBK, change vicidial_callback record to INACTIVE + if (eregi("CALLBK|CBHOLD", $dispo)) + { + $stmt="UPDATE vicidial_callbacks set status='INACTIVE' where lead_id='$lead_id' and status NOT IN('INACTIVE','DEAD','ARCHIVE');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00125',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ##### check if system is set to generate logfile for transfers + $stmt="SELECT enable_agc_xfer_log FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00126',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_xfer_log_ct = mysql_num_rows($rslt); + if ($enable_agc_xfer_log_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_agc_xfer_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_xfer_log > 0) ) + { + # DATETIME|campaign|lead_id|phone_number|user|type + # 2007-08-22 11:11:11|TESTCAMP|65432|3125551212|1234|A + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|$Ctype|$callerid|$uniqueid\n"); + fclose($fp); + } + + } + else + { + echo "0\n"; + # echo "No calls in QUEUE for $user на $server_ip\n"; + exit; + } + } +} + + +################################################################################ +### userLOGout - Logs the user out of VICIDiaL client, deleting db records and +### inserting into vicidial_user_log +################################################################################ +if ($ACTION == 'userLOGout') +{ + $MT[0]=''; + $row=''; $rowx=''; +if ( (strlen($campaign)<1) || (strlen($conf_exten)<1) ) + { + echo "NO\n"; + echo "campaign $campaign or conf_exten $conf_exten это неправильно\n"; + exit; + } +else + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00127',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + ##### Insert a ВЫХОД record into the user log + $stmt="INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$user','ВЫХОД','$campaign','$NOW_TIME','$StarTtime','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00128',$user,$server_ip,$session_name,$one_mysql_log);} + $vul_insert = mysql_affected_rows($link); + + if ($no_delete_sessions < 1) + { + ##### Remove the reservation на the vicidial_conferences meetme room + $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);} + $vc_remove = mysql_affected_rows($link); + } + + ##### Delete the vicidial_live_agents record for this session + $stmt="DELETE from vicidial_live_agents where server_ip='$server_ip' and user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00130',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9130$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $vla_delete = mysql_affected_rows($link); + + ##### Delete the vicidial_live_inbound_agents records for this session + $stmt="DELETE from vicidial_live_inbound_agents where user ='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00131',$user,$server_ip,$session_name,$one_mysql_log);} + $vlia_delete = mysql_affected_rows($link); + + ##### Delete the web_client_sessions + $stmt="DELETE from web_client_sessions where server_ip='$server_ip' and session_name ='$session_name';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00132',$user,$server_ip,$session_name,$one_mysql_log);} + $wcs_delete = mysql_affected_rows($link); + + ##### Hangup the client phone + $stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$protocol/$extension%\" order by channel desc;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00133',$user,$server_ip,$session_name,$one_mysql_log);} + if ($rslt) + { + $row=mysql_fetch_row($rslt); + $agent_channel = "$row[0]"; + if ($format=='debug') {echo "\n";} + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','ULGH3459$StarTtime','Channel: $agent_channel','','','','','','','','','');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00134',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($LogouTKicKAlL > 0) + { + $local_DEF = 'Local/5555'; + $local_AMP = '@'; + $kick_local_channel = "$local_DEF$conf_exten$local_AMP$ext_context"; + $queryCID = "ULGH3458$StarTtime"; + + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$channel','$exten');"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00135',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec,wait_epoch,talk_epoch,dispo_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00136',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ( ($VDpr_ct > 0) and (strlen($row[3]<5)) and (strlen($row[4]<5)) ) + { + $row=mysql_fetch_row($rslt); + $pause_sec = (($StarTtime - $row[0]) + $row[1]); + + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00137',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($vla_delete > 0) + { + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00138',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_message = 'LOGGED OUT'; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_message\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + } + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + # $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$campaign',agent='Agent/$user',verb='ПАУЗПА',serverid='1';"; + # if ($DB) {echo "$stmt\n";} + # + # $rslt=mysql_query($stmt, $linkB); + # $affected_rows = mysql_affected_rows($linkB); + + $stmt = "SELECT time_id FROM queue_log where agent='Agent/$user' and verb='AGENTLOGIN' order by time_id desc limit 1;"; + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00139',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + echo "$stmt\n"; + $li_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $li_conf_ct) + { + $row=mysql_fetch_row($rslt); + $logintime = $row[0]; + $i++; + } + + $time_logged_in = ($StarTtime - $logintime); + if ($time_logged_in > 1000000) {$time_logged_in=1;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='AGENTLOGOFF',data1='$user$agents',data2='$time_logged_in',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00140',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + + echo "$vul_insert|$vc_remove|$vla_delete|$wcs_delete|$agent_channel|$vlia_delete\n"; + } +} + + +################################################################################ +### updateDISPO - update the vicidial_list table to reflect the agent choice of +### call disposition for that leand +################################################################################ +if ($ACTION == 'updateDISPO') +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($dispo_choice)<1) || (strlen($lead_id)<1) ) + { + echo "Dispo Choice $dispo or lead_id $lead_id это неправильно\n"; + exit; + } + else + { + ### update the comments in vicidial_live_agents record + $stmt = "UPDATE vicidial_live_agents set lead_id=0,external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9141$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt = "select count(*) from vicidial_inbound_groups where group_id='$stage';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00143',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt = "UPDATE vicidial_closer_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="UPDATE vicidial_log set status='$dispo_choice' where lead_id='$lead_id' and user='$user' order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ( ($use_internal_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00146',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + } + if ( ($use_campaign_dnc=='Y') and ($dispo_choice=='DNC') ) + { + $stmt = "select phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00148',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $stmt="INSERT INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$row[0]','$campaign');"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + } + } + + $dispo_sec=0; + $dispo_epochSQL=''; + $StarTtime = date("U"); + $stmt = "select dispo_epoch,dispo_sec,talk_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00150',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ( (eregi("NULL",$row[0])) or ($row[0] < 1000) ) + { + $dispo_epochSQL=",dispo_epoch='$StarTtime'"; + $row[0]=$row[2]; + } + $dispo_sec = (($StarTtime - $row[0]) + $row[1]); + } + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec',status='$dispo_choice' $dispo_epochSQL where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00151',$user,$server_ip,$session_name,$one_mysql_log);} + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00152',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + if ($auto_dial_level < 1) + { + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + } + + ### ВЫЗОВBACK ENTRY + if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) + { + $comments = eregi_replace('"','',$comments); + $comments = eregi_replace("'",'',$comments); + $comments = eregi_replace(';','',$comments); + $comments = eregi_replace("\\\\",' ',$comments); + $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00154',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $stmt="SELECT auto_alt_dial_statuses from vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00155',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + if ( ($auto_dial_level > 0) and (ereg(" $dispo_choice ",$row[0])) ) + { + $stmt = "select count(*) from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00156',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE vicidial_hopper set status='READY' where lead_id='$lead_id' and status='HOLD' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00157',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + else + { + $stmt="DELETE from vicidial_hopper where lead_id='$lead_id' and status='HOLD';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00158',$user,$server_ip,$session_name,$one_mysql_log);} + } + + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00159',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + if (strlen($stage) < 2) + {$stage = $campaign;} + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$stage',agent='Agent/$user',verb='CALLСТАТУС',data1='$dispo_choice',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00160',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + + echo 'Lead ' . $lead_id . ' был изменен на ' . $dispo_choice . " Статус\nNext agent_log_id:\n" . $agent_log_id . "\n"; +} + +################################################################################ +### updateLEAD - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'updateLEAD') +{ + $MT[0]=''; + $row=''; $rowx=''; + $DO_NOT_UPDATE=0; + $DO_NOT_UPDATE_text=''; + if ( (strlen($phone_number)<1) || (strlen($lead_id)<1) ) + { + echo "phone_number $phone_number or lead_id $lead_id это неправильно\n"; + exit; + } + else + { + + $stmt = "SELECT disable_alter_custdata,disable_alter_custphone FROM vicidial_campaigns where campaign_id='$campaign'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00161',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dac_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $dac_conf_ct) + { + $row=mysql_fetch_row($rslt); + $disable_alter_custdata = $row[0]; + $disable_alter_custphone = $row[1]; + $i++; + } + if ( (ereg('Y',$disable_alter_custdata)) or (ereg('Y',$disable_alter_custphone)) ) + { + if (ereg('Y',$disable_alter_custdata)) + { + $DO_NOT_UPDATE=1; + $DO_NOT_UPDATE_text=' NOT'; + } + if (ereg('Y',$disable_alter_custphone)) + { + $DO_NOT_UPDATEphone=1; + } + $stmt = "SELECT alter_custdata_override,alter_custphone_override FROM vicidial_users where user='$user'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00162',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $aco_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $aco_conf_ct) + { + $row=mysql_fetch_row($rslt); + $alter_custdata_override = $row[0]; + $alter_custphone_override = $row[1]; + $i++; + } + if (ereg('ALLOW_ALTER',$alter_custdata_override)) + { + $DO_NOT_UPDATE=0; + $DO_NOT_UPDATE_text=''; + } + if (ereg('ALLOW_ALTER',$alter_custphone_override)) + { + $DO_NOT_UPDATEphone=0; + } + } + + if ($DO_NOT_UPDATE < 1) + { + $comments = eregi_replace("\r",'',$comments); + $comments = eregi_replace("\n",'!N',$comments); + $comments = eregi_replace("--AMP--",'&',$comments); + $comments = eregi_replace("--QUES--",'?',$comments); + $comments = eregi_replace("--POUND--",'#',$comments); + + $phoneSQL=''; + if ($DO_NOT_UPDATEphone < 1) + {$phoneSQL = ",phone_number='$phone_number'";} + + $stmt="UPDATE vicidial_list set vendor_lead_code='" . mysql_real_escape_string($vendor_lead_code) . "', title='" . mysql_real_escape_string($title) . "', first_name='" . mysql_real_escape_string($first_name) . "', middle_initial='" . mysql_real_escape_string($middle_initial) . "', last_name='" . mysql_real_escape_string($last_name) . "', address1='" . mysql_real_escape_string($address1) . "', address2='" . mysql_real_escape_string($address2) . "', address3='" . mysql_real_escape_string($address3) . "', city='" . mysql_real_escape_string($city) . "', state='" . mysql_real_escape_string($state) . "', province='" . mysql_real_escape_string($province) . "', postal_code='" . mysql_real_escape_string($postal_code) . "', country_code='" . mysql_real_escape_string($country_code) . "', gender='" . mysql_real_escape_string($gender) . "', date_of_birth='" . mysql_real_escape_string($date_of_birth) . "', alt_phone='" . mysql_real_escape_string($alt_phone) . "', email='" . mysql_real_escape_string($email) . "', security_phrase='" . mysql_real_escape_string($security_phrase) . "', comments='" . mysql_real_escape_string($comments) . "' $phoneSQL where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00163',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set random_id='$random' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00164',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9164$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + } + echo "Lead $lead_id information has$DO_NOT_UPDATE_text been updated\n"; +} + + +################################################################################ +### VDADpause - update the vicidial_live_agents table to show that the agent is +### or ready now active and ready to take calls +################################################################################ +if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) +{ + $MT[0]=''; + $row=''; $rowx=''; + if ( (strlen($stage)<2) || (strlen($server_ip)<1) ) + { + echo "stage $stage это неправильно\n"; + exit; + } + else + { + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9165$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + $stmt="UPDATE vicidial_live_agents set status='$stage' where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_query($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9166$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00167',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + if ( (ereg('READY',$stage)) or (ereg('CLOSER',$stage)) ) {$QMstatus='UNPAUSEALL';} + if (ereg('ПАУЗПА',$stage)) {$QMstatus='ПАУЗПАALL';} + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00182',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='NONE',agent='Agent/$user',verb='$QMstatus',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00168',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + + $pause_sec=0; + $stmt = "select pause_epoch,pause_sec,wait_epoch,wait_sec,dispo_epoch from vicidial_agent_log where agent_log_id='$agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00169',$user,$server_ip,$session_name,$one_mysql_log);} + $VDpr_ct = mysql_num_rows($rslt); + if ($VDpr_ct > 0) + { + $row=mysql_fetch_row($rslt); + $dispo_epoch = $row[4]; + $wait_sec=0; + if ($row[2] > 0) + { + $wait_sec = (($StarTtime - $row[2]) + $row[3]); + } + if ( (eregi("NULL",$row[4])) or ($row[4] < 1000) ) + {$pause_sec = (($StarTtime - $row[0]) + $row[1]);} + else + {$pause_sec = (($row[4] - $row[0]) + $row[1]);} + + } + if ($ACTION == 'VDADready') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set pause_sec='$pause_sec',wait_epoch='$StarTtime' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00170',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + if ($ACTION == 'VDADpause') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set wait_sec='$wait_sec' where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00171',$user,$server_ip,$session_name,$one_mysql_log);} + } + + $agent_log = 'NEW_ID'; + } + + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + + if ($agent_log == 'NEW_ID') + { + $user_group=''; + $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00182',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysql_num_rows($rslt); + if ($ug_record_ct > 0) + { + $row=mysql_fetch_row($rslt); + $user_group = trim("$row[0]"); + } + + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group) values('$user','$server_ip','$NOW_TIME','$campaign','$StarTtime','0','$StarTtime','$user_group');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00153',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + } + } + echo 'Agent ' . $user . ' новый статус ' . $stage . "\nNext agent_log_id:\n$agent_log_id\n"; +} + + +################################################################################ +### UpdatEFavoritEs - update the astguiclient favorites list for this extension +################################################################################ +if ($ACTION == 'UpdatEFavoritEs') +{ + $row=''; $rowx=''; + $channel_live=1; + if ( (strlen($favorites_list)<1) || (strlen($user)<1) || (strlen($exten)<1) ) + { + echo "favorites list $favorites_list это неправильно\n"; + exit; + } + else + { + $stmt = "select count(*) from phone_favorites where extension='$exten' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00172',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + if ($row[0] > 0) + { + $stmt="UPDATE phone_favorites set extensions_list=\"$favorites_list\" where extension='$exten' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00173',$user,$server_ip,$session_name,$one_mysql_log);} + } + else + { + $stmt="INSERT INTO phone_favorites values('$exten','$server_ip',\"$favorites_list\");"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00174',$user,$server_ip,$session_name,$one_mysql_log);} + } + } + echo "Favorites list has been updated to $favorites_list for $exten\n"; +} + + +################################################################################ +### PauseCodeSubmit - Update vicidial_agent_log with pause code +################################################################################ +if ($ACTION == 'ПаузаCodeSubmit') +{ + $row=''; $rowx=''; + if ( (strlen($status)<1) || (strlen($agent_log_id)<1) ) + { + echo "agent_log_id $agent_log_id or pause_code $status это неправильно\n"; + exit; + } + else + { + $stmt="UPDATE vicidial_agent_log set sub_status=\"$status\" where agent_log_id='$agent_log_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00175',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + if ($affected_rows > 0) + { + ############################################# + ##### СТАРТ QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00176',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $allow_sipsak_messages = $row[6]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_prefix = 'BK-'; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$status\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + } + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='NONE',queue='$campaign',agent='Agent/$user',verb='ПАУЗПАREASON',serverid='$queuemetrics_log_id',data1='$status';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'00177',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + } + } +echo " Пауза Code has been updated to $status for $agent_log_id\n"; +} + + +################################################################################ +### CalLBacKLisT - List the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKLisT') +{ +$stmt = "select callback_id,lead_id,campaign_id,status,entry_time,callback_time,comments from vicidial_callbacks where recipient='USERONLY' and user='$user' and campaign_id='$campaign' and status NOT IN('INACTIVE','DEAD') order by callback_time;"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00178',$user,$server_ip,$session_name,$one_mysql_log);} +if ($rslt) {$callbacks_count = mysql_num_rows($rslt);} +echo "$callbacks_count\n"; +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $row=mysql_fetch_row($rslt); + $callback_id[$loop_count] = $row[0]; + $lead_id[$loop_count] = $row[1]; + $campaign_id[$loop_count] = $row[2]; + $status[$loop_count] = $row[3]; + $entry_time[$loop_count] = $row[4]; + $callback_time[$loop_count] = $row[5]; + $comments[$loop_count] = $row[6]; + $loop_count++; + } +$loop_count=0; + while ($callbacks_count>$loop_count) + { + $stmt = "select first_name,last_name,phone_number from vicidial_list where lead_id='$lead_id[$loop_count]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00179',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + echo "$row[0] ~$row[1] ~$row[2] ~$callback_id[$loop_count] ~$lead_id[$loop_count] ~$campaign_id[$loop_count] ~$status[$loop_count] ~$entry_time[$loop_count] ~$callback_time[$loop_count] ~$comments[$loop_count]\n"; + $loop_count++; + } + +} + + +################################################################################ +### CalLBacKCounT - send the count of the USERONLY callbacks for an agent +################################################################################ +if ($ACTION == 'CalLBacKCounT') +{ +$stmt = "select count(*) from vicidial_callbacks where recipient='USERONLY' and user='$user' and campaign_id='$campaign' and status NOT IN('INACTIVE','DEAD');"; +if ($DB) {echo "$stmt\n";} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00180',$user,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$cbcount=$row[0]; + +echo "$cbcount"; +} + + + + +if ($format=='debug') +{ +$ENDtime = date("U"); +$RUNtime = ($ENDtime - $StarTtime); +echo "\n"; +echo "\n\n\n"; +} + +exit; + + + + + +##### MySQL Error Logging ##### +function mysql_error_logging($NOW_TIME,$link,$mel,$stmt,$query_id,$user,$server_ip,$session_name,$one_mysql_log) +{ +$NOW_TIME = date("Y-m-d H:i:s"); +# mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log); +$errno=''; $error=''; +if ( ($mel > 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|vdc_db_query|$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> diff --git a/LANG_www/agc_ru/vicidial.php b/LANG_www/agc_ru/vicidial.php new file mode 100644 index 00000000..7ec051e3 --- /dev/null +++ b/LANG_www/agc_ru/vicidial.php @@ -0,0 +1,8606 @@ + LICENSE: AGPLv2 +# +# Other scripts that this application depends on: +# - vdc_db_query.php: Updates information in the database +# - manager_send.php: Sends manager actions to the DB for execution +# - conf_exten_check.php: time sync and status updater, calls in queue +# +# CHANGELOG +# 50607-1426 - First Build of VICIDIAL web client basic login process finished +# 50628-1620 - Added some basic formatting and worked on process flow +# 50628-1715 - Startup variables mapped to javascript variables +# 50629-1303 - Added Login Closer in-groups selection box and vla update +# 50629-1530 - Rough layout for customer info form section and button links +# 50630-1453 - Rough Manual Dial/Hangup with customer info displayed +# 50701-1450 - Added vicidial_log entries on dial and hangup +# 50701-1634 - Added Logout function +# 50705-1259 - Added call disposition functionality +# 50705-1432 - Added lead info DB update function +# 50705-1658 - Added web form functionality +# 50706-1043 - Added call park and pickup functions +# 50706-1234 - Added Start/Stop Recording functionality +# 50706-1614 - Added conference channels display option +# 50711-1333 - Removed call check redundancy and fixed a span bug +# 50727-1424 - Added customer channel and participant present sensing/alerts +# 50804-1057 - Added SendDTMF function and reconfigured the transfer span +# 50804-1224 - Added Local and Internal Closer transfer functions +# 50804-1628 - Added Blind transfer, activated LIVE CALL image and fixed bugs +# 50804-1808 - Added button images for left buttons +# 50815-1151 - Added 3Way calling functions to Transfer-conf frame +# 50815-1602 - Added images and buttons for xfer functions +# 50816-1813 - Added basic autodial outbound call pickup functions +# 50817-1113 - Fixes to auto_dialing call receipt +# 50817-1234 - Added inbound call receipt capability +# 50817-1541 - Added customer time display +# 50817-1541 - Added customer time display +# 50818-1327 - Added stop-all-recordings-after-each-vicidial-call option +# 50818-1703 - Added pretty login section +# 50825-1200 - Modified form field lengths, added double-click dispositions +# 50831-1603 - Fixed customer time bug and fronter display bug for CLOSER +# 50901-1314 - Fixed CLOSER IN-GROUP Web Form bug +# 50903-0904 - Added preview-lead code for manual dialing +# 50904-0016 - Added ability to hangup manual dials before pickup +# 50906-1319 - Added override for filters on xfer calls, fixed login display bug +# 50909-1243 - Added hotkeys functionality for quick dispoing in auto-dial mode +# 50912-0958 - Modified hotkeys function, agent must have user_level >= 5 to use +# 50913-1212 - Added campaign_cid to 3rd party calls +# 50923-1546 - Modified to work with language translation +# 50926-1656 - Added campaign pull-down at login of active campaigns +# 50928-1633 - Added manual dial alternate number dial option +# 50930-1538 - Added session_id empty login failure and fixed 2 minor bugs +# 51004-1656 - Fixed recording filename bug and new Spanish translation +# 51020-1103 - Added campaign-specific recording control abilities +# 51020-1352 - Added Basic vicidial_agent_log framework +# 51021-1050 - Fixed custtime display and disable Enter/Return keypresses +# 51021-1718 - Allows for multi-line comments (changes \n to !N in database) +# 51110-1432 - Fixed non-standard http port issue +# 51111-1047 - Added vicidial_agent_log lead_id earlier for manual dial +# 51118-1305 - Activate multi-line comments from $multi_line_comments var +# 51118-1313 - Move Transfer DIV to a floating span to preserve 800x600 view +# 51121-1506 - Small PHP optimizations in many scripts and disabled globalize +# 51129-1010 - Added ability to accept calls from other VICIDIAL servers +# 51129-1254 - Fixed Hangups of other agents channels when customer hangs up +# 51208-1732 - Created user-first login that looks for default phone info +# 51219-1526 - Added variable framework for campaign and in-group scripts +# 51221-1200 - Added SCRIPT tab, layout and functionality +# 51221-1714 - Added auto-switch-to-SCRIPT-tab and auto-webform-popup +# 51222-1605 - Added VMail message blind transfer button to xfer-conf frame +# 51229-1028 - Added checks on web_form_address to allow for var in the DB value +# 60117-1312 - Added Transfer-conf frame toggle on button press +# 60208-1152 - Added DTMF-xfernumber preset links to xfer-conf frame +# 60213-1129 - Added vicidial_users.hotkeys_active for any user hotkeys +# 60213-1210 - Added ability to sort routing of calls by user_level +# 60214-0932 - Initial Callback calendar display framework +# 60214-1407 - Added ability to minimize the dispo screen to see info below +# 60215-1104 - Added ANYONE scheduled callbacks functionality +# 60410-1116 - Added persistant pause after dispo option and change dispo text +# - Added web form submit that opens new window with dispo on submit +# - Added PREVIOUS CALLBACK in customer info to flag callbacks +# - Added link to try to hangup the call again in the dispo screen +# - Added link noone-in-session screen to call agent phone again +# - Added link customer-hungup screen to go straight to dispo screen +# 60410-1532 - Added agent status and campaign calls dialing display option +# 60411-1547 - Add ability to set callback as USERONLY and some basic formatting +# 60413-1752 - Add basic USERONLY callback frame and listings +# 60414-1039 - Changed manual dial preview and alt dial checkboxes to spans +# - Added beta-level USERONLY callback functionality +# - Added beta-level manual dialing with lead insertion functionality +# 60415-1534 - Fixed manual dial lead preview and fixed manuald dial override bug +# 60417-1108 - Added capability to do alt-number-dialing in auto-dial mode +# - Changed several permissions to database-defined +# 60419-1529 - Prevent manual dial or callbacks when alt-dial lead not finished +# 60420-1647 - Fixed DiaLDiaLAltPhonE error, Call Agent Again DialControl error +# 60421-1229 - Check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60424-1005 - Fixed Alt phone disabled bug for callbacks and manual dials +# 60426-1058 - Added vicidial_user setting for default blended check for CLOSER +# 60501-1008 - Added option to manual dial screen to manually lookup phone number +# 60503-1653 - Fixed agentonly_callback not-defined bug in scheduled callbacks screen +# 60504-1032 - Fixed manual dial display bug and transfer dispo alert bug +# - Fixed recording filename display to not overrun 25 characters +# 60510-1051 - Added Wrapup timer and wrapup message on wrapup screen after dispo +# 60608-1453 - Added CLOSER campaign allowable in-groups limitations +# 60609-1123 - Added add-number-to-DNC-list function and manual dial check DNC +# 60619-1047 - Added variable filters to close security holes for login form +# 60804-1710 - fixed scheduled CALLBK for other languages build +# 60808-1145 - Added consultative transfers with customer data +# 60808-2232 - Added campaign name to pulldown for login screen +# 60809-1603 - Added option to locally transfer consult xfers +# 60809-1732 - Added recheck of transferred channels before customer gone mesg +# 60810-1011 - Fixed CXFER leave 3way call bugs +# 60816-1602 - Added ALLCALLS recording delay option allcalls_delay +# 60816-1716 - Fixed customer time display bug and client DST setting +# 60821-1555 - Added option to omit phone_code on dialout of leads +# 60821-1628 - Added ALLFORCE recording option +# 60821-1643 - Added no_delete_sessions option to not delete sessions +# 60822-0512 - Changed phone number fields to be maxlength of 12 +# 60829-1531 - Made compatible with WeBRooTWritablE setting in dbconnect.php +# 60906-1152 - Added Previous CallBack info display span +# 60906-1715 - Allow for Local phone extension conferences +# 61004-1729 - Add ability to control volume per channel in "calls in this session" +# 61122-1341 - Added vicidial_user_groups allowed_campaigns restrictions +# 61122-1523 - Added more SCRIPT variables +# 61128-2229 - Added vicidial_live_agents and vicidial_auto_calls manual dial entries +# 61130-1617 - Added lead_id to MonitorConf for recording_log +# 61221-1212 - Changed width to 760 to better fit 800x600 screens, widened SCRIPT +# 70109-1128 - Fixed wrapup timer bug +# 70109-1635 - Added option for HotKeys automatically dialing next number in manual mode +# - Added option for alternate number dialing with hotkeys +# 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70118-1517 - Added vicidial_agent_log and vicidial_user_log logging of user_group +# 70201-1249 - Added FAST DIAL option for manually dialing, added UTF8 compatible code +# 70201-1703 - Fixed cursor bug for most text input fields +# 70202-1453 - Added first portions of Agent Pause Codes +# 70203-0108 - Finished Agent Pause Codes functionality +# 70203-0930 - Added dialed_number to webform output +# 70203-1010 - Added dialed_label to webform output +# 70206-1201 - Fixed allow_closers bug +# 70206-1332 - Added vicidial_recording_override users setting function +# 70212-1252 - Fixed small issue with CXFER +# 70213-1018 - Changed CXFER and AXFER to update customer information before transfer +# 70214-1233 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1240 - Added queuemetrics_log_id field for server_id in queue_log +# 70222-1617 - Changed queue_log PAUSE/UNPAUSE to PAUSEALL/UNPAUSEALL +# 70226-1252 - Added Mute/UnMute to agent screen +# 70309-1035 - Allow amphersands and questions marks in comments to pass through +# 70313-1052 - Allow pound signs(hash) in comments to pass through +# 70316-1406 - Moved the MUTE button to be accessible during a transfer/conf +# 70319-1446 - Added agent-deactive-display and disable customer info update functions +# 70319-1626 - Added option to allow agent logins to campaigns with no leads in the hopper +# 70320-1501 - Added option to allow retry of leave-3way-call from dispo screen +# 70322-1545 - Added sipsak display ability +# 70510-1319 - Added onUnload force Logout +# 70806-1530 - Added Presets Dial links above agent mute button +# 70823-2118 - Fixed XMLHTTPRequest, HotKeys and Scheduled Callbacks issues with MSIE +# 70828-1443 - Added source_id to output of SCRIPTtab-IFRAME and WEBFORM +# 71022-1427 - Added formatting of the customer phone number in the main status bar +# 71029-1848 - Changed CLOSER-type campaign to not use campaign_id restrictions +# 71101-1204 - Fixed bug in callback calendar with DST +# 71116-0957 - Added campaign_weight and calls_today to the vla table insertion +# 71120-1719 - Added XMLHTPRequest lookup of allowable campaigns for agents during login +# 71122-0256 - Added auto-pause notification +# 71125-1751 - Changed Transfer section to allow for selection of in-groups to send calls to +# 71127-0408 - Added height and width settings for easier modification of screen size +# 71129-2025 - restricted callbacks count and list to campaign only +# 71223-0318 - changed logging of closer calls +# 71226-1117 - added option to kick all calls from conference upon logout +# 80109-1510 - added gender select list +# 80116-1032 - added option on CLOSER-type campaigns to change in-groups when paused +# 80317-2106 - added recording override options for inbound group calls +# 80331-1433 - Added second transfer try for VICIDIAL transfers/hangups on manual dial calls +# 80402-0121 - Fixes for manual dial transfers on some systems +# 80407-2112 - Work on adding phone login load balancing across servers +# 80416-0559 - Added ability to log computer_ip at login, set the $PhoneSComPIP variable +# 80428-0413 - UTF8 changes and testing +# 80505-0054 - Added multi-phones load-balanced alias option +# 80507-0932 - Fixed Script display bug (+ instead of space) +# 80519-1425 - Added calls in queue display +# 80523-1630 - Added Timeclock links +# 80625-0047 - Added U option for gender, added date/phone display options +# 80630-2210 - Added queue_log entries for Manual Dial +# 80703-0139 - Added alter customer phone permissions +# 80703-1106 - Added API functionality for Hangup and Dispo, added Agent Display Queue Count +# 80707-2325 - Added vicidial_id to recording_log for tracking of vicidial or closer log to recording +# 80709-0358 - Added Default alt phone dial hard-code option +# 80719-1147 - Changed recording and senddtmf conf prefix +# 80815-1014 - Added manual dial list restriction option +# 80823-2123 - Fixed form scroll for IE, added copy to clipboard(IE-only feature) +# 80831-0548 - Added Extended alt-dial-phone display information for non-manual calls +# 80909-1717 - Added support for campaign-specific DNC lists +# 80915-1754 - Rewrote leave-3way functions for external calling +# 81002-1908 - Fixed double-login bug in some conditions +# 81007-0945 - Added three_way_call_cid option for outbound 3way calls +# 81010-1047 - Fixed conf calling prefix to use settings, other 3way improvements +# 81011-1403 - Fixed bugs in leave3way when transferring a manual dial call +# 81012-1729 - Added INBOUND_MAN dial method to allow manual list dialing and inbound calls +# 81013-1644 - Fixed bug in leave 3way for manual dial fronters +# 81015-0405 - Fixed bug related to hangups on 3way calls +# 81016-0703 - Changed leave 3way to allow function at any time transfer-conf is available +# 81020-1501 - Fixed bugs in queue_log logging +# 81023-0411 - Added compatibility for dial-in agents using AGI, bug fixes +# 81030-0403 - Added option to force Pause Codes on PAUSE +# 81103-1427 - Added 3way call dial prefix +# 81104-0140 - Added mysql error logging capability +# 81104-1618 - Changed MySQL queries logging +# 81106-0411 - Changedthe campaign login list behaviour +# 81110-0057 - Changed Pause time to start new vicidial_agent_log on every pause +# 81110-1514 - Added hangup_all_non_reserved to fix non-Hangup bug +# 81119-1811 - webform backslash fix +# 81124-2213 - Fixes blind transfer bug +# 81209-1617 - Added campaign web form target option and web form address variables +# 81211-0422 - Fixed Manual dial agent_log bug +# 90102-1402 - Added time sync check notification +# 90115-0619 - Added ability to send Local Closer to AGENTDIRECT agent_only +# 90120-1719 - Added API pause/resume and number dial functionality +# 90126-2302 - Added Vtiger login option and agent alert option +# 90128-0230 - Added vendor_lead_code to API dial and manuald dial with lookup +# 90202-0148 - Added option to disable BLENDED checkbox +# 90209-0132 - Changed tab images and color scheme +# 90303-1145 - Fixed rare manual dial live hangup bug +# 90304-1333 - Added user-specific web vars option +# 90305-0917 - Added prefix-choice and group-alias options for calls coming from API +# 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time +# + +$version = '2.0.5-202'; +$build = '90320-0309'; +$mel=1; # Mysql Error Log enabled = 1 +$mysql_log_count=60; +$one_mysql_log=0; + +require("dbconnect.php"); + +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["phone_login"])) {$phone_login=$_GET["phone_login"];} + elseif (isset($_POST["phone_login"])) {$phone_login=$_POST["phone_login"];} +if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} + elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VD_login"])) {$VD_login=$_GET["VD_login"];} + elseif (isset($_POST["VD_login"])) {$VD_login=$_POST["VD_login"];} +if (isset($_GET["VD_pass"])) {$VD_pass=$_GET["VD_pass"];} + elseif (isset($_POST["VD_pass"])) {$VD_pass=$_POST["VD_pass"];} +if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign"];} + elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} +if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} + elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} +if (isset($_GET["MGR_override"])) {$MGR_override=$_GET["MGR_override"];} + elseif (isset($_POST["MGR_override"])) {$MGR_override=$_POST["MGR_override"];} + if (!isset($phone_login)) + { + if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} + elseif (isset($_POST["pl"])) {$phone_login=$_POST["pl"];} + } + if (!isset($phone_pass)) + { + if (isset($_GET["pp"])) {$phone_pass=$_GET["pp"];} + elseif (isset($_POST["pp"])) {$phone_pass=$_POST["pp"];} + } + if (isset($VD_campaign)) + { + $VD_campaign = strtoupper($VD_campaign); + $VD_campaign = eregi_replace(" ",'',$VD_campaign); + } + if (!isset($flag_channels)) + { + $flag_channels=0; + $flag_string=''; + } + +### security strip all non-alphanumeric characters out of the variables ### + $DB=ereg_replace("[^0-9a-z]","",$DB); + $phone_login=ereg_replace("[^\,0-9a-zA-Z]","",$phone_login); + $phone_pass=ereg_replace("[^0-9a-zA-Z]","",$phone_pass); + $VD_login=ereg_replace("[^0-9a-zA-Z]","",$VD_login); + $VD_pass=ereg_replace("[^0-9a-zA-Z]","",$VD_pass); + $VD_campaign = ereg_replace("[^-\_0-9a-zA-Z]","",$VD_campaign); + + +$forever_stop=0; + +if ($force_logout) +{ + echo "Вы вышли из системы. Спасибо\n"; + exit; +} + +$isdst = date("I"); +$StarTtimE = date("U"); +$NOW_TIME = date("Y-m-d H:i:s"); +$tsNOW_TIME = date("YmdHis"); +$FILE_TIME = date("Ymd-His"); +$loginDATE = date("Ymd"); +$CIDdate = date("ymdHis"); + $month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y")); + $past_month_date = date("Y-m-d H:i:s",$month_old); + $minutes_old = mktime(date("H"), date("i")-2, date("s"), date("m"), date("d"), date("Y")); + $past_minutes_date = date("Y-m-d H:i:s",$minutes_old); + + +$random = (rand(1000000, 9999999) + 10000000); + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,webroot_writable,timeclock_end_of_day,vtiger_url,enable_vtiger_integration,outbound_autodial_active FROM system_settings;"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01001',$VD_login,$server_ip,$session_name,$one_mysql_log);} +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +$i=0; +while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $vdc_header_date_format = $row[1]; + $vdc_customer_date_format = $row[2]; + $vdc_header_phone_format = $row[3]; + $WeBRooTWritablE = $row[4]; + $timeclock_end_of_day = $row[5]; + $vtiger_url = $row[6]; + $enable_vtiger_integration = $row[7]; + $outbound_autodial_active = $row[8]; + + $i++; + } +##### END SETTINGS LOOKUP ##### +########################################### + + +##### DEFINABLE SETTINGS AND OPTIONS +########################################### +$conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording +$dtmf_silent_prefix = '7'; # vicidial_conferences prefix to enter silently +$HKuser_level = '5'; # minimum vicidial user_level for HotKeys +$campaign_login_list = '1'; # show drop-down list of campaigns at login +$manual_dial_preview = '1'; # allow preview lead option when manual dial +$multi_line_comments = '1'; # set to 1 to allow multi-line comment box +$user_login_first = '0'; # set to 1 to have the vicidial_user login before the phone login +$view_scripts = '1'; # set to 1 to show the SCRIPTS tab +$dispo_check_all_pause = '0'; # set to 1 to allow for persistent pause after dispo +$callholdstatus = '1'; # set to 1 to show calls на hold count +$agentcallsstatus = '0'; # set to 1 to show agent status and call dialed count + $campagentstatctmax = '3'; # Number of секунды for campaign call and agent stats +$show_campname_pulldown = '1'; # set to 1 to show campaign name на login pulldown +$webform_sessionname = '1'; # set to 1 to include the session_name in webform URL +$local_consult_xfers = '1'; # set to 1 to send consultative transfers from original server +$clientDST = '1'; # set to 1 to check for DST на server for agent time +$no_delete_sessions = '0'; # set to 1 to not delete sessions at logout +$volumecontrol_active = '1'; # set to 1 to allow agents to alter volume of channels +$PreseT_DiaL_LinKs = '0'; # set to 1 to show a НАБОР НОМЕРА link for Dial Presets +$LogiNAJAX = '1'; # set to 1 to do lookups на campaigns for login +$HidEMonitoRSessionS = '1'; # set to 1 to hide remote monitoring channels from "session calls" +$hangup_all_non_reserved= '1'; # set to 1 to force hangup all non-reserved channels upon Разъединить Клиента +$LogouTKicKAlL = '1'; # set to 1 to hangup all calls in session upon agent logout +$ТелефонSComPIP = '1'; # set to 1 to log computer IP to phone if blank, set to 2 to force log each login +$DefaulTAlTDiaL = '0'; # set to 1 to enable ALT НАБОР НОМЕРА by default if enabled for the campaign +$AgentAlert_allowed = '1'; # set to 1 to allow Agent alert option +$disable_blended_checkbox='0'; # set to 1 to disable the BLENDED checkbox from the in-group chooser screen + +$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen + +$BROWSER_HEIGHT = 500; # set to the minimum browser height, default=500 +$BROWSER_WIDTH = 770; # set to the minimum browser width, default=770 +$MAIN_COLOR = '#CCCCCC'; # old default is E0C2D6 +$SCRIPT_COLOR = '#E6E6E6'; # old default is FFE7D0 + +# options now set in DB: +#$alt_phone_dialing = '1'; # allow agents to call alt phone numbers +#$scheduled_callbacks = '1'; # set to 1 to allow agent to choose scheduled callbacks +# $agentonly_callbacks = '1'; # set to 1 to allow agent to choose agent-only scheduled callbacks +#$agentcall_manual = '1'; # set to 1 to allow agent to make manual calls during autodial session + +### SCREEN WIDTH AND HEIGHT CALCULATIONS ### +### DO NOT EDIT! ### +$MASTERwidth=($BROWSER_WIDTH - 340); +$MASTERheight=($BROWSER_HEIGHT - 200); +if ($MASTERwidth < 430) {$MASTERwidth = '430';} +if ($MASTERheight < 300) {$MASTERheight = '300';} + +$CAwidth = ($MASTERwidth + 340); # 770 - cover all (none-in-session, customer hunngup, etc...) +$MNwidth = ($MASTERwidth + 330); # 760 - main frame +$XFwidth = ($MASTERwidth + 320); # 750 - transfer/conference +$HCwidth = ($MASTERwidth + 310); # 740 - hotkeys and callbacks +$AMwidth = ($MASTERwidth + 270); # 700 - agent mute and preset-dial links +$SCwidth = ($MASTERwidth + 230); # 670 - live call секунды counter +$SSwidth = ($MASTERwidth + 176); # 606 - scroll script +$SDwidth = ($MASTERwidth + 170); # 600 - scroll script, customer data and calls-in-session +$HKwidth = ($MASTERwidth + 70); # 500 - Hotkeys button +$HSwidth = ($MASTERwidth + 1); # 431 - Header spacer + +$HKheight = ($MASTERheight + 105); # 405 - HotKey active Button +$AMheight = ($MASTERheight + 100); # 400 - Agent mute and preset dial links +$MBheight = ($MASTERheight + 65); # 365 - Manual Dial Buttons +$CBheight = ($MASTERheight + 50); # 350 - Agent Callback, pause code, volume control Buttons and agent status +$SSheight = ($MASTERheight + 31); # 331 - script content +$HTheight = ($MASTERheight + 10); # 310 - transfer frame, callback comments and hotkey +$BPheight = ($MASTERheight - 250); # 50 - bottom buffer + + +$US='_'; +$CL=':'; +$AT='@'; +$DS='-'; +$date = date("r"); +$ip = getenv("REMOTE_ADDR"); +$browser = getenv("HTTP_USER_AGENT"); +$script_name = getenv("SCRIPT_NAME"); +$server_name = getenv("SERVER_NAME"); +$server_port = getenv("SERVER_PORT"); +if (eregi("443",$server_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($server_port == '80') or ($server_port == '443') ) {$server_port='';} +else {$server_port = "$CL$server_port";} +$agcPAGE = "$HTTPprotocol$server_name$server_port$script_name"; +$agcDIR = eregi_replace('vicidial.php','',$agcPAGE); + +header ("Content-type: text/html; charset=utf-8"); +header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 +header ("Pragma: no-cache"); // HTTP/1.0 +echo "\n"; +echo "\n"; +echo "\n"; + +if ($campaign_login_list > 0) +{ +$camp_form_code = "\n"; +} +else +{ +$camp_form_code = "\n"; +} + + +if ($LogiNAJAX > 0) +{ +?> + + + +web-клиент VICIНАБОР НОМЕРА: Re-Логин\n"; +echo "\n"; +echo "\n"; +echo "Timeclock
\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Russian
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Re-Логин
 
Логин Телефона:
Пароль Телефона:
Логин Пользователя:
Пароль Пользователя:
Кампания: $camp_form_code
  \n"; +echo "

ВЕРСИЯ: $version       СБОРКА: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} + +if ($user_login_first == 1) +{ + if ( (strlen($VD_login)<1) or (strlen($VD_pass)<1) or (strlen($VD_campaign)<1) ) + { + echo "web-клиент VICIНАБОР НОМЕРА: Логин Кампании\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + #echo "\n"; + #echo "\n"; + echo "

Логин Пользователя

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин Кампании
 
Логин Пользователя:
Пароль Пользователя:
Кампания: $camp_form_code
  \n"; + echo "

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + else + { + if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) + { + $stmt="SELECT phone_login,phone_pass from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01005',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $phone_login=$row[0]; + $phone_pass=$row[1]; + + echo "web-клиент VICIНАБОР НОМЕРА: Логин\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин
 
Логин Телефона:
Пароль Телефона:
Логин Пользователя:
Пароль Пользователя:
Кампания: $camp_form_code
  \n"; + echo "

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + + } + } +} + +if ( (strlen($phone_login)<2) or (strlen($phone_pass)<2) ) +{ +echo "web-клиент VICIНАБОР НОМЕРА: Логин Телефона\n"; +echo "\n"; +echo "\n"; +echo "Timeclock
\n"; +echo "\n"; +echo "\n"; +echo "\n";echo "\n";echo "
English Russian
\n"; +echo "
\n"; +echo "\n"; +echo "


"; +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Логин Телефона
 
Логин Телефона:
Пароль Телефона:
  \n"; +echo "

ВЕРСИЯ: $version       СБОРКА: $build
\n"; +echo "\n\n"; +echo "\n\n"; +echo "\n\n"; +exit; +} +else +{ +if ($WeBRooTWritablE > 0) + {$fp = fopen ("./vicidial_auth_entries.txt", "a");} +$VDloginDISPLAY=0; + + if ( (strlen($VD_login)<2) or (strlen($VD_pass)<2) or (strlen($VD_campaign)<2) ) + { + $VDloginDISPLAY=1; + } + else + { + $stmt="SELECT count(*) from vicidial_users where user='$VD_login' and pass='$VD_pass' and user_level > 0 and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01006',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if($auth>0) + { + $login=strtoupper($VD_login); + $password=strtoupper($VD_pass); + ##### grab the full name of the agent + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $user_level = $row[1]; + $VU_hotkeys_active = $row[2]; + $VU_agent_choose_ingroups = $row[3]; + $VU_scheduled_callbacks = $row[4]; + $agentonly_callbacks = $row[5]; + $agentcall_manual = $row[6]; + $VU_vicidial_recording = $row[7]; + $VU_vicidial_transfers = $row[8]; + $VU_closer_default_blended = $row[9]; + $VU_user_group = $row[10]; + $VU_vicidial_recording_override = $row[11]; + $VU_alter_custphone_override = $row[12]; + $VU_alert_enabled = $row[13]; + $VU_agent_shift_enforcement_override = $row[14]; + $VU_shift_override_flag = $row[15]; + + if ($VU_alert_enabled > 0) {$VU_alert_enabled = 'ON';} + else {$VU_alert_enabled = 'OFF';} + + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01052',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $forced_timeclock_login = $row[0]; + $shift_enforcement = $row[1]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[2]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + + ### BEGIN - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + if ( (ereg('Y',$forced_timeclock_login)) or ( (ereg('ADMIN_EXEMPT',$forced_timeclock_login)) and ($VU_user_level < 8) ) ) + { + $last_agent_event=''; + $HHMM = date("Hi"); + $HHteod = substr($timeclock_end_of_day,0,2); + $MMteod = substr($timeclock_end_of_day,2,2); + + if ($HHMM < $timeclock_end_of_day) + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d")-1, date("Y"));} + else + {$EoD = mktime($HHteod, $MMteod, 10, date("m"), date("d"), date("Y"));} + + $EoDdate = date("Y-m-d H:i:s", $EoD); + + ##### grab timeclock logged-in time for each user ##### + $stmt="SELECT event from vicidial_timeclock_log where user='$VD_login' and event_epoch >= '$EoD' order by timeclock_id desc limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01053',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $events_to_parse = mysql_num_rows($rslt); + if ($events_to_parse > 0) + { + $rowx=mysql_fetch_row($rslt); + $last_agent_event = $rowx[0]; + } + if ($DB>0) {echo "|$stmt|$events_to_parse|$last_agent_event|";} + if ( (strlen($last_agent_event)<2) or (ereg('ВЫХОД',$last_agent_event)) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Вы должны войти в систему TIMECLOCK ПЕРВЫЙ
"; + } + } + ### END - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + + ### BEGIN - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + if ( ( (ereg("СТАРТ|ALL",$shift_enforcement)) and (!ereg("OFF",$VU_agent_shift_enforcement_override)) ) or (ereg("СТАРТ|ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if ( (strlen($LOGgroup_shiftsSQL) < 3) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ОШИБКА: Есть сдвиги не включена для пользователя группы
"; + } + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01056',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ОШИБКА: Вы не можете войти в вашу за переход
"; + } + } + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) and ($VDloginDISPLAY > 0) ) + { + $VDdisplayMESSAGE.= "

МЕНЕДЖЕР Переопределить:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "Manager Логин:
\n"; + $VDdisplayMESSAGE.= "Manager Пароль:
\n"; + $VDdisplayMESSAGE.= "
\n"; + } + } + ### END - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + + + + + + + + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "vdweb|GOOD|$date|$VD_login|$VD_pass|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } + $user_abb = "$VD_login$VD_login$VD_login$VD_login"; + while ( (strlen($user_abb) > 4) and ($forever_stop < 200) ) + {$user_abb = eregi_replace("^.","",$user_abb); $forever_stop++;} + + $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01008',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $LOGallowed_campaigns =$row[0]; + + if ( (!eregi(" $VD_campaign ",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAIGNS",$LOGallowed_campaigns)) ) + { + echo "web-клиент VICIНАБОР НОМЕРА: VICIНАБОР НОМЕРА Логин Кампании\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "Sorry, you are not allowed to login to this campaign: $VD_campaign\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Логин: \n
"; + echo "Пароль:
\n"; + echo "Кампания: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + ##### check to see that the campaign is active + $stmt="SELECT count(*) FROM vicidial_campaigns where campaign_id='$VD_campaign' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01009',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $CAMPactive=$row[0]; + if($CAMPactive>0) + { + if ($TEST_all_statuses > 0) {$selectableSQL = '';} + else {$selectableSQL = "selectable='Y' and";} + $VARstatuses=''; + $VARstatusnames=''; + ##### grab the statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_statuses WHERE $selectableSQL status != 'NEW' order by status limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01010',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_statuses_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $VD_statuses_ct) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + } + + ##### grab the campaign-specific statuses that can be used for dispositioning by an agent + $stmt="SELECT status,status_name FROM vicidial_campaign_statuses WHERE $selectableSQL status != 'NEW' and campaign_id='$VD_campaign' order by status limit 80;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01011',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_statuses_camp = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $statuses[$i] =$row[0]; + $status_names[$i] =$row[1]; + $VARstatuses = "$VARstatuses'$statuses[$i]',"; + $VARstatusnames = "$VARstatusnames'$status_names[$i]',"; + $i++; + $j++; + } + $VD_statuses_ct = ($VD_statuses_ct+$VD_statuses_camp); + $VARstatuses = substr("$VARstatuses", 0, -1); + $VARstatusnames = substr("$VARstatusnames", 0, -1); + + ##### grab the campaign-specific HotKey statuses that can be used for dispositioning by an agent + $stmt="SELECT hotkey,status,status_name FROM vicidial_campaign_hotkeys WHERE selectable='Y' and status != 'NEW' and campaign_id='$VD_campaign' order by hotkey limit 9;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01012',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $HK_statuses_camp = mysql_num_rows($rslt); + $w=0; + $HKboxA=''; + $HKboxB=''; + $HKboxC=''; + while ($w < $HK_statuses_camp) + { + $row=mysql_fetch_row($rslt); + $HKhotkey[$w] =$row[0]; + $HKstatus[$w] =$row[1]; + $HKstatus_name[$w] =$row[2]; + $HKhotkeys = "$HKhotkeys'$HKhotkey[$w]',"; + $HKstatuses = "$HKstatuses'$HKstatus[$w]',"; + $HKstatusnames = "$HKstatusnames'$HKstatus_name[$w]',"; + if ($w < 3) + {$HKboxA = "$HKboxA $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ( ($w >= 3) and ($w < 6) ) + {$HKboxB = "$HKboxB $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + if ($w >= 6) + {$HKboxC = "$HKboxC $HKhotkey[$w] - $HKstatus[$w] - $HKstatus_name[$w]
";} + $w++; + } + $HKhotkeys = substr("$HKhotkeys", 0, -1); + $HKstatuses = substr("$HKstatuses", 0, -1); + $HKstatusnames = substr("$HKstatusnames", 0, -1); + + ##### grab the campaign settings + $stmt="SELECT park_ext,park_file_name,web_form_address,allow_closers,auto_dial_level,dial_timeout,dial_prefix,campaign_cid,campaign_vdad_exten,campaign_rec_exten,campaign_recording,campaign_rec_filename,campaign_script,get_call_launch,am_message_exten,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number,alt_number_dialing,scheduled_callbacks,wrapup_seconds,wrapup_message,closer_campaigns,use_internal_dnc,allcalls_delay,omit_phone_code,agent_pause_codes_active,no_hopper_leads_logins,campaign_allow_inbound,manual_dial_list_id,default_xfer_group,xfer_groups,disable_alter_custphone,display_queue_count,manual_dial_filter,agent_clipboard_copy,use_campaign_dnc,three_way_call_cid,dial_method,three_way_dial_prefix,web_form_target,vtiger_screen_login,agent_allow_group_alias,default_group_alias FROM vicidial_campaigns where campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01013',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $park_ext = $row[0]; + $park_file_name = $row[1]; + $web_form_address = stripslashes($row[2]); + $allow_closers = $row[3]; + $auto_dial_level = $row[4]; + $dial_timeout = $row[5]; + $dial_prefix = $row[6]; + $campaign_cid = $row[7]; + $campaign_vdad_exten = $row[8]; + $campaign_rec_exten = $row[9]; + $campaign_recording = $row[10]; + $campaign_rec_filename = $row[11]; + $campaign_script = $row[12]; + $get_call_launch = $row[13]; + $campaign_am_message_exten = $row[14]; + $xferconf_a_dtmf = $row[15]; + $xferconf_a_number = $row[16]; + $xferconf_b_dtmf = $row[17]; + $xferconf_b_number = $row[18]; + $alt_number_dialing = $row[19]; + $VC_scheduled_callbacks = $row[20]; + $wrapup_секунды = $row[21]; + $wrapup_message = $row[22]; + $closer_campaigns = $row[23]; + $use_internal_dnc = $row[24]; + $allcalls_delay = $row[25]; + $omit_phone_code = $row[26]; + $agent_pause_codes_active = $row[27]; + $no_hopper_leads_logins = $row[28]; + $campaign_allow_inbound = $row[29]; + $manual_dial_list_id = $row[30]; + $default_xfer_group = $row[31]; + $xfer_groups = $row[32]; + $disable_alter_custphone = $row[33]; + $display_queue_count = $row[34]; + $manual_dial_filter = $row[35]; + $CopY_tO_ClipboarD = $row[36]; + $use_campaign_dnc = $row[37]; + $three_way_call_cid = $row[38]; + $dial_method = $row[39]; + $three_way_dial_prefix = $row[40]; + $web_form_target = $row[41]; + $vtiger_screen_login = $row[42]; + $agent_allow_group_alias = $row[43]; + $default_group_alias = $row[44]; + + $default_group_alias_cid=''; + if (strlen($default_group_alias)>1) + { + $stmt = "select caller_id_number from groups_alias where group_alias_id='$default_group_alias';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01055',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidnum_ct = mysql_num_rows($rslt); + if ($VDIG_cidnum_ct > 0) + { + $row=mysql_fetch_row($rslt); + $default_group_alias_cid = $row[0]; + } + } + + $stmt = "select group_web_vars from vicidial_campaign_agents where campaign_id='$VD_campaign' and user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01056',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidogwv = mysql_num_rows($rslt); + if ($VDIG_cidogwv > 0) + { + $row=mysql_fetch_row($rslt); + $default_web_vars = $row[0]; + } + + if ( (!ereg('DISABLED',$VU_vicidial_recording_override)) and ($VU_vicidial_recording > 0) ) + { + $campaign_recording = $VU_vicidial_recording_override; + print "\n"; + } + if ( ($VC_scheduled_callbacks=='Y') and ($VU_scheduled_callbacks=='1') ) + {$scheduled_callbacks='1';} + if ($VU_vicidial_recording=='0') + {$campaign_recording='NEVER';} + if ($VU_alter_custphone_override=='ALLOW_ALTER') + {$disable_alter_custphone='N';} + if (strlen($three_way_dial_prefix) < 1) + {$three_way_dial_prefix = $dial_prefix ;} + if ($alt_number_dialing=='Y') + {$alt_phone_dialing='1';} + else + { + $alt_phone_dialing='0'; + $DefaulTAlTDiaL='0'; + } + if ($display_queue_count=='N') + {$callholdstatus='0';} + if ( ($dial_method == 'INBOUND_MAN') or ($outbound_autodial_active < 1) ) + {$VU_closer_default_blended=0;} + + $closer_campaigns = preg_replace("/^ | -$/","",$closer_campaigns); + $closer_campaigns = preg_replace("/ /","','",$closer_campaigns); + $closer_campaigns = "'$closer_campaigns'"; + + if ( (ereg('Y',$agent_pause_codes_active)) or (ereg('FORCE',$agent_pause_codes_active)) ) + { + ##### grab the pause codes for this campaign + $stmt="SELECT pause_code,pause_code_name FROM vicidial_pause_codes WHERE campaign_id='$VD_campaign' order by pause_code limit 50;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01014',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_pause_codes = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_pause_codes) + { + $row=mysql_fetch_row($rslt); + $pause_codes[$i] =$row[0]; + $pause_code_names[$i] =$row[1]; + $VARpause_codes = "$VARpause_codes'$pause_codes[$i]',"; + $VARpause_code_names = "$VARpause_code_names'$pause_code_names[$i]',"; + $i++; + $j++; + } + $VD_pause_codes_ct = ($VD_pause_codes_ct+$VD_pause_codes); + $VARpause_codes = substr("$VARpause_codes", 0, -1); + $VARpause_code_names = substr("$VARpause_code_names", 0, -1); + } + + ##### grab the inbound groups to choose from if campaign contains CLOSER + $VARingroups="''"; + if ($campaign_allow_inbound == 'Y') + { + $VARingroups=''; + $stmt="select group_id from vicidial_inbound_groups where active = 'Y' and group_id IN($closer_campaigns) order by group_id limit 60;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01015',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $closer_ct = mysql_num_rows($rslt); + $INgrpCT=0; + while ($INgrpCT < $closer_ct) + { + $row=mysql_fetch_row($rslt); + $closer_groups[$INgrpCT] =$row[0]; + $VARingroups = "$VARingroups'$closer_groups[$INgrpCT]',"; + $INgrpCT++; + } + $VARingroups = substr("$VARingroups", 0, -1); + } + + ##### grab the allowable inbound groups to choose from for transfer options + $xfer_groups = preg_replace("/^ | -$/","",$xfer_groups); + $xfer_groups = preg_replace("/ /","','",$xfer_groups); + $xfer_groups = "'$xfer_groups'"; + $VARxfergroups="''"; + if ($allow_closers == 'Y') + { + $VARxfergroups=''; + $stmt="select group_id,group_name from vicidial_inbound_groups where active = 'Y' and group_id IN($xfer_groups) order by group_id limit 60;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01016',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $xfer_ct = mysql_num_rows($rslt); + $XFgrpCT=0; + while ($XFgrpCT < $xfer_ct) + { + $row=mysql_fetch_row($rslt); + $VARxfergroups = "$VARxfergroups'$row[0]',"; + $VARxfergroupsnames = "$VARxfergroupsnames'$row[1]',"; + if ($row[0] == "$default_xfer_group") {$default_xfer_group_name = $row[1];} + $XFgrpCT++; + } + $VARxfergroups = substr("$VARxfergroups", 0, -1); + $VARxfergroupsnames = substr("$VARxfergroupsnames", 0, -1); + } + + if (ereg('Y',$agent_allow_group_alias)) + { + ##### grab the active group aliases + $stmt="SELECT group_alias_id,group_alias_name,caller_id_number FROM groups_alias WHERE active='Y' order by group_alias_id limit 1000;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01054',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VD_group_aliases = mysql_num_rows($rslt); + $j=0; + while ($j < $VD_group_aliases) + { + $row=mysql_fetch_row($rslt); + $group_alias_id[$i] = $row[0]; + $group_alias_name[$i] = $row[1]; + $caller_id_number[$i] = $row[2]; + $VARgroup_alias_ids = "$VARgroup_alias_ids'$group_alias_id[$i]',"; + $VARgroup_alias_names = "$VARgroup_alias_names'$group_alias_name[$i]',"; + $VARcaller_id_numbers = "$VARcaller_id_numbers'$caller_id_number[$i]',"; + $i++; + $j++; + } + $VD_group_aliases_ct = ($VD_group_aliases_ct+$VD_group_aliases); + $VARgroup_alias_ids = substr("$VARgroup_alias_ids", 0, -1); + $VARgroup_alias_names = substr("$VARgroup_alias_names", 0, -1); + $VARcaller_id_numbers = substr("$VARcaller_id_numbers", 0, -1); + } + + ##### grab the number of leads in the hopper for this campaign + $stmt="SELECT count(*) FROM vicidial_hopper where campaign_id = '$VD_campaign' and status='READY';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01017',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_leads_to_call = $row[0]; + print "\n"; + + } + else + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Кампания не активна, пожалуйста, попробуйте еще раз
"; + } + } + else + { + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "vdweb|FAIL|$date|$VD_login|$VD_pass|$ip|$browser|\n"); + fclose($fp); + } + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "Логин неправильный, пожалуйста, попробуйте еще раз
"; + } + } + if ($VDloginDISPLAY) + { + echo "web-клиент VICIНАБОР НОМЕРА: Логин Кампании\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

$VDdisplayMESSAGE

"; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин Кампании
 
Логин Пользователя:
Пароль Пользователя:
Кампания: $camp_form_code
  \n"; + echo "

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + +# code for parsing load-balanced agent phone allocation where agent interface +# will send multiple phones-table logins so that the script can determine the +# server that has the fewest agents logged into it. +# login: ca101,cb101,cc101 + $alias_found=0; +$stmt="select count(*) from phones_alias where alias_id = '$phone_login';"; +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01018',$VD_login,$server_ip,$session_name,$one_mysql_log);} +$alias_ct = mysql_num_rows($rslt); +if ($alias_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alias_found = "$row[0]"; + } +if ($alias_found > 0) + { + $stmt="select alias_name,logins_list from phones_alias where alias_id = '$phone_login' limit 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01019',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $alias_ct = mysql_num_rows($rslt); + if ($alias_ct > 0) + { + $row=mysql_fetch_row($rslt); + $alias_name = "$row[0]"; + $phone_login = "$row[1]"; + } + } + +$pa=0; +if ( (eregi(',',$phone_login)) and (strlen($phone_login) > 2) ) + { + $phoneSQL = "("; + $phones_auto = explode(',',$phone_login); + $phones_auto_ct = count($phones_auto); + while($pa < $phones_auto_ct) + { + if ($pa > 0) + {$phoneSQL .= " or ";} + $desc = ($phones_auto_ct - $pa); # traverse in reverse order + $phoneSQL .= "(login='$phones_auto[$desc]' and pass='$phone_pass')"; + $pa++; + } + $phoneSQL .= ")"; + } +else {$phoneSQL = "login='$phone_login' and pass='$phone_pass'";} + +$authphone=0; +$stmt="SELECT count(*) from phones where $phoneSQL and active = 'Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01020',$VD_login,$server_ip,$session_name,$one_mysql_log);} +$row=mysql_fetch_row($rslt); +$authphone=$row[0]; +if (!$authphone) + { + echo "web-клиент VICIНАБОР НОМЕРА: Логин Телефона Error\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "


"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Логин Error
 
Извините, но ваш логин и пароль телефона не активен в этой системе. Пожалуйста, попробуйте еще раз:
 
Логин Телефона:
Пароль Телефона:

ВЕРСИЯ: $version       СБОРКА: $build
\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } +else + { +### go through the entered phones to figure out which server has fewest agents +### logged in and use that phone login account + if ($pa > 0) + { + $pb=0; + $pb_login=''; + $pb_server_ip=''; + $pb_count=0; + $pb_log=''; + while($pb < $phones_auto_ct) + { + ### find the server_ip of each phone_login + $stmtx="SELECT server_ip from phones where login = '$phones_auto[$pb]';"; + if ($DB) {echo "|$stmtx|\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmtx, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01021',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowx=mysql_fetch_row($rslt); + + ### get number of agents logged in to each server + $stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01022',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + + ### find out whether the server is set to active + $stmt="SELECT count(*) from servers where server_ip = '$rowx[0]' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowy=mysql_fetch_row($rslt); + + ### find out whether the server_updater is running + $stmt="SELECT count(*) from server_updater where server_ip = '$rowx[0]' and last_update > '$past_minutes_date';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01024',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $rowz=mysql_fetch_row($rslt); + + $pb_log .= "$phones_auto[$pb]|$rowx[0]|$row[0]|$rowy[0]|$rowz[0]| "; + + if ( ($rowy[0] > 0) && ($rowz[0] > 0) ) + { + if ( ($pb_count >= $row[0]) || (strlen($pb_server_ip) < 4) ) + { + $pb_count=$row[0]; + $pb_server_ip=$rowx[0]; + $phone_login=$phones_auto[$pb]; + } + } + $pb++; + } + echo "\n"; + } + echo "web-клиент VICIНАБОР НОМЕРА\n"; + $stmt="SELECT * from phones where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01025',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $extension=$row[0]; + $dialplan_number=$row[1]; + $voicemail_id=$row[2]; + $phone_ip=$row[3]; + $computer_ip=$row[4]; + $server_ip=$row[5]; + $login=$row[6]; + $pass=$row[7]; + $status=$row[8]; + $active=$row[9]; + $phone_type=$row[10]; + $fullname=$row[11]; + $company=$row[12]; + $picture=$row[13]; + $messages=$row[14]; + $old_messages=$row[15]; + $protocol=$row[16]; + $local_gmt=$row[17]; + $ASTmgrUSERNAME=$row[18]; + $ASTmgrSECRET=$row[19]; + $login_user=$row[20]; + $login_pass=$row[21]; + $login_campaign=$row[22]; + $park_on_extension=$row[23]; + $conf_on_extension=$row[24]; + $VICIDiaL_park_on_extension=$row[25]; + $VICIDiaL_park_on_filename=$row[26]; + $monitor_prefix=$row[27]; + $recording_exten=$row[28]; + $voicemail_exten=$row[29]; + $voicemail_dump_exten=$row[30]; + $ext_context=$row[31]; + $dtmf_send_extension=$row[32]; + $call_out_number_group=$row[33]; + $client_browser=$row[34]; + $install_directory=$row[35]; + $local_web_callerID_URL=$row[36]; + $VICIDiaL_web_URL=$row[37]; + $AGI_call_logging_enabled=$row[38]; + $user_switching_enabled=$row[39]; + $conferencing_enabled=$row[40]; + $admin_hangup_enabled=$row[41]; + $admin_hijack_enabled=$row[42]; + $admin_monitor_enabled=$row[43]; + $call_parking_enabled=$row[44]; + $updater_check_enabled=$row[45]; + $AFLogging_enabled=$row[46]; + $QUEUE_ACTION_enabled=$row[47]; + $ВызывающийID_popup_enabled=$row[48]; + $voicemail_button_enabled=$row[49]; + $enable_fast_refresh=$row[50]; + $fast_refresh_rate=$row[51]; + $enable_persistant_mysql=$row[52]; + $auto_dial_next_number=$row[53]; + $VDstop_rec_after_each_call=$row[54]; + $DBX_server=$row[55]; + $DBX_database=$row[56]; + $DBX_user=$row[57]; + $DBX_pass=$row[58]; + $DBX_port=$row[59]; + $outbound_cid=$row[65]; + $enable_sipsak_messages=$row[66]; + + if ($ТелефонSComPIP == '1') + { + if (strlen($computer_ip) < 4) + { + $stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01026',$VD_login,$server_ip,$session_name,$one_mysql_log);} + } + } + if ($ТелефонSComPIP == '2') + { + $stmt="UPDATE phones SET computer_ip='$ip' where login='$phone_login' and pass='$phone_pass' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01027',$VD_login,$server_ip,$session_name,$one_mysql_log);} + } + if ($clientDST) + { + $local_gmt = ($local_gmt + $isdst); + } + if ($protocol == 'EXTERNAL') + { + $protocol = 'Local'; + $extension = "$dialplan_number$AT$ext_context"; + } + $SIP_user = "$protocol/$extension"; + $SIP_user_DiaL = "$protocol/$extension"; + if ( (ereg('8300',$dialplan_number)) and (strlen($dialplan_number)<5) and ($protocol == 'Local') ) + { + $SIP_user = "$protocol/$extension$VD_login"; + } + + $stmt="SELECT asterisk_version from servers where server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $asterisk_version=$row[0]; + + # If a park extension is not set, use the default one + if ( (strlen($park_ext)>0) && (strlen($park_file_name)>0) ) + { + $VICIDiaL_park_on_extension = "$park_ext"; + $VICIDiaL_park_on_filename = "$park_file_name"; + print "\n"; + } + print "\n"; + + # If a web form address is not set, use the default one + if (strlen($web_form_address)>0) + { + $VICIDiaL_web_form_address = "$web_form_address"; + print "\n"; + } + else + { + $VICIDiaL_web_form_address = "$VICIDiaL_web_URL"; + print "\n"; + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + } + $VICIDiaL_web_form_address_enc = rawurlencode($VICIDiaL_web_form_address); + + # If closers are allowed на this campaign + if ($allow_closers=="Y") + { + $VICIDiaL_allow_closers = 1; + print "\n"; + } + else + { + $VICIDiaL_allow_closers = 0; + print "\n"; + } + + + $session_ext = eregi_replace("[^a-z0-9]", "", $extension); + if (strlen($session_ext) > 10) {$session_ext = substr($session_ext, 0, 10);} + $session_rand = (rand(1,9999999) + 10000000); + $session_name = "$StarTtimE$US$session_ext$session_rand"; + + if ($webform_sessionname) + {$webform_sessionname = "&session_name=$session_name";} + else + {$webform_sessionname = '';} + + $stmt="DELETE from web_client_sessions where start_time < '$past_month_date' and extension='$extension' and server_ip = '$server_ip' and program = 'vicidial';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01029',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + $stmt="INSERT INTO web_client_sessions values('$extension','$server_ip','vicidial','$NOW_TIME','$session_name');"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01030',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + if ( ($campaign_allow_inbound == 'Y') || ($campaign_leads_to_call > 0) || (ereg('Y',$no_hopper_leads_logins)) ) + { + ### insert an entry into the user log for the login event + $stmt = "INSERT INTO vicidial_user_log (user,event,campaign_id,event_date,event_epoch,user_group) values('$VD_login','LOGIN','$VD_campaign','$NOW_TIME','$StarTtimE','$VU_user_group')"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01031',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + ##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly + $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01032',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $prev_login_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $prev_login_ct) + { + $row=mysql_fetch_row($rslt); + $session_id =$row[0]; + $i++; + } + if ($prev_login_ct > 0) + {print "\n";} + else + { + ##### grab the next available vicidial_conference room and reserve it + $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null));"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt="UPDATE vicidial_conferences set extension='$SIP_user', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01034',$VD_login,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$user') );"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $session_id = $row[0]; + } + print "\n"; + } + + ### mark leads that were not dispositioned during previous calls as ERI + $stmt="UPDATE vicidial_list set status='ERI', user='' where status IN('QUEUE','INCALL') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01036',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_hopper where status IN('QUEUE','INCALL','DONE') and user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01037',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01038',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + $stmt="DELETE from vicidial_live_inbound_agents where user ='$VD_login';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01039',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + # print "You have logged in as user: $VD_login на phone: $SIP_user в кампанию: $VD_campaign
\n"; + $VICIDiaL_is_logged_in=1; + + ### set the callerID for manager middleware-app to connect the phone to the user + $SIqueryCID = "S$CIDdate$session_id"; + + ############################################# + ##### СТАРТ SYSTEM_SETTINGS LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,vicidial_agent_disable,allow_sipsak_messages FROM system_settings;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01040',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $vicidial_agent_disable = $row[6]; + $allow_sipsak_messages = $row[7]; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + + if ( ($enable_sipsak_messages > 0) and ($allow_sipsak_messages > 0) and (eregi("SIP",$protocol)) ) + { + $SIPSAK_prefix = 'LIN-'; + print "\n"; + passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$VD_campaign\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); + $SIqueryCID = "$SIPSAK_prefix$VD_campaign$DS$CIDdate"; + } + + ### insert a НОВЫЙ record to the vicidial_manager table to be processed + $stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $SIP_user_DiaL','Context: $ext_context','Exten: $session_id','Priority: 1','Callerid: $SIqueryCID','','','','','');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01041',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($auto_dial_level > 0) + { + print "\n"; + + ##### grab the campaign_weight and number of calls today на that campaign for the agent + $stmt="SELECT campaign_weight,calls_today FROM vicidial_campaign_agents where user='$VD_login' and campaign_id = '$VD_campaign';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01042',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vca_ct = mysql_num_rows($rslt); + if ($vca_ct > 0) + { + $row=mysql_fetch_row($rslt); + $campaign_weight = $row[0]; + $calls_today = $row[1]; + $i++; + } + else + { + $campaign_weight = '0'; + $calls_today = '0'; + $stmt="INSERT INTO vicidial_campaign_agents (user,campaign_id,campaign_rank,campaign_weight,calls_today) values('$VD_login','$VD_campaign','0','0','$calls_today');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01043',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + } + $closer_chooser_string=''; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01045',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + print "\n"; + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='ПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01046',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + print "\n"; + + mysql_close($linkB); + mysql_select_db("$VARDB_database", $link); + } + + + if ($campaign_allow_inbound == 'Y') + { + print "\n"; + } + } + else + { + print "\n"; + + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01047',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + print "\n"; + + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='$VD_campaign',agent='Agent/$VD_login',verb='AGENTLOGIN',data1='$VD_login@agents',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01048',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + print "\n"; + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtimE',call_id='NONE',queue='NONE',agent='Agent/$VD_login',verb='ПАУЗПАALL',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $linkB); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$linkB,$mel,$stmt,'01049',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($linkB); + print "\n"; + + mysql_close($linkB); + mysql_select_db("$VARDB_database", $link); + } + } + } + else + { + echo "web-клиент VICIНАБОР НОМЕРА: VICIНАБОР НОМЕРА Логин Кампании\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "Жаль, но leads нет в контейнере этой кампании\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Логин: \n
"; + echo "Пароль:
\n"; + echo "Кампания: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + if (strlen($session_id) < 1) + { + echo "web-клиент VICIНАБОР НОМЕРА: VICIНАБОР НОМЕРА Логин Кампании\n"; + echo "\n"; + echo "\n"; + echo "Timeclock
\n"; + echo "\n"; + echo "\n"; +echo "\n";echo "\n"; echo "
English Russian
\n"; + echo "Sorry, there are no available sessions\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Логин: \n
"; + echo "Пароль:
\n"; + echo "Кампания: $camp_form_code
\n"; + echo "   \n"; + echo "\n"; + echo "
\n\n"; + echo "\n\n"; + echo "\n\n"; + exit; + } + + if (ereg('MSIE',$browser)) + { + $useIE=1; + print "\n"; + } + else + { + $useIE=0; + print "\n"; + } + + $StarTtimE = date("U"); + $NOW_TIME = date("Y-m-d H:i:s"); + ##### Agent is going to log in so insert the vicidial_agent_log entry now + $stmt="INSERT INTO vicidial_agent_log (user,server_ip,event_time,campaign_id,pause_epoch,pause_sec,wait_epoch,user_group,sub_status) values('$VD_login','$server_ip','$NOW_TIME','$VD_campaign','$StarTtimE','0','$StarTtimE','$VU_user_group','LOGIN');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01050',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysql_affected_rows($link); + $agent_log_id = mysql_insert_id($link); + print "\n"; + + $stmt="UPDATE vicidial_users SET shift_override_flag='0' where user='$VD_login' and shift_override_flag='1';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01057',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VUaffected_rows = mysql_affected_rows($link); + + $S='*'; + $D_s_ip = explode('.', $server_ip); + if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[0])<3) {$D_s_ip[0] = "0$D_s_ip[0]";} + if (strlen($D_s_ip[1])<2) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[1])<3) {$D_s_ip[1] = "0$D_s_ip[1]";} + if (strlen($D_s_ip[2])<2) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[2])<3) {$D_s_ip[2] = "0$D_s_ip[2]";} + if (strlen($D_s_ip[3])<2) {$D_s_ip[3] = "0$D_s_ip[3]";} + if (strlen($D_s_ip[3])<3) {$D_s_ip[3] = "0$D_s_ip[3]";} + $server_ip_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; + + ##### grab the datails of all active scripts in the system + $stmt="SELECT script_id,script_name,script_text FROM vicidial_scripts WHERE active='Y' order by script_id limit 100;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01051',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $MM_scripts = mysql_num_rows($rslt); + $e=0; + while ($e < $MM_scripts) + { + $row=mysql_fetch_row($rslt); + $MMscriptid[$e] =$row[0]; + $MMscriptname[$e] = urlencode($row[1]); + $MMscripttext[$e] = urlencode($row[2]); + $MMscriptids = "$MMscriptids'$MMscriptid[$e]',"; + $MMscriptnames = "$MMscriptnames'$MMscriptname[$e]',"; + $MMscripttexts = "$MMscripttexts'$MMscripttext[$e]',"; + $e++; + } + $MMscriptids = substr("$MMscriptids", 0, -1); + $MMscriptnames = substr("$MMscriptnames", 0, -1); + $MMscripttexts = substr("$MMscripttexts", 0, -1); + + } +} + +################################################################ +### BEGIN - build the callback calendar (12 months) ### +################################################################ +define ('ADAY', (60*60*24)); +$CdayARY = getdate(); +$Cmon = $CdayARY['mon']; +$Cyear = $CdayARY['year']; +$CTODAY = date("Y-m"); +$CTODAYmday = date("j"); +$CINC=0; + +$Cmonths = Array('Январь','February','Март','Апрель','Май','Июнь', + 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'); +$Cdays = Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); + +$CCAL_OUT = ''; + +$CCAL_OUT .= ""; + +while ($CINC < 12) +{ +if ( ($CINC == 0) || ($CINC == 4) ||($CINC == 8) ) + {$CCAL_OUT .= "";} + +$CCAL_OUT .= ""; + +if ( ($CINC == 3) || ($CINC == 7) ||($CINC == 11) ) + {$CCAL_OUT .= "";} +$CINC++; +} + +$CCAL_OUT .= "
"; + +$CYyear = $Cyear; +$Cmonth= ($Cmon + $CINC); +if ($Cmonth > 12) + { + $Cmonth = ($Cmonth - 12); + $CYyear++; + } +$Cstart= mktime(11,0,0,$Cmonth,1,$CYyear); +$CfirstdayARY = getdate($Cstart); +#echo "|$Cmon|$Cmonth|$CINC|\n"; +$CPRNTDAY = date("Y-m", $Cstart); + +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; +$CCAL_OUT .= ""; + +foreach($Cdays as $Cday) +{ + $CDCLR="#ffffff"; +$CCAL_OUT .= ""; +} + +for( $Ccount=0;$Ccount<(6*7);$Ccount++) +{ + $Cdayarray = getdate($Cstart); + if((($Ccount) % 7) == 0) + { + if($Cdayarray['mon'] != $CfirstdayARY['mon']) + break; + $CCAL_OUT .= ""; + } + if($Ccount < $CfirstdayARY['wday'] || $Cdayarray['mon'] != $Cmonth) + { + $CCAL_OUT .= ""; + } + else + { + if( ($Cdayarray['mday'] == $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + else + { + $CDCLR="#ffffff"; + if ( ($Cdayarray['mday'] < $CTODAYmday) and ($CPRNTDAY == $CTODAY) ) + { + $CDCLR="#CCCCCC"; + $CBL = ''; + $CEL = ''; + } + else + { + $CPRNTmday = $Cdayarray['mday']; + if ($CPRNTmday < 10) {$CPRNTmday = "0$CPRNTmday";} + $CBL = ""; + $CEL = ""; + } + + $CCAL_OUT .= ""; + $Cstart += ADAY; + } + } +} +$CCAL_OUT .= ""; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$CfirstdayARY[month] $CfirstdayARY[year]"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "$Cday"; +$CCAL_OUT .= "
"; +$CCAL_OUT .= "
 "; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "$CBL$Cdayarray[mday]$CEL"; + $CCAL_OUT .= "
"; + $CCAL_OUT .= "
"; +$CCAL_OUT .= "
"; + +#echo "$CCAL_OUT\n"; +################################################################ +### END - build the callback calendar (12 months) ### +################################################################ + + +?> + + + + +\n"; + + +?> + +
+ + MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 VALIGN=TOP ALIGN=LEFT> +
+ + + +     + + 0) {echo "GROUPS     \n";} ?> +ВЫХОД\n"; ?> +
+
+ + + height=30> + + + + + +
VICIНАБОР НОМЕРАSCRIPT VALIGN=MIDDLE ALIGN=CENTER>   LIVE     ID сессии:     Живой Вызов
+
+ + + + + height=>

VICIНАБОР НОМЕРА
+
+ + +РУЧНОЙ НАБОР НОМЕРА       БЫСТРЫЙ НАБОР НОМЕРА
+
+ + +X АКТИВНЫЕ ВЫЗОВBACK
+
+ + +
+
+ + секунды: +     + + + + D1 - НАБОР НОМЕРА\n"; + echo "
\n"; + echo "D2 - НАБОР НОМЕРА\n"; + } + else {echo "
\n";} + ?> +

+
+
+ + + height=460>
ВЫЗОВBACK ДЛЯ ОПЕРАТОРА :
Чтобы позвонить клиенту сейчас, кликните на callback ниже. Если Вы нажмете на record ниже, чтобы позвонить, то это будет удалено из списка. +
+
+
  + Обновление +                 + Вернуться +
+
+ + + height=460>
НОВЫЙ LEAD РУЧНОЙ НАБОР НОМЕРА ДЛЯ :

Ведите информацию ниже для нового lead который вы хотите вызвать. +
+ \n"; + } + ?> + Note: all new manual dial leads will go into list

+ + + + + + + + + + + + + + + +
Код страны:   (Обычно 7 для России и некоторых стран СНГ)
Телефон Number: +   (12 digits max - digits only) +
Поиск Существующих Leads:   (Если эта опция выбрана, то будет предпринята попытка найти телефонный номер в системе, прежде чем вставить его как новый lead)
+

+     +
+

Если вы хотите набрать номер, но не добовлять новый lead, введите точный dialstring который вы хотите вызвать в поле Отмены Номера ниже. Для разъединения этого запроса вы должны будете открыть ссылку ЗАПРОСЫ В ЭТОЙ СЕССИИ внизу экрана, at the bottom of the screen and hang it up by clicking на its channel link there.
 
Отмененный набор номера:   (только цифры, пожалуйста) +
+
+ Новый Набор номера +                 + Предварительный Звоните +                 + Вернуться +
+
+ + + +
+
+ + + + +Ваш Статус:
Calls Dialing: +
+ + + + + > + +
+
+ + Перевод - Конференция            
+ + + ЛОКАЛЬНЫЙ CLOSER + Разъединение Xfer Линии + Разъединить Обе Линии + +
+ + Номер для вызова   + + НАБЕРИТЕ ОТМЕНУ   + ОСТАВИТЬ 3-WAY ЗАПРОС + Слепой Перевод Набора номера + D1 + D2 + +
+ + секунды   + channel + Набор номера С Клиентом + Парковать Набор номера Клиента + Blind Transfer VMail Message +
+
+
+
+ + + + height=70> + +
Lead Диспозицию как:

+ -
+
+
+ + + height=70> + + + + +
Горячие Клавиши Диспозиции: + Когда активно, просто нажмите клавишу желаемой диспозиции для этого запроса. Тогда запрос будет автоматически разъединен и dispositioned:
+ + + + + +
+
+ + + height=70> + + + + + + +
Предыдущая Информация о Callback: close
+
+
+
+
+ +
+
+ + + height=70> + + + + + + +
Расширенная информация Alt Телефон: минимизировать
+
+
+
+
+ +
+
+ + + + + +
максимизировать
Alt Телефон Info
+
+ + + height=500>
Никого нет в вашей сессии:
+ Вернуться +

+ Вызов Оператора Снова +
+
+ + + height=500>
Клиент разъединен:
+ Вернуться +

+ Конец и Вызов Диспозиции + +
+
+ + + height=550>
Call Wrapup: секунд осталось в wrapup

+ +

+ Финиш Wrapup и Переход + +
+
+ + + height=500>
Ваша сессия отключена
ВЫХОД

Вернуться +
+
+ + + height=500>
Существует проблема синхронизации времени с вашей системой, пожалуйста, сообщите об этом вашему системному администратору


Вернуться +
+
+ + + height=500>

ВЫХОД
+
+ + +
+
+ + +
 
+
+ + + height=47>
Any changes made to the customer information below at this time will not be comitted, You must change customer information before you Hangup the call.
+
+ + + height=460>
DISPOSITION ВЫЗОВ :       Разъединить Снова       минимизировать
+ Выбор Диспозиции End-of-call +
+ ПАУЗА ВЫЗОВА
+ ОЧИСТИТЬ ФОРМУ | + SUBMIT +

+ WEB FORM SUBMIT +

  +
+
+ + + height=460>
ВЫБЕРИТЕ КОД ПАУЗЫ :
+ Пауза Code Selection + +

  +
+
+ + + height=460>
ВЫБОР ГРУППЫ ALIAS :
+ Группа Alias выбора + +

  +
+
+ + + + + + height=460>
Выберите дату для CallBack :
+ + + Выберите Дату Ниже   +     + Hour: +   + Minutes: +   + +  
+ ТОЛЬКО МОИ ВЫЗОВBACK
";} + ?> + CB Комментарии:

+ + SUBMIT

+ +

  +
+
+ + + height=460>
ВЫБОР INBOUND ГРУППЫ CLOSER
+ Closer Inbound Group Selection +
+ 0) and ($disable_blended_checkbox < 1) ) + { + ?> + BLENDED ВЫЗОВING(исходящие активированы)
+ + RESET | + SUBMIT +



  +
+
+ + + + Канал + Канал + ТОЛЬКО МОИ ВЫЗОВBACK
";} + if ( ($outbound_autodial_active < 1) or ($disable_blended_checkbox > 0) ) + {echo " BLENDED ВЫЗОВING
";} + ?> +
+ + + + height=>
VICIНАБОР НОМЕРА SCRIPT
+
+ + + 0) && ( ($user_level>=$HKuser_level) or ($VU_hotkeys_active > 0) ) ) { ?> +НЕАКТИВНЫЕ ГОРЯЧИЕ КЛАВИШИ + + + + +> + + + + +
Версия web-клиента VICIНАБОР НОМЕРА:     СБОРКА:               Сервер:              
+Показать информацию о канале конференц-связи

 
+
+ 0) ) + {echo "Alert is ON";} +else + {echo "Alert is OFF";} +?> +
+ + + +
+
+ + + + + id="MainTable"> + + + + + + + + + + + + + + + +
СТАТУС:
+
+Набрать следующий номер
+ ПРЕДВАРИТЕЛЬНЫЙ ПРОСМОТР LEAD
+ НАБРАТЬ АЛЬТ. НОМЕР
+ + +ФАЙЛ ЗАПИСИ:
+
+
+ID ЗАПИСИ:
+
+ +Начать Запись
+
+Web Форма
+
+Парковать Вызов
+Перевод - Конференция
+
+Разъединить Клиента
+
+
Послать DTMF

+
+
+
align=left valign=top> + + + + + + + + + + +
+ + + + + + + +
  Customer Time:   Канал:
Информация Клиента:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title:   Имя:   MI:   Фамилия:
Адрес1:
Адрес2: Адрес3:
Город: Округ: Индекс:
Область/Край: ID Вендора: Пол:
Телефон: +                     "; + echo ""; + } +else + { + echo ""; + } +?> + +Код: Альт. Телефон:
Показать: Email:
Комментарии: + +\n";} +else + {echo "\n";} +?> + +
+
+ +
+
> + 
+ + + + + + + 0) or ($one_mysql_log > 0) ) + { + $errno = mysql_errno($link); + if ( ($errno > 0) or ($mel > 1) or ($one_mysql_log > 0) ) + { + $error = mysql_error($link); + $efp = fopen ("./vicidial_mysql_errors.txt", "a"); + fwrite ($efp, "$NOW_TIME|vicidial |$query_id|$errno|$error|$stmt|$user|$server_ip|$session_name|\n"); + fclose($efp); + } + } +$one_mysql_log=0; +return $errno; +} + +?> + + + + + diff --git a/LANG_www/agc_ru/voicemail_check.php b/LANG_www/agc_ru/voicemail_check.php new file mode 100644 index 00000000..cdef7060 --- /dev/null +++ b/LANG_www/agc_ru/voicemail_check.php @@ -0,0 +1,140 @@ + LICENSE: AGPLv2 +# +# This script is designed purely to check whether the voicemail box on the server defined has new and old messages +# This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table +# +# required variables: +# - $server_ip +# - $session_name +# - $user +# - $pass +# optional variables: +# - $format - ('text','debug') +# - $vmail_box - ('101','1234',...) +# +# +# changes +# 50422-1147 - First build of script +# 50503-1241 - added session_name checking for extra security +# 50711-1201 - removed HTTP authentication in favor of user/pass vars +# 60421-1147 - check GET/POST vars lines with isset to not trigger PHP NOTICES +# 60619-1204 - Added variable filters to close security holes for login form +# + +require("dbconnect.php"); + +### If you have globals turned off uncomment these lines +if (isset($_GET["user"])) {$user=$_GET["user"];} + elseif (isset($_POST["user"])) {$user=$_POST["user"];} +if (isset($_GET["pass"])) {$pass=$_GET["pass"];} + elseif (isset($_POST["pass"])) {$pass=$_POST["pass"];} +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["session_name"])) {$session_name=$_GET["session_name"];} + elseif (isset($_POST["session_name"])) {$session_name=$_POST["session_name"];} +if (isset($_GET["format"])) {$format=$_GET["format"];} + elseif (isset($_POST["format"])) {$format=$_POST["format"];} +if (isset($_GET["vmail_box"])) {$vmail_box=$_GET["vmail_box"];} + elseif (isset($_POST["vmail_box"])) {$vmail_box=$_POST["vmail_box"];} + +$user=ereg_replace("[^0-9a-zA-Z]","",$user); +$pass=ereg_replace("[^0-9a-zA-Z]","",$pass); + +# default optional vars if not set +if (!isset($format)) {$format="text";} + +$version = '0.0.5'; +$build = '60619-1204'; +$StarTtime = date("U"); +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} + + $stmt="SELECT count(*) from vicidial_users where user='$user' and pass='$pass' and user_level > 0;"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $auth=$row[0]; + + if( (strlen($user)<2) or (strlen($pass)<2) or ($auth==0)) + { + echo "Недопустимо Пользовательname/Пароль: |$user|$pass|\n"; + exit; + } + else + { + + if( (strlen($server_ip)<6) or (!isset($server_ip)) or ( (strlen($session_name)<12) or (!isset($session_name)) ) ) + { + echo "Недопустимо server_ip: |$server_ip| or Недопустимо session_name: |$session_name|\n"; + exit; + } + else + { + $stmt="SELECT count(*) from web_client_sessions where session_name='$session_name' and server_ip='$server_ip';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $SNauth=$row[0]; + if($SNauth==0) + { + echo "Недопустимо session_name: |$session_name|$server_ip|\n"; + exit; + } + else + { + # do nothing for now + } + } + } + +if ($format=='debug') +{ +echo "\n"; +echo "\n"; +echo "\n"; +echo "Проверка Voicemail"; +echo "\n"; +echo "\n"; +echo "\n"; +} + + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($vmail_box)<1) + { + $channel_live=0; + echo "voicemail box $vmail_box это неправильно\n"; + exit; + } + else + { + $stmt="SELECT messages,old_messages FROM phones where server_ip='$server_ip' and voicemail_id='$vmail_box' limit 1;"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + $vmails_list = mysql_num_rows($rslt); + $loop_count=0; + while ($vmails_list>$loop_count) + { + $loop_count++; + $row=mysql_fetch_row($rslt); + echo "$row[0]|$row[1]"; + if ($format=='debug') {echo "\n";} + } + } + + +if ($format=='debug') + { + $ENDtime = date("U"); + $RUNtime = ($ENDtime - $StarTtime); + echo "\n"; + echo "\n\n\n"; + } + +exit; + +?> diff --git a/LANG_www/agc_sk/manager_send.php b/LANG_www/agc_sk/manager_send.php index e4133a15..b544f341 100644 --- a/LANG_www/agc_sk/manager_send.php +++ b/LANG_www/agc_sk/manager_send.php @@ -1637,7 +1637,7 @@ if ( ($ACTION=="Monitor") || ($ACTION=="StopMonitor") ) $row=''; $rowx=''; $channel_live=1; - if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<15) ) + if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanál $channel Nie je správny or queryCID $queryCID Nie je správny or filename: $filename Nie je správny, $ACTION príkaz nebol vložený\n"; @@ -1725,7 +1725,7 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") ) $channel_live=1; $uniqueidSQL=''; - if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15) ) + if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<8) ) { $channel_live=0; echo "Kanál $channel Nie je správny or exten $exten Nie je správny or filename: $filename Nie je správny, $ACTION príkaz nebol vložený\n"; diff --git a/LANG_www/agc_sk/vdc_db_query.php b/LANG_www/agc_sk/vdc_db_query.php index f04f0a7e..d2bdc814 100644 --- a/LANG_www/agc_sk/vdc_db_query.php +++ b/LANG_www/agc_sk/vdc_db_query.php @@ -82,6 +82,7 @@ # - $account - ('DEFAULT',...) # - $agent_dialed_number - ('1','') # - $agent_dialed_type - ('MANUAL_OVERRIDE','MANUAL_DIALNOW','MANUAL_PREVIEW',...) +# - $wrapup - ('WRAPUP','') # # CHANGELOG: # 50629-1044 - First build of script @@ -190,12 +191,13 @@ # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature # 90307-1735 - Added Shift enforcement and manager override features +# 90320-0306 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-103'; -$build = '90307-1735'; +$version = '2.0.5-104'; +$build = '90320-0306'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=193; +$mysql_log_count=194; $one_mysql_log=0; require("dbconnect.php"); @@ -359,6 +361,10 @@ if (isset($_GET["agent_dialed_number"])) {$agent_dialed_number=$_GET["agent_di elseif (isset($_POST["agent_dialed_number"])) {$agent_dialed_number=$_POST["agent_dialed_number"];} if (isset($_GET["agent_dialed_type"])) {$agent_dialed_type=$_GET["agent_dialed_type"];} elseif (isset($_POST["agent_dialed_type"])) {$agent_dialed_type=$_POST["agent_dialed_type"];} +if (isset($_GET["wrapup"])) {$wrapup=$_GET["wrapup"];} + elseif (isset($_POST["wrapup"])) {$wrapup=$_POST["wrapup"];} + + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -3728,6 +3734,23 @@ if ( ($ACTION == 'VDADpause') || ($ACTION == 'VDADready') ) $agent_log = 'NEW_ID'; } + if ($wrapup == 'WRAPUP') + { + if ( (eregi("NULL",$dispo_epoch)) or ($dispo_epoch < 1000) ) + { + $stmt="UPDATE vicidial_agent_log set dispo_epoch='$StarTtime', dispo_sec='0' where agent_log_id='$agent_log_id';"; + } + else + { + $dispo_sec = ($StarTtime - $dispo_epoch); + $stmt="UPDATE vicidial_agent_log set dispo_sec='$dispo_sec' where agent_log_id='$agent_log_id';"; + } + + if ($format=='debug') {echo "\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00194',$user,$server_ip,$session_name,$one_mysql_log);} + } + if ($agent_log == 'NEW_ID') { $user_group=''; diff --git a/LANG_www/agc_sk/vicidial.php b/LANG_www/agc_sk/vicidial.php index 9a1a53b8..d9b95a83 100644 --- a/LANG_www/agc_sk/vicidial.php +++ b/LANG_www/agc_sk/vicidial.php @@ -222,10 +222,11 @@ # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API # 90307-1736 - Added Shift enforcement and manager override features +# 90320-0309 - Fixed agent log bug when using wrapup time # -$version = '2.0.5-201'; -$build = '90307-1736'; +$version = '2.0.5-202'; +$build = '90320-0309'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=60; $one_mysql_log=0; @@ -2240,7 +2241,6 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var campaign_am_message_exten = ''; var park_on_extension = ''; var park_count=0; - var park_refresh=0; var customerparked=0; var check_n = 0; var conf_check_recheck = 0; @@ -4791,7 +4791,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Set the client to READY and start looking for calls (VDADready, VDADpause) - function AutoDial_ReSume_PauSe(taskaction,taskagentlog) + function AutoDial_ReSume_PauSe(taskaction,taskagentlog,taskwrapup) { if (taskaction == 'VDADready') { @@ -4859,7 +4859,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&campaign=" + campaign; + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(autoDiaLready_query); @@ -7497,10 +7497,6 @@ else { // check_for_live_calls(); check_s = check_n.toString(); - if ( (park_refresh > 0) && (check_s.match(/0$|5$/)) ) - { - // parked_calls_display_refresh(); - } } if (wrapup_sekúnd > 0) { @@ -7515,6 +7511,7 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 0; + // alert('wrapup pause'); AutoDial_ReSume_PauSe("VDADpause"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; } @@ -7530,7 +7527,8 @@ else if (auto_dial_level != '0') { AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready"); + // alert('wrapup ready'); + AutoDial_ReSume_PauSe("VDADready","NEW_ID","WRAPUP"); // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; } } diff --git a/LANG_www/vicidial_de/AST_timeonVDADall.php b/LANG_www/vicidial_de/AST_timeonVDADall.php index 0a84bd4c..c2bd505a 100644 --- a/LANG_www/vicidial_de/AST_timeonVDADall.php +++ b/LANG_www/vicidial_de/AST_timeonVDADall.php @@ -959,6 +959,7 @@ if ($campaign_allow_inbound > 0) $rslt=mysql_query($stmt, $link); $ccamps_to_print = mysql_num_rows($rslt); $c=0; + $closer_campaignsSQL=''; while ($ccamps_to_print > $c) { $row=mysql_fetch_row($rslt); diff --git a/LANG_www/vicidial_de/admin.php b/LANG_www/vicidial_de/admin.php index 9dd6910a..739d72ce 100644 --- a/LANG_www/vicidial_de/admin.php +++ b/LANG_www/vicidial_de/admin.php @@ -1644,11 +1644,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90308-0956 - Added server statistics # 90309-0059 - Changed logging to admin_server_log # 90310-2203 - Added export_reports option for call activity report data exports +# 90320-0424 - Fixed several small bugs conf records group alias and permissions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-172'; -$build = '90310-2203'; +$admin_version = '2.0.5-173'; +$build = '90320-0424'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -2850,7 +2851,7 @@ if ($SSqc_features_active > 0)

-Exportieren von Berichten - Diese Einstellung, wenn auf 1 gesetzt wird ein Manager für den Zugriff auf die Ausfuhr rufen Berichte über die Berichte Bildschirm. Der Standardwert ist 0. Für die Export-Bericht fordert, um das folgende Feld wird für die Ausfuhr:
call_date,phone_number,status,user,full_name,campaign_id/in-group,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,length_in_sec,user_group,alt_dial/queue_seconds +Exportieren von Berichten - Diese Einstellung, wenn auf 1 gesetzt wird ein Manager für den Zugriff auf die Ausfuhr rufen Berichte über die Berichte Bildschirm. Der Standardwert ist 0. Für die Export-Bericht fordert, um das folgende Feld wird für die Ausfuhr:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds @@ -7891,6 +7892,9 @@ if ($ADD==21111111111) $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8014,6 +8018,9 @@ if ($ADD==211111111111) $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8144,6 +8151,9 @@ if ($ADD==241111111111) $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -12410,6 +12420,9 @@ if ($ADD==61111111111) $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -14842,6 +14855,7 @@ if ( ($ADD==34) or ($ADD==31) ) } } + echo "
\n"; } @@ -18771,7 +18785,7 @@ if ($ADD==1300) $rslt=mysql_query($stmt, $link); $dids_to_print = mysql_num_rows($rslt); - echo "
INBOUND GRUPPE AUFLISTUNGEN:\n"; + echo "
INBOUND DID LISTINGS:\n"; echo "
\n"; echo ""; echo ""; @@ -19864,9 +19878,6 @@ if ($ADD==999999) } - - - echo "
#
\n"; echo "
\n"; @@ -20208,6 +20219,7 @@ if (isset($camp_lists)) $Dsql .= "'$Dstatuses[$o]',"; } $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; #$DB=1; diff --git a/LANG_www/vicidial_de/admin_header.php b/LANG_www/vicidial_de/admin_header.php index aa45a0e8..dd48f6e9 100644 --- a/LANG_www/vicidial_de/admin_header.php +++ b/LANG_www/vicidial_de/admin_header.php @@ -911,13 +911,6 @@ if (strlen($reports_hh) > 1) {
\n"; - echo "Sie haben nicht die Rechte, um diese Seite anzusehen. Bitte zurück gehen.\n"; - } if (strlen($reports_hh) > 1) { ?> diff --git a/LANG_www/vicidial_de/welcome_demo.php b/LANG_www/vicidial_de/welcome_demo.php index 49c0e470..65997b08 100644 --- a/LANG_www/vicidial_de/welcome_demo.php +++ b/LANG_www/vicidial_de/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_de/welcome_languages.php b/LANG_www/vicidial_de/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/LANG_www/vicidial_de/welcome_languages.php +++ b/LANG_www/vicidial_de/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_el/AST_timeonVDADall.php b/LANG_www/vicidial_el/AST_timeonVDADall.php index 69e911db..9821af6f 100644 --- a/LANG_www/vicidial_el/AST_timeonVDADall.php +++ b/LANG_www/vicidial_el/AST_timeonVDADall.php @@ -959,6 +959,7 @@ if ($campaign_allow_inbound > 0) $rslt=mysql_query($stmt, $link); $ccamps_to_print = mysql_num_rows($rslt); $c=0; + $closer_campaignsSQL=''; while ($ccamps_to_print > $c) { $row=mysql_fetch_row($rslt); diff --git a/LANG_www/vicidial_el/admin.php b/LANG_www/vicidial_el/admin.php index 25217b5e..e91c056d 100644 --- a/LANG_www/vicidial_el/admin.php +++ b/LANG_www/vicidial_el/admin.php @@ -1644,11 +1644,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90308-0956 - Added server statistics # 90309-0059 - Changed logging to admin_server_log # 90310-2203 - Added export_reports option for call activity report data exports +# 90320-0424 - Fixed several small bugs conf records group alias and permissions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-172'; -$build = '90310-2203'; +$admin_version = '2.0.5-173'; +$build = '90320-0424'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -2850,7 +2851,7 @@ if ($SSqc_features_active > 0)

-Εξαγωγή Εκθέσεις - Αυτή η ρύθμιση, εάν ρυθμιστεί σε 1 θα επιτρέψει την πρόσβαση του διευθυντή της εξαγωγής κλήση εκθέσεις σχετικά με τις εκθέσεις της οθόνης. Η προεπιλογή είναι 0. Για την εξαγωγή ζητεί έκθεση, ώστε τα ακόλουθα τομέα χρησιμοποιείται για τις εξαγωγές:
call_date,phone_number,status,user,full_name,campaign_id/in-group,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,length_in_sec,user_group,alt_dial/queue_seconds +Εξαγωγή Εκθέσεις - Αυτή η ρύθμιση, εάν ρυθμιστεί σε 1 θα επιτρέψει την πρόσβαση του διευθυντή της εξαγωγής κλήση εκθέσεις σχετικά με τις εκθέσεις της οθόνης. Η προεπιλογή είναι 0. Για την εξαγωγή ζητεί έκθεση, ώστε τα ακόλουθα τομέα χρησιμοποιείται για τις εξαγωγές:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds @@ -7895,6 +7896,9 @@ if ($ADD==21111111111) $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8018,6 +8022,9 @@ if ($ADD==211111111111) $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8148,6 +8155,9 @@ if ($ADD==241111111111) $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -12414,6 +12424,9 @@ if ($ADD==61111111111) $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -14857,6 +14870,7 @@ if ( ($ADD==34) or ($ADD==31) ) } } + echo "
\n"; } @@ -18789,7 +18803,7 @@ if ($ADD==1300) $rslt=mysql_query($stmt, $link); $dids_to_print = mysql_num_rows($rslt); - echo "
ΕΝΤΑΓΜΕΝΕΣ ΕΙΣΕΡΧΟΜΕΝΕΣ ΟΜΑΔΕΣ:\n"; + echo "
Εισερχόμενα DID LISTINGS:\n"; echo "
\n"; echo ""; echo ""; @@ -19882,9 +19896,6 @@ if ($ADD==999999) } - - - echo "
#
\n"; echo "
\n"; @@ -20226,6 +20237,7 @@ if (isset($camp_lists)) $Dsql .= "'$Dstatuses[$o]',"; } $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; #$DB=1; diff --git a/LANG_www/vicidial_el/admin_header.php b/LANG_www/vicidial_el/admin_header.php index 9de27417..3988f456 100644 --- a/LANG_www/vicidial_el/admin_header.php +++ b/LANG_www/vicidial_el/admin_header.php @@ -911,13 +911,6 @@ if (strlen($reports_hh) > 1) {
\n"; - echo "Δεν έχετε το δικαίωμα για να δείτε την σελίδα. Παρακαλώ επιστρέψτε.\n"; - } if (strlen($reports_hh) > 1) { ?> diff --git a/LANG_www/vicidial_el/welcome_demo.php b/LANG_www/vicidial_el/welcome_demo.php index 49c0e470..65997b08 100644 --- a/LANG_www/vicidial_el/welcome_demo.php +++ b/LANG_www/vicidial_el/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_el/welcome_languages.php b/LANG_www/vicidial_el/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/LANG_www/vicidial_el/welcome_languages.php +++ b/LANG_www/vicidial_el/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_es/AST_timeonVDADall.php b/LANG_www/vicidial_es/AST_timeonVDADall.php index f4d26c54..cd522e9c 100644 --- a/LANG_www/vicidial_es/AST_timeonVDADall.php +++ b/LANG_www/vicidial_es/AST_timeonVDADall.php @@ -959,6 +959,7 @@ if ($campaign_allow_inbound > 0) $rslt=mysql_query($stmt, $link); $ccamps_to_print = mysql_num_rows($rslt); $c=0; + $closer_campaignsSQL=''; while ($ccamps_to_print > $c) { $row=mysql_fetch_row($rslt); diff --git a/LANG_www/vicidial_es/admin.php b/LANG_www/vicidial_es/admin.php index a22d7a12..9afe5812 100644 --- a/LANG_www/vicidial_es/admin.php +++ b/LANG_www/vicidial_es/admin.php @@ -1644,11 +1644,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90308-0956 - Added server statistics # 90309-0059 - Changed logging to admin_server_log # 90310-2203 - Added export_reports option for call activity report data exports +# 90320-0424 - Fixed several small bugs conf records group alias and permissions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-172'; -$build = '90310-2203'; +$admin_version = '2.0.5-173'; +$build = '90320-0424'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -2850,7 +2851,7 @@ if ($SSqc_features_active > 0)

-Informes de exportación - Este ajuste, si se pone a 1 permitirá un gerente de exportación para acceder a la llamada de los informes sobre la INFORMES pantalla. El valor predeterminado es 0. Pide para el Informe de Exportación, para el siguiente campo se utiliza para las exportaciones:
call_date,phone_number,status,user,full_name,campaign_id/in-group,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,length_in_sec,user_group,alt_dial/queue_seconds +Informes de exportación - Este ajuste, si se pone a 1 permitirá un gerente de exportación para acceder a la llamada de los informes sobre la INFORMES pantalla. El valor predeterminado es 0. Pide para el Informe de Exportación, para el siguiente campo se utiliza para las exportaciones:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds @@ -7891,6 +7892,9 @@ if ($ADD==21111111111) $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8014,6 +8018,9 @@ if ($ADD==211111111111) $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8144,6 +8151,9 @@ if ($ADD==241111111111) $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -12410,6 +12420,9 @@ if ($ADD==61111111111) $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -14842,6 +14855,7 @@ if ( ($ADD==34) or ($ADD==31) ) } } + echo "
\n"; } @@ -18771,7 +18785,7 @@ if ($ADD==1300) $rslt=mysql_query($stmt, $link); $dids_to_print = mysql_num_rows($rslt); - echo "
GRUPOS DE ENTRADA :\n"; + echo "
Entrantes DID LISTINGS:\n"; echo "
\n"; echo ""; echo ""; @@ -19864,9 +19878,6 @@ if ($ADD==999999) } - - - echo "
#
\n"; echo "
\n"; @@ -20208,6 +20219,7 @@ if (isset($camp_lists)) $Dsql .= "'$Dstatuses[$o]',"; } $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; #$DB=1; diff --git a/LANG_www/vicidial_es/admin_header.php b/LANG_www/vicidial_es/admin_header.php index 1f8f46b5..bf7dec3f 100644 --- a/LANG_www/vicidial_es/admin_header.php +++ b/LANG_www/vicidial_es/admin_header.php @@ -911,13 +911,6 @@ if (strlen($reports_hh) > 1) {
\n"; - echo "Le no autorizan a visión esta página. Vaya por favor detrás.\n"; - } if (strlen($reports_hh) > 1) { ?> diff --git a/LANG_www/vicidial_es/welcome_demo.php b/LANG_www/vicidial_es/welcome_demo.php index 49c0e470..65997b08 100644 --- a/LANG_www/vicidial_es/welcome_demo.php +++ b/LANG_www/vicidial_es/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_es/welcome_languages.php b/LANG_www/vicidial_es/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/LANG_www/vicidial_es/welcome_languages.php +++ b/LANG_www/vicidial_es/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_fr/AST_timeonVDADall.php b/LANG_www/vicidial_fr/AST_timeonVDADall.php index 5f0c8fb0..e33960f4 100644 --- a/LANG_www/vicidial_fr/AST_timeonVDADall.php +++ b/LANG_www/vicidial_fr/AST_timeonVDADall.php @@ -959,6 +959,7 @@ if ($campaign_allow_inbound > 0) $rslt=mysql_query($stmt, $link); $ccamps_to_print = mysql_num_rows($rslt); $c=0; + $closer_campaignsSQL=''; while ($ccamps_to_print > $c) { $row=mysql_fetch_row($rslt); diff --git a/LANG_www/vicidial_fr/admin.php b/LANG_www/vicidial_fr/admin.php index 5498b895..0edcd060 100644 --- a/LANG_www/vicidial_fr/admin.php +++ b/LANG_www/vicidial_fr/admin.php @@ -1644,11 +1644,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90308-0956 - Added server statistics # 90309-0059 - Changed logging to admin_server_log # 90310-2203 - Added export_reports option for call activity report data exports +# 90320-0424 - Fixed several small bugs conf records group alias and permissions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-172'; -$build = '90310-2203'; +$admin_version = '2.0.5-173'; +$build = '90320-0424'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -2175,7 +2176,7 @@ if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD $UGcampaigns = explode(" ", $allowed_campaigns); $p=0; $RANK_camp_active=0; $CR_disabled = ''; - if (eregi('-ALL-CAMPAGNES-',$allowed_campaigns)) + if (eregi('-ALL-CAMPAIGNS-',$allowed_campaigns)) {$RANK_camp_active++;} else { @@ -2409,23 +2410,23 @@ if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD } $campaigns_value=''; - $campaigns_list='4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD } $p++; } - $campaigns_list.="> ALL-CAMPAGNES - LES UTILISATEURS PEUVENT VOIR CHAQUE CAMPAGNE
\n"; - $qc_campaigns_list.="> ALL-CAMPAGNES - UTILISATEURS CAN QC TOUTE LA CAMPAGNE

\n"; + $campaigns_list.="> ALL-CAMPAIGNS - LES UTILISATEURS PEUVENT VOIR CHAQUE CAMPAGNE

\n"; + $qc_campaigns_list.="> ALL-CAMPAIGNS - UTILISATEURS CAN QC TOUTE LA CAMPAGNE
\n"; $qc_groups_list.="> ALL-GROUPS - UTILISATEURS CAN QC ENTRANT TOUT GROUP
\n"; $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns order by campaign_id"; @@ -2850,7 +2851,7 @@ if ($SSqc_features_active > 0)

-Rapports d'exportation - Ce paramètre, s'il est à 1 permettra d'accéder à un gestionnaire de l'exportation des rapports sur l'appel RAPPORTS écran. La valeur par défaut est 0. Pour le rapport invite l'exportation, l'ordre suivant est utilisé pour les exportations:
call_date,phone_number,status,user,full_name,campaign_id/in-group,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,length_in_sec,user_group,alt_dial/queue_seconds +Rapports d'exportation - Ce paramètre, s'il est à 1 permettra d'accéder à un gestionnaire de l'exportation des rapports sur l'appel RAPPORTS écran. La valeur par défaut est 0. Pour le rapport invite l'exportation, l'ordre suivant est utilisé pour les exportations:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds @@ -3042,7 +3043,7 @@ if ($SSoutbound_autodial_active > 0) - 8365 - Will seulement envoyer l'appel à un agent sur le même serveur que l'appel est en - 8366 - Occasions-1 pour la presse et campagnes de sondage - 8367 - Le premier à essayer d'envoyer l'appel à un agent sur le serveur local, il se penchera sur d'autres serveurs - - 8368 - DEFAULT Will send the call to the next available agent no matter what server they are on + - 8368 - DEFAULT Will send the call to the next available agent no matter what server they are on - 8369 - Occasions de Answering Machine de détection après que, même comportement que 8368 - 8373 - Occasions de Answering Machine de détection après cette même comportement que 8366 @@ -6933,7 +6934,7 @@ if ($ADD==21) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='ADD', record_id='$campaign_id', event_code='ADMIN AJOUTER UNE CAMPAGNE', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN AJOUTER UNE CAMPAGNE', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); } @@ -6988,7 +6989,7 @@ if ($ADD==20) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='COPY', record_id='$campaign_id', event_code='ADMIN COPY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='COPY', record_id='$campaign_id', event_code='ADMIN COPY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); } @@ -7556,7 +7557,7 @@ if ($ADD==211111) } else { - $stmt="INSERT INTO vicidial_user_groups(user_group,group_name,allowed_campaigns) values('$user_group','$group_name','-ALL-CAMPAGNES-');"; + $stmt="INSERT INTO vicidial_user_groups(user_group,group_name,allowed_campaigns) values('$user_group','$group_name','-ALL-CAMPAIGNS-');"; $rslt=mysql_query($stmt, $link); echo "
GROUPE D'UTILISATEURS AJOUTE: $user_group\n"; @@ -7891,6 +7892,9 @@ if ($ADD==21111111111) $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8014,6 +8018,9 @@ if ($ADD==211111111111) $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8144,6 +8151,9 @@ if ($ADD==241111111111) $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -9128,7 +9138,7 @@ if ($ADD==41) $SQL_log = "$stmt|$stmtB|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTES', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTES', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -9192,7 +9202,7 @@ if ($ADD==41) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); } @@ -9201,7 +9211,7 @@ if ($ADD==41) $SQL_log = "$stmtA|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); } @@ -9382,7 +9392,7 @@ if ($ADD==44) $SQL_log = "$stmt|$stmtB|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTES', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN ACTIVE LISTES', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -9432,7 +9442,7 @@ if ($ADD==44) $SQL_log = "$stmtA|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='MODIFY', record_id='$campaign_id', event_code='ADMIN MODIFY CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -9447,7 +9457,7 @@ if ($ADD==44) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN LEAD HOPPER', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); } @@ -11728,7 +11738,7 @@ if ($ADD==61) $SQL_log = "$stmtA|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='DELETE', record_id='$campaign_id', event_code='ADMIN DELETE CAMPAIGN', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -11763,7 +11773,7 @@ if ($ADD==62) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='LOGOUT', record_id='$campaign_id', event_code='ADMIN LOGOUT CAMPAIGN AGENTS', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='LOGOUT', record_id='$campaign_id', event_code='ADMIN LOGOUT CAMPAIGN AGENTS', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -11806,7 +11816,7 @@ if ($ADD==63) $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAGNES', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN JAM', event_sql=\"$SQL_log\", event_notes='';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGNS', event_type='RESET', record_id='$campaign_id', event_code='ADMIN RESET CAMPAIGN JAM', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_query($stmt, $link); @@ -12410,6 +12420,9 @@ if ($ADD==61111111111) $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -12982,7 +12995,7 @@ if ($ADD==3) if ( ($LOGcampaign_detail < 1) and ($ADD==31) ) {$ADD=34;} # send to Basic if not allowed -if ( ($ADD==31) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAGNES",$LOGallowed_campaigns)) ) ) +if ( ($ADD==31) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAIGNS",$LOGallowed_campaigns)) ) ) {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list if ($ADD==31) @@ -13768,7 +13781,7 @@ if ($ADD==31) echo "
Cliquez ici pour voir les rappels réservés de cette campagne

\n"; if ($LOGuser_level >= 9) { - echo "

Cliquez ici pour voir Admin chages à cette campagne
\n"; + echo "

Cliquez ici pour voir Admin chages à cette campagne
\n"; } echo "
\n"; } @@ -14216,7 +14229,7 @@ if ($ADD==31) # ADD=34 modify campaign info in the system - Basic View ###################### -if ( ($ADD==34) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAGNES",$LOGallowed_campaigns)) ) ) +if ( ($ADD==34) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAIGNS",$LOGallowed_campaigns)) ) ) {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list if ($ADD==34) @@ -14584,7 +14597,7 @@ if ($ADD==34) echo "Cliquez ici pour voir les rappels réservés de cette campagne

\n"; if ($LOGuser_level >= 9) { - echo "

Cliquez ici pour voir Admin chages à cette campagne
\n"; + echo "

Cliquez ici pour voir Admin chages à cette campagne\n"; } echo "
\n"; @@ -14637,7 +14650,7 @@ if ($ADD==34) ###################### # ADD=31 or 34 and SUB=29 for list mixes ###################### -if ( ( ($ADD==34) or ($ADD==31) ) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAGNES",$LOGallowed_campaigns)) ) ) +if ( ( ($ADD==34) or ($ADD==31) ) and ( (!eregi("$campaign_id",$LOGallowed_campaigns)) and (!eregi("ALL-CAMPAIGNS",$LOGallowed_campaigns)) ) ) {$ADD=30;} # send to not allowed screen if not in vicidial_user_groups allowed_campaigns list if ( ($ADD==34) or ($ADD==31) ) @@ -14842,6 +14855,7 @@ if ( ($ADD==34) or ($ADD==31) ) } } + echo "
\n"; } @@ -18771,7 +18785,7 @@ if ($ADD==1300) $rslt=mysql_query($stmt, $link); $dids_to_print = mysql_num_rows($rslt); - echo "
LISTE DES GROUPES ENTRANTS:\n"; + echo "
ENTRANT DID LISTINGS:\n"; echo "
\n"; echo ""; echo ""; @@ -19864,9 +19878,6 @@ if ($ADD==999999) } - - - echo "
#
\n"; echo "
\n"; @@ -20208,6 +20219,7 @@ if (isset($camp_lists)) $Dsql .= "'$Dstatuses[$o]',"; } $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; #$DB=1; diff --git a/LANG_www/vicidial_fr/admin_header.php b/LANG_www/vicidial_fr/admin_header.php index 96afeacd..c4c2fc78 100644 --- a/LANG_www/vicidial_fr/admin_header.php +++ b/LANG_www/vicidial_fr/admin_header.php @@ -911,13 +911,6 @@ if (strlen($reports_hh) > 1) {
\n"; - echo "Vous n'êtes pas autorisé à voir cette page. Veuillez revenir en arrière.\n"; - } if (strlen($reports_hh) > 1) { ?> diff --git a/LANG_www/vicidial_fr/welcome_demo.php b/LANG_www/vicidial_fr/welcome_demo.php index 49c0e470..65997b08 100644 --- a/LANG_www/vicidial_fr/welcome_demo.php +++ b/LANG_www/vicidial_fr/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_fr/welcome_languages.php b/LANG_www/vicidial_fr/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/LANG_www/vicidial_fr/welcome_languages.php +++ b/LANG_www/vicidial_fr/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_it/AST_timeonVDADall.php b/LANG_www/vicidial_it/AST_timeonVDADall.php index e0d40b77..0f2e8ac9 100644 --- a/LANG_www/vicidial_it/AST_timeonVDADall.php +++ b/LANG_www/vicidial_it/AST_timeonVDADall.php @@ -959,6 +959,7 @@ if ($campaign_allow_inbound > 0) $rslt=mysql_query($stmt, $link); $ccamps_to_print = mysql_num_rows($rslt); $c=0; + $closer_campaignsSQL=''; while ($ccamps_to_print > $c) { $row=mysql_fetch_row($rslt); diff --git a/LANG_www/vicidial_it/admin.php b/LANG_www/vicidial_it/admin.php index d707dc95..e748e1ec 100644 --- a/LANG_www/vicidial_it/admin.php +++ b/LANG_www/vicidial_it/admin.php @@ -1644,11 +1644,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90308-0956 - Added server statistics # 90309-0059 - Changed logging to admin_server_log # 90310-2203 - Added export_reports option for call activity report data exports +# 90320-0424 - Fixed several small bugs conf records group alias and permissions # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.0.5-172'; -$build = '90310-2203'; +$admin_version = '2.0.5-173'; +$build = '90320-0424'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -2850,7 +2851,7 @@ if ($SSqc_features_active > 0)

-Rapporti Export - Questa impostazione, se impostato su 1 consente di accedere a un manager di esportazione chiamata relazioni sulle relazioni schermo. Il valore di default è 0. Per la relazione chiede di esportazione, per il seguente campo è utilizzato per le esportazioni:
call_date,phone_number,status,user,full_name,campaign_id/in-group,vendor_lead_code,source_id,list_id,gmt_offset_now,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,length_in_sec,user_group,alt_dial/queue_seconds +Rapporti Export - Questa impostazione, se impostato su 1 consente di accedere a un manager di esportazione chiamata relazioni sulle relazioni schermo. Il valore di default è 0. Per la relazione chiede di esportazione, per il seguente campo è utilizzato per le esportazioni:
call_date, phone_number, status, user, full_name, campaign_id/in-group, vendor_lead_code, source_id, list_id, gmt_offset_now, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, length_in_sec, user_group, alt_dial/queue_seconds @@ -7891,6 +7892,9 @@ if ($ADD==21111111111) $stmt="INSERT INTO phones (extension,dialplan_number,voicemail_id,phone_ip,computer_ip,server_ip,login,pass,status,active,phone_type,fullname,company,picture,protocol,local_gmt,outbound_cid) values('$extension','$dialplan_number','$voicemail_id','$phone_ip','$computer_ip','$server_ip','$login','$pass','$status','$active','$phone_type','$fullname','$company','$picture','$protocol','$local_gmt','$outbound_cid');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8014,6 +8018,9 @@ if ($ADD==211111111111) $stmt="INSERT INTO servers (server_id,server_description,server_ip,active,asterisk_version) values('$server_id','$server_description','$server_ip','$active','$asterisk_version');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -8144,6 +8151,9 @@ if ($ADD==241111111111) $stmt="INSERT INTO vicidial_server_carriers (carrier_id,carrier_name,registration_string,template_id,account_entry,protocol,globals_string,dialplan_entry,server_ip,active) values('$carrier_id','$carrier_name','$registration_string','$template_id','$account_entry','$protocol','$globals_string','$dialplan_entry','$server_ip','N');"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -12410,6 +12420,9 @@ if ($ADD==61111111111) $stmt="DELETE from phones where extension='$extension' and server_ip='$server_ip' limit 1;"; $rslt=mysql_query($stmt, $link); + $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y' and server_ip='$server_ip';"; + $rslt=mysql_query($stmtA, $link); + ### LOG INSERTION Admin Log Table ### $SQL_log = "$stmt|"; $SQL_log = ereg_replace(';','',$SQL_log); @@ -14842,6 +14855,7 @@ if ( ($ADD==34) or ($ADD==31) ) } } + echo "
\n"; } @@ -18771,7 +18785,7 @@ if ($ADD==1300) $rslt=mysql_query($stmt, $link); $dids_to_print = mysql_num_rows($rslt); - echo "
ELENCO GRUPPI INBOUND:\n"; + echo "
INBOUND DID LISTINGS:\n"; echo "
\n"; echo ""; echo ""; @@ -19864,9 +19878,6 @@ if ($ADD==999999) } - - - echo "
#
\n"; echo "\n"; @@ -20208,6 +20219,7 @@ if (isset($camp_lists)) $Dsql .= "'$Dstatuses[$o]',"; } $Dsql = preg_replace("/,$/","",$Dsql); + if (strlen($Dsql) < 2) {$Dsql = "''";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($all_gmtSQL) $fSQL"; #$DB=1; diff --git a/LANG_www/vicidial_it/admin_header.php b/LANG_www/vicidial_it/admin_header.php index 8cf52091..4b17c387 100644 --- a/LANG_www/vicidial_it/admin_header.php +++ b/LANG_www/vicidial_it/admin_header.php @@ -911,13 +911,6 @@ if (strlen($reports_hh) > 1) { \n"; - echo "Le no autorizan a visio`n esta página. Vaya por favor detrás.\n"; - } if (strlen($reports_hh) > 1) { ?> diff --git a/LANG_www/vicidial_it/welcome_demo.php b/LANG_www/vicidial_it/welcome_demo.php index 49c0e470..65997b08 100644 --- a/LANG_www/vicidial_it/welcome_demo.php +++ b/LANG_www/vicidial_it/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "  
\n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/LANG_www/vicidial_it/welcome_languages.php b/LANG_www/vicidial_it/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/LANG_www/vicidial_it/welcome_languages.php +++ b/LANG_www/vicidial_it/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/extras/app_conference/0.gsm b/extras/app_conference/0.gsm deleted file mode 100644 index 8c57c411..00000000 Binary files a/extras/app_conference/0.gsm and /dev/null differ diff --git a/extras/app_conference/0.wav b/extras/app_conference/0.wav deleted file mode 100644 index fe3fc124..00000000 Binary files a/extras/app_conference/0.wav and /dev/null differ diff --git a/extras/app_conference/1.gsm b/extras/app_conference/1.gsm deleted file mode 100644 index 7f6c842f..00000000 --- a/extras/app_conference/1.gsm +++ /dev/null @@ -1 +0,0 @@ -8z*PScOȪP,r)" +E<7j2h#8誙B,65Cb (Ra.4WFR2) 8z.hK]%Mq]ͷM] %ty\ ,Yc:Sd<,iUK:B.eZ%Vn*䡝QE!t+DC5сWETbok]bcCzՔ.46_M]]Dbv])`]kʜ_uY]UU2Fr.]MtZld]C]6]Y[.jR=_a 뭺_ܭ1Z]r2բ)6A]](,Q]\gS4a&Q2c>v\udI$P`u \ No newline at end of file diff --git a/extras/app_conference/1.wav b/extras/app_conference/1.wav deleted file mode 100644 index e5f5359a..00000000 Binary files a/extras/app_conference/1.wav and /dev/null differ diff --git a/extras/app_conference/2.gsm b/extras/app_conference/2.gsm deleted file mode 100644 index 82d6e751..00000000 --- a/extras/app_conference/2.gsm +++ /dev/null @@ -1,3 +0,0 @@ -xZP4e5cU\ #n7#HVc ͌xC=A`a肹 B+3+x;4QӇx7 T_ xJB<]%]и -]t1]"0s wb2"hϣ& 0_C%,#dAxZ=a#^TIXVաs6IsBtIrx%~—b!a8sa8cF )8xZvEX]#yM02":#8txZv"%|_,äϢ)YxJA}me+6j_-gF|xK>a- -wCY 藡J,FsͮZx<>_"q- ) *Ƭs Psv_cgβrG$R 埗Y \ No newline at end of file diff --git a/extras/app_conference/2.wav b/extras/app_conference/2.wav deleted file mode 100644 index c3e9edd9..00000000 Binary files a/extras/app_conference/2.wav and /dev/null differ diff --git a/extras/app_conference/3.gsm b/extras/app_conference/3.gsm deleted file mode 100644 index a41d6679..00000000 --- a/extras/app_conference/3.gsm +++ /dev/null @@ -1,2 +0,0 @@ -;=PW1W#X [r)d[K%7 -$c#2+)UBV4F¬SC{4[Hnpޥꕷbªσ`gC?=W n(*En,{Q6qR=!Ʈ\b#V) h~R=ѓ \%.kn\R=pzr>ܙ=$u R=ρfGϠȵj&ayC<·+61㍂aϣpK;WClRLJ$=Rf%>##xwb LM}bj&V:3k+[? kS%vAbÝ97qݑ \ No newline at end of file diff --git a/extras/app_conference/3.wav b/extras/app_conference/3.wav deleted file mode 100644 index bc37ff5d..00000000 Binary files a/extras/app_conference/3.wav and /dev/null differ diff --git a/extras/app_conference/4.gsm b/extras/app_conference/4.gsm deleted file mode 100644 index d2bae3f8..00000000 --- a/extras/app_conference/4.gsm +++ /dev/null @@ -1,2 +0,0 @@ -8PRW\-elG'XVb,b*V rK"bTJ5~aȋf9ZTȁ`IZ^8nYZ2!Qhzk*"xS8nƸ*"fsSzCdփHΡQTmqZsb=iB -Vbc #meTQJeS;4UQ\H'k JX+ 82U" #9k:'Q "I.Sc"7оRr%ڜD~V΢e Vqr!EKi}9EiUELyXz9#3ȭrQ Ysq[HܘaM2 \ No newline at end of file diff --git a/extras/app_conference/4.wav b/extras/app_conference/4.wav deleted file mode 100644 index 05f1adf8..00000000 Binary files a/extras/app_conference/4.wav and /dev/null differ diff --git a/extras/app_conference/5.gsm b/extras/app_conference/5.gsm deleted file mode 100644 index 239c7aca..00000000 --- a/extras/app_conference/5.gsm +++ /dev/null @@ -1 +0,0 @@ -xj=P3cWcT qFܚ$DVD%CHxS&TxD?4A9E'ڸU2r [SyqxbWXWlK%a.Ռ̩ح4+Mv_dȗ˱.#IZAY \ No newline at end of file diff --git a/extras/app_conference/6.wav b/extras/app_conference/6.wav deleted file mode 100644 index 7c32ca36..00000000 Binary files a/extras/app_conference/6.wav and /dev/null differ diff --git a/extras/app_conference/64_Makefile b/extras/app_conference/64_Makefile deleted file mode 100644 index 531caf54..00000000 --- a/extras/app_conference/64_Makefile +++ /dev/null @@ -1,115 +0,0 @@ -# $Id: Makefile,v 1.9 2005/10/27 17:53:35 stevek Exp $ - -# -# Makefile, based on the Asterisk Makefile, Coypright (C) 1999, Mark Spencer -# -# Copyright (C) 2002,2003 Junghanns.NET GmbH -# -# Klaus-Peter Junghanns -# -# This program is free software and may be modified and -# distributed under the terms of the GNU Public License. -# - -.EXPORT_ALL_VARIABLES: - -# -# app_conference defines which can be passed on the command-line -# - -DESTDIR := -INSTALL_MODULES_DIR := /usr/lib/asterisk/modules -INSTALL_CONFIG_DIR := /etc/asterisk - -ASTERISK_INCLUDE_DIR := /usr/include/asterisk - -# turn app_conference debugging on or off ( 0 == OFF, 1 == ON ) -APP_CONFERENCE_DEBUG := 1 - -# 0 = OFF 1 = astdsp 2 = speex -SILDET := 2 - -# -# app_conference objects to build -# - -OBJS = app_conference.o conference.o member.o frame.o cli.o -SHAREDOS = app_conference.so - -# -# standard compile settings -# - -PROC = $(shell uname -m) -INSTALL = install -CC = gcc - -# skip asterisk includes if they are in /usr/include/asterisk -ifneq ($(shell dirname $(ASTERISK_INCLUDE_DIR)), /usr/include) -INCLUDE = -I$(ASTERISK_INCLUDE_DIR) -endif - -LIBS = -ldl -lpthread -lm -DEBUG := -g - -CFLAGS += -pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE - -CFLAGS += $(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi) -CFLAGS += -DCRYPTO - -ifeq ($(APP_CONFERENCE_DEBUG), 1) -CFLAGS += -DAPP_CONFERENCE_DEBUG -endif - -# -# additional flag values for silence detection -# - -ifeq ($(SILDET), 2) -OBJS += libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o -CFLAGS += -Ilibspeex -DSILDET=2 -endif - -ifeq ($(SILDET), 1) -CFLAGS += -DSILDET=1 -endif - -OSARCH=$(shell uname -s) -ifeq (${OSARCH},Darwin) -SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace -else -SOLINK=-shared -Xlinker -x -endif - -# -# targets -# - -all: $(SHAREDOS) - -clean: - rm -f *.so *.o $(OBJS) - -app_conference.so : $(OBJS) - $(CC) -shared -Xlinker -x -o $@ $(OBJS) - -vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o - $(CC) $(PROFILE) -o $@ $^ -lm - -install: all - if [ ! -d ${DESTDIR}${INSTALL_MODULES_DIR} ]; then \ - $(INSTALL) -m 755 -d ${DESTDIR}${INSTALL_MODULES_DIR} ; \ - fi - for x in $(SHAREDOS); do \ - $(INSTALL) -m 755 $$x ${DESTDIR}$(INSTALL_MODULES_DIR) ; \ - done - cp -f *.gsm /var/lib/asterisk/sounds - cp -f *.wav /var/lib/asterisk/sounds - - -#config: all -# if [ ! -d ${DESTDIR}${INSTALL_CONFIG_DIR} ]; then \ -# $(INSTALL) -m 755 -d ${DESTDIR}${INSTALL_CONFIG_DIR} ; \ -# fi -# $(INSTALL) -m 640 conf.conf ${DESTDIR}${INSTALL_CONFIG_DIR} - diff --git a/extras/app_conference/7.gsm b/extras/app_conference/7.gsm deleted file mode 100644 index 0260531d..00000000 --- a/extras/app_conference/7.gsm +++ /dev/null @@ -1,2 +0,0 @@ -8PR=:^ -r(۞fM[E88vG(QE!f݅ Q[O*֩r<HWSwt8Dx"IGDL4:RīUXj]H䋨L~rA fa֮2_(9FܗL]ëRQh_7#uGB.Vi]McjE2[vADyac]loHtRFz􇁗Hy!Aq8!QȤc=6 B)SdޭU9"<55c=ۉmbSc_ܩHUD{7=_!1֥!S왩n:5P!ku \ No newline at end of file diff --git a/extras/app_conference/7.wav b/extras/app_conference/7.wav deleted file mode 100644 index 6cdce5c1..00000000 Binary files a/extras/app_conference/7.wav and /dev/null differ diff --git a/extras/app_conference/8.gsm b/extras/app_conference/8.gsm deleted file mode 100644 index e931896a..00000000 Binary files a/extras/app_conference/8.gsm and /dev/null differ diff --git a/extras/app_conference/8.wav b/extras/app_conference/8.wav deleted file mode 100644 index 3ed04b3b..00000000 Binary files a/extras/app_conference/8.wav and /dev/null differ diff --git a/extras/app_conference/9.gsm b/extras/app_conference/9.gsm deleted file mode 100644 index 4a994705..00000000 Binary files a/extras/app_conference/9.gsm and /dev/null differ diff --git a/extras/app_conference/9.wav b/extras/app_conference/9.wav deleted file mode 100644 index 1439a595..00000000 Binary files a/extras/app_conference/9.wav and /dev/null differ diff --git a/extras/app_conference/LICENSE b/extras/app_conference/LICENSE deleted file mode 100644 index a52b16e4..00000000 --- a/extras/app_conference/LICENSE +++ /dev/null @@ -1,341 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/extras/app_conference/Makefile b/extras/app_conference/Makefile deleted file mode 100644 index d8b54a44..00000000 --- a/extras/app_conference/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -# $Id: Makefile,v 1.9 2005/10/27 17:53:35 stevek Exp $ - -# -# Makefile, based on the Asterisk Makefile, Coypright (C) 1999, Mark Spencer -# -# Copyright (C) 2002,2003 Junghanns.NET GmbH -# -# Klaus-Peter Junghanns -# -# This program is free software and may be modified and -# distributed under the terms of the GNU Public License. -# - -.EXPORT_ALL_VARIABLES: - -# -# app_conference defines which can be passed on the command-line -# - -INSTALL_PREFIX := /usr -INSTALL_MODULES_DIR := $(INSTALL_PREFIX)/lib/asterisk/modules - -ASTERISK_INCLUDE_DIR := $(HOME)/local/asterisk/asterisk/include - -# turn app_conference debugging on or off ( 0 == OFF, 1 == ON ) -APP_CONFERENCE_DEBUG := 1 - -# 0 = OFF 1 = astdsp 2 = speex -SILDET := 2 - -# -# app_conference objects to build -# - -OBJS = app_conference.o conference.o member.o frame.o cli.o -SHAREDOS = app_conference.so - -# -# standard compile settings -# - -PROC = $(shell uname -m) -INSTALL = install -CC = gcc - -INCLUDE = -I$(ASTERISK_INCLUDE_DIR) -LIBS = -ldl -lpthread -lm -DEBUG := -g - -CFLAGS = -pipe -fPIC -Wall -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE -#CFLAGS += -O2 -#CFLAGS += -O3 -march=pentium3 -msse -mfpmath=sse,387 -ffast-math -# PERF: below is 10% faster than -O2 or -O3 alone. -#CFLAGS += -O3 -ffast-math -funroll-loops -# below is another 5% faster or so. -CFLAGS += -O3 -ffast-math -funroll-all-loops -fprefetch-loop-arrays -fsingle-precision-constant - -# this is fun for PPC -#CFLAGS += -mcpu=7450 -faltivec -mabi=altivec -mdynamic-no-pic - -# this is fun for x86 -CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 - - -# adding -msse -mfpmath=sse has little effect. -#CFLAGS += -O3 -msse -mfpmath=sse -#CFLAGS += $(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) -CFLAGS += $(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi) -CFLAGS += -DCRYPTO - -ifeq ($(APP_CONFERENCE_DEBUG), 1) -CFLAGS += -DAPP_CONFERENCE_DEBUG -endif - -# -# additional flag values for silence detection -# - -ifeq ($(SILDET), 2) -OBJS += libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o -CFLAGS += -Ilibspeex -DSILDET=2 -endif - -ifeq ($(SILDET), 1) -CFLAGS += -DSILDET=1 -endif - -OSARCH=$(shell uname -s) -ifeq (${OSARCH},Darwin) -SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace -else -SOLINK=-shared -Xlinker -x -endif - -# -# targets -# - -all: $(SHAREDOS) - -clean: - rm -f *.so *.o $(OBJS) - -app_conference.so : $(OBJS) - $(CC) -pg -shared -Xlinker -x -o $@ $(OBJS) - -vad_test: vad_test.o libspeex/preprocess.o libspeex/misc.o libspeex/smallft.o - $(CC) $(PROFILE) -o $@ $^ -lm - -install: all - for x in $(SHAREDOS); do $(INSTALL) -m 755 $$x $(INSTALL_MODULES_DIR) ; done - cp -f *.gsm /var/lib/asterisk/sounds - cp -f *.wav /var/lib/asterisk/sounds - -# /var/horizon/mojo/lib/horizoncmd restart asterisk -# make sure you restart asterisk after make install - -# config: all -# cp conf.conf /etc/asterisk/ - - diff --git a/extras/app_conference/README b/extras/app_conference/README deleted file mode 100644 index 2a1c5141..00000000 --- a/extras/app_conference/README +++ /dev/null @@ -1,170 +0,0 @@ -app_conference is a channel-independent conference application. - -Design goals -It has several design goals which are different than meetme: - - * It does not require a zap channel for timing. - * It is very efficient when used with channels which support DTX (silence - detection/discontinuous transmission). - - * It can do VAD on channels which do not support DTX (although this - is more expensive than just mixing them, but less expensive then - encoding; therefore it might still be a win). - * It presents messages on the Monitor interface for determine which - speakers are active. - - -I believe that people other than myself are using this, but my environment is -pretty rigid, and cases outside of this aren't tested: - - * Some callers come from the PSTN via IAX2 from a box with Zaptel cards, - via uLaw. - * Other callers come from iaxclient based softphones using speex - (was GSM) via IAX2 (with DTX). - * Some conferences have a single SIP channel which listens in GSM. - - -Mixing design - - * Minimize encoding/decoding, minimize mixing. - * Minimize generational loss from trancoding. - * Usual cases are handled very efficiently: - o One speaker: That speaker's frame is sent directly to each - participant which uses the same codec. It is trancoded - _once_ for each additional codec type used by participants. - o Two speakers: Each speaker gets the other speaker's frames. - The two speaker's frames are decoded and mixed, and then - encoded _once_ for each codec type used by participants. - - -License -Naturally, app_conference is GPL. The CVS also includes parts of libspeex, -which is distributed under it's a BSD-style license. - -Getting app_conference -app_conference is available from the 'iaxclient' project on sourceforge: - - * CVS browse: http://iaxclient.cvs.sourceforge.net/iaxclient/app_conference/ - * Project page: http://sourceforge.net/projects/iaxclient/ - - -Compiling app_conference - - * just like any other asterisk application. - * Some makefile fiddling may be necessary - - -Using app_conference -There is no configuration file. Conferences are created on-the-fly. - -Dialplan syntax: Conference(ConferenceName|Flags|Priority[|VADSTART|VADCONTINUE]) - - * ConferenceName: Whatever you want to name the conference - * Flags one of more of the following: - o M: Moderator (presently same as speaker) - o S: Speaker - o L: Listener - o T: "Telephone caller" (just for stats?). - o V: Do VAD on this caller - o D: Use Denoise filter on this caller. - o d: Send manager events when DTMF is received. - o q: Do not play enter or exit sounds. - o i: use inband dtmf broadcast. - o t: use rfc dtmf signal broadcast. - * Priority: Currently ignored; was to be a "speaking priority" so a - higher priority caller could "override" others. - * VADSTART: Optional: "probability" to use to detect start of speech. - * VADCONTINUE: Optional: "probability" to use to detect continuation - of speech. - - -Features / CLI/Manager Commands - - * conference debug [ on | off ] - enable debugging for a conference - - * conference show stats show conference stats - - * conference play sound [mute] - play a sound to a conference member, optionally muting them. - -Manager Events -app_conference generates several detailed manager events so that applications -interfacing with the manager API can monitor conferences: - - * ConferenceState: sent as members begin/end speaking. - Channel: The channel - State: "speaking" or "silent" - - * ConferenceDTMF: sent when conference members send DTMF to the conference - Channel: The channel - Key: The DTMF key send [0-9*#] - - * ConferenceSoundComplete: send when the conference has finished playing - a sound to a user - Channel: The channel - Sound: The first 255 bytes of the file requested in conference play - sound CLI/Mgr command. - - -Benchmarking -It would be nice to have solid benchmarks to present, but a good size -machine should be able to handle many callers when either (a) they are -using DTX, or (b) they are listen-only. It's used often with hundreds of -simultaneous callers. - -Discussion -The iaxclient-devel mailing list is probably as good a place as any to discuss. - - ---- - -app_conference is brought to you by the letter q, and the number e - - -Matt Florell Changes for VD_app_conference tarball version. In order to use this -as seemlessly as possible for VICIDIAL it was necessary to modify the code. This -module can now be used in place of using meetme for VICIDIAL. This is -experimental, please test thoroughly before putting it in production. - -CHANGES MADE FOR VICIDIAL: - -- Default to member type of S instead of L -- Commented out many repetative NOTICEs and ERRORs -- Added entry and exit sounds except for Local/786 and Local/8500998 (VDsilent and DTMFapp) -- Added conf-onlyperson mesage to first conference participant -- Included enter.gsm and leave.gsm files as well as DTMF wav and gsm sounds -- Removed restart from "make install" and added audio file copying -- If no 'd' option is set and DTMF frames are detected, the DTMF audio will be played to the member -- Added 'q' flag to prevent playing of entry/exit sounds -- Added 'i' flag to enable playing of DTMF sounds inband to all members -- Added 't' flag to enable sending of RFC DTMF signals to all members -- Changed delimiter to pipe | from slash / to be more compliant with meetme standards - - -NOTE TO 64-BIT LINUX USERS: -If you have problems with 64-bit Linux please use the included 64_Makefile instead of the default one. - -COMPILE NOTES: - -Some Makefile alterations may be necessary for your system: - -From Alek Barkley: -I am running FC4 with latest updates ( 2.6.16 kernel ) -My CPU is AMD K6 and GCC 4.0.2. - -I edited Makefile in app_conference distribution. -To enter CPU architecture in my case -march=k6 -======================================================== -PROC = k6 -# this is fun for x86 -#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 -CFLAGS += -march=k6 -=========================================================== - - -VD_app_conference CHANGELOG -- Release 0.4 - First VICIDIAL-centric release -- Release 0.5 - Fixed the dtmf broadcast logic and a star/hash bug - - Added 64-bit makefile thanks to Jon Hood -- Release 0.6 - Added Makefile notes and changed some Makefile flags diff --git a/extras/app_conference/VICIDIAL.txt b/extras/app_conference/VICIDIAL.txt deleted file mode 100644 index 92011ec2..00000000 --- a/extras/app_conference/VICIDIAL.txt +++ /dev/null @@ -1,86 +0,0 @@ -VICIDIAL and app_conference -(1.2 tree) EXPERIMENTAL!!! - -app_conference offers the plusses of being able to do conferencing -without any zaptel hardware or timers as well as doing native codec -streaming, meaning no manditory downsampling to slin like meetme. -These two features alone mean a rather significant performance boost -to companies who only use VOIP for agents and trunks as well as not -requiring the cost of zaptel hardware or the nightmare of getting -ztdummy to work on some systems. - -As of right now, I have a test system fully up and running using -app_conference with VICIDIAL on Asterisk 1.2.8. I have made several -modifications to the app_conference code to make it more of a drop-in -replacement for meetme so that it does not require any changes to the -VICIDIAL codebase. I have added entry and exit sounds(slightly -different from meetme's) as well as "only one in this conference" -message in addition to changing the default member type to speaker(S). -So far I have tested with IAX and SIP channels only and everything -works just like on meetme but I have not done any capacity testing or -tested it in production yet. - -If you want to use app_conference instead of meetme for VICIDIAL then follow these instructions: - -cd /usr/src/asterisk -wget http://www.eflo.net/files/VD_app_conference_0.6.zip -unzip VD_app_conference_0.6.zip -cd app_conference -make clean -make -make install - - -In your extensions.conf file you would replace these lines: -exten => 8600051,1,Meetme,8600051 -exten => 8600052,1,Meetme,8600052 -...continue through 8600100... -exten => 78600051,1,Meetme,8600051|q -exten => 78600052,1,Meetme,8600052|q -...continue through 78600100... -exten => 68600051,1,Meetme,8600051|mq -exten => 68600052,1,Meetme,8600052|mq -...continue through 68600100... - - -with these lines: -exten => 8600051,1,Conference(8600051) -exten => 8600052,1,Conference(8600052) -...continue through 8600100... -exten => 78600051,1,Conference(8600051|q) -exten => 78600052,1,Conference(8600052|q) -...continue through 78600100... -exten => 68600051,1,Conference(8600051|Lq) -exten => 68600052,1,Conference(8600052|Lq) -...continue through 68600100... - -NOTES: -Here are the possible feature flags for this version of app_conference: - o M: Moderator (presently same as speaker) [default] - o S: Speaker - o L: Listener - o T: "Telephone caller" (just for stats?). - o V: Do VAD on this caller - o D: Use Denoise filter on this caller. - o d: Send manager events when DTMF is received. - o q: Do not play enter or exit sounds. - o i: use inband dtmf broadcast. - o t: use rfc dtmf signal broadcast. - -COMPILE NOTES: - -Some Makefile alterations may be necessary for your system: - -From Alek Barkley: -I am running FC4 with latest updates ( 2.6.16 kernel ) -My CPU is AMD K6 and GCC 4.0.2. - -I edited Makefile in app_conference distribution. -To enter CPU architecture in my case -march=k6 -======================================================== -PROC = k6 -# this is fun for x86 -#CFLAGS += -march=pentium3 -msse -mfpmath=sse,387 -CFLAGS += -march=k6 -=========================================================== - diff --git a/extras/app_conference/app_conference.c b/extras/app_conference/app_conference.c deleted file mode 100644 index 9be6c3a3..00000000 --- a/extras/app_conference/app_conference.c +++ /dev/null @@ -1,146 +0,0 @@ - -// $Id: app_conference.c,v 1.22 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#include "app_conference.h" -#include "common.h" - -/* - -a conference has n + 1 threads, where n is the number of -members and 1 is a conference thread which sends audio -back to the members. - -each member thread reads frames from the channel and -add's them to the member's frame queue. - -the conference thread reads frames from each speaking members -queue, mixes them, and then re-queues them for the member thread -to send back to the user. - -*/ - -// -// app_conference text descriptions -// - -static char *tdesc = "Channel Independent Conference Application" ; -static char *app = "Conference" ; -static char *synopsis = "Channel Independent Conference" ; -static char *descrip = " Conference(): returns 0\n" -"if the user exits with the '#' key, or -1 if the user hangs up.\n" ; - -// -// functions defined in asterisk/module.h -// - -STANDARD_LOCAL_USER ; -LOCAL_USER_DECL; - -int unload_module( void ) -{ - ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ; - - STANDARD_HANGUP_LOCALUSERS ; // defined in asterisk/module.h - - // register conference cli functions - unregister_conference_cli() ; - - return ast_unregister_application( app ) ; -} - -int load_module( void ) -{ - ast_log( LOG_NOTICE, "loading app_conference module [ $Revision: 1.22 $ ]\n" ) ; - - // intialize conference - init_conference() ; - - // register conference cli functions - register_conference_cli() ; - - return ast_register_application( app, app_conference_main, synopsis, descrip ) ; -} - -char *description( void ) -{ - return tdesc ; -} - -int usecount( void ) -{ - int res; - STANDARD_USECOUNT( res ) ; // defined in asterisk/module.h - return res; -} - -char *key() -{ - return ASTERISK_GPL_KEY ; -} - -// -// main app_conference function -// - -int app_conference_main( struct ast_channel* chan, void* data ) -{ - int res = 0 ; - struct localuser *u ; - - // defined in asterisk/module.h - LOCAL_USER_ADD( u ) ; - - // call member thread function - res = member_exec( chan, data ) ; - - // defined in asterisk/module.h - LOCAL_USER_REMOVE( u ) ; - - return res ; -} - -// -// utility functions -// - -// now returns milliseconds -long usecdiff( struct timeval* timeA, struct timeval* timeB ) -{ - long a_secs = timeA->tv_sec - timeB->tv_sec ; - long b_secs = (long)( timeA->tv_usec / 1000 ) - (long)( timeB->tv_usec / 1000 ) ; - long u_secs = ( a_secs * 1000 ) + b_secs ; - return u_secs ; -} - -// increment a timeval by ms milliseconds -void add_milliseconds( struct timeval* tv, long ms ) -{ - // add the microseconds to the microseconds field - tv->tv_usec += ( ms * 1000 ) ; - - // calculate the number of seconds to increment - long s = ( tv->tv_usec / 1000000 ) ; - - // adjust the microsends field - if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ; - - // increment the seconds field - tv->tv_sec += s ; - - return ; -} diff --git a/extras/app_conference/app_conference.h b/extras/app_conference/app_conference.h deleted file mode 100644 index 695a65a9..00000000 --- a/extras/app_conference/app_conference.h +++ /dev/null @@ -1,200 +0,0 @@ - -// $Id: app_conference.h,v 1.11 2005/12/16 22:31:58 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _ASTERISK_CONF_H -#define _ASTERISK_CONF_H - -#include - -/* asterisk includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* standard includes */ -#include -#include -#include -#include - -#include - -#if (SILDET == 2) -#include "libspeex/speex_preprocess.h" -#endif - -// -// app_conference defines -// - -// debug logging level - -// LOG_NOTICE for debugging, LOG_DEBUG for production -#ifdef APP_CONFERENCE_DEBUG -#define AST_CONF_DEBUG LOG_NOTICE -#else -#define AST_CONF_DEBUG LOG_DEBUG -#endif - -// -// feature defines -// - -// number of times the last non-silent frame should be -// repeated after silence starts -//#define AST_CONF_CACHE_LAST_FRAME 1 - -// -// debug defines -// - -#define DEBUG_USE_TIMELOG - -#define DEBUG_FRAME_TIMESTAMPS - -// #define DEBUG_OUTPUT_PCM - -// -// !!! THESE CONSTANTS SHOULD BE CLEANED UP AND CLARIFIED !!! -// - -// -// sample information for AST_FORMAT_SLINEAR format -// - -#define AST_CONF_SAMPLE_RATE 8000 -#define AST_CONF_SAMPLE_SIZE 16 -#define AST_CONF_FRAME_INTERVAL 20 - -// -// so, since we cycle approximately every 20ms, -// we can compute the following values: -// -// 160 samples per 20 ms frame -or- -// ( 8000 samples-per-second * ( 20 ms / 1000 ms-per-second ) ) = 160 samples -// -// 320 bytes ( 2560 bits ) of data 20 ms frame -or- -// ( 160 samples * 16 bits-per-sample / 8 bits-per-byte ) = 320 bytes -// - -// 160 samples 16-bit signed linear -#define AST_CONF_BLOCK_SAMPLES 160 - -// 2 bytes per sample ( i.e. 16-bit ) -#define AST_CONF_BYTES_PER_SAMPLE 2 - -// 320 bytes for each 160 sample frame of 16-bit audio -#define AST_CONF_FRAME_DATA_SIZE 320 - -// 1000 ms-per-second / 20 ms-per-frame = 50 frames-per-second -#define AST_CONF_FRAMES_PER_SECOND ( 1000 / AST_CONF_FRAME_INTERVAL ) - - -// -// buffer and queue values -// - -// account for friendly offset when allocating buffer for frame -#define AST_CONF_BUFFER_SIZE ( AST_CONF_FRAME_DATA_SIZE + AST_FRIENDLY_OFFSET ) - -// maximum number of frames queued per member -#define AST_CONF_MAX_QUEUE 100 - -// minimum number of frames queued per member -#define AST_CONF_MIN_QUEUE 0 - -// number of queued frames before we start dropping -#define AST_CONF_QUEUE_DROP_THRESHOLD 4 - -// number of milliseconds between frame drops -#define AST_CONF_QUEUE_DROP_TIME_LIMIT 750 - -// -// timer and sleep values -// - -// milliseconds we're willing to wait for a channel -// event before we check for outgoing frames -#define AST_CONF_WAITFOR_LATENCY 40 - -// milliseconds to sleep before trying to process frames -#define AST_CONF_CONFERENCE_SLEEP 40 - -// milliseconds to wait between state notification updates -#define AST_CONF_NOTIFICATION_SLEEP 500 - -// -// warning threshold values -// - -// number of frames behind before warning -#define AST_CONF_OUTGOING_FRAMES_WARN 50 - -// number of milliseconds off AST_CONF_FRAME_INTERVAL before warning -#define AST_CONF_INTERVAL_WARNING 1000 - -// -// silence detection values -// - -// toggle silence detection -#define ENABLE_SILENCE_DETECTION 1 - -// silence threshold -#define AST_CONF_SILENCE_THRESHOLD 128 - -// speech tail (delay before dropping silent frames, in ms. -// #define AST_CONF_SPEECH_TAIL 180 - -// number of frames to ignore speex_preprocess() after speech detected -#define AST_CONF_SKIP_SPEEX_PREPROCESS 20 - -// our speex probability values -#define AST_CONF_PROB_START 0.05 -#define AST_CONF_PROB_CONTINUE 0.02 - -// -// format translation values -// - -// AST_FORMAT_MAX_AUDIO is 1 << 15, so we support 0..15 -#define AC_SUPPORTED_FORMATS 16 -#define AC_SLINEAR_INDEX 6 - -// -// app_conference functions -// - -// main module function -int app_conference_main( struct ast_channel* chan, void* data ) ; - -// utility functions -long usecdiff( struct timeval* timeA, struct timeval* timeB ) ; -void add_milliseconds( struct timeval* tv, long ms ) ; - -#endif - - diff --git a/extras/app_conference/cli.c b/extras/app_conference/cli.c deleted file mode 100644 index d5797034..00000000 --- a/extras/app_conference/cli.c +++ /dev/null @@ -1,332 +0,0 @@ - -// $Id: cli.c,v 1.6 2005/12/21 21:34:50 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#include "cli.h" - -// -// debug functions -// - -static char conference_debug_usage[] = - "usage: conference debug [ on | off ]\n" - " enable debugging for a conference\n" -; - -static struct ast_cli_entry cli_debug = { - { "conference", "debug", NULL }, - conference_debug, - "enable debugging for a conference", - conference_debug_usage -} ; - - -int conference_debug( int fd, int argc, char *argv[] ) -{ - if ( argc < 3 ) - return RESULT_SHOWUSAGE ; - - // get the conference name - const char* name = argv[2] ; - - // get the new state - int state = 0 ; - - if ( argc == 3 ) - { - // no state specified, so toggle it - state = -1 ; - } - else - { - if ( strncasecmp( name, "YES", 4 ) == 0 ) - state = 1 ; - else if ( strncasecmp( name, "NO", 3 ) == 0 ) - state = 0 ; - else - return RESULT_SHOWUSAGE ; - } - - int new_state = set_conference_debugging( name, state ) ; - - if ( new_state == 1 ) - { - ast_cli( fd, "enabled conference debugging, name => %s, new_state => %d\n", - name, new_state ) ; - } - else if ( new_state == 0 ) - { - ast_cli( fd, "disabled conference debugging, name => %s, new_state => %d\n", - name, new_state ) ; - } - else - { - // error setting state - ast_cli( fd, "\nunable to set debugging state, name => %s\n\n", name ) ; - } - - return RESULT_SUCCESS ; -} - -// -// stats functions -// - -static char conference_show_stats_usage[] = - "usage: conference show stats\n" - " display stats for active conferences.\n" -; - -static struct ast_cli_entry cli_show_stats = { - { "conference", "show", "stats", NULL }, - conference_show_stats, - "show conference stats", - conference_show_stats_usage -} ; - -int conference_show_stats( int fd, int argc, char *argv[] ) -{ - if ( argc < 3 ) - return RESULT_SHOWUSAGE ; - - // get count of active conferences - int count = get_conference_count() ; - - ast_cli( fd, "\n\nCONFERENCE STATS, ACTIVE( %d )\n\n", count ) ; - - // if zero, go no further - if ( count <= 0 ) - return RESULT_SUCCESS ; - - // - // get the conference stats - // - - // array of stats structs - ast_conference_stats stats[ count ] ; - - // get stats structs - count = get_conference_stats( stats, count ) ; - - // make sure we were able to fetch some - if ( count <= 0 ) - { - ast_cli( fd, "!!! error fetching conference stats, available => %d !!!\n", count ) ; - return RESULT_SUCCESS ; - } - - // - // output the conference stats - // - - // output header - ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", "Name", "Connection Type", "Member Type" ) ; - ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", "----", "---------------", "-----------" ) ; - - ast_conference_stats* s = NULL ; - - char ct[64] ; - char mt[64] ; - - int i; - for ( i = 0 ; i < count ; ++i ) - { - s = &(stats[i]) ; - - // format connection type - snprintf( ct, 40, "phone( %d ), iax( %d ), sip( %d )", - s->phone, s->iaxclient, s->sip ) ; - - // format memeber type - snprintf( mt, 40, "moderators( %d ), listeners( %d )", - s->moderators, s->listeners ) ; - - // output this conferences stats - ast_cli( fd, "%-20.20s %-40.40s %-40.40s\n", (char*)( &(s->name) ), ct, mt ) ; - } - - ast_cli( fd, "\n" ) ; - - // - // drill down to specific stats - // - - if ( argc == 4 ) - { - // show stats for a particular conference - conference_show_stats_name( fd, argv[3] ) ; - } - - return RESULT_SUCCESS ; -} - -int conference_show_stats_name( int fd, const char* name ) -{ - // not implemented yet - return RESULT_SUCCESS ; -} - -// -// play sound -// - -static char conference_play_sound_usage[] = - "usage: conference play sound [mute]\n" - " play sound to conference member .\n" - " mute the channel if 'mute' is present.\n" -; - -static struct ast_cli_entry cli_play_sound = { - { "conference", "play", "sound", NULL }, - conference_play_sound, - "play a sound to a conference member", - conference_play_sound_usage -} ; - -int conference_play_sound( int fd, int argc, char *argv[] ) -{ - char *channel, *file; - int mute = 0; - struct ast_conf_member *member; - struct ast_conf_soundq *newsound; - struct ast_conf_soundq **q; - - if ( argc < 5 ) - return RESULT_SHOWUSAGE ; - - channel = argv[3]; - file = argv[4]; - - if(argc > 5 && !strcmp(argv[5], "mute")) - mute = 1; - - - member = find_member(channel, 1); - if(!member) { - ast_cli(fd, "Member %s not found\n", channel); - return RESULT_FAILURE; - } - - newsound = calloc(1,sizeof(struct ast_conf_soundq)); - newsound->stream = ast_openstream(member->chan, file, NULL); - if(!newsound->stream) { - ast_cli(fd, "Sound %s not found\n", file); - free(newsound); - ast_mutex_unlock(&member->lock); - return RESULT_FAILURE; - } - member->chan->stream = NULL; - - newsound->muted = mute; - ast_copy_string(newsound->name, file, sizeof(newsound->name)); - - // append sound to the end of the list. - for(q=&member->soundq; *q; q = &((*q)->next)) ;; - - *q = newsound; - - ast_mutex_unlock(&member->lock); - - ast_cli( fd, "Playing sound %s to member %s %s\n", - file, channel, mute ? "with mute" : ""); - - - return RESULT_SUCCESS ; -} - -// -// stop sounds -// - -static char conference_stop_sounds_usage[] = - "usage: conference stop sounds \n" - " stop sounds for conference member .\n" -; - -static struct ast_cli_entry cli_stop_sounds = { - { "conference", "stop", "sounds", NULL }, - conference_stop_sounds, - "stop sounds for a conference member", - conference_stop_sounds_usage -} ; - -int conference_stop_sounds( int fd, int argc, char *argv[] ) -{ - char *channel; - struct ast_conf_member *member; - struct ast_conf_soundq *sound; - struct ast_conf_soundq *next; - - if ( argc < 4 ) - return RESULT_SHOWUSAGE ; - - channel = argv[3]; - - member = find_member(channel, 1); - if(!member) { - ast_cli(fd, "Member %s not found\n", channel); - return RESULT_FAILURE; - } - - - - // clear all sounds - sound = member->soundq; - member->soundq = NULL; - - while(sound) { - next = sound->next; - ast_closestream(sound->stream); - free(sound); - sound = next; - } - - // reset write format, since we're done playing the sound - if ( ast_set_write_format( member->chan, member->write_format ) < 0 ) - { - ast_log( LOG_ERROR, "unable to set write format to %d\n", - member->write_format ) ; - } - - ast_mutex_unlock(&member->lock); - - ast_cli( fd, "Stopped sounds to member %s\n", channel); - - - return RESULT_SUCCESS ; -} - - -// -// cli initialization function -// - -void register_conference_cli( void ) -{ - ast_cli_register( &cli_debug ) ; - ast_cli_register( &cli_show_stats ) ; - ast_cli_register( &cli_play_sound ) ; - ast_cli_register( &cli_stop_sounds ) ; -} - -void unregister_conference_cli( void ) -{ - ast_cli_unregister( &cli_debug ) ; - ast_cli_unregister( &cli_show_stats ) ; - ast_cli_unregister( &cli_play_sound ) ; - ast_cli_unregister( &cli_stop_sounds ) ; -} diff --git a/extras/app_conference/cli.h b/extras/app_conference/cli.h deleted file mode 100644 index 735b284d..00000000 --- a/extras/app_conference/cli.h +++ /dev/null @@ -1,47 +0,0 @@ - -// $Id: cli.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_CLI_H -#define _APP_CONF_CLI_H - -// -// includes -// - -#include "app_conference.h" -#include "common.h" - -// -// function declarations -// - -int conference_show_stats( int fd, int argc, char *argv[] ) ; -int conference_show_stats_name( int fd, const char* name ) ; - - -int conference_debug( int fd, int argc, char *argv[] ) ; -int conference_no_debug( int fd, int argc, char *argv[] ) ; - -int conference_play_sound( int fd, int argc, char *argv[] ) ; -int conference_stop_sounds( int fd, int argc, char *argv[] ) ; - -void register_conference_cli( void ) ; -void unregister_conference_cli( void ) ; - - -#endif diff --git a/extras/app_conference/common.h b/extras/app_conference/common.h deleted file mode 100644 index a8015462..00000000 --- a/extras/app_conference/common.h +++ /dev/null @@ -1,50 +0,0 @@ - -// $Id: common.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_COMMON_H -#define _APP_CONF_COMMON_H - -// typedef includes -#include "conf_frame.h" - -// function includesee -#include "conference.h" -#include "member.h" -#include "frame.h" -#include "cli.h" - - -/* Utility functions */ - -/* LOG the time taken to execute a function (like lock acquisition */ -#if 1 -#define TIMELOG(func,min,message) \ - do { \ - struct timeval t1, t2; \ - int diff; \ - gettimeofday(&t1,NULL); \ - func; \ - gettimeofday(&t2,NULL); \ - if((diff = usecdiff(&t2, &t1)) > min) \ - ast_log( AST_CONF_DEBUG, "TimeLog: %s: %d ms\n", message, diff); \ - } while (0) -#else -#define TIMELOG(func,min,message) func -#endif - -#endif diff --git a/extras/app_conference/conf_frame.h b/extras/app_conference/conf_frame.h deleted file mode 100644 index 24cac7f9..00000000 --- a/extras/app_conference/conf_frame.h +++ /dev/null @@ -1,61 +0,0 @@ - -// $Id: conf_frame.h,v 1.3 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_STRUCTS_H -#define _APP_CONF_STRUCTS_H - -// -// includes -// - -#include "app_conference.h" -#include "common.h" - -// -// struct declarations -// - -typedef struct conf_frame -{ - // frame audio data - struct ast_frame* fr ; - - // array of converted versions for listeners - struct ast_frame* converted[ AC_SUPPORTED_FORMATS ] ; - - // pointer to the frame's owner - struct ast_conf_member* member ; // who sent this frame - - // frame meta data -// struct timeval timestamp ; -// unsigned long cycleid ; -// int priority ; - - // linked-list pointers - struct conf_frame* next ; - struct conf_frame* prev ; - - // should this frame be preserved - short static_frame ; - - // pointer to mixing buffer - char* mixed_buffer ; -} conf_frame ; - - -#endif diff --git a/extras/app_conference/conference.c b/extras/app_conference/conference.c deleted file mode 100644 index 4bdb64ca..00000000 --- a/extras/app_conference/conference.c +++ /dev/null @@ -1,1410 +0,0 @@ - -// $Id: conference.c,v 1.7 2005/10/27 17:53:35 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#include "conference.h" -#include "regex.h" - -// -// static variables -// - -// single-linked list of current conferences -static struct ast_conference *conflist = NULL ; - -// mutex for synchronizing access to conflist -AST_MUTEX_DEFINE_STATIC(conflist_lock); -//static ast_mutex_t conflist_lock = AST_MUTEX_INITIALIZER ; - -// mutex for synchronizing calls to start_conference() and remove_conf() -AST_MUTEX_DEFINE_STATIC(start_stop_conf_lock); -//static ast_mutex_t start_stop_conf_lock = AST_MUTEX_INITIALIZER ; - -static int conference_count = 0 ; - -// -// main conference function -// - -void conference_exec( struct ast_conference *conf ) -{ - - struct ast_conf_member *member, *temp_member , *membertest; - struct conf_frame *cfr, *spoken_frames, *send_frames ; - - // count number of speakers, number of listeners - int speaker_count ; - int listener_count ; - - ast_log( AST_CONF_DEBUG, "[ $Revision: 1.7 $ ] entered conference_exec, name => %s\n", conf->name ) ; - - // timer timestamps - struct timeval base, curr, notify ; - gettimeofday( &base, NULL ) ; - gettimeofday( ¬ify, NULL ) ; - - // holds differences of curr and base - long time_diff = 0 ; - long time_sleep = 0 ; - - int since_last_slept = 0 ; - - // - // variables for checking thread frequency - // - - // count to AST_CONF_FRAMES_PER_SECOND - int tf_count = 0 ; - long tf_diff = 0 ; - float tf_frequency = 0.0 ; - - struct timeval tf_base, tf_curr ; - gettimeofday( &tf_base, NULL ) ; - - // - // main conference thread loop - // - - - while ( 42 == 42 ) - { - // update the current timestamp - gettimeofday( &curr, NULL ) ; - - // calculate difference in timestamps - time_diff = usecdiff( &curr, &base ) ; - - // calculate time we should sleep - time_sleep = AST_CONF_FRAME_INTERVAL - time_diff ; - - if ( time_sleep > 0 ) - { - // sleep for sleep_time ( as milliseconds ) - usleep( time_sleep * 1000 ) ; - - // reset since last slept counter - since_last_slept = 0 ; - - continue ; - } - else - { - // long sleep warning - if ( - since_last_slept == 0 - && time_diff > AST_CONF_CONFERENCE_SLEEP * 2 - ) - { - ast_log( - AST_CONF_DEBUG, - "long scheduling delay, time_diff => %ld, AST_CONF_FRAME_INTERVAL => %d\n", - time_diff, AST_CONF_FRAME_INTERVAL - ) ; - } - - // increment times since last slept - ++since_last_slept ; - - // sleep every other time - if ( since_last_slept % 2 ) - usleep( 0 ) ; - } - - // adjust the timer base ( it will be used later to timestamp outgoing frames ) - add_milliseconds( &base, AST_CONF_FRAME_INTERVAL ) ; - - // - // check thread frequency - // - - if ( ++tf_count >= AST_CONF_FRAMES_PER_SECOND ) - { - // update current timestamp - gettimeofday( &tf_curr, NULL ) ; - - // compute timestamp difference - tf_diff = usecdiff( &tf_curr, &tf_base ) ; - - // compute sampling frequency - tf_frequency = ( float )( tf_diff ) / ( float )( tf_count ) ; - - if ( - ( tf_frequency <= ( float )( AST_CONF_FRAME_INTERVAL - 1 ) ) - || ( tf_frequency >= ( float )( AST_CONF_FRAME_INTERVAL + 1 ) ) - ) - { - ast_log( - LOG_WARNING, - "processed frame frequency variation, name => %s, tf_count => %d, tf_diff => %ld, tf_frequency => %2.4f\n", - conf->name, tf_count, tf_diff, tf_frequency - ) ; - } - - // reset values - tf_base = tf_curr ; - tf_count = 0 ; - } - - //-----------------// - // INCOMING FRAMES // - //-----------------// - - // ast_log( AST_CONF_DEBUG, "PROCESSING FRAMES, conference => %s, step => %d, ms => %ld\n", - // conf->name, step, ( base.tv_usec / 20000 ) ) ; - - // acquire conference mutex - TIMELOG(ast_mutex_lock( &conf->lock ),1,"conf thread conf lock"); - - // update the current delivery time - conf->delivery_time = base ; - - // - // loop through the list of members - // ( conf->memberlist is a single-linked list ) - // - - // ast_log( AST_CONF_DEBUG, "begin processing incoming audio, name => %s\n", conf->name ) ; - - // reset speaker and listener count - speaker_count = 0 ; - listener_count = 0 ; - - // get list of conference members - member = conf->memberlist ; - - // reset pointer lists - spoken_frames = NULL ; - - // loop over member list to retrieve queued frames - while ( member != NULL ) - { - // acquire member mutex - TIMELOG(ast_mutex_lock( &member->lock ),1,"conf thread member lock") ; - - // check for dead members - if ( member->remove_flag == 1 ) - { - // leave message for other members of the conference - membertest = conf->memberlist ; - - int silent_exit = 0 ; - if (member->quiet_entry_exit == -1) - { - silent_exit = 1 ; - } - - while (membertest != NULL) - { - if (silent_exit < 1) - { - if(!strcmp(membertest->channel_name, member->channel_name)) - { - ast_log( LOG_ERROR, "skipping leave message on %s\n", membertest->channel_name ) ; - } - else - { - if (!basic_play_sound ( membertest->channel_name, "leave" )) - { - ast_log( LOG_ERROR, "playing conference leave message FAILED on %s\n", membertest->channel_name ) ; - } - } - } - else - { - ast_log( LOG_NOTICE, "skipping all entry messages on %s\n", membertest->channel_name ) ; - } - membertest = membertest->next; - } - - - ast_log( LOG_NOTICE, "found member slated for removal, channel => %s\n", member->channel_name ) ; - temp_member = member->next ; - remove_member( member, conf ) ; - member = temp_member ; - continue ; - } - - // get speaking member's audio frames, - if ( member->type == 'L' ) - { - // listeners never have frames - cfr = NULL ; - } - else - { - // tell member the number of frames we're going to need ( used to help dropping algorithm ) - member->inFramesNeeded = ( time_diff / AST_CONF_FRAME_INTERVAL ) - 1 ; - -// !!! TESTING !!! -if ( - conf->debug_flag == 1 - && member->inFramesNeeded > 0 -) -{ - ast_log( AST_CONF_DEBUG, "channel => %s, inFramesNeeded => %d, inFramesCount => %d\n", - member->channel_name, member->inFramesNeeded, member->inFramesCount ) ; -} - - // non-listener member should have frames, - // unless silence detection dropped them - cfr = get_incoming_frame( member ) ; - } - - // handle retrieved frames - if ( cfr == NULL ) - { - // this member is listen-only, or has not spoken - // ast_log( AST_CONF_DEBUG, "silent member, channel => %s\n", member->channel_name ) ; - -// !!! TESTING !!! -#if 0 -if ( member->speaking_state == 1 ) -{ - ast_log( AST_CONF_DEBUG, "member has stopped speaking, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} -#endif -if ( conf->debug_flag == 1 ) -{ - ast_log( AST_CONF_DEBUG, "member is silent, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} - - // mark member as silent - member->speaking_state = 0 ; - - // count the listeners - ++listener_count ; - } - else if ( cfr->fr == NULL ) - { - ast_log( AST_CONF_DEBUG, "got incoming conf_frame with null ast_frame\n" ) ; - -// !!! TESTING !!! -#if 0 -if ( member->speaking_state == 1 ) -{ - ast_log( AST_CONF_DEBUG, "member has stopped speaking, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} -#endif -if ( conf->debug_flag == 1 ) -{ - ast_log( AST_CONF_DEBUG, "member is silent, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} - - // mark member as silent - member->speaking_state = 0 ; - - // count the listeners - ++listener_count ; - } - else - { - // this speaking member has spoken - // ast_log( AST_CONF_DEBUG, "speaking member, channel => %s\n", member->channel_name ) ; - - // append the frame to the list of spoken frames - if ( spoken_frames != NULL ) - { - // add new frame to end of list - cfr->next = spoken_frames ; - spoken_frames->prev = cfr ; - } - - // point the list at the new frame - spoken_frames = cfr ; - -// !!! TESTING !!! -#if 0 -if ( member->speaking_state == 0 ) -{ - ast_log( AST_CONF_DEBUG, "member has started speaking, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} -#endif -if ( conf->debug_flag == 1 ) -{ - ast_log( AST_CONF_DEBUG, "member is speaking, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; -} - - // mark member as speaker - member->speaking_state = 1 ; - member->speaking_state_notify = 1 ; - - // count the speakers - ++speaker_count ; - } - - // release member mutex - ast_mutex_unlock( &member->lock ) ; - - // adjust our pointer to the next inline - member = member->next ; - } - - // - // break, if we have no more members - // - - if ( conf->membercount == 0 ) - { - ast_log( LOG_NOTICE, "removing conference, count => %d, name => %s\n", conf->membercount, conf->name ) ; - remove_conf( conf ) ; // stop the conference - break ; // break from main processing loop - } - - // ast_log( AST_CONF_DEBUG, "finished processing incoming audio, name => %s\n", conf->name ) ; - - - //---------------// - // MIXING FRAMES // - //---------------// - - // mix frames and get batch of outgoing frames - send_frames = mix_frames( spoken_frames, speaker_count, listener_count ) ; - - // accounting: if there are frames, count them as one incoming frame - if ( send_frames != NULL ) - { - // set delivery timestamp - // set_conf_frame_delivery( send_frames, base ) ; - - // ast_log( AST_CONF_DEBUG, "base => %ld.%ld %d\n", base.tv_sec, base.tv_usec, ( int )( base.tv_usec / 1000 ) ) ; - - conf->stats.frames_in++ ; - } - - //-----------------// - // OUTGOING FRAMES // - //-----------------// - - - // - // queue send frames - // - - // ast_log( AST_CONF_DEBUG, "begin queueing outgoing audio, name => %s\n", conf->name ) ; - - // - // loop over member list to queue outgoing frames - // - for ( member = conf->memberlist ; member != NULL ; member = member->next ) - { - // skip members that are not ready - if ( member->ready_for_outgoing == 0 ) - continue ; - - if ( member->speaking_state == 0 ) - { - // queue listener frame - queue_frame_for_listener( conf, member, send_frames ) ; - } - else - { - // queue speaker frame - queue_frame_for_speaker( conf, member, send_frames ) ; - } - } - - // ast_log( AST_CONF_DEBUG, "end queueing outgoing audio, name => %s\n", conf->name ) ; - - //---------// - // CLEANUP // - //---------// - - // clean up send frames - while ( send_frames != NULL ) - { - // accouting: count all frames and mixed frames - if ( send_frames->member == NULL ) - conf->stats.frames_out++ ; - else - conf->stats.frames_mixed++ ; - - // delete the frame - send_frames = delete_conf_frame( send_frames ) ; - } - - // - // notify the manager of state changes every 500 milliseconds - // - - if ( ( usecdiff( &curr, ¬ify ) / AST_CONF_NOTIFICATION_SLEEP ) >= 1 ) - { - // send the notifications - send_state_change_notifications( conf->memberlist ) ; - - // increment the notification timer base - add_milliseconds( ¬ify, AST_CONF_NOTIFICATION_SLEEP ) ; - } - - // release conference mutex - ast_mutex_unlock( &conf->lock ) ; - - // !!! TESTING !!! - // usleep( 1 ) ; - } - // end while ( 42 == 42 ) - - // - // exit the conference thread - // - - ast_log( AST_CONF_DEBUG, "exit conference_exec\n" ) ; - - // exit the thread - pthread_exit( NULL ) ; - - return ; -} - -// -// manange conference functions -// - -// called by app_conference.c:load_module() -void init_conference( void ) -{ - ast_mutex_init( &start_stop_conf_lock ) ; - ast_mutex_init( &conflist_lock ) ; -} - -struct ast_conference* start_conference( struct ast_conf_member* member ) -{ - // check input - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to handle null member\n" ) ; - return NULL ; - } - - struct ast_conference* conf = NULL ; - - // acquire mutex - ast_mutex_lock( &start_stop_conf_lock ) ; - - // look for an existing conference - ast_log( AST_CONF_DEBUG, "attempting to find requested conference\n" ) ; - conf = find_conf( member->id ) ; - - // unable to find an existing conference, try to create one - if ( conf == NULL ) - { - // create a new conference - ast_log( AST_CONF_DEBUG, "attempting to create requested conference\n" ) ; - - // create the new conference with one member - conf = create_conf( member->id, member ) ; - - // return an error if create_conf() failed - if ( conf == NULL ) - { - ast_log( LOG_ERROR, "unable to find or create requested conference\n" ) ; - ast_mutex_unlock( &start_stop_conf_lock ) ; // release mutex - return NULL ; - } - } - else - { - // - // existing conference found, add new member to the conference - // - // once we call add_member(), this thread - // is responsible for calling delete_member() - // - add_member( member, conf ) ; - - } - - // release mutex - ast_mutex_unlock( &start_stop_conf_lock ) ; - - return conf ; -} - - -struct ast_conference* find_conf( const char* name ) -{ - // no conferences exist - if ( conflist == NULL ) - { - ast_log( AST_CONF_DEBUG, "conflist has not yet been initialized, name => %s\n", name ) ; - return NULL ; - } - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - struct ast_conference *conf = conflist ; - - // loop through conf list - while ( conf != NULL ) - { - if ( strncasecmp( (char*)&(conf->name), name, 80 ) == 0 ) - { - // found conf name match - ast_log( AST_CONF_DEBUG, "found conference in conflist, name => %s\n", name ) ; - break ; - } - - conf = conf->next ; - } - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - if ( conf == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to find conference in conflist, name => %s\n", name ) ; - } - - return conf ; -} - -struct ast_conference* create_conf( char* name, struct ast_conf_member* member ) -{ - ast_log( AST_CONF_DEBUG, "entered create_conf, name => %s\n", name ) ; - - // - // allocate memory for conference - // - - struct ast_conference *conf = malloc( sizeof( struct ast_conference ) ) ; - - if ( conf == NULL ) - { - ast_log( LOG_ERROR, "unable to malloc ast_conference\n" ) ; - return NULL ; - } - - // - // initialize conference - // - - conf->next = NULL ; - conf->memberlist = NULL ; - - conf->membercount = 0 ; - conf->conference_thread = -1 ; - - conf->debug_flag = 0 ; - - // zero stats - memset( &conf->stats, 0x0, sizeof( ast_conference_stats ) ) ; - - // record start time - gettimeofday( &conf->stats.time_entered, NULL ) ; - - // copy name to conference - strncpy( (char*)&(conf->name), name, sizeof(conf->name) - 1 ) ; - strncpy( (char*)&(conf->stats.name), name, sizeof(conf->name) - 1 ) ; - - // initialize mutexes - ast_mutex_init( &conf->lock ) ; - - // build translation paths - - int c; - for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) - { - if ( c == AC_SLINEAR_INDEX ) - conf->from_slinear_paths[ c ] = NULL; - else - conf->from_slinear_paths[ c ] =ast_translator_build_path( 1 << c, AST_FORMAT_SLINEAR); - } - - // add the initial member - add_member( member, conf ) ; - - // - // prepend new conference to conflist - // - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - conf->next = conflist ; - conflist = conf ; - - ast_log( AST_CONF_DEBUG, "added new conference to conflist, name => %s\n", name ) ; - - // - // spawn thread for new conference, using conference_exec( conf ) - // - - // acquire conference mutexes - ast_mutex_lock( &conf->lock ) ; - - if ( pthread_create( &conf->conference_thread, NULL, (void*)conference_exec, conf ) == 0 ) - { - // detach the thread so it doesn't leak - pthread_detach( conf->conference_thread ) ; - - // release conference mutexes - ast_mutex_unlock( &conf->lock ) ; - - ast_log( AST_CONF_DEBUG, "started conference thread for conference, name => %s\n", conf->name ) ; - } - else - { - ast_log( LOG_ERROR, "unable to start conference thread for conference %s\n", conf->name ) ; - - conf->conference_thread = -1 ; - - // release conference mutexes - ast_mutex_unlock( &conf->lock ) ; - - // clean up conference - free( conf ) ; - conf = NULL ; - } - - // count new conference - if ( conf != NULL ) - ++conference_count ; - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - return conf ; -} - -void remove_conf( struct ast_conference *conf ) -{ - // ast_log( AST_CONF_DEBUG, "attempting to remove conference, name => %s\n", conf->name ) ; - - struct ast_conference *conf_current = conflist ; - struct ast_conference *conf_temp = NULL ; - - // acquire mutex - ast_mutex_lock( &start_stop_conf_lock ) ; - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - // loop through list of conferences - while ( conf_current != NULL ) - { - // if conf_current point to the passed conf, - if ( conf_current == conf ) - { - if ( conf_temp == NULL ) - { - // this is the first conf in the list, so we just point - // conflist past the current conf to the next - conflist = conf_current->next ; - } - else - { - // this is not the first conf in the list, so we need to - // point the preceeding conf to the next conf in the list - conf_temp->next = conf_current->next ; - } - - // - // do some frame clean up - // - int c; - for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) - { - // free the translation paths - if ( conf_current->from_slinear_paths[ c ] != NULL ) - { - ast_translator_free_path( conf_current->from_slinear_paths[ c ] ) ; - conf_current->from_slinear_paths[ c ] = NULL ; - } - } - - // calculate time in conference - struct timeval time_exited ; - gettimeofday( &time_exited, NULL ) ; - - // total time converted to seconds - long tt = ( usecdiff( &time_exited, &conf_current->stats.time_entered ) / 1000 ) ; - - // report accounting information - ast_log( LOG_NOTICE, "conference accounting, fi => %ld, fo => %ld, fm => %ld, tt => %ld\n", - conf_current->stats.frames_in, conf_current->stats.frames_out, conf_current->stats.frames_mixed, tt ) ; - - ast_log( AST_CONF_DEBUG, "removed conference, name => %s\n", conf_current->name ) ; - - ast_mutex_unlock( &conf_current->lock ) ; - - free( conf_current ) ; - conf_current = NULL ; - - break ; - } - - // save a refence to the soon to be previous conf - conf_temp = conf_current ; - - // move conf_current to the next in the list - conf_current = conf_current->next ; - } - - // count new conference - --conference_count ; - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - // release mutex - ast_mutex_unlock( &start_stop_conf_lock ) ; - - return ; -} - -// -// member-related functions -// - -void add_member( struct ast_conf_member *member, struct ast_conference *conf ) -{ - if ( conf == NULL ) - { - ast_log( LOG_ERROR, "unable to add member to NULL conference\n" ) ; - return ; - } - - // acquire the conference lock - ast_mutex_lock( &conf->lock ) ; - - member->next = conf->memberlist ; // next is now list - conf->memberlist = member ; // member is now at head of list - - // update conference stats - count_member( member, conf, 1 ) ; - - ast_log( AST_CONF_DEBUG, "member added to conference, name => %s\n", conf->name ) ; - - // release the conference lock - ast_mutex_unlock( &conf->lock ) ; - - return ; -} - -int remove_member( struct ast_conf_member* member, struct ast_conference* conf ) -{ - // check for member - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to remove NULL member\n" ) ; - return -1 ; - } - - // check for conference - if ( conf == NULL ) - { - ast_log( LOG_WARNING, "unable to remove member from NULL conference\n" ) ; - return -1 ; - } - - // - // loop through the member list looking - // for the requested member - // - - struct ast_conf_member *member_list = conf->memberlist ; - struct ast_conf_member *member_temp = NULL ; - - int count = -1 ; // default return code - - while ( member_list != NULL ) - { - if ( member_list == member ) - { - // - // log some accounting information - // - - // calculate time in conference - struct timeval time_exited ; - gettimeofday( &time_exited, NULL ) ; - long tt = ( usecdiff( &time_exited, &member->time_entered ) / 1000 ) ; // convert to seconds - - ast_log( - LOG_NOTICE, - "member accounting, channel => %s, te => %ld, fi => %ld, fid => %ld, fo => %ld, fod => %ld, tt => %ld\n", - member->channel_name, - member->time_entered.tv_sec, member->frames_in, member->frames_in_dropped, - member->frames_out, member->frames_out_dropped, tt - ) ; - - // - // if this is the first member in the linked-list, - // skip over the first member in the list, else - // - // point the previous 'next' to the current 'next', - // thus skipping the current member in the list - // - if ( member_temp == NULL ) - conf->memberlist = member->next ; - else - member_temp->next = member->next ; - - // update conference stats - count = count_member( member, conf, 0 ) ; - - // delete the member - delete_member( member ) ; - - ast_log( AST_CONF_DEBUG, "removed member from conference, name => %s, remaining => %d\n", conf->name, conf->membercount ) ; - - break ; - } - - // save a pointer to the current member, - // and then point to the next member in the list - member_temp = member_list ; - member_list = member_list->next ; - } - - // return -1 on error, or the number of members - // remaining if the requested member was deleted - return count ; -} - -int count_member( struct ast_conf_member* member, struct ast_conference* conf, short add_member ) -{ - if ( member == NULL || conf == NULL ) - { - ast_log( LOG_WARNING, "unable to count member\n" ) ; - return -1 ; - } - - short delta = ( add_member == 1 ) ? 1 : -1 ; - - // member type - if ( memberIsModerator( member ) == 1 ) - { - conf->stats.moderators += delta ; - } - else - { - // count non-moderators as listeners - conf->stats.listeners += delta ; - } - - // connection type - if ( memberIsPhoneClient( member ) == 1 ) - { - conf->stats.phone += delta ; - } - else if ( memberIsIaxClient( member ) == 1 ) - { - conf->stats.iaxclient += delta ; - } - else if ( memberIsSIPClient( member ) == 1 ) - { - conf->stats.sip += delta ; - } - - // increment member count - conf->membercount += delta ; - - return conf->membercount ; -} - -// -// queue incoming frame functions -// - -int queue_frame_for_speaker( - struct ast_conference* conf, - struct ast_conf_member* member, - conf_frame* frame -) -{ - // - // check inputs - // - - if ( conf == NULL ) - { - ast_log( LOG_WARNING, "unable to queue speaker frame with null conference\n" ) ; - return -1 ; - } - - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to queue speaker frame with null member\n" ) ; - return -1 ; - } - - // - // loop over spoken frames looking for member's appropriate match - // - - short found_flag = 0 ; - struct ast_frame* qf ; - - for ( ; frame != NULL ; frame = frame->next ) - { - if ( frame->member != member ) - continue ; - - if ( frame->fr == NULL ) - { - ast_log( LOG_WARNING, "unable to queue speaker frame with null data\n" ) ; - continue ; - } - - // - // convert and queue frame - // - - // short-cut pointer to the ast_frame - qf = frame->fr ; - - // acquire member lock - TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_frame_for_speaker: memberlock") ; - - if ( qf->subclass == member->write_format ) - { - // frame is already in correct format, so just queue it - queue_outgoing_frame( member, qf, conf->delivery_time ) ; - } - else - { - // - // convert frame to member's write format - // ( calling ast_frdup() to make sure the translator's copy sticks around ) - // - qf = convert_frame_from_slinear( member->from_slinear, ast_frdup( qf ) ) ; - - if ( qf != NULL ) - { - // queue frame - queue_outgoing_frame( member, qf, conf->delivery_time ) ; - - // free frame ( the translator's copy ) - ast_frfree( qf ) ; - } - else - { - ast_log( LOG_WARNING, "unable to translate outgoing speaker frame, channel => %s\n", member->channel_name ) ; - } - } - - // release member lock - ast_mutex_unlock( &member->lock ) ; - - // set found flag - found_flag = 1 ; - - // we found the frame, skip to the next member - break ; - } - - // queue a silent frame - if ( found_flag == 0 ) - queue_silent_frame( conf, member ) ; - - return 0 ; -} - -int queue_frame_for_listener( - struct ast_conference* conf, - struct ast_conf_member* member, - conf_frame* frame -) -{ - // - // check inputs - // - - if ( conf == NULL ) - { - ast_log( LOG_WARNING, "unable to queue listener frame with null conference\n" ) ; - return -1 ; - } - - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to queue listener frame with null member\n" ) ; - return -1 ; - } - - // - // loop over spoken frames looking for member's appropriate match - // - - short found_flag = 0 ; - struct ast_frame* qf ; - - for ( ; frame != NULL ; frame = frame->next ) - { - // we're looking for a null or matching member - if ( frame->member != NULL && frame->member != member ) - continue ; - - if ( frame->fr == NULL ) - { - ast_log( LOG_WARNING, "unknown error queueing frame for listener, frame->fr == NULL\n" ) ; - continue ; - } - - // acquire member lock - TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_frame_for_listener") ; - - // first, try for a pre-converted frame - qf = frame->converted[ member->write_format_index ] ; - - /* - if ( qf != NULL && (member->smooth_size_out > 0)) { - if (qf->datalen != member->smooth_size_out ) { -//ast_log (AST_CONF_DEBUG, "ignoring and freeing previously stored frame, with datalen=>%d != smooth_size_out=>%d\n",qf->datalen,member->smooth_size_out); - ast_frfree( qf ) ; - qf = NULL ; - } - } - */ - - // convert ( and store ) the frame - if ( qf == NULL ) - { - // make a copy of the slinear version of the frame - qf = ast_frdup( frame->fr ) ; - - if ( qf == NULL ) - { - ast_log( LOG_WARNING, "unable to duplicate frame\n" ) ; - continue ; - } - - // convert using the conference's translation path - qf = convert_frame_from_slinear( conf->from_slinear_paths[ member->write_format_index ], qf ) ; - if ( qf == NULL ) - ast_log( LOG_WARNING, "unable to translate frame for listener, channel => %s , member->write_format => %d , member->write_format_index %d , qf->frametype -> %d , qf->subclass -> %d, qf->datalen=> %d, qf->samples =>%d\n", member->channel_name , member->write_format, member->write_format_index, qf->frametype, qf->subclass , qf->datalen, qf->samples) ; - - // store the converted frame - // ( the frame will be free'd next time through the loop ) - frame->converted[ member->write_format_index ] = qf ; -//ast_log (AST_CONF_DEBUG, "storing converted frame into index=>%d, qf->frametype=>%d, qf->subclass=%d, qf->datalen=%d \n",member->write_format_index, qf->frametype, qf->subclass, qf->datalen); - } - - if ( qf != NULL ) - { - // duplicate the frame before queue'ing it - // ( since this member doesn't own this _shared_ frame ) - // qf = ast_frdup( qf ) ; - - if ( queue_outgoing_frame( member, qf, conf->delivery_time ) != 0 ) - { - // free the new frame if it couldn't be queue'd - ast_frfree( qf ) ; - qf = NULL ; - } - } - else - { - ast_log( LOG_WARNING, "unable to translate outgoing listener frame, channel => %s\n", member->channel_name ) ; - } - - // release member lock - ast_mutex_unlock( &member->lock ) ; - - // set found flag - found_flag = 1 ; - - // break from for loop - break ; - } - - // queue a silent frame - if ( found_flag == 0 ) - queue_silent_frame( conf, member ) ; - - return 0 ; -} - -int queue_silent_frame( - struct ast_conference* conf, - struct ast_conf_member* member -) -{ -#ifdef APP_CONFERENCE_DEBUG - // - // check inputs - // - - if ( conf == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to queue silent frame for null conference\n" ) ; - return -1 ; - } - - if ( member == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to queue silent frame for null member\n" ) ; - return -1 ; - } -#endif // APP_CONFERENCE_DEBUG - - // - // initialize static variables - // - - static conf_frame* silent_frame = NULL ; - static struct ast_frame* qf = NULL ; - - if ( silent_frame == NULL ) - { - if ( ( silent_frame = get_silent_frame() ) == NULL ) - { - ast_log( LOG_WARNING, "unable to initialize static silent frame\n" ) ; - return -1 ; - } - } - - // acquire member lock - TIMELOG(ast_mutex_lock( &member->lock ),1,"queue_silent_frame") ; - - // get the appropriate silent frame - qf = silent_frame->converted[ member->write_format_index ] ; - - if ( qf == NULL ) - { - // - // we need to do this to avoid echo on the speaker's line. - // translators seem to be single-purpose, i.e. they - // can't be used simultaneously for multiple audio streams - // - - struct ast_trans_pvt* trans = ast_translator_build_path( member->write_format, AST_FORMAT_SLINEAR ) ; - - if ( trans != NULL ) - { - // attempt ( five times ) to get a silent frame - // to make sure we provice the translator with enough data - int c; - for ( c = 0 ; c < 5 ; ++c ) - { - // translate the frame - qf = ast_translate( trans, silent_frame->fr, 0 ) ; - - // break if we get a frame - if ( qf != NULL ) break ; - } - - if ( qf != NULL ) - { - // isolate the frame so we can keep it around after trans is free'd - qf = ast_frisolate( qf ) ; - - // cache the new, isolated frame - silent_frame->converted[ member->write_format_index ] = qf ; - } - - ast_translator_free_path( trans ) ; - } - } - - // - // queue the frame, if it's not null, - // otherwise there was an error - // - if ( qf != NULL ) - { - queue_outgoing_frame( member, qf, conf->delivery_time ) ; - } - else - { - ast_log( LOG_ERROR, "unable to translate outgoing silent frame, channel => %s\n", member->channel_name ) ; - } - - // release member lock - ast_mutex_unlock( &member->lock ) ; - - return 0 ; -} - -// -// get conference stats -// - -// -// returns: -1 => error, 0 => debugging off, 1 => debugging on -// state: on => 1, off => 0, toggle => -1 -// -int set_conference_debugging( const char* name, int state ) -{ - if ( name == NULL ) - return -1 ; - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - struct ast_conference *conf = conflist ; - int new_state = -1 ; - - // loop through conf list - while ( conf != NULL ) - { - if ( strncasecmp( (const char*)&(conf->name), name, 80 ) == 0 ) - { - // lock conference - // ast_mutex_lock( &(conf->lock) ) ; - - // toggle or set the state - if ( state == -1 ) - conf->debug_flag = ( conf->debug_flag == 0 ) ? 1 : 0 ; - else - conf->debug_flag = ( state == 0 ) ? 0 : 1 ; - - new_state = conf->debug_flag ; - - // unlock conference - // ast_mutex_unlock( &(conf->lock) ) ; - - break ; - } - - conf = conf->next ; - } - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - return new_state ; -} - -int get_conference_count( void ) -{ - return conference_count ; -} - -int get_conference_stats( ast_conference_stats* stats, int requested ) -{ - // no conferences exist - if ( conflist == NULL ) - { - ast_log( AST_CONF_DEBUG, "conflist has not yet been initialize\n" ) ; - return 0 ; - } - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - // compare the number of requested to the number of available conferences - requested = ( get_conference_count() < requested ) ? get_conference_count() : requested ; - - // - // loop through conf list - // - - struct ast_conference* conf = conflist ; - int count = 0 ; - - while ( count <= requested && conf != NULL ) - { - // copy stats struct to array - stats[ count ] = conf->stats ; - - conf = conf->next ; - ++count ; - } - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - return count ; -} - -int get_conference_stats_by_name( ast_conference_stats* stats, const char* name ) -{ - // no conferences exist - if ( conflist == NULL ) - { - ast_log( AST_CONF_DEBUG, "conflist has not yet been initialized, name => %s\n", name ) ; - return 0 ; - } - - // make sure stats is null - stats = NULL ; - - // acquire mutex - ast_mutex_lock( &conflist_lock ) ; - - struct ast_conference *conf = conflist ; - - // loop through conf list - while ( conf != NULL ) - { - if ( strncasecmp( (const char*)&(conf->name), name, 80 ) == 0 ) - { - // copy stats for found conference - *stats = conf->stats ; - break ; - } - - conf = conf->next ; - } - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - return ( stats == NULL ) ? 0 : 1 ; -} - -struct ast_conf_member *find_member ( char *chan, int lock) -{ - struct ast_conf_member *found = NULL; - struct ast_conf_member *member; - struct ast_conference *conf; - - - - ast_mutex_lock( &conflist_lock ) ; - - conf = conflist; - - // loop through conf list - while ( conf != NULL && !found ) - { - // lock conference - ast_mutex_lock( &conf->lock ); - - member = conf->memberlist ; - - while (member != NULL) - { - if(!strcmp(member->channel_name, chan)) { - found = member; - if(lock) - ast_mutex_lock(&member->lock); - break; - } - member = member->next; - } - - // unlock conference - ast_mutex_unlock( &conf->lock ); - - conf = conf->next ; - } - - // release mutex - ast_mutex_unlock( &conflist_lock ) ; - - return found; -} - diff --git a/extras/app_conference/conference.h b/extras/app_conference/conference.h deleted file mode 100644 index 08c1018f..00000000 --- a/extras/app_conference/conference.h +++ /dev/null @@ -1,121 +0,0 @@ - -// $Id: conference.h,v 1.6 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_CONFERENCE_H -#define _APP_CONF_CONFERENCE_H - -// -// includes -// - -#include "app_conference.h" -#include "common.h" - -// -// struct declarations -// - -typedef struct ast_conference_stats -{ - // conference name ( copied for ease of use ) - char name[128] ; - - // type of connection - unsigned short phone ; - unsigned short iaxclient ; - unsigned short sip ; - - // type of users - unsigned short moderators ; - unsigned short listeners ; - - // accounting data - unsigned long frames_in ; - unsigned long frames_out ; - unsigned long frames_mixed ; - - struct timeval time_entered ; - -} ast_conference_stats ; - - -struct ast_conference -{ - // conference name - char name[128] ; - - // single-linked list of members in conference - struct ast_conf_member* memberlist ; - int membercount ; - - // conference thread id - pthread_t conference_thread ; - - // conference data mutex - ast_mutex_t lock ; - - // pointer to next conference in single-linked list - struct ast_conference* next ; - - // pointer to translation paths - struct ast_trans_pvt* from_slinear_paths[ AC_SUPPORTED_FORMATS ] ; - - // conference stats - ast_conference_stats stats ; - - // keep track of current delivery time - struct timeval delivery_time ; - - // 1 => on, 0 => off - short debug_flag ; -} ; - -// -// function declarations -// - -struct ast_conference* start_conference( struct ast_conf_member* member ) ; - -void conference_exec( struct ast_conference* conf ) ; - -struct ast_conference* find_conf( const char* name ) ; -struct ast_conference* create_conf( char* name, struct ast_conf_member* member ) ; -void remove_conf( struct ast_conference* conf ) ; - -// find a particular member, locking if requested. -struct ast_conf_member *find_member ( char *chan, int lock) ; - - -int queue_frame_for_listener( struct ast_conference* conf, struct ast_conf_member* member, conf_frame* frame ) ; -int queue_frame_for_speaker( struct ast_conference* conf, struct ast_conf_member* member, conf_frame* frame ) ; -int queue_silent_frame( struct ast_conference* conf, struct ast_conf_member* member ) ; - -void add_member( struct ast_conf_member* member, struct ast_conference* conf ) ; -int remove_member( struct ast_conf_member* member, struct ast_conference* conf ) ; -int count_member( struct ast_conf_member* member, struct ast_conference* conf, short add_member ) ; - -// called by app_confernce.c:load_module() -void init_conference( void ) ; - -int get_conference_count( void ) ; -int get_conference_stats( ast_conference_stats* stats, int requested ) ; -int get_conference_stats_by_name( ast_conference_stats* stats, const char* name ) ; - -int set_conference_debugging( const char* name, int state ) ; - -#endif diff --git a/extras/app_conference/enter.gsm b/extras/app_conference/enter.gsm deleted file mode 100644 index aa4dafb6..00000000 Binary files a/extras/app_conference/enter.gsm and /dev/null differ diff --git a/extras/app_conference/frame.c b/extras/app_conference/frame.c deleted file mode 100644 index a50a378e..00000000 --- a/extras/app_conference/frame.c +++ /dev/null @@ -1,614 +0,0 @@ - -// $Id: frame.c,v 1.7 2005/10/27 17:53:35 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#include "frame.h" - -conf_frame* mix_frames( conf_frame* frames_in, int speaker_count, int listener_count ) -{ - if ( frames_in == NULL ) - return NULL ; - - conf_frame* frames_out = NULL ; - - if ( speaker_count > 1 ) - { - if ( speaker_count == 2 && listener_count == 0 ) - { - // optimize here also? - frames_out = mix_multiple_speakers( frames_in, speaker_count, listener_count ) ; - } - else - { - // mix spoken frames for sending - // ( note: this call also releases us from free'ing spoken_frames ) - frames_out = mix_multiple_speakers( frames_in, speaker_count, listener_count ) ; - } - } - else if ( speaker_count == 1 ) - { - // pass-through frames - frames_out = mix_single_speaker( frames_in ) ; - } - else - { - // no frames to send, leave frames_out null - } - - return frames_out ; -} - -conf_frame* mix_single_speaker( conf_frame* frames_in ) -{ -#ifdef APP_CONFERENCE_DEBUG - // ast_log( AST_CONF_DEBUG, "returning single spoken frame\n" ) ; - - // - // check input - // - - if ( frames_in == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null frame\n" ) ; - return NULL ; - } - - if ( frames_in->fr == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null data\n" ) ; - return NULL ; - } - - if ( frames_in->member == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to mix single spoken frame with null member\n" ) ; - return NULL ; - } -#endif // APP_CONFERENCE_DEBUG - - // - // 'mix' the frame - // - - // copy orignal frame to converted array so listeners don't need to re-encode it - frames_in->converted[ frames_in->member->read_format_index ] = ast_frdup( frames_in->fr ) ; - - // convert frame to slinear, if we have a path - frames_in->fr = convert_frame_to_slinear( - frames_in->member->to_slinear, - frames_in->fr - ) ; - - // set the frame's member to null ( i.e. all listeners ) - frames_in->member = NULL ; - - return frames_in ; -} - -// { - // - // a little optimization for testing only: - // when two speakers ( of the same type ) and no listeners - // are in a conference, we just swamp the frame's member pointers - // -/* - if ( - listeners == 0 - && speakers == 2 - && cf_spokenFrames->member->read_format == cf_spokenFrames->next->member->write_format - && cf_spokenFrames->member->write_format == cf_spokenFrames->next->member->read_format - ) - { - struct ast_conf_member* m = NULL ; - m = cf_spokenFrames->member ; - cf_spokenFrames->member = cf_spokenFrames->next->member ; - cf_spokenFrames->next->member = m ; - return cf_spokenFrames ; - } -*/ -// } - -void set_conf_frame_delivery( conf_frame* frame, struct timeval time ) -{ - for ( ; frame != NULL ; frame = frame->next ) - { - if ( frame->fr != NULL ) - { - // copy passed timeval to frame's delivery timeval - frame->fr->delivery = time ; - } - } - - return ; -} - -conf_frame* mix_multiple_speakers( - conf_frame* frames_in, - int speakers, - int listeners -) -{ -#ifdef APP_CONFERENCE_DEBUG - // - // check input - // - - // no frames to mix - if ( ( frames_in == NULL ) || ( frames_in->fr == NULL ) ) - { - ast_log( AST_CONF_DEBUG, "passed spoken frame list was NULL\n" ) ; - return NULL ; - } - - // if less than two speakers, then no frames to mix - if ( speakers < 2 ) - { - ast_log( AST_CONF_DEBUG, "mix_multiple_speakers() called with less than two speakers\n" ) ; - return NULL ; - } -#endif // APP_CONFERENCE_DEBUG - - // - // at this point we know that there is more than one frame, - // and that the frames need to be converted to pcm to be mixed - // - // now, if there are only two frames and two members, - // we can swap them. ( but we'll get to that later. ) - // - - // - // loop through the spoken frames, making a list of spoken members, - // and converting gsm frames to slinear frames so we can mix them. - // - - // pointer to the spoken frames list - conf_frame* cf_spoken = frames_in ; - - // pointer to the new list of mixed frames - conf_frame* cf_sendFrames = NULL ; - - while ( cf_spoken != NULL ) - { - // - // while we're looping through the spoken frames, we'll - // convert the frame to a format suitable for mixing - // - // if the frame fails to convert, drop it and treat - // the speaking member like a listener by not adding - // them to the cf_sendFrames list - // - - if ( cf_spoken->member == NULL ) - { - ast_log( LOG_WARNING, "unable to determine frame member\n" ) ; - } - else - { - // ast_log( AST_CONF_DEBUG, "converting frame to slinear, channel => %s\n", cf_spoken->member->channel_name ) ; - cf_spoken->fr = convert_frame_to_slinear( - cf_spoken->member->to_slinear, - cf_spoken->fr - ) ; - - if ( cf_spoken->fr == NULL ) - { - ast_log( LOG_WARNING, "unable to convert frame to slinear\n" ) ; - } - else - { - // create new conf frame with last frame as 'next' - cf_sendFrames = create_conf_frame( cf_spoken->member, cf_sendFrames, NULL ) ; - } - } - - // point to the next spoken frame - cf_spoken = cf_spoken->next ; - } - - // if necessary, add a frame with a null member pointer. - // this frame will hold the audio mixed for all listeners - if ( listeners > 0 ) - { - cf_sendFrames = create_conf_frame( NULL, cf_sendFrames, NULL ) ; - } - - // - // mix the audio - // - - // convenience pointer that skips over the friendly offset - char* cp_listenerData ; - - // pointer to the send frames list - conf_frame* cf_send = NULL ; - - for ( cf_send = cf_sendFrames ; cf_send != NULL ; cf_send = cf_send->next ) - { - // allocate a mix buffer which fill large enough memory to - // hold a frame, and reset it's memory so we don't get noise - char* cp_listenerBuffer = malloc( AST_CONF_BUFFER_SIZE ) ; - memset( cp_listenerBuffer, 0x0, AST_CONF_BUFFER_SIZE ) ; - - // point past the friendly offset right to the data - cp_listenerData = cp_listenerBuffer + AST_FRIENDLY_OFFSET ; - - // reset the spoken list pointer - cf_spoken = frames_in ; - - // really mix the audio - for ( ; cf_spoken != NULL ; cf_spoken = cf_spoken->next ) - { - // - // if the members are equal, and they - // are not null, do not mix them. - // - if ( - ( cf_send->member == cf_spoken->member ) - && ( cf_send->member != NULL ) - ) - { - // don't mix this frame - } - else if ( cf_spoken->fr == NULL ) - { - ast_log( LOG_WARNING, "unable to mix conf_frame with null ast_frame\n" ) ; - } - else - { - // mix the new frame in with the existing buffer - mix_slinear_frames( cp_listenerData, (char*)( cf_spoken->fr->data ), cf_spoken->fr->samples ) ; - } - } - - // copy a pointer to the frame data to the conf_frame - cf_send->mixed_buffer = cp_listenerData ; - } - - // - // copy the mixed buffer to a new frame - // - - // reset the send list pointer - cf_send = cf_sendFrames ; - - while ( cf_send != NULL ) - { - cf_send->fr = create_slinear_frame( cf_send->mixed_buffer ) ; - cf_send = cf_send->next ; - } - - // - // clean up the spoken frames we were passed - // ( caller will only be responsible for free'ing returns frames ) - // - - // reset the spoken list pointer - cf_spoken = frames_in ; - - while ( cf_spoken != NULL ) - { - // delete the frame - cf_spoken = delete_conf_frame( cf_spoken ) ; - } - - // return the list of frames for sending - return cf_sendFrames ; -} - - -struct ast_frame* convert_frame_to_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) -{ - // check for null frame - if ( fr == NULL ) - { - ast_log( LOG_ERROR, "unable to translate null frame to slinear\n" ) ; - return NULL ; - } - - // we don't need to duplicate this frame since - // the normal translation would free it anyway, so - // we'll just pretend we free'd and malloc'd a new one. - if ( fr->subclass == AST_FORMAT_SLINEAR ) - return fr ; - - // check for null translator ( after we've checked that we need to translate ) - if ( trans == NULL ) - { -// ast_log( LOG_ERROR, "unable to translate frame with null translation path\n" ) ; - return fr ; - } - - // return the converted frame - return convert_frame( trans, fr ) ; -} - -struct ast_frame* convert_frame_from_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) -{ - // check for null translator ( after we've checked that we need to translate ) - if ( trans == NULL ) - { -// ast_log( LOG_ERROR, "unable to translate frame with null translation path\n" ) ; - return fr ; - } - - // check for null frame - if ( fr == NULL ) - { - ast_log( LOG_ERROR, "unable to translate null slinear frame\n" ) ; - return NULL ; - } - - // if the frame is not slinear, return an error - if ( fr->subclass != AST_FORMAT_SLINEAR ) - { - ast_log( LOG_ERROR, "unable to translate non-slinear frame\n" ) ; - return NULL ; - } - - // return the converted frame - return convert_frame( trans, fr ) ; -} - -struct ast_frame* convert_frame( struct ast_trans_pvt* trans, struct ast_frame* fr ) -{ - if ( trans == NULL ) - { - ast_log( LOG_WARNING, "unable to convert frame with null translator\n" ) ; - return NULL ; - } - - if ( fr == NULL ) - { - ast_log( LOG_WARNING, "unable to convert null frame\n" ) ; - return NULL ; - } - - // convert the frame - struct ast_frame* translated_frame = ast_translate( trans, fr, 1 ) ; - - // check for errors - if ( translated_frame == NULL ) - { - ast_log( LOG_ERROR, "unable to translate frame\n" ) ; - return NULL ; - } - - // return the translated frame - return translated_frame ; -} - -conf_frame* delete_conf_frame( conf_frame* cf ) -{ - // check for null frames - if ( cf == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to delete null conf frame\n" ) ; - return NULL ; - } - - // check for frame marked as static - if ( cf->static_frame == 1 ) - return NULL ; - - if ( cf->fr != NULL ) - { - ast_frfree( cf->fr ) ; - cf->fr = NULL ; - } - - // make sure converted frames are set to null - int c; - for ( c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) - { - if ( cf->converted[ c ] != NULL ) - { - ast_frfree( cf->converted[ c ] ) ; - cf->converted[ c ] = NULL ; - } - } - - // get a pointer to the next frame - // in the list so we can return it - conf_frame* nf = cf->next ; - - free( cf ) ; - cf = NULL ; - - return nf ; -} - -conf_frame* create_conf_frame( struct ast_conf_member* member, conf_frame* next, const struct ast_frame* fr ) -{ - // pointer to list of mixed frames - conf_frame* cf = malloc( sizeof( struct conf_frame ) ) ; - - if ( cf == NULL ) - { - ast_log( LOG_ERROR, "unable to allocate memory for conf frame\n" ) ; - return NULL ; - } - - // - // init with some defaults - // - - // make sure converted frames are set to null -// for ( int c = 0 ; c < AC_SUPPORTED_FORMATS ; ++c ) -// { -// cf->converted[ c ] = NULL ; -// } - - memset( (struct ast_frame*)( cf->converted ), 0x0, ( sizeof( struct ast_frame* ) * AC_SUPPORTED_FORMATS ) ) ; - - cf->member = member ; - // cf->priority = 0 ; - - cf->prev = NULL ; - cf->next = next ; - - cf->static_frame = 0 ; - - // establish relationship to 'next' - if ( next != NULL ) next->prev = cf ; - - // this holds the ast_frame pointer - cf->fr = ( fr == NULL ) ? NULL : ast_frdup( ( struct ast_frame* )( fr ) ) ; - - // this holds the temporu mix buffer - cf->mixed_buffer = NULL ; - - return cf ; -} - -conf_frame* copy_conf_frame( conf_frame* src ) -{ - // - // check inputs - // - - if ( src == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to copy null conf frame\n" ) ; - return NULL ; - } - - // - // copy the frame - // - - struct conf_frame *cfr = NULL ; - - // create a new conf frame - cfr = create_conf_frame( src->member, NULL, src->fr ) ; - - if ( cfr == NULL ) - { - ast_log( AST_CONF_DEBUG, "unable to create new conf frame for copy\n" ) ; - return NULL ; - } - - return cfr ; -} - -// -// slinear frame functions -// - -struct ast_frame* create_slinear_frame( char* data ) -{ - struct ast_frame* f ; - - f = calloc( 1, sizeof( struct ast_frame ) ) ; - if ( f == NULL ) - { - ast_log( LOG_ERROR, "unable to allocate memory for slinear frame\n" ) ; - return NULL ; - } - - f->frametype = AST_FRAME_VOICE ; - f->subclass = AST_FORMAT_SLINEAR ; - f->samples = AST_CONF_BLOCK_SAMPLES ; - f->offset = AST_FRIENDLY_OFFSET ; - f->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_DATA ; - - f->datalen = AST_CONF_FRAME_DATA_SIZE ; - f->data = data ; - - f->src = NULL ; - - return f ; -} - -void mix_slinear_frames( char *dst, const char *src, int samples ) -{ - if ( dst == NULL ) return ; - if ( src == NULL ) return ; - - int i, val ; - - for ( i = 0 ; i < samples ; ++i ) - { - val = ( (short*)dst )[i] + ( (short*)src )[i] ; - - if ( val > 0x7fff ) - { - ( (short*)dst )[i] = 0x7fff - 1 ; - continue ; - } - else if ( val < -0x7fff ) - { - ( (short*)dst )[i] = -0x7fff + 1 ; - continue ; - } - else - { - ( (short*)dst )[i] = val ; - continue ; - } - } - - return ; -} - -// -// silent frame functions -// - -conf_frame* get_silent_frame( void ) -{ - static conf_frame* static_silent_frame = NULL ; - - // we'll let this leak until the application terminates - if ( static_silent_frame == NULL ) - { - // ast_log( AST_CONF_DEBUG, "creating cached silent frame\n" ) ; - struct ast_frame* fr = get_silent_slinear_frame() ; - - static_silent_frame = create_conf_frame( NULL, NULL, fr ) ; - - if ( static_silent_frame == NULL ) - { - ast_log( LOG_WARNING, "unable to create cached silent frame\n" ) ; - return NULL ; - } - - // init the 'converted' slinear silent frame - static_silent_frame->converted[ AC_SLINEAR_INDEX ] = get_silent_slinear_frame() ; - - // mark frame as static so it's not deleted - static_silent_frame->static_frame = 1 ; - } - - return static_silent_frame ; -} - -struct ast_frame* get_silent_slinear_frame( void ) -{ - static struct ast_frame* f = NULL ; - - // we'll let this leak until the application terminates - if ( f == NULL ) - { - char* data = malloc( AST_CONF_BUFFER_SIZE ) ; - memset( data, 0x0, AST_CONF_BUFFER_SIZE ) ; - f = create_slinear_frame( data ) ; - } - - return ast_frdup( f ) ; -} - - diff --git a/extras/app_conference/frame.h b/extras/app_conference/frame.h deleted file mode 100644 index d5b39613..00000000 --- a/extras/app_conference/frame.h +++ /dev/null @@ -1,60 +0,0 @@ - -// $Id: frame.h,v 1.6 2005/10/26 21:02:07 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_FRAME_H -#define _APP_CONF_FRAME_H - -// -// includes -// - -#include "app_conference.h" -#include "common.h" - -// -// function declarations -// - -// mixing -conf_frame* mix_frames( conf_frame* frames_in, int speaker_count, int listener_count ) ; - -conf_frame* mix_multiple_speakers( conf_frame* frames_in, int speakers, int listeners ) ; -conf_frame* mix_single_speaker( conf_frame* frames_in ) ; - -// frame creation and deletion -conf_frame* create_conf_frame( struct ast_conf_member* member, conf_frame* next, const struct ast_frame* fr ) ; -conf_frame* delete_conf_frame( conf_frame* cf ) ; -conf_frame* copy_conf_frame( conf_frame* src ) ; - -// convert frame functions -struct ast_frame* convert_frame_to_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; -struct ast_frame* convert_frame_from_slinear( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; -struct ast_frame* convert_frame( struct ast_trans_pvt* trans, struct ast_frame* fr ) ; - -// slinear frame functions -struct ast_frame* create_slinear_frame( char* data ) ; -void mix_slinear_frames( char* dst, const char* src, int samples ) ; - -// silent frame functions -conf_frame* get_silent_frame( void ) ; -struct ast_frame* get_silent_slinear_frame( void ) ; - -// set delivery timestamp for frames -void set_conf_frame_delivery( conf_frame* frame, struct timeval time ) ; - -#endif diff --git a/extras/app_conference/hash.gsm b/extras/app_conference/hash.gsm deleted file mode 100644 index 0d0a8ecf..00000000 --- a/extras/app_conference/hash.gsm +++ /dev/null @@ -1,2 +0,0 @@ -\}PcȣP tۆD#E)#i(*E3yBF:W2wWԢ6TyuWI+sdWysuk2yct9,,Wk|UTWu#.1c}yQ( dº\2! Q\?;waWnfy.7FW){?YW!Q nSB*qUUy>XWQDm! \ No newline at end of file diff --git a/extras/app_conference/hash.wav b/extras/app_conference/hash.wav deleted file mode 100644 index a079f449..00000000 Binary files a/extras/app_conference/hash.wav and /dev/null differ diff --git a/extras/app_conference/leave.gsm b/extras/app_conference/leave.gsm deleted file mode 100644 index 7b3bef01..00000000 Binary files a/extras/app_conference/leave.gsm and /dev/null differ diff --git a/extras/app_conference/libspeex/CVS/Entries b/extras/app_conference/libspeex/CVS/Entries deleted file mode 100644 index a6a76f82..00000000 --- a/extras/app_conference/libspeex/CVS/Entries +++ /dev/null @@ -1,7 +0,0 @@ -/misc.c/1.1/Thu Mar 25 15:10:17 2004// -/misc.h/1.1/Thu Mar 25 15:10:17 2004// -/preprocess.c/1.4/Fri Mar 25 20:26:26 2005// -/smallft.c/1.3/Fri Mar 25 20:26:26 2005// -/smallft.h/1.2/Wed Jul 7 13:39:42 2004// -/speex_preprocess.h/1.1/Thu Mar 25 15:10:17 2004// -D diff --git a/extras/app_conference/libspeex/CVS/Repository b/extras/app_conference/libspeex/CVS/Repository deleted file mode 100644 index c74f117b..00000000 --- a/extras/app_conference/libspeex/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -app_conference/libspeex diff --git a/extras/app_conference/libspeex/CVS/Root b/extras/app_conference/libspeex/CVS/Root deleted file mode 100644 index 76ea6939..00000000 --- a/extras/app_conference/libspeex/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:pserver:anonymous@iaxclient.cvs.sourceforge.net:/cvsroot/iaxclient diff --git a/extras/app_conference/libspeex/misc.c b/extras/app_conference/libspeex/misc.c deleted file mode 100644 index 55728099..00000000 --- a/extras/app_conference/libspeex/misc.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 2002 Jean-Marc Valin - File: mics.c - Various utility routines for Speex - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "misc.h" -#include -#include -#include - -#ifndef RELEASE -void print_vec(float *vec, int len, char *name) -{ - int i; - printf ("%s ", name); - for (i=0;i>24; - ret += (i>>8)&0x0000ff00; - ret += (i<<8)&0x00ff0000; - ret += (i<<24); -#endif - return ret; -} - -unsigned int le_int(unsigned int i) -{ - unsigned int ret=i; -#ifdef WORDS_BIGENDIAN - ret = i>>24; - ret += (i>>8)&0x0000ff00; - ret += (i<<8)&0x00ff0000; - ret += (i<<24); -#endif - return ret; -} - -unsigned short be_short(unsigned short s) -{ - unsigned short ret=s; -#ifndef WORDS_BIGENDIAN - ret = s>>8; - ret += s<<8; -#endif - return ret; -} - -unsigned short le_short(unsigned short s) -{ - unsigned short ret=s; -#ifdef WORDS_BIGENDIAN - ret = s>>8; - ret += s<<8; -#endif - return ret; -} - -void *speex_alloc (int size) -{ - return calloc(size,1); -} - -void *speex_realloc (void *ptr, int size) -{ - return realloc(ptr, size); -} - -void speex_free (void *ptr) -{ - free(ptr); -} - -void *speex_move (void *dest, void *src, int n) -{ - return memmove(dest,src,n); -} - -void speex_error(char *str) -{ - fprintf (stderr, "Fatal error: %s\n", str); - exit(1); -} - -void speex_warning(char *str) -{ - fprintf (stderr, "warning: %s\n", str); -} - -void speex_warning_int(char *str, int val) -{ - fprintf (stderr, "warning: %s %d\n", str, val); -} - -void speex_rand_vec(float std, spx_sig_t *data, int len) -{ - int i; - for (i=0;i> (shift)) -#define SHR(a,shift) ((a) >> (shift)) -#define SHL(a,shift) ((a) << (shift)) - -/* result fits in 16 bits */ -#define MULT16_16_16(a,b) (((short)(a))*(b)) - -#define MULT16_16(a,b) (((signed int)(a))*(b)) -#define MULT16_32_Q13(a,b) (((a)*((b)>>13)) + ((a)*((signed int)((b)&0x00001fff))>>13)) -#define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14)) -#define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15)) - -#define MULT16_16_Q13(a,b) (((signed int)(a))*(b)>>13) -#define MULT16_16_Q14(a,b) (((signed int)(a))*(b)>>14) -#define MULT16_16_Q15(a,b) (((signed int)(a))*(b)>>15) - -#define MULT16_16_P14(a,b) ((8192+((signed int)(a))*(b))>>14) - - -#define DIV32_16(a,b) (((signed int)(a))/(b)) - -#else - -typedef float spx_mem_t; -typedef float spx_coef_t; -typedef float spx_lsp_t; -typedef float spx_sig_t; -typedef float spx_word16_t; -typedef float spx_word32_t; - -#define LPC_SCALING 1. -#define SIG_SCALING 1. -#define LSP_SCALING 1. - -#define LPC_SHIFT 0 -#define SIG_SHIFT 0 - -#define PSHR(a,shift) (a) -#define SHR(a,shift) (a) -#define SHL(a,shift) (a) -#define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((a)*(b)) - -#define MULT16_32_Q13(a,b) ((a)*(b)) -#define MULT16_32_Q14(a,b) ((a)*(b)) -#define MULT16_32_Q15(a,b) ((a)*(b)) - -#define MULT16_16_Q13(a,b) ((a)*(b)) -#define MULT16_16_Q14(a,b) ((a)*(b)) -#define MULT16_16_Q15(a,b) ((a)*(b)) - - -#endif - -#ifndef RELEASE -void print_vec(float *vec, int len, char *name); -#endif - -unsigned int be_int(unsigned int i); -unsigned int le_int(unsigned int i); - - -unsigned short be_short(unsigned short s); -unsigned short le_short(unsigned short s); - -/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */ -void *speex_alloc (int size); - -/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ -void *speex_realloc (void *ptr, int size); - -/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ -void speex_free (void *ptr); - -/** Speex wrapper for mem_move */ -void *speex_move (void *dest, void *src, int n); - -void speex_error(char *str); - -void speex_warning(char *str); - -void speex_warning_int(char *str, int val); - -void speex_rand_vec(float std, spx_sig_t *data, int len); - -float speex_rand(float std); - -void _speex_putc(int ch, void *file); - -#endif diff --git a/extras/app_conference/libspeex/preprocess.c b/extras/app_conference/libspeex/preprocess.c deleted file mode 100644 index 4e8a5470..00000000 --- a/extras/app_conference/libspeex/preprocess.c +++ /dev/null @@ -1,1136 +0,0 @@ -/* Copyright (C) 2003 Epic Games - Written by Jean-Marc Valin - - File: preprocess.c - Preprocessor with denoising based on the algorithm by Ephraim and Malah - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include "speex_preprocess.h" -#include "misc.h" -#include "smallft.h" - -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define min(a,b) ((a) < (b) ? (a) : (b)) - -/* use single-precision math funcs. (1.3% perf improvement). */ -#if 1 -#define exp(a) expf(a) -#define sqrt(a) sqrtf(a) -#define floor(a) floorf(a) -#define log(a) logf(a) -#endif - - - -#ifndef M_PI -#define M_PI 3.14159263 -#endif - -#define SQRT_M_PI_2 0.88623 -#define LOUDNESS_EXP 2.5 - -#define NB_BANDS 8 - -#define ZMIN .1 -#define ZMAX .316 -#define ZMIN_1 10 -#define LOG_MIN_MAX_1 0.86859 - -static void conj_window(float *w, int len) -{ - int i; - for (i=0;i9.5) - return 1+.12/x; - - integer = floor(x); - frac = x-integer; - ind = (int)integer; - - return ((1-frac)*table[ind] + frac*table[ind+1])/sqrt(x+.0001); -} - -SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate) -{ - int i; - int N, N3, N4; - - SpeexPreprocessState *st = (SpeexPreprocessState *)speex_alloc(sizeof(SpeexPreprocessState)); - st->frame_size = frame_size; - - /* Round ps_size down to the nearest power of two */ -#if 0 - i=1; - st->ps_size = st->frame_size; - while(1) - { - if (st->ps_size & ~i) - { - st->ps_size &= ~i; - i<<=1; - } else { - break; - } - } - - - if (st->ps_size < 3*st->frame_size/4) - st->ps_size = st->ps_size * 3 / 2; -#else - st->ps_size = st->frame_size; -#endif - - N = st->ps_size; - N3 = 2*N - st->frame_size; - N4 = st->frame_size - N3; - - st->sampling_rate = sampling_rate; - st->denoise_enabled = 1; - st->agc_enabled = 0; - st->agc_level = 8000; - st->vad_enabled = 0; - - st->speech_prob_start = SPEEX_PROB_START ; - st->speech_prob_continue = SPEEX_PROB_CONTINUE ; - - st->frame = (float*)speex_alloc(2*N*sizeof(float)); - st->ps = (float*)speex_alloc(N*sizeof(float)); - st->gain2 = (float*)speex_alloc(N*sizeof(float)); - st->window = (float*)speex_alloc(2*N*sizeof(float)); - st->noise = (float*)speex_alloc(N*sizeof(float)); - st->old_ps = (float*)speex_alloc(N*sizeof(float)); - st->gain = (float*)speex_alloc(N*sizeof(float)); - st->prior = (float*)speex_alloc(N*sizeof(float)); - st->post = (float*)speex_alloc(N*sizeof(float)); - st->loudness_weight = (float*)speex_alloc(N*sizeof(float)); - st->inbuf = (float*)speex_alloc(N3*sizeof(float)); - st->outbuf = (float*)speex_alloc(N3*sizeof(float)); - st->echo_noise = (float*)speex_alloc(N*sizeof(float)); - - st->S = (float*)speex_alloc(N*sizeof(float)); - st->Smin = (float*)speex_alloc(N*sizeof(float)); - st->Stmp = (float*)speex_alloc(N*sizeof(float)); - st->update_prob = (float*)speex_alloc(N*sizeof(float)); - - st->zeta = (float*)speex_alloc(N*sizeof(float)); - st->Zpeak = 0; - st->Zlast = 0; - - st->noise_bands = (float*)speex_alloc(NB_BANDS*sizeof(float)); - st->noise_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float)); - st->speech_bands = (float*)speex_alloc(NB_BANDS*sizeof(float)); - st->speech_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float)); - st->noise_bandsN = st->speech_bandsN = 1; - - conj_window(st->window, 2*N3); - for (i=2*N3;i<2*st->ps_size;i++) - st->window[i]=1; - - if (N4>0) - { - for (i=N3-1;i>=0;i--) - { - st->window[i+N3+N4]=st->window[i+N3]; - st->window[i+N3]=1; - } - } - for (i=0;inoise[i]=1e4; - st->old_ps[i]=1e4; - st->gain[i]=1; - st->post[i]=1; - st->prior[i]=1; - } - - for (i=0;iinbuf[i]=0; - st->outbuf[i]=0; - } - - for (i=0;iloudness_weight[i] = .35-.35*ff/16000+.73*exp(-.5*(ff-3800)*(ff-3800)/9e5); - if (st->loudness_weight[i]<.01) - st->loudness_weight[i]=.01; - st->loudness_weight[i] *= st->loudness_weight[i]; - } - - st->speech_prob = 0; - st->last_speech = 1000; - st->loudness = pow(6000,LOUDNESS_EXP); - st->loudness2 = 6000; - st->nb_loudness_adapt = 0; - - st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup)); - drft_init(st->fft_lookup,2*N); - - st->nb_adapt=0; - st->consec_noise=0; - st->nb_preprocess=0; - return st; -} - -void speex_preprocess_state_destroy(SpeexPreprocessState *st) -{ - speex_free(st->frame); - speex_free(st->ps); - speex_free(st->gain2); - speex_free(st->window); - speex_free(st->noise); - speex_free(st->old_ps); - speex_free(st->gain); - speex_free(st->prior); - speex_free(st->post); - speex_free(st->loudness_weight); - speex_free(st->echo_noise); - - speex_free(st->S); - speex_free(st->Smin); - speex_free(st->Stmp); - speex_free(st->update_prob); - - speex_free(st->noise_bands); - speex_free(st->noise_bands2); - speex_free(st->speech_bands); - speex_free(st->speech_bands2); - - speex_free(st->inbuf); - speex_free(st->outbuf); - - drft_clear(st->fft_lookup); - speex_free(st->fft_lookup); - - speex_free(st); -} - -static void update_noise(SpeexPreprocessState *st, float *ps, float *echo) -{ - int i; - float beta; - st->nb_adapt++; - beta=1.0/st->nb_adapt; - if (beta < .05) - beta=.05; - - if (!echo) - { - for (i=0;ips_size;i++) - st->noise[i] = (1-beta)*st->noise[i] + beta*ps[i]; - } else { - for (i=0;ips_size;i++) - st->noise[i] = (1-beta)*st->noise[i] + beta*max(0,ps[i]-echo[i]); -#if 0 - for (i=0;ips_size;i++) - st->noise[i] = 0; -#endif - } -} - -static int speex_compute_vad(SpeexPreprocessState *st, float *ps, float mean_prior, float mean_post) -{ - int i, is_speech=0; - int N = st->ps_size; - float scale=.5/N; - - /* FIXME: Clean this up a bit */ - { - float bands[NB_BANDS]; - int j; - float p0, p1; - float tot_loudness=0; - float x = sqrt(mean_post); - - for (i=5;ips[i] * st->loudness_weight[i]; - } - - for (i=0;ispeech_prob + .01*(1-st->speech_prob); - p1 *= .01*st->speech_prob + .99*(1-st->speech_prob); - - st->speech_prob = p0/(p1+p0); - */ - - if (st->noise_bandsN < 50 || st->speech_bandsN < 50) - { - if (mean_post > 5) - { - float adapt = 1./st->speech_bandsN++; - if (adapt<.005) - adapt = .005; - for (i=0;ispeech_bands[i] = (1-adapt)*st->speech_bands[i] + adapt*bands[i]; - /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/ - st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]); - } - } else { - float adapt = 1./st->noise_bandsN++; - if (adapt<.005) - adapt = .005; - for (i=0;inoise_bands[i] = (1-adapt)*st->noise_bands[i] + adapt*bands[i]; - /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/ - st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]); - } - } - } - p0=p1=1; - for (i=0;inoise_bands2[i] - st->noise_bands[i]*st->noise_bands[i]; - speech_var = 1.01*st->speech_bands2[i] - st->speech_bands[i]*st->speech_bands[i];*/ - noise_var = st->noise_bands2[i]; - speech_var = st->speech_bands2[i]; - if (noise_var < .1) - noise_var = .1; - if (speech_var < .1) - speech_var = .1; - - /*speech_var = sqrt(speech_var*noise_var); - noise_var = speech_var;*/ - if (speech_var < .05*speech_var) - noise_var = .05*speech_var; - if (speech_var < .05*noise_var) - speech_var = .05*noise_var; - - if (bands[i] < st->noise_bands[i]) - speech_var = noise_var; - if (bands[i] > st->speech_bands[i]) - noise_var = speech_var; - - speech_mean = st->speech_bands[i]; - noise_mean = st->noise_bands[i]; - if (noise_mean < speech_mean - 5) - noise_mean = speech_mean - 5; - - tmp1 = exp(-.5*(bands[i]-speech_mean)*(bands[i]-speech_mean)/speech_var)/sqrt(2*M_PI*speech_var); - tmp2 = exp(-.5*(bands[i]-noise_mean)*(bands[i]-noise_mean)/noise_var)/sqrt(2*M_PI*noise_var); - /*fprintf (stderr, "%f ", (float)(p0/(.01+p0+p1)));*/ - /*fprintf (stderr, "%f ", (float)(bands[i]));*/ - pr = tmp1/(1e-25+tmp1+tmp2); - /*if (bands[i] < st->noise_bands[i]) - pr=.01; - if (bands[i] > st->speech_bands[i] && pr < .995) - pr=.995;*/ - if (pr>.999) - pr=.999; - if (pr<.001) - pr=.001; - /*fprintf (stderr, "%f ", pr);*/ - p0 *= pr; - p1 *= (1-pr); - } - - p0 = pow(p0,.2); - p1 = pow(p1,.2); - -#if 1 - p0 *= 2; - p0=p0/(p1+p0); - if (st->last_speech>20) - { - float tmp = sqrt(tot_loudness)/st->loudness2; - tmp = 1-exp(-10*tmp); - if (p0>tmp) - p0=tmp; - } - p1=1-p0; -#else - if (sqrt(tot_loudness) < .6*st->loudness2 && p0>15*p1) - p0=15*p1; - if (sqrt(tot_loudness) < .45*st->loudness2 && p0>7*p1) - p0=7*p1; - if (sqrt(tot_loudness) < .3*st->loudness2 && p0>3*p1) - p0=3*p1; - if (sqrt(tot_loudness) < .15*st->loudness2 && p0>p1) - p0=p1; - /*fprintf (stderr, "%f %f ", (float)(sqrt(tot_loudness) /( .25*st->loudness2)), p0/(p1+p0));*/ -#endif - - p0 *= .99*st->speech_prob + .01*(1-st->speech_prob); - p1 *= .01*st->speech_prob + .99*(1-st->speech_prob); - - st->speech_prob = p0/(1e-25+p1+p0); - /*fprintf (stderr, "%f %f %f ", tot_loudness, st->loudness2, st->speech_prob);*/ - - /* decide if frame is speech using speech probability settings */ - -/* if (st->speech_prob> .35 || (st->last_speech < 20 && st->speech_prob>.1)) */ - if ( - st->speech_prob > st->speech_prob_start - || ( st->last_speech < 20 && st->speech_prob > st->speech_prob_continue ) - ) - { - is_speech = 1; - st->last_speech = 0; - } - else - { - st->last_speech++; - if ( st->last_speech < 20 ) - is_speech = 1; - } - - if (st->noise_bandsN > 50 && st->speech_bandsN > 50) - { - if (mean_post > 5) - { - float adapt = 1./st->speech_bandsN++; - if (adapt<.005) - adapt = .005; - for (i=0;ispeech_bands[i] = (1-adapt)*st->speech_bands[i] + adapt*bands[i]; - /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/ - st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]); - } - } else { - float adapt = 1./st->noise_bandsN++; - if (adapt<.005) - adapt = .005; - for (i=0;inoise_bands[i] = (1-adapt)*st->noise_bands[i] + adapt*bands[i]; - /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/ - st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]); - } - } - } - - - } - - return is_speech; -} - -static void speex_compute_agc(SpeexPreprocessState *st, float mean_prior) -{ - int i; - int N = st->ps_size; - float scale=.5/N; - float agc_gain; - int freq_start, freq_end; - float active_bands = 0; - - freq_start = (int)(300.0*2*N/st->sampling_rate); - freq_end = (int)(2000.0*2*N/st->sampling_rate); - for (i=freq_start;iS[i] > 20*st->Smin[i]+1000) - active_bands+=1; - } - active_bands /= (freq_end-freq_start+1); - - if (active_bands > .2) - { - float loudness=0; - float rate, rate2=.2; - st->nb_loudness_adapt++; - rate=2.0/(1+st->nb_loudness_adapt); - if (rate < .05) - rate = .05; - if (rate < .1 && pow(loudness, LOUDNESS_EXP) > st->loudness) - rate = .1; - if (rate < .2 && pow(loudness, LOUDNESS_EXP) > 3*st->loudness) - rate = .2; - if (rate < .4 && pow(loudness, LOUDNESS_EXP) > 10*st->loudness) - rate = .4; - - for (i=2;ips[i] * st->gain2[i] * st->gain2[i] * st->loudness_weight[i]; - } - loudness=sqrt(loudness); - /*if (loudness < 2*pow(st->loudness, 1.0/LOUDNESS_EXP) && - loudness*2 > pow(st->loudness, 1.0/LOUDNESS_EXP))*/ - st->loudness = (1-rate)*st->loudness + (rate)*pow(loudness, LOUDNESS_EXP); - - st->loudness2 = (1-rate2)*st->loudness2 + rate2*pow(st->loudness, 1.0/LOUDNESS_EXP); - - loudness = pow(st->loudness, 1.0/LOUDNESS_EXP); - - /*fprintf (stderr, "%f %f %f\n", loudness, st->loudness2, rate);*/ - } - - agc_gain = st->agc_level/st->loudness2; - /*fprintf (stderr, "%f %f %f %f\n", active_bands, st->loudness, st->loudness2, agc_gain);*/ - if (agc_gain>200) - agc_gain = 200; - - for (i=0;igain2[i] *= agc_gain; - -} - -static void preprocess_analysis(SpeexPreprocessState *st, short *x) -{ - int i; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - int N4 = st->frame_size - N3; - float *ps=st->ps; - - /* 'Build' input frame */ - for (i=0;iframe[i]=st->inbuf[i]; - for (i=0;iframe_size;i++) - st->frame[N3+i]=x[i]; - - /* Update inbuf */ - for (i=0;iinbuf[i]=x[N4+i]; - - /* Windowing */ - for (i=0;i<2*N;i++) - st->frame[i] *= st->window[i]; - - /* Perform FFT */ - drft_forward(st->fft_lookup, st->frame); - - /* Power spectrum */ - ps[0]=1; - for (i=1;iframe[2*i-1]*st->frame[2*i-1] + st->frame[2*i]*st->frame[2*i]; - -} - -static void update_noise_prob(SpeexPreprocessState *st) -{ - int i; - int N = st->ps_size; - - for (i=1;iS[i] = 100+ .8*st->S[i] + .05*st->ps[i-1]+.1*st->ps[i]+.05*st->ps[i+1]; - - if (st->nb_preprocess<1) - { - for (i=1;iSmin[i] = st->Stmp[i] = st->S[i]+100; - } - - if (st->nb_preprocess%200==0) - { - for (i=1;iSmin[i] = min(st->Stmp[i], st->S[i]); - st->Stmp[i] = st->S[i]; - } - } else { - for (i=1;iSmin[i] = min(st->Smin[i], st->S[i]); - st->Stmp[i] = min(st->Stmp[i], st->S[i]); - } - } - for (i=1;iupdate_prob[i] *= .2; - if (st->S[i] > 5*st->Smin[i]) - st->update_prob[i] += .8; - /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/ - /*fprintf (stderr, "%f ", st->update_prob[i]);*/ - } - -} - -inline void ephraim_malah(SpeexPreprocessState *st, int N, float Pframe) -{ - int i; - - /* defactor loop for i=1,1 < i < N-1, and i= N-1 cases */ - /* i=1 case */ - { - float MM; - float theta; - float prior_ratio; - float p, q; - float zeta1; - float P1; - - prior_ratio = st->prior[1]/(1.0001+st->prior[1]); - theta = (1+st->post[1])*prior_ratio; - - zeta1 = st->zeta[1]; - - if (zeta1ZMAX) - P1 = 1; - else - P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); - - /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ - - /* FIXME: add global prop (P2) */ - q = 1-Pframe*P1; - if (q>.95) - q=.95; - p=1/(1 + (q/(1-q))*(1+st->prior[1])*exp(-theta)); - - /* Optimal estimator for loudness domain */ - MM = hypergeom_gain(theta); - - st->gain[1] = prior_ratio * MM; - /*Put some (very arbitraty) limit on the gain*/ - if (st->gain[1]>2) - { - st->gain[1]=2; - } - - if (st->denoise_enabled) - { - st->gain2[1]=p*p*st->gain[1]; - } else { - st->gain2[1]=1; - } - } - - for (i=2;i<(N-1);i++) - { - float MM; - float theta; - float prior_ratio; - float p, q; - float zeta1; - float P1; - - - zeta1 = .25*st->zeta[i-1] + .5*st->zeta[i] + .25*st->zeta[i+1]; - - prior_ratio = st->prior[i]/(1.0001+st->prior[i]); - theta = (1+st->post[i])*prior_ratio; - - - - if (zeta1ZMAX) - P1 = 1; - else - P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); - - /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ - - - /* FIXME: add global prop (P2) */ - q = 1-Pframe*P1; - if (q>.95) - q=.95; - p=1/(1 + (q/(1-q))*(1+st->prior[i])*exp(-theta)); - - /* Optimal estimator for loudness domain */ - MM = hypergeom_gain(theta); - - st->gain[i] = prior_ratio * MM; - /*Put some (very arbitraty) limit on the gain*/ - if (st->gain[i]>2) - { - st->gain[i]=2; - } - - if (st->denoise_enabled) - { - st->gain2[i]=p*p*st->gain[i]; - } else { - st->gain2[i]=1; - } - } - - /* i = N-1 case */ - { - float MM; - float theta; - float prior_ratio; - float p, q; - float zeta1; - float P1; - - prior_ratio = st->prior[N-1]/(1.0001+st->prior[N-1]); - theta = (1+st->post[N-1])*prior_ratio; - - zeta1 = st->zeta[N-1]; - - if (zeta1ZMAX) - P1 = 1; - else - P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1); - - /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/ - - /* FIXME: add global prop (P2) */ - q = 1-Pframe*P1; - if (q>.95) - q=.95; - p=1/(1 + (q/(1-q))*(1+st->prior[N-1])*exp(-theta)); - - /* Optimal estimator for loudness domain */ - MM = hypergeom_gain(theta); - - st->gain[N-1] = prior_ratio * MM; - /*Put some (very arbitraty) limit on the gain*/ - if (st->gain[N-1]>2) - { - st->gain[N-1]=2; - } - - if (st->denoise_enabled) - { - st->gain2[N-1]=p*p*st->gain[N-1]; - } else { - st->gain2[N-1]=1; - } - } - st->gain2[0]=st->gain[0]=0; - st->gain2[N-1]=st->gain[N-1]=0; -} - - -int speex_preprocess(SpeexPreprocessState *st, short *x, float *echo) -{ - int i; - int is_speech=1; - float mean_post=0; - float mean_prior=0; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - int N4 = st->frame_size - N3; - float scale=.5/N; - float *ps=st->ps; - float Zframe=0, Pframe; - - preprocess_analysis(st, x); - - update_noise_prob(st); - - st->nb_preprocess++; - - /* Noise estimation always updated for the 20 first times */ - if (st->nb_adapt<10) - { - update_noise(st, ps, echo); - } - - /* Deal with residual echo if provided */ - if (echo) - for (i=1;iecho_noise[i] = (.7*st->echo_noise[i] + .3* echo[i]); - - /* Compute a posteriori SNR */ - for (i=1;ipost[i] = ps[i]/(1+st->noise[i]+st->echo_noise[i]) - 1; - if (st->post[i]>100) - st->post[i]=100; - /*if (st->post[i]<0) - st->post[i]=0;*/ - mean_post+=st->post[i]; - } - mean_post /= N; - if (mean_post<0) - mean_post=0; - - /* Special case for first frame */ - if (st->nb_adapt==1) - for (i=1;iold_ps[i] = ps[i]; - - /* Compute a priori SNR */ - { - /* A priori update rate */ - float gamma; - float min_gamma=0.12; - gamma = 1.0/st->nb_preprocess; - - /*Make update rate smaller when there's no speech*/ -#if 0 - if (mean_post<3.5 && mean_prior < 1) - min_gamma *= (mean_post+.5); - else - min_gamma *= 4.; -#else - min_gamma = .1*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post); - if (min_gamma>.15) - min_gamma = .15; - if (min_gamma<.02) - min_gamma = .02; -#endif - /*min_gamma = .08;*/ - - /*if (gammaprior[i] = gamma*max(0.0,st->post[i]) + - (1-gamma)*st->gain[i]*st->gain[i]*st->old_ps[i]/(1+st->noise[i]+st->echo_noise[i]); - - if (st->prior[i]>100) - st->prior[i]=100; - - mean_prior+=st->prior[i]; - } - } - mean_prior /= N; - -#if 0 - for (i=0;iprior[i]); - } - fprintf (stderr, "\n"); -#endif - /*fprintf (stderr, "%f %f\n", mean_prior,mean_post);*/ - - if (st->nb_preprocess>=20) - { - int do_update = 0; - float noise_ener=0, sig_ener=0; - /* If SNR is low (both a priori and a posteriori), update the noise estimate*/ - /*if (mean_prior<.23 && mean_post < .5)*/ - if (mean_prior<.23 && mean_post < .5) - do_update = 1; - for (i=1;inoise[i]; - sig_ener += ps[i]; - } - if (noise_ener > 3*sig_ener) - do_update = 1; - /*do_update = 0;*/ - if (do_update) - { - st->consec_noise++; - } else { - st->consec_noise=0; - } - } - - if (st->vad_enabled) - is_speech = speex_compute_vad(st, ps, mean_prior, mean_post); - - - if (st->consec_noise>=3) - { - update_noise(st, st->old_ps, echo); - } else { - for (i=1;iupdate_prob[i]<.5) - st->noise[i] = .90*st->noise[i] + .1*st->ps[i]; - } - } - - for (i=1;izeta[i] = .7*st->zeta[i] + .3*st->prior[i]; - } - - { - int freq_start = (int)(300.0*2*N/st->sampling_rate); - int freq_end = (int)(2000.0*2*N/st->sampling_rate); - for (i=freq_start;izeta[i]; - } - } - - Zframe /= N; - if (Zframe 1.5*st->Zlast) - { - Pframe = 1; - st->Zpeak = Zframe; - if (st->Zpeak > 10) - st->Zpeak = 10; - if (st->Zpeak < 1) - st->Zpeak = 1; - } else { - if (Zframe < st->Zpeak*ZMIN) - { - Pframe = 0; - } else if (Zframe > st->Zpeak*ZMAX) - { - Pframe = 1; - } else { - Pframe = log(Zframe/(st->Zpeak*ZMIN)) / log(ZMAX/ZMIN); - } - } - } - st->Zlast = Zframe; - - /*fprintf (stderr, "%f\n", Pframe);*/ - /* Compute gain according to the Ephraim-Malah algorithm */ - ephraim_malah(st,N,Pframe); - - if (st->agc_enabled) - speex_compute_agc(st, mean_prior); - -#if 0 - if (!is_speech) - { - for (i=0;igain2[i] = 0; - } -#if 0 - else { - for (i=0;igain2[i] = 1; - } -#endif -#endif - - /* PERF: 14% when only vad is enabled [7.0 vs 8.2 sec] */ - if(st->agc_enabled || st->denoise_enabled) { - /* Apply computed gain */ - for (i=1;iframe[2*i-1] *= st->gain2[i]; - st->frame[2*i] *= st->gain2[i]; - } - - /* Get rid of the DC and very low frequencies */ - st->frame[0]=0; - st->frame[1]=0; - st->frame[2]=0; - /* Nyquist frequency is mostly useless too */ - st->frame[2*N-1]=0; - - /* Inverse FFT with 1/N scaling */ - drft_backward(st->fft_lookup, st->frame); - - for (i=0;i<2*N;i++) - st->frame[i] *= scale; - - { - float max_sample=0; - for (i=0;i<2*N;i++) - if (fabs(st->frame[i])>max_sample) - max_sample = fabs(st->frame[i]); - if (max_sample>28000) - { - float damp = 28000./max_sample; - for (i=0;i<2*N;i++) - st->frame[i] *= damp; - } - } - - for (i=0;i<2*N;i++) - st->frame[i] *= st->window[i]; - - /* Perform overlap and add */ - for (i=0;ioutbuf[i] + st->frame[i]; - for (i=0;iframe[N3+i]; - - /* Update outbuf */ - for (i=0;ioutbuf[i] = st->frame[st->frame_size+i]; - } - - /* Save old power spectrum */ - for (i=1;iold_ps[i] = ps[i]; - - return is_speech; -} - -void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, float *noise) -{ - int i; - int N = st->ps_size; - int N3 = 2*N - st->frame_size; - - float *ps=st->ps; - - preprocess_analysis(st, x); - - update_noise_prob(st); - - st->nb_preprocess++; - - for (i=1;iupdate_prob[i]<.5) - st->noise[i] = .90*st->noise[i] + .1*ps[i]; - } - - for (i=0;ioutbuf[i] = x[st->frame_size-N3+i]*st->window[st->frame_size+i]; - - /* Save old power spectrum */ - for (i=1;iold_ps[i] = ps[i]; - -} - - -int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr) -{ - SpeexPreprocessState *st; - st=(SpeexPreprocessState*)state; - switch(request) - { - case SPEEX_PREPROCESS_SET_DENOISE: - st->denoise_enabled = (*(int*)ptr); - break; - case SPEEX_PREPROCESS_GET_DENOISE: - (*(int*)ptr) = st->denoise_enabled; - break; - - case SPEEX_PREPROCESS_SET_AGC: - st->agc_enabled = (*(int*)ptr); - break; - case SPEEX_PREPROCESS_GET_AGC: - (*(int*)ptr) = st->agc_enabled; - break; - - case SPEEX_PREPROCESS_SET_AGC_LEVEL: - st->agc_level = (*(float*)ptr); - if (st->agc_level<1) - st->agc_level=1; - if (st->agc_level>32768) - st->agc_level=32768; - break; - case SPEEX_PREPROCESS_GET_AGC_LEVEL: - (*(float*)ptr) = st->agc_level; - break; - - case SPEEX_PREPROCESS_SET_VAD: - st->vad_enabled = (*(int*)ptr); - break; - case SPEEX_PREPROCESS_GET_VAD: - (*(int*)ptr) = st->vad_enabled; - break; - - case SPEEX_PREPROCESS_SET_PROB_START: - st->speech_prob_start = (*(float*)ptr) ; - if ( st->speech_prob_start > 1 ) - st->speech_prob_start = st->speech_prob_start / 100 ; - if ( st->speech_prob_start > 1 || st->speech_prob_start < 0 ) - st->speech_prob_start = SPEEX_PROB_START ; - break ; - case SPEEX_PREPROCESS_GET_PROB_START: - (*(float*)ptr) = st->speech_prob_start ; - break ; - - case SPEEX_PREPROCESS_SET_PROB_CONTINUE: - st->speech_prob_continue = (*(float*)ptr) ; - if ( st->speech_prob_continue > 1 ) - st->speech_prob_continue = st->speech_prob_continue / 100 ; - if ( st->speech_prob_continue > 1 || st->speech_prob_continue < 0 ) - st->speech_prob_continue = SPEEX_PROB_CONTINUE ; - break ; - break ; - case SPEEX_PREPROCESS_GET_PROB_CONTINUE: - (*(float*)ptr) = st->speech_prob_continue ; - break ; - - default: - speex_warning_int("Unknown speex_preprocess_ctl request: ", request); - return -1; - } - return 0; -} diff --git a/extras/app_conference/libspeex/qc_20060323.zip b/extras/app_conference/libspeex/qc_20060323.zip deleted file mode 100644 index a2a4d3b3..00000000 Binary files a/extras/app_conference/libspeex/qc_20060323.zip and /dev/null differ diff --git a/extras/app_conference/libspeex/smallft.c b/extras/app_conference/libspeex/smallft.c deleted file mode 100644 index 2a4fc02a..00000000 --- a/extras/app_conference/libspeex/smallft.c +++ /dev/null @@ -1,1256 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - * * - ******************************************************************** - - function: *unnormalized* fft transform - last mod: $Id: smallft.c,v 1.3 2005/03/25 20:26:26 stevek Exp $ - - ********************************************************************/ - -/* FFT implementation from OggSquish, minus cosine transforms, - * minus all but radix 2/4 case. In Vorbis we only need this - * cut-down version. - * - * To do more than just power-of-two sized vectors, see the full - * version I wrote for NetLib. - * - * Note that the packing is a little strange; rather than the FFT r/i - * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, - * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the - * FORTRAN version - */ - -#include -#include "smallft.h" -#include "misc.h" - -static void drfti1(int n, float *wa, int *ifac){ - static int ntryh[4] = { 4,2,3,5 }; - static float tpi = 6.28318530717958648f; - float arg,argh,argld,fi; - int ntry=0,i,j=-1; - int k1, l1, l2, ib; - int ld, ii, ip, is, nq, nr; - int ido, ipm, nfm1; - int nl=n; - int nf=0; - - L101: - j++; - if (j < 4) - ntry=ntryh[j]; - else - ntry+=2; - - L104: - nq=nl/ntry; - nr=nl-ntry*nq; - if (nr!=0) goto L101; - - nf++; - ifac[nf+1]=ntry; - nl=nq; - if(ntry!=2)goto L107; - if(nf==1)goto L107; - - for (i=1;i>1; - ipp2=ip; - idp2=ido; - nbd=(ido-1)>>1; - t0=l1*ido; - t10=ip*ido; - - if(ido==1)goto L119; - for(ik=0;ikl1){ - for(j=1;j>1; - ipp2=ip; - ipph=(ip+1)>>1; - if(idol1)goto L139; - - is= -ido-1; - t1=0; - for(j=1;jn==1)return; - drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void drft_backward(struct drft_lookup *l,float *data){ - if (l->n==1)return; - drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache); -} - -void drft_init(struct drft_lookup *l,int n) -{ - l->n=n; - l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache)); - l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache)); - fdrffti(n, l->trigcache, l->splitcache); -} - -void drft_clear(struct drft_lookup *l) -{ - if(l) - { - if(l->trigcache) - speex_free(l->trigcache); - if(l->splitcache) - speex_free(l->splitcache); - } -} diff --git a/extras/app_conference/libspeex/smallft.h b/extras/app_conference/libspeex/smallft.h deleted file mode 100644 index d44c41b1..00000000 --- a/extras/app_conference/libspeex/smallft.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - * * - ******************************************************************** - - function: fft transform - last mod: $Id: smallft.h,v 1.2 2004/07/07 13:39:42 stevek Exp $ - - ********************************************************************/ - -#ifndef _V_SMFT_H_ -#define _V_SMFT_H_ - -/*#include "vorbis/codec.h"*/ - -#ifdef __cplusplus -extern "C" { -#endif - -struct drft_lookup{ - int n; - float *trigcache; - int *splitcache; -}; - -extern void drft_forward(struct drft_lookup *l,float *data); -extern void drft_backward(struct drft_lookup *l,float *data); -extern void drft_init(struct drft_lookup *l,int n); -extern void drft_clear(struct drft_lookup *l); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/extras/app_conference/libspeex/speex_preprocess.h b/extras/app_conference/libspeex/speex_preprocess.h deleted file mode 100644 index 320224ea..00000000 --- a/extras/app_conference/libspeex/speex_preprocess.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2003 Epic Games - Written by Jean-Marc Valin - - File: speex_preprocess.h - - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - - -#ifdef __cplusplus -extern "C" { -#endif - -struct drft_lookup; - -typedef struct SpeexPreprocessState { - int frame_size; /**< Number of samples processed each time */ - int ps_size; /**< Number of points in the power spectrum */ - int sampling_rate; /**< Sampling rate of the input/output */ - - /* parameters */ - int denoise_enabled; - int agc_enabled; - float agc_level; - int vad_enabled; - - // probabilities to check speech_prob against - float speech_prob_start ; - float speech_prob_continue ; - - float *frame; /**< Processing frame (2*ps_size) */ - float *ps; /**< Current power spectrum */ - float *gain2; /**< Adjusted gains */ - float *window; /**< Analysis/Synthesis window */ - float *noise; /**< Noise estimate */ - float *old_ps; /**< Power spectrum for last frame */ - float *gain; /**< Ephraim Malah gain */ - float *prior; /**< A-priori SNR */ - float *post; /**< A-posteriori SNR */ - - float *S; /**< Smoothed power spectrum */ - float *Smin; /**< See Cohen paper */ - float *Stmp; /**< See Cohen paper */ - float *update_prob; /**< Propability of speech presence for noise update */ - - float *zeta; /**< Smoothed a priori SNR */ - float Zpeak; - float Zlast; - - float *loudness_weight; /**< Perceptual loudness curve */ - - float *echo_noise; - - float *noise_bands; - float *noise_bands2; - int noise_bandsN; - float *speech_bands; - float *speech_bands2; - int speech_bandsN; - - float *inbuf; /**< Input buffer (overlapped analysis) */ - float *outbuf; /**< Output buffer (for overlap and add) */ - - float speech_prob; - int last_speech; - float loudness; /**< loudness estimate */ - float loudness2; /**< loudness estimate */ - int nb_adapt; /**< Number of frames used for adaptation so far */ - int nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */ - int consec_noise; /**< Number of consecutive noise frames */ - int nb_preprocess; /**< Number of frames processed so far */ - struct drft_lookup *fft_lookup; /**< Lookup table for the FFT */ - -} SpeexPreprocessState; - -/** Creates a new preprocessing state */ -SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate); - -/** Destroys a denoising state */ -void speex_preprocess_state_destroy(SpeexPreprocessState *st); - -/** Preprocess a frame */ -int speex_preprocess(SpeexPreprocessState *st, short *x, float *noise); - -/** Preprocess a frame */ -void speex_preprocess_estimate_update(SpeexPreprocessState *st, short *x, float *noise); - -/** Used like the ioctl function to control the preprocessor parameters */ -int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr); - -#define SPEEX_PROB_START 0.35 -#define SPEEX_PROB_CONTINUE 0.1 - -#define SPEEX_PREPROCESS_SET_DENOISE 0 -#define SPEEX_PREPROCESS_GET_DENOISE 1 - -#define SPEEX_PREPROCESS_SET_AGC 2 -#define SPEEX_PREPROCESS_GET_AGC 3 - -#define SPEEX_PREPROCESS_SET_VAD 4 -#define SPEEX_PREPROCESS_GET_VAD 5 - -#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6 -#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7 - -#define SPEEX_PREPROCESS_SET_PROB_START 8 -#define SPEEX_PREPROCESS_GET_PROB_START 9 - -#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 10 -#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 11 - -#ifdef __cplusplus -} -#endif diff --git a/extras/app_conference/member.c b/extras/app_conference/member.c deleted file mode 100644 index 30f6ccc8..00000000 --- a/extras/app_conference/member.c +++ /dev/null @@ -1,1946 +0,0 @@ - -// $Id: member.c,v 1.9-1 2006/06/01 16:10:10 mflorell Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003, 2004 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#include "member.h" -#include "regex.h" - - - -// process an incoming frame. Returns 0 normally, 1 if hangup was received. -static int process_incoming(struct ast_conference *conf, struct ast_conf_member *member, struct ast_frame *f) -{ - - int silent_frame = 0; - - if ( - f->frametype == AST_FRAME_DTMF - && member->send_dtmf - ) - { // send the DTMF event to the MGR interface.. - manager_event( - EVENT_FLAG_CALL, - "ConferenceDTMF", - "Channel: %s\r\n" - "Key: %c\r\n", - member->channel_name, - f->subclass - ) ; - - ast_frfree(f); - f = NULL; - } - else if ( member->type == 'L' ) - { - // this is a listen-only user, ignore the frame - ast_frfree( f ) ; - f = NULL ; - } - else if ( ( f->frametype == AST_FRAME_VOICE ) || (f->frametype == AST_FRAME_DTMF) ) -// else if ( f->frametype == AST_FRAME_VOICE ) - { - // accounting: count the incoming frame - member->frames_in++ ; - - if (f->frametype == AST_FRAME_DTMF) - { - if ( (member->inband_dtmf == -1) || (member->rfc_dtmf == -1) ) - { - char *digit = "X" ; - char *dtmfRFC = "X" ; - int conf_count ; - struct ast_conf_member *membertest; - - if (f->subclass == 35) { digit = "hash" ; dtmfRFC = "#" ; } - if (f->subclass == 42) { digit = "star" ; dtmfRFC = "*" ; } - if (f->subclass == 48) { digit = "0" ; dtmfRFC = "0" ; } - if (f->subclass == 49) { digit = "1" ; dtmfRFC = "1" ; } - if (f->subclass == 50) { digit = "2" ; dtmfRFC = "2" ; } - if (f->subclass == 51) { digit = "3" ; dtmfRFC = "3" ; } - if (f->subclass == 52) { digit = "4" ; dtmfRFC = "4" ; } - if (f->subclass == 53) { digit = "5" ; dtmfRFC = "5" ; } - if (f->subclass == 54) { digit = "6" ; dtmfRFC = "6" ; } - if (f->subclass == 55) { digit = "7" ; dtmfRFC = "7" ; } - if (f->subclass == 56) { digit = "8" ; dtmfRFC = "8" ; } - if (f->subclass == 57) { digit = "9" ; dtmfRFC = "9" ; } - - ast_log( LOG_NOTICE, "DTMF debug frame output to voice %d - %s\n", f->subclass, digit ) ; - - int res = 0 ; - int dtmf_invalid = 0 ; - regex_t re; - - if(regcomp(&re, digit, REG_EXTENDED|REG_NOSUB) != 0) { dtmf_invalid = 0; } - dtmf_invalid = regexec(&re, "0123456789*#abcdABCDstarhash", (size_t)0, NULL, 0); - regfree(&re); - ast_log( LOG_NOTICE, "Regex debug %d - %s - %s\n", dtmf_invalid, member->channel_name, digit) ; - - // play DTMF for other members of the conference - membertest = conf->memberlist ; - conf_count = conf->membercount ; - - // ast_log( LOG_NOTICE, "2 DTMF debug frame output to voice, conf count %d\n", conf_count) ; - - while (membertest != NULL) - { - - if( (!strcmp(membertest->channel_name, member->channel_name)) || ( digit == "X" ) ) - { - ast_log( LOG_ERROR, "skipping playing DTMF tone on %s\n", membertest->channel_name ) ; - } - else - { - - if (member->inband_dtmf == -1) - { - if (!basic_play_sound ( membertest->channel_name, digit )) - { - ast_log( LOG_ERROR, "playing DTMF tone FAILED on %s\n", membertest->channel_name ) ; - } - } - - if (member->rfc_dtmf == -1) - { - ast_log( LOG_NOTICE, "START sending DTMF signal on %s\n", membertest->channel_name ) ; - - if(dtmf_invalid > 0) - { - ast_log(LOG_WARNING, "Illegal DTMF character '%s' in string. (0-9*#aAbBcCdD allowed)\n", digit); - } - else - { - - res = ast_dtmf_stream(membertest->chan,NULL,digit,250); - if (res) - { - ast_log( LOG_NOTICE, "DTMF signal %s on %s sent\n", digit, membertest->channel_name ) ; - } - } - } - } - membertest = membertest->next; - } - } - - - } - - -#ifdef DEBUG_OUTPUT_PCM - // !!! TESTING !!! - if ( member->incoming_fh != NULL ) - { - fwrite( f->data, f->datalen, 1, member->incoming_fh ) ; - fflush( member->incoming_fh ) ; - } -#endif - -#if ( SILDET == 2 ) - // - // make sure we have a valid dsp and frame type - // - if ( - member->dsp != NULL - && f->subclass == AST_FORMAT_SLINEAR - && f->datalen == AST_CONF_FRAME_DATA_SIZE - ) - { - // send the frame to the preprocessor -#ifdef DEBUG_USE_TIMELOG - int spx_ret; - TIMELOG(spx_ret = speex_preprocess( member->dsp, f->data, NULL ), 3, "speex_preprocess"); - if ( spx_ret == 0 ) -#else - if ( speex_preprocess( member->dsp, f->data, NULL ) == 0 ) -#endif - { - // - // we ignore the preprocessor's outcome if we've seen voice frames - // in within the last AST_CONF_SKIP_SPEEX_PREPROCESS frames - // - if ( member->ignore_speex_count > 0 ) - { - // ast_log( AST_CONF_DEBUG, "ignore_speex_count => %d\n", member->ignore_speex_count ) ; - - // skip speex_preprocess(), and decrement counter - --member->ignore_speex_count ; - } - else - { - // set silent_frame flag - silent_frame = 1 ; - } - } - else - { - // voice detected, reset skip count - member->ignore_speex_count = AST_CONF_SKIP_SPEEX_PREPROCESS ; - } - } -#endif - - // used to debug drop off in received frames - // struct timeval tv ; - // gettimeofday( &tv, NULL ) ; - - if ( silent_frame == 1 ) - { - // ignore silent frames - // ast_log( AST_CONF_DEBUG, "RECEIVED SILENT FRAME, channel => %s, frames_in => %ld, s => %ld, ms => %ld\n", - // member->channel_name, member->frames_in, tv.tv_sec, tv.tv_usec ) ; - } - else - { - // queue a non-silent frame for mixing - - // ast_log( AST_CONF_DEBUG, "RECEIVED VOICE FRAME, channel => %s, frames_in => %ld, s => %ld, ms => %ld\n", - // member->channel_name, member->frames_in, tv.tv_sec, tv.tv_usec ) ; - - // acquire member lock - ast_mutex_lock( &member->lock ) ; - - // - // queue up the voice frame so the conference - // thread can mix them before sending - // - - // struct ast_frame* af = ast_frdup( f ) ; - - // if ( queue_incoming_frame( member, af ) != 0 ) - if ( queue_incoming_frame( member, f ) != 0 ) - { - // free the duplicated frame, if we can't queue it - // ast_log( LOG_NOTICE, "dropped incoming frame, channel => %s\n", chan->name ) ; - // ast_frfree( af ) ; - // af = NULL ; - } - else - { - // everything is going ok - } - - // release member mutex - ast_mutex_unlock( &member->lock ) ; - } - - // free the original frame - ast_frfree( f ) ; - f = NULL ; - } - else if ( - f->frametype == AST_FRAME_CONTROL - && f->subclass == AST_CONTROL_HANGUP - ) - { - // hangup received - - // free the frame - ast_frfree( f ) ; - f = NULL ; - - // break out of the while ( 42 == 42 ) - return 1 ; - } - else - { - // undesirables - ast_frfree( f ) ; - f = NULL ; - } - return 0; -} - -// get the next frame from the soundq; must be called with member locked. -static struct ast_frame *get_next_soundframe(struct ast_conf_member *member, struct ast_frame - *exampleframe) { - struct ast_frame *f; - -again: - f=ast_readframe(member->soundq->stream); - - if(!f) { // we're done with this sound; remove it from the queue, and try again - struct ast_conf_soundq *toboot = member->soundq; - - ast_closestream(toboot->stream); - member->soundq = toboot->next; - - //ast_log( LOG_WARNING, "finished playing a sound, next = %x\n", member->soundq); - // notify applications via mgr interface that this sound has been played - manager_event( - EVENT_FLAG_CALL, - "ConferenceSoundComplete", - "Channel: %s\r\n" - "Sound: %s\r\n", - member->channel_name, - toboot->name - ); - - free(toboot); - if(member->soundq) goto again; - - // if we get here, we've gotten to the end of the queue; reset write format - if ( ast_set_write_format( member->chan, member->write_format ) < 0 ) - { - ast_log( LOG_ERROR, "unable to set write format to %d\n", - member->write_format ) ; - } - } else { - // copy delivery from exampleframe - f->delivery = exampleframe->delivery; - } - - return f; -} - -// process outgoing frames for the channel, playing either normal conference audio, -// or requested sounds -static int process_outgoing(struct ast_conf_member *member) -{ - conf_frame* cf ; // frame read from the output queue - struct ast_frame *f; - struct ast_frame *realframe = NULL; - - for(;;) - { - // acquire member mutex and grab a frame. - ast_mutex_lock( &member->lock ) ; - cf = get_outgoing_frame( member ) ; - - // if there's no frames exit the loop. - if(!cf){ - ast_mutex_unlock( &member->lock ) ; - break; - } - - f = cf->fr; - - // if we're playing sounds, we can just replace the frame with the - // next sound frame, and send it instead - if(member->soundq) { - realframe = f; - f = get_next_soundframe(member, f); - if(!f) { // if we didn't get anything, just revert to "normal" - f = realframe; - realframe = NULL; - } - } - - ast_mutex_unlock(&member->lock); - -#ifdef DEBUG_FRAME_TIMESTAMPS - // !!! TESTING !!! - int delivery_diff = usecdiff( &f->delivery, &member->lastsent_timeval ) ; - if ( ( delivery_diff != AST_CONF_FRAME_INTERVAL ) && - ( delivery_diff != 2 * AST_CONF_FRAME_INTERVAL ) && - ( delivery_diff != 3 * AST_CONF_FRAME_INTERVAL ) ) - { - ast_log( AST_CONF_DEBUG, "unanticipated delivery time, delivery_diff => %d, delivery.tv_usec => %ld\n", - delivery_diff, f->delivery.tv_usec ) ; - } - - // !!! TESTING !!! - if ( - f->delivery.tv_sec < member->lastsent_timeval.tv_sec - || ( - f->delivery.tv_sec == member->lastsent_timeval.tv_sec - && f->delivery.tv_usec <= member->lastsent_timeval.tv_usec - ) - ) - { - ast_log( LOG_WARNING, "queued frame timestamped in the past, %ld.%ld <= %ld.%ld\n", - f->delivery.tv_sec, f->delivery.tv_usec, - member->lastsent_timeval.tv_sec, member->lastsent_timeval.tv_usec ) ; - } - member->lastsent_timeval = f->delivery ; -#endif - -//#ifdef DEBUG_USE_TIMELOG -// TIMELOG( ast_write( member->chan, f ), 10, "member: ast_write"); -//#else - // send the voice frame - if ( ast_write( member->chan, f ) == 0 ) - { - // struct timeval tv ; - // gettimeofday( &tv, NULL ) ; - // ast_log( AST_CONF_DEBUG, "SENT VOICE FRAME, channel => %s, frames_out => %ld, s => %ld, ms => %ld\n", - // member->channel_name, member->frames_out, tv.tv_sec, tv.tv_usec ) ; - } - else - { - // log 'dropped' outgoing frame - ast_log( LOG_ERROR, "unable to write voice frame to channel, channel => %s\n", member->channel_name ) ; - - // accounting: count dropped outgoing frames - member->frames_out_dropped++ ; - } -//#endif - - // clean up frame - delete_conf_frame( cf ) ; - } - return 0; -} - -// -// main member thread function -// - -int member_exec( struct ast_channel* chan, void* data ) -{ -// struct timeval start, end ; -// gettimeofday( &start, NULL ) ; - - struct ast_conference *conf ; - struct ast_conf_member *member, *membertest; - - struct ast_frame *f ; // frame received from ast_read() - - int left = 0 ; - int res; - - ast_log( AST_CONF_DEBUG, "[ $Revision: 1.9 $ ] begin processing member thread, channel => %s\n", chan->name ) ; - - // - // If the call has not yet been answered, answer the call - // Note: asterisk apps seem to check _state, but it seems like it's safe - // to just call ast_answer. It will just do nothing if it is up. - // it will also return -1 if the channel is a zombie, or has hung up. - // - - res = ast_answer( chan ) ; - if ( res ) - { - ast_log( LOG_ERROR, "unable to answer call\n" ) ; - return -1 ; - } - - // - // create a new member for the conference - // - -// ast_log( AST_CONF_DEBUG, "creating new member, id => %s, flags => %s, p => %s\n", -// id, flags, priority ) ; - - member = create_member( chan, (const char*)( data ) ) ; // flags, atoi( priority ) ) ; - - // unable to create member, return an error - if ( member == NULL ) - { - ast_log( LOG_ERROR, "unable to create member\n" ) ; - return -1 ; - } - - // - // setup asterisk read/write formats - // - - ast_log( AST_CONF_DEBUG, "CHANNEL INFO, CHANNEL => %s, DNID => %s, CALLER_ID => %s, ANI => %s\n", - chan->name, chan->cid.cid_dnid, chan->cid.cid_num, chan->cid.cid_ani ) ; - - ast_log( AST_CONF_DEBUG, "CHANNEL CODECS, CHANNEL => %s, NATIVE => %d, READ => %d, WRITE => %d\n", - chan->name, chan->nativeformats, member->read_format, member->write_format ) ; - - if ( ast_set_read_format( chan, member->read_format ) < 0 ) - { - ast_log( LOG_ERROR, "unable to set read format to signed linear\n" ) ; - delete_member( member ) ; - return -1 ; - } - - // for right now, we'll send everything as slinear - if ( ast_set_write_format( chan, member->write_format ) < 0 ) // AST_FORMAT_SLINEAR, chan->nativeformats - { - ast_log( LOG_ERROR, "unable to set write format to signed linear\n" ) ; - delete_member( member ) ; - return -1 ; - } - - // - // setup a conference for the new member - // - - conf = start_conference( member ) ; - - if ( conf == NULL ) - { - ast_log( LOG_ERROR, "unable to setup member conference\n" ) ; - delete_member( member) ; - return -1 ; - } - -#ifdef DEBUG_OUTPUT_PCM - // !!! TESTING !!! - char* incoming_fn = malloc( 512 ) ; - snprintf( incoming_fn, 512, "/tmp/ac_%s_%ld.gsm", chan->dnid, fr_base.tv_usec ) ; - - // !!! TESTING !!! - member->incoming_fh = ( member->read_format == 2 ) - ? fopen( member->incoming_fn, "wb" ) - : NULL - ; - - // !!! TESTING !!! - if ( member->incoming_fh == NULL ) - { - ast_log( AST_CONF_DEBUG, "incoming_fh is null, incoming_fn => %s\n", incoming_fn ) ; - } - else - { - ast_log( AST_CONF_DEBUG, "incoming_fh is not null, incoming_fn => %s\n", incoming_fn ) ; - } - - // !!! TESTING !!! - free( incoming_fn ) ; -#endif - - // - // process loop for new member ( this runs in it's own thread - // - - ast_log( AST_CONF_DEBUG, "begin member event loop, channel => %s\n", chan->name ) ; - - // timer timestamps - struct timeval base, curr ; - gettimeofday( &base, NULL ) ; - - - - // tell conference_exec we're ready for frames - member->ready_for_outgoing = 1 ; - - int conf_count = 0 ; - int silent_entry = 0 ; - - // entry message for other members of the conference - membertest = conf->memberlist ; - conf_count = conf->membercount ; - - ast_log( LOG_NOTICE, "Conference Members: %d\n", conf_count ) ; - - if (member->quiet_entry_exit == -1) - { - silent_entry = 1 ; - } - ast_log( LOG_NOTICE, "Quiet debug %d - %d\n", member->quiet_entry_exit, silent_entry ) ; - - while (membertest != NULL) - { - if (silent_entry < 1) - { - if( (!strcmp(membertest->channel_name, member->channel_name)) && (conf_count < 2) ) - { - ast_log( LOG_NOTICE, "skipping entry message on %s\n", membertest->channel_name ) ; - - if (!basic_play_sound ( member->channel_name, "conf-onlyperson" )) - { - ast_log( LOG_ERROR, "playing conference welcome message FAILED\n" ) ; - } - } - else - { - if (!basic_play_sound ( membertest->channel_name, "enter" )) - { - ast_log( LOG_ERROR, "playing conference entry message FAILED on %s\n", membertest->channel_name ) ; - } - } - } - else - { - ast_log( LOG_NOTICE, "skipping all entry messages on %s\n", membertest->channel_name ) ; - } - - membertest = membertest->next; - } - - - - while ( 42 == 42 ) - { - // make sure we have a channel to process - if ( chan == NULL ) - { - ast_log( LOG_NOTICE, "member channel has closed\n" ) ; - break ; - } - - //-----------------// - // INCOMING FRAMES // - //-----------------// - - // wait for an event on this channel - left = ast_waitfor( chan, AST_CONF_WAITFOR_LATENCY ) ; - - // ast_log( AST_CONF_DEBUG, "received event on channel, name => %s, rest => %d\n", chan->name, rest ) ; - - if ( left < 0 ) - { - // an error occured - ast_log( - LOG_NOTICE, - "an error occured waiting for a frame, channel => %s, error => %d\n", - chan->name, left - ) ; - } - else if ( left == 0 ) - { - // no frame has arrived yet - // ast_log( LOG_NOTICE, "no frame available from channel, channel => %s\n", chan->name ) ; - } - else if ( left > 0 ) - { - // a frame has come in before the latency timeout - // was reached, so we process the frame - - f = ast_read( chan ) ; - - if ( f == NULL ) - { - ast_log( LOG_NOTICE, "unable to read from channel, channel => %s\n", chan->name ) ; - break ; - } - - // actually process the frame: break if we got hangup. - if(process_incoming(conf, member, f)) break; - - } - - //-----------------// - // OUTGOING FRAMES // - //-----------------// - - // update the current timestamps - gettimeofday( &curr, NULL ) ; - - process_outgoing(member); - - - // back to process incoming frames - continue ; - } - - ast_log( AST_CONF_DEBUG, "end member event loop, time_entered => %ld\n", member->time_entered.tv_sec ) ; - - // - // clean up - // - -#ifdef DEBUG_OUTPUT_PCM - // !!! TESTING !!! - if ( member->incoming_fh != NULL ) - fclose( member->incoming_fh ) ; -#endif - - if ( member != NULL ) member->remove_flag = 1 ; - -// gettimeofday( &end, NULL ) ; -// int expected_frames = ( int )( floor( (double)( usecdiff( &end, &start ) / AST_CONF_FRAME_INTERVAL ) ) ) ; -// ast_log( AST_CONF_DEBUG, "expected_frames => %d\n", expected_frames ) ; - - return -1 ; -} - -// basic sound playing function -int basic_play_sound ( char *channel, char *file ) -{ -// char *channel, *file; - struct ast_conf_member *play_member; - struct ast_conf_soundq *newsound; - struct ast_conf_soundq **q; - - play_member = find_member(channel, 1); - if(!play_member) { - ast_log( LOG_ERROR, "Member %s not found\n", channel) ; - return 0; - } - - newsound = calloc(1,sizeof(struct ast_conf_soundq)); - newsound->stream = ast_openstream(play_member->chan, file, NULL); - if(!newsound->stream) { - free(newsound); - ast_mutex_unlock(&play_member->lock); - ast_log( LOG_ERROR, "sound file not found\n" ) ; - } - play_member->chan->stream = NULL; - - ast_copy_string(newsound->name, file, sizeof(newsound->name)); - - // append sound to the end of the list. - for(q=&play_member->soundq; *q; q = &((*q)->next)) ;; - - *q = newsound; - - ast_mutex_unlock(&play_member->lock); - - ast_log( LOG_NOTICE, "playing conference message %s\n", file ) ; - return 1; -} - -// -// manange member functions -// - -struct ast_conf_member* create_member( struct ast_channel *chan, const char* data ) -{ - // - // check input - // - - if ( chan == NULL ) - { - ast_log( LOG_ERROR, "unable to create member with null channel\n" ) ; - return NULL ; - } - - if ( chan->name == NULL ) - { - ast_log( LOG_ERROR, "unable to create member with null channel name\n" ) ; - return NULL ; - } - - // - // allocate memory for new conference member - // - - struct ast_conf_member *member = calloc( 1, sizeof( struct ast_conf_member ) ) ; - - if ( member == NULL ) - { - ast_log( LOG_ERROR, "unable to malloc ast_conf_member\n" ) ; - return NULL ; - } - - // initialize mutex - ast_mutex_init( &member->lock ) ; - - // - // initialize member with passed data values - // - - char argstr[80] ; - char *stringp, *token ; - - // copy the passed data - strncpy( argstr, data, sizeof(argstr) - 1 ) ; - - // point to the copied data - stringp = argstr ; - - ast_log( AST_CONF_DEBUG, "attempting to parse passed params, stringp => %s\n", stringp ) ; - - // parse the id - if ( ( token = strsep( &stringp, "|" ) ) != NULL ) - { - member->id = malloc( strlen( token ) + 1 ) ; - strcpy( member->id, token ) ; - } - else - { - ast_log( LOG_ERROR, "unable to parse member id\n" ) ; - free( member ) ; - return NULL ; - } - - // parse the flags - if ( ( token = strsep( &stringp, "|" ) ) != NULL ) - { - member->flags = malloc( strlen( token ) + 1 ) ; - strcpy( member->flags, token ) ; - } - else - { - // make member->flags something - member->flags = malloc( sizeof( char ) ) ; - memset( member->flags, 0x0, sizeof( char ) ) ; - } - - // parse the priority - member->priority = ( token = strsep( &stringp, "|" ) ) != NULL - ? atoi( token ) - : 0 - ; - - // parse the vad_prob_start - member->vad_prob_start = ( token = strsep( &stringp, "|" ) ) != NULL - ? atof( token ) - : AST_CONF_PROB_START - ; - - // parse the vad_prob_continue - member->vad_prob_continue = ( token = strsep( &stringp, "|" ) ) != NULL - ? atof( token ) - : AST_CONF_PROB_CONTINUE - ; - - // parse the expected frame size, in samples. ?? - - - // debugging - ast_log( - AST_CONF_DEBUG, - "parsed data params, id => %s, flags => %s, priority => %d, vad_prob_start => %f, vad_prob_continue => %f\n", - member->id, member->flags, member->priority, member->vad_prob_start, member->vad_prob_continue - ) ; - - // - // initialize member with default values - // - - // keep pointer to member's channel - member->chan = chan ; - - // copy the channel name - member->channel_name = malloc( strlen( chan->name ) + 1 ) ; - strcpy( member->channel_name, chan->name ) ; - - // ( default can be overridden by passed flags ) -// member->type = 'L' ; - member->type = 'S' ; - - // ready flag - member->ready_for_outgoing = 0 ; - - // incoming frame queue - member->inFrames = NULL ; - member->inFramesTail = NULL ; - member->inFramesCount = 0 ; - - // last frame caching - member->inFramesRepeatLast = 0 ; - member->inFramesLast = NULL ; - member->okayToCacheLast = 0 ; - - // outgoing frame queue - member->outFrames = NULL ; - member->outFramesTail = NULL ; - member->outFramesCount = 0 ; - - member->outPacker = NULL; - - // ( not currently used ) - // member->samplesperframe = AST_CONF_BLOCK_SAMPLES ; - - // used for determining need to mix frames - // and for management interface notification - member->speaking_state_prev = 0 ; - member->speaking_state_notify = 0 ; - member->speaking_state = 0 ; - - // linked-list pointer - member->next = NULL ; - - // account data - member->frames_in = 0 ; - member->frames_in_dropped = 0 ; - member->frames_out = 0 ; - member->frames_out_dropped = 0 ; - - // for counting sequentially dropped frames - member->sequential_drops = 0 ; - member->since_dropped = 0 ; - - // flags - member->remove_flag = 0 ; - - // record start time - gettimeofday( &member->time_entered, NULL ) ; - - // init dropped frame timestamps - gettimeofday( &member->last_in_dropped, NULL ) ; - gettimeofday( &member->last_out_dropped, NULL ) ; - - // - // parse passed flags - // - - // silence detection flags w/ defaults - int vad_flag = 0 ; - int denoise_flag = 0 ; - int agc_flag = 0 ; - - // is this member using the telephone? - int via_telephone = 0 ; - - // temp pointer to flags string - // char* flags = member->flags ; - char* flags = member->flags ; - int i; - for ( i = 0 ; i < strlen( flags ) ; ++i ) - { - // allowed flags are M, L, S, V, D, A - switch ( flags[i] ) - { - // call via telephone - case 'T': - via_telephone = 1 ; - break ; - - // member types ( last flag wins ) - case 'M': - member->type = 'M' ; - break ; - case 'L': - member->type = 'L' ; - break ; - case 'S': - member->type = 'S' ; - break ; - - // speex preprocessing options - case 'V': - vad_flag = 1 ; - break ; - case 'D': - denoise_flag = 1 ; - break ; - case 'A': - agc_flag = 1 ; - break ; - - // additional features - case 'd': // Send DTMF manager events.. - member->send_dtmf = 1; - break; - case 'q': // Quiet entry and exit from conference - member->quiet_entry_exit = 1; - break; - case 'i': // use Inband DTMF broadcast - member->inband_dtmf = 1; - break; - case 't': // use RFC DTMF broadcast - member->rfc_dtmf = 1; - break; - - default: - ast_log( LOG_WARNING, "received invalid flag, chan => %s, flag => %c\n", - chan->name, flags[i] ) ; - break ; - } - } - - // set the dsp to null so silence detection is disabled by default - member->dsp = NULL ; - -#if ( SILDET == 2 ) - // - // configure silence detection and preprocessing - // if the user is coming in via the telephone, - // and is not listen-only - // - if ( - via_telephone == 1 - && member->type != 'L' - ) - { - // create a speex preprocessor - member->dsp = speex_preprocess_state_init( AST_CONF_BLOCK_SAMPLES, AST_CONF_SAMPLE_RATE ) ; - - if ( member->dsp == NULL ) - { - ast_log( LOG_WARNING, "unable to initialize member dsp, channel => %s\n", chan->name ) ; - } - else - { - ast_log( LOG_NOTICE, "member dsp initialized, channel => %s, v => %d, d => %d, a => %d\n", - chan->name, vad_flag, denoise_flag, agc_flag ) ; - - // set speex preprocessor options - speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_VAD, &vad_flag ) ; - speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_DENOISE, &denoise_flag ) ; - speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_AGC, &agc_flag ) ; - - speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_PROB_START, &member->vad_prob_start ) ; - speex_preprocess_ctl( member->dsp, SPEEX_PREPROCESS_SET_PROB_CONTINUE, &member->vad_prob_continue ) ; - - ast_log( AST_CONF_DEBUG, "speech_prob_start => %f, speech_prob_continue => %f\n", - member->dsp->speech_prob_start, member->dsp->speech_prob_continue ) ; - } - } -#endif - - // - // set connection type - // - - if ( via_telephone == 1 ) - { - member->connection_type = 'T' ; - } - else if ( strncmp( member->channel_name, "SIP", 3 ) == 0 ) - { - member->connection_type = 'S' ; - } - else // default to iax - { - member->connection_type = 'X' ; - } - - // - // read, write, and translation options - // - - // set member's audio formats, taking dsp preprocessing into account - // ( chan->nativeformats, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, AST_FORMAT_GSM ) - member->read_format = ( member->dsp == NULL ) ? chan->nativeformats : AST_FORMAT_SLINEAR ; - member->write_format = chan->nativeformats ; - - // translation paths ( ast_translator_build_path() returns null if formats match ) - member->to_slinear = ast_translator_build_path( AST_FORMAT_SLINEAR, member->read_format ) ; - member->from_slinear = ast_translator_build_path( member->write_format, AST_FORMAT_SLINEAR ) ; - - //ast_log( AST_CONF_DEBUG, "AST_FORMAT_SLINEAR => %d\n", AST_FORMAT_SLINEAR ) ; - - // index for converted_frames array - { - int format, index; - index=-1; - format = member->write_format; - while( format > 0){ - index++; - format = format >> 1; - } - member->write_format_index= index; - //ast_log( AST_CONF_DEBUG, "converted write_format [%d] to index[%d]\n", member->write_format, index ); - - index=-1; - format = member->read_format; - while( format > 0){ - index++; - format = format >> 1; - } - member->read_format_index=index; - //ast_log( AST_CONF_DEBUG, "converted read_format [%d] to index[%d]\n", member->read_format, index ); - } - - // smoother defaults. - member->smooth_multiple =1; - member->smooth_size_in = -1; - member->smooth_size_out = -1; - member->inSmoother= NULL; - member->outPacker= NULL; - - switch (member->read_format){ - /* these assumptions may be incorrect */ - case AST_FORMAT_ULAW: - case AST_FORMAT_ALAW: - /* - member->smooth_size_in = 160; //bytes - member->smooth_size_out = 160; //samples - */ - break; - case AST_FORMAT_GSM: - /* - member->smooth_size_in = 33; //bytes - member->smooth_size_out = 160;//samples - */ - break; - case AST_FORMAT_SPEEX: - /* this assumptions are wrong - member->smooth_multiple = 2 ; // for testing, force to dual frame - member->smooth_size_in = 39; // bytes - member->smooth_size_out = 160; // samples - */ - break; - case AST_FORMAT_SLINEAR: - /* - member->smooth_size_in = 320; //bytes - member->smooth_size_out = 160; //samples - */ - break; - default: - member->inSmoother = NULL; //don't use smoother for this type. - //ast_log( AST_CONF_DEBUG, "smoother is NULL for member->read_format => %d\n", member->read_format); - } - if (member->smooth_size_in > 0){ - member->inSmoother = ast_smoother_new(member->smooth_size_in); - //ast_log( AST_CONF_DEBUG, "created smoother(%d) for %d\n", member->smooth_size_in , member->read_format); - } - - - // - // finish up - // - - ast_log( AST_CONF_DEBUG, "created member, type => %c, priority => %d, readformat => %d\n", - member->type, member->priority, chan->readformat ) ; - - return member ; -} - -struct ast_conf_member* delete_member( struct ast_conf_member* member ) -{ - // !!! NO RETURN TEST !!! - // do { sleep(1) ; } while (1) ; - - // !!! CRASH TEST !!! - // *((int *)0) = 0; - - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to the delete null member\n" ) ; - return NULL ; - } - - // - // clean up member flags - // - - if ( member->flags != NULL ) - { - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "freeing member flags, name => %s\n", - member->channel_name ) ; - free( member->flags ) ; - } - - // - // delete the members frames - // - - conf_frame* cf ; - - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "deleting member input frames, name => %s\n", - member->channel_name ) ; - - // incoming frames - cf = member->inFrames ; - - while ( cf != NULL ) - { - cf = delete_conf_frame( cf ) ; - } - if (member->inSmoother != NULL) - ast_smoother_free(member->inSmoother); - - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "deleting member output frames, name => %s\n", - member->channel_name ) ; - - // outgoing frames - cf = member->outFrames ; - - while ( cf != NULL ) - { - cf = delete_conf_frame( cf ) ; - } - - if (member->outPacker != NULL) - ast_packer_free(member->outPacker); - - -#if ( SILDET == 2 ) - if ( member->dsp != NULL ) - { - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "destroying member preprocessor, name => %s\n", - member->channel_name ) ; - speex_preprocess_state_destroy( member->dsp ) ; - } -#endif - - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "freeing member translator paths, name => %s\n", - member->channel_name ) ; - - // free the mixing translators - ast_translator_free_path( member->to_slinear ) ; - ast_translator_free_path( member->from_slinear ) ; - - // get a pointer to the next - // member so we can return it - struct ast_conf_member* nm = member->next ; - - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "freeing member channel name, name => %s\n", - member->channel_name ) ; - - // free the member's copy for the channel name - free( member->channel_name ) ; - - // !!! DEBUGING !!! - ast_log( AST_CONF_DEBUG, "freeing member\n" ) ; - - // free the member's memory - free( member ) ; - member = NULL ; - - return nm ; -} - -// -// incoming frame functions -// - -conf_frame* get_incoming_frame( struct ast_conf_member *member ) -{ - // - // sanity checks - // - - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to get frame from null member\n" ) ; - return NULL ; - } - - // - // repeat last frame a couple times to smooth transition - // - -#ifdef AST_CONF_CACHE_LAST_FRAME - if ( member->inFramesCount == 0 ) - { - // nothing to do if there's no cached frame - if ( member->inFramesLast == NULL ) - return NULL ; - - // turn off 'okay to cache' flag - member->okayToCacheLast = 0 ; - - if ( member->inFramesRepeatLast >= AST_CONF_CACHE_LAST_FRAME ) - { - // already used this frame AST_CONF_CACHE_LAST_FRAME times - - // reset repeat count - member->inFramesRepeatLast = 0 ; - - // clear the cached frame - delete_conf_frame( member->inFramesLast ) ; - member->inFramesLast = NULL ; - - // return null - return NULL ; - } - else - { - ast_log( AST_CONF_DEBUG, "repeating cached frame, channel => %s, inFramesRepeatLast => %d\n", - member->channel_name, member->inFramesRepeatLast ) ; - - // increment counter - member->inFramesRepeatLast++ ; - - // return a copy of the cached frame - return copy_conf_frame( member->inFramesLast ) ; - } - } - else if ( member->okayToCacheLast == 0 && member->inFramesCount >= 3 ) - { - ast_log( AST_CONF_DEBUG, "enabling cached frame, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount ) ; - - // turn on 'okay to cache' flag - member->okayToCacheLast = 1 ; - } -#else - if ( member->inFramesCount == 0 ) - return NULL ; -#endif // AST_CONF_CACHE_LAST_FRAME - - // - // return the next frame in the queue - // - - conf_frame* cfr = NULL ; - - // get first frame in line - cfr = member->inFramesTail ; - - // if it's the only frame, reset the queue, - // else, move the second frame to the front - if ( member->inFramesTail == member->inFrames ) - { - member->inFramesTail = NULL ; - member->inFrames = NULL ; - } - else - { - // move the pointer to the next frame - member->inFramesTail = member->inFramesTail->prev ; - - // reset it's 'next' pointer - if ( member->inFramesTail != NULL ) - member->inFramesTail->next = NULL ; - } - - // separate the conf frame from the list - cfr->next = NULL ; - cfr->prev = NULL ; - - // decriment frame count - member->inFramesCount-- ; - -#ifdef AST_CONF_CACHE_LAST_FRAME - // copy frame if queue is now empty - if ( - member->inFramesCount == 0 - && member->okayToCacheLast == 1 - ) - { - // reset repeat count - member->inFramesRepeatLast = 0 ; - - // clear cached frame - if ( member->inFramesLast != NULL ) - { - delete_conf_frame( member->inFramesLast ) ; - member->inFramesLast = NULL ; - } - - // cache new frame - member->inFramesLast = copy_conf_frame( cfr ) ; - } -#endif // AST_CONF_CACHE_LAST_FRAME - - return cfr ; -} - -int queue_incoming_frame( struct ast_conf_member* member, struct ast_frame* fr ) -{ - // - // sanity checks - // - - // check on frame - if ( fr == NULL ) - { - ast_log( LOG_ERROR, "unable to queue null frame\n" ) ; - return -1 ; - } - - // check on member - if ( member == NULL ) - { - ast_log( LOG_ERROR, "unable to queue frame for null member\n" ) ; - return -1 ; - } - - // - // drop a frame if we've filled half the buffer - // ( no more than once per AST_CONF_QUEUE_DROP_TIME_LIMIT ms ) - // - - - /* -ast_log( - AST_CONF_DEBUG, - "queue frame on channel => %s, fr->subclass => %d, fr->datalen => %d, fr->samples => %d\n", - member->channel_name, fr->subclass, fr->datalen, fr->samples -) ; -*/ - - - if ( member->inFramesCount > member->inFramesNeeded ) - { - if ( member->inFramesCount > AST_CONF_QUEUE_DROP_THRESHOLD ) - { - struct timeval curr ; - gettimeofday( &curr, NULL ) ; - - // time since last dropped frame - long diff = usecdiff( &curr, &member->last_in_dropped ) ; - - // number of milliseconds which must pass between frame drops - // ( 15 frames => -100ms, 10 frames => 400ms, 5 frames => 900ms, 0 frames => 1400ms, etc. ) - long time_limit = 1000 - ( ( member->inFramesCount - AST_CONF_QUEUE_DROP_THRESHOLD ) * 100 ) ; - - if ( diff >= time_limit ) - { - // count sequential drops - member->sequential_drops++ ; - - // ast_log( - // AST_CONF_DEBUG, - // "dropping frame from input buffer, channel => %s, incoming => %d, outgoing => %d\n", - // member->channel_name, member->inFramesCount, member->outFramesCount - // ) ; - - // accounting: count dropped incoming frames - member->frames_in_dropped++ ; - - // reset frames since dropped - member->since_dropped = 0 ; - - // delete the frame - delete_conf_frame( get_incoming_frame( member ) ) ; - - gettimeofday( &member->last_in_dropped, NULL ) ; - } - else - { -/* - ast_log( - AST_CONF_DEBUG, - "input buffer larger than drop threshold, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount - ) ; -*/ - } - } - } - - // - // if we have to drop frames, we'll drop new frames - // because it's easier ( and doesn't matter much anyway ). - // - - if ( member->inFramesCount >= AST_CONF_MAX_QUEUE ) - { - // count sequential drops - member->sequential_drops++ ; - - ast_log( - AST_CONF_DEBUG, - "unable to queue incoming frame, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount - ) ; - - // accounting: count dropped incoming frames - member->frames_in_dropped++ ; - - // reset frames since dropped - member->since_dropped = 0 ; - - return -1 ; - } - - // reset sequential drops - member->sequential_drops = 0 ; - - // increment frames since dropped - member->since_dropped++ ; - - // - // create new conf frame from passed data frame - // - - // ( member->inFrames may be null at this point ) - if (member->inSmoother == NULL ){ - conf_frame* cfr = create_conf_frame( member, member->inFrames, fr ) ; - if ( cfr == NULL ) - { - ast_log( LOG_ERROR, "unable to malloc conf_frame\n" ) ; - return -1 ; - } - - // - // add new frame to speaking members incoming frame queue - // ( i.e. save this frame data, so we can distribute it in conference_exec later ) - // - - if ( member->inFrames == NULL ) { - member->inFramesTail = cfr ; - } - member->inFrames = cfr ; - member->inFramesCount++ ; - } else { - //feed frame(fr) into the smoother - - // smoother tmp frame - struct ast_frame *sfr; - int multiple = 1; - int i=0; - - if ( (member->smooth_size_in > 0 ) && (member->smooth_size_in * member->smooth_multiple != fr->datalen) ) - { - //ast_log(AST_CONF_DEBUG,"resetting smooth_size_in. old size=> %d, multiple =>%d, datalen=> %d\n", member->smooth_size_in, member->smooth_multiple, fr->datalen ); - if ( fr->datalen % member->smooth_multiple != 0) { - // if datalen not divisible by smooth_multiple, assume we're just getting normal encoding. - // ast_log(AST_CONF_DEBUG,"smooth_multiple does not divide datalen. changing smooth size from %d to %d, multiple => 1\n", member->smooth_size_in, fr->datalen); - member->smooth_size_in = fr->datalen; - member->smooth_multiple = 1; - } else { - // assume a fixed multiple, so divide into datalen. - int newsmooth = fr->datalen / member->smooth_multiple ; - // ast_log(AST_CONF_DEBUG,"datalen is divisible by smooth_multiple, changing smooth size from %d to %d\n", member->smooth_size_in, newsmooth); - member->smooth_size_in = newsmooth; - } - - //free input smoother. - if (member->inSmoother != NULL) - ast_smoother_free(member->inSmoother); - - //make new input smoother. - member->inSmoother = ast_smoother_new(member->smooth_size_in); - } - - ast_smoother_feed( member->inSmoother, fr ); -//ast_log (AST_CONF_DEBUG, "SMOOTH:Feeding frame into inSmoother, timestamp => %ld.%ld\n", fr->delivery.tv_sec, fr->delivery.tv_usec); - - if ( multiple > 1 ) - fr->samples /= multiple; - - // read smoothed version of frames, add to queue - while( ( sfr = ast_smoother_read( member->inSmoother ) ) ){ - - ++i; -//ast_log( AST_CONF_DEBUG , "\treading new frame [%d] from smoother, inFramesCount[%d], \n\tsfr->frametype -> %d , sfr->subclass -> %d , sfr->datalen => %d sfr->samples => %d\n", i , member->inFramesCount , sfr->frametype, sfr->subclass, sfr->datalen, sfr->samples); -//ast_log (AST_CONF_DEBUG, "SMOOTH:Reading frame from inSmoother, i=>%d, timestamp => %ld.%ld\n",i, sfr->delivery.tv_sec, sfr->delivery.tv_usec); - conf_frame* cfr = create_conf_frame( member, member->inFrames, sfr ) ; - if ( cfr == NULL ) - { - ast_log( LOG_ERROR, "unable to malloc conf_frame\n" ) ; - return -1 ; - } - - // - // add new frame to speaking members incoming frame queue - // ( i.e. save this frame data, so we can distribute it in conference_exec later ) - // - - if ( member->inFrames == NULL ) { - member->inFramesTail = cfr ; - } - member->inFrames = cfr ; - member->inFramesCount++ ; - } - } - - return 0 ; -} - -// -// outgoing frame functions -// - -conf_frame* get_outgoing_frame( struct ast_conf_member *member ) -{ - if ( member == NULL ) - { - ast_log( LOG_WARNING, "unable to get frame from null member\n" ) ; - return NULL ; - } - - conf_frame* cfr ; - - // ast_log( AST_CONF_DEBUG, "getting member frames, count => %d\n", member->outFramesCount ) ; - - if ( member->outFramesCount > AST_CONF_MIN_QUEUE ) - { - cfr = member->outFramesTail ; - - // if it's the only frame, reset the queu, - // else, move the second frame to the front - if ( member->outFramesTail == member->outFrames ) - { - member->outFrames = NULL ; - member->outFramesTail = NULL ; - } - else - { - // move the pointer to the next frame - member->outFramesTail = member->outFramesTail->prev ; - - // reset it's 'next' pointer - if ( member->outFramesTail != NULL ) - member->outFramesTail->next = NULL ; - } - - // separate the conf frame from the list - cfr->next = NULL ; - cfr->prev = NULL ; - - // decriment frame count - member->outFramesCount-- ; - - return cfr ; - } - - return NULL ; -} - -int __queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) -{ - // accounting: count the number of outgoing frames for this member - member->frames_out++ ; - -/* - // - // drop a frame if we've filled half the buffer - // - - if ( member->outFramesCount > AST_CONF_QUEUE_DROP_THRESHOLD ) - { - struct timeval curr ; - gettimeofday( &curr, NULL ) ; - - long diff = usecdiff( &curr, &member->last_out_dropped ) ; - - if ( diff >= AST_CONF_QUEUE_DROP_TIME_LIMIT ) - { - ast_log( - AST_CONF_DEBUG, - "dropping frame from output buffer, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount - ) ; - - // accounting: count dropped outgoing frames - member->frames_out_dropped++ ; - - // delete the frame - delete_conf_frame( get_outgoing_frame( member ) ) ; - - gettimeofday( &member->last_out_dropped, NULL ) ; - } - } -*/ - - // - // we have to drop frames, so we'll drop new frames - // because it's easier ( and doesn't matter much anyway ). - // - if ( member->outFramesCount >= AST_CONF_MAX_QUEUE ) - { - ast_log( - AST_CONF_DEBUG, - "unable to queue outgoing frame, channel => %s, incoming => %d, outgoing => %d\n", - member->channel_name, member->inFramesCount, member->outFramesCount - ) ; - - // accounting: count dropped outgoing frames - member->frames_out_dropped++ ; - - return -1 ; - } - - // - // create new conf frame from passed data frame - // - - conf_frame* cfr = create_conf_frame( member, member->outFrames, fr ) ; - - if ( cfr == NULL ) - { - ast_log( LOG_ERROR, "unable to create new conf frame\n" ) ; - - // accounting: count dropped outgoing frames - member->frames_out_dropped++ ; - - return -1 ; - } - - // set delivery timestamp - cfr->fr->delivery = delivery ; - - // - // add new frame to speaking members incoming frame queue - // ( i.e. save this frame data, so we can distribute it in conference_exec later ) - // - - if ( member->outFrames == NULL ) { - member->outFramesTail = cfr ; - } - member->outFrames = cfr ; - member->outFramesCount++ ; - - // return success - return 0 ; -} - -int queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) -{ - // check on frame - if ( fr == NULL ) - { - ast_log( LOG_ERROR, "unable to queue null frame\n" ) ; - return -1 ; - } - - // check on member - if ( member == NULL ) - { - ast_log( LOG_ERROR, "unable to queue frame for null member\n" ) ; - return -1 ; - } - - - if ( ( member->outPacker == NULL ) && ( member->smooth_multiple > 1 ) && ( member->smooth_size_out > 0 ) ){ - //ast_log (AST_CONF_DEBUG, "creating outPacker with size => %d \n\t( multiple => %d ) * ( size => %d )\n", member->smooth_multiple * member-> smooth_size_out, member->smooth_multiple , member->smooth_size_out); - member->outPacker = ast_packer_new( member->smooth_multiple * member->smooth_size_out); - } - - if (member->outPacker == NULL ){ - return __queue_outgoing_frame( member, fr, delivery ) ; - } - else - { - struct ast_frame *sfr; - int exitval = 0; -//ast_log (AST_CONF_DEBUG, "sending fr into outPacker, datalen=>%d, samples=>%d\n",fr->datalen, fr->samples); - ast_packer_feed( member->outPacker , fr ); - while( (sfr = ast_packer_read( member->outPacker ) ) ) - { -//ast_log (AST_CONF_DEBUG, "read sfr from outPacker, datalen=>%d, samples=>%d\n",sfr->datalen, sfr->samples); - if ( __queue_outgoing_frame( member, sfr, delivery ) == -1 ) { - exitval = -1; - } - } - return exitval; - } -} - -// -// manager functions -// - -void send_state_change_notifications( struct ast_conf_member* member ) -{ - // ast_log( AST_CONF_DEBUG, "sending state change notification\n" ) ; - - // loop through list of members, sending state changes - while ( member != NULL ) - { - // has the state changed since last time through this loop? - if ( member->speaking_state_notify != member->speaking_state_prev ) - { - manager_event( - EVENT_FLAG_CALL, - "ConferenceState", - "Channel: %s\r\n" - "State: %s\r\n", - member->channel_name, - ( ( member->speaking_state_notify == 1 ) ? "speaking" : "silent" ) - ) ; -#if 0 - ast_log( AST_CONF_DEBUG, "member state changed, channel => %s, state => %d, incoming => %d, outgoing => %d\n", - member->channel_name, member->speaking_state_notify, member->inFramesCount, member->outFramesCount ) ; -#endif - - // remember current state - member->speaking_state_prev = member->speaking_state_notify ; - - // we do not reset the speaking_state_notify flag here - } - - // reset notification flag so that - member->speaking_state_notify = 0 ; - - // move the pointer to the next member - member = member->next ; - } - - return ; -} - -// -// meta-info accessors functions -// - -short memberIsPhoneClient( struct ast_conf_member* member ) -{ - if ( member == NULL ) - return 0 ; - - return ( member->connection_type == 'T' ) ? 1 : 0 ; -} - -short memberIsIaxClient( struct ast_conf_member* member ) -{ - if ( member == NULL ) - return 0 ; - - return ( member->connection_type == 'X' ) ? 1 : 0 ; -} - -short memberIsSIPClient( struct ast_conf_member* member ) -{ - if ( member == NULL ) - return 0 ; - - return ( member->connection_type == 'S' ) ? 1 : 0 ; -} - -short memberIsModerator( struct ast_conf_member* member ) -{ - if ( member == NULL ) - return 0 ; - - return ( member->type == 'M' ) ? 1 : 0 ; -} - -short memberIsListener( struct ast_conf_member* member ) -{ - if ( member == NULL ) - return 0 ; - - return ( member->type == 'L' ) ? 1 : 0 ; -} - - -// -// ast_packer, adapted from ast_smoother -// pack multiple frames together into one packet on the wire. -// - -#define PACKER_SIZE 8000 -#define PACKER_QUEUE 10 // store at most 10 complete packets in the queue - -struct ast_packer { - int framesize; // number of frames per packet on the wire. - int size; - int packet_index; - int format; - int readdata; - int optimizablestream; - int flags; - float samplesperbyte; - struct ast_frame f; - struct timeval delivery; - char data[PACKER_SIZE]; - char framedata[PACKER_SIZE + AST_FRIENDLY_OFFSET]; - int samples; - int sample_queue[PACKER_QUEUE]; - int len_queue[PACKER_QUEUE]; - struct ast_frame *opt; - int len; -}; - -void ast_packer_reset(struct ast_packer *s, int framesize) -{ - memset(s, 0, sizeof(struct ast_packer)); - s->framesize = framesize; - s->packet_index=0; - s->len=0; -} - -struct ast_packer *ast_packer_new(int framesize) -{ - struct ast_packer *s; - if (framesize < 1) - return NULL; - s = malloc(sizeof(struct ast_packer)); - if (s) - ast_packer_reset(s, framesize); - return s; -} - -int ast_packer_get_flags(struct ast_packer *s) -{ - return s->flags; -} - -void ast_packer_set_flags(struct ast_packer *s, int flags) -{ - s->flags = flags; -} - -int ast_packer_feed(struct ast_packer *s, const struct ast_frame *f) -{ - if (f->frametype != AST_FRAME_VOICE) { - ast_log(LOG_WARNING, "Huh? Can't pack a non-voice frame!\n"); - return -1; - } - if (!s->format) { - s->format = f->subclass; - s->samples=0; - } else if (s->format != f->subclass) { - ast_log(LOG_WARNING, "Packer was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass); - return -1; - } - if (s->len + f->datalen > PACKER_SIZE) { - ast_log(LOG_WARNING, "Out of packer space\n"); - return -1; - } - if (s->packet_index >= PACKER_QUEUE ){ - ast_log(LOG_WARNING, "Out of packer queue space\n"); - return -1; - } - - memcpy(s->data + s->len, f->data, f->datalen); - /* If either side is empty, reset the delivery time */ - if (!s->len || (!f->delivery.tv_sec && !f->delivery.tv_usec) || - (!s->delivery.tv_sec && !s->delivery.tv_usec)) - s->delivery = f->delivery; - s->len += f->datalen; -//packer stuff - s->len_queue[s->packet_index] += f->datalen; - s->sample_queue[s->packet_index] += f->samples; - s->samples += f->samples; - - if (s->samples > s->framesize ) - ++s->packet_index; - - return 0; -} - -struct ast_frame *ast_packer_read(struct ast_packer *s) -{ - struct ast_frame *opt; - int len; - /* IF we have an optimization frame, send it */ - if (s->opt) { - opt = s->opt; - s->opt = NULL; - return opt; - } - - /* Make sure we have enough data */ - if (s->samples < s->framesize ){ - return NULL; - } - len = s->len_queue[0]; - if (len > s->len) - len = s->len; - /* Make frame */ - s->f.frametype = AST_FRAME_VOICE; - s->f.subclass = s->format; - s->f.data = s->framedata + AST_FRIENDLY_OFFSET; - s->f.offset = AST_FRIENDLY_OFFSET; - s->f.datalen = len; - s->f.samples = s->sample_queue[0]; - s->f.delivery = s->delivery; - /* Fill Data */ - memcpy(s->f.data, s->data, len); - s->len -= len; - /* Move remaining data to the front if applicable */ - if (s->len) { - /* In principle this should all be fine because if we are sending - G.729 VAD, the next timestamp will take over anyawy */ - memmove(s->data, s->data + len, s->len); - if (s->delivery.tv_sec || s->delivery.tv_usec) { - /* If we have delivery time, increment it, otherwise, leave it at 0 */ - s->delivery.tv_sec += s->sample_queue[0] / 8000.0; - s->delivery.tv_usec += (((int)(s->sample_queue[0])) % 8000) * 125; - if (s->delivery.tv_usec > 1000000) { - s->delivery.tv_usec -= 1000000; - s->delivery.tv_sec += 1; - } - } - } - int j; - s->samples -= s->sample_queue[0]; - if( s->packet_index > 0 ){ - for (j=0; jpacket_index -1 ; j++){ - s->len_queue[j]=s->len_queue[j+1]; - s->sample_queue[j]=s->sample_queue[j+1]; - } - s->len_queue[s->packet_index]=0; - s->sample_queue[s->packet_index]=0; - s->packet_index--; - } else { - s->len_queue[0]=0; - s->sample_queue[0]=0; - } - - - /* Return frame */ - return &s->f; -} - -void ast_packer_free(struct ast_packer *s) -{ - free(s); -} diff --git a/extras/app_conference/member.h b/extras/app_conference/member.h deleted file mode 100644 index 3a1fa4bf..00000000 --- a/extras/app_conference/member.h +++ /dev/null @@ -1,212 +0,0 @@ - -// $Id: member.h,v 1.7 2005/11/02 22:42:42 stevek Exp $ - -/* - * app_conference - * - * A channel independent conference application for Asterisk - * - * Copyright (C) 2002, 2003 Junghanns.NET GmbH - * Copyright (C) 2003-2005 HorizonLive.com, Inc. - * - * Klaus-Peter Junghanns - * Steve Kann - * - * This program may be modified and distributed under the - * terms of the GNU Public License. - * - */ - -#ifndef _APP_CONF_MEMBER_H -#define _APP_CONF_MEMBER_H - -// -// includes -// - -#include "app_conference.h" -#include "common.h" -#include "asterisk/app.h" - - -// -// struct declarations -// - -struct ast_conf_soundq -{ - char name[256]; - struct ast_filestream *stream; // the stream - int muted; // should incoming audio be muted while we play? - struct ast_conf_soundq *next; -}; - -struct ast_conf_member -{ - ast_mutex_t lock ; // member data mutex - - struct ast_channel* chan ; // member's channel - char* channel_name ; // member's channel name - - // values passed to create_member () via *data - int priority ; // highest priority gets the channel - char* flags ; // raw member-type flags - char type ; // L = ListenOnly, M = Moderator, S = Standard (Listen/Talk) - char* id ; // member id - - // determine by flags and channel name - char connection_type ; // T = telephone, X = iaxclient, S = sip - - // vad voice probability thresholds - float vad_prob_start ; - float vad_prob_continue ; - - // ready flag - short ready_for_outgoing ; - - // input frame queue - conf_frame* inFrames ; - conf_frame* inFramesTail ; - unsigned int inFramesCount ; - - // input/output smoother - struct ast_smoother *inSmoother; - struct ast_packer *outPacker; - int smooth_size_in; - int smooth_size_out; - int smooth_multiple; - - // frames needed by conference_exec - unsigned int inFramesNeeded ; - - // used when caching last frame - conf_frame* inFramesLast ; - unsigned int inFramesRepeatLast ; - unsigned short okayToCacheLast ; - - // output frame queue - conf_frame* outFrames ; - conf_frame* outFramesTail ; - unsigned int outFramesCount ; - - // time we last dropped a frame - struct timeval last_in_dropped ; - struct timeval last_out_dropped ; - - // ( not currently used ) - // int samplesperframe ; - - // used for determining need to mix frames - // and for management interface notification - short speaking_state_prev ; - short speaking_state_notify ; - short speaking_state ; - - // pointer to next member in single-linked list - struct ast_conf_member* next ; - - // accounting values - unsigned long frames_in ; - unsigned long frames_in_dropped ; - unsigned long frames_out ; - unsigned long frames_out_dropped ; - - // for counting sequentially dropped frames - unsigned int sequential_drops ; - unsigned long since_dropped ; - - // start time - struct timeval time_entered ; - struct timeval lastsent_timeval ; - - // flag indicating we should remove this member - short remove_flag ; - -#if ( SILDET == 2 ) - // pointer to speex preprocessor dsp - SpeexPreprocessState *dsp ; - // number of frames to ignore speex_preprocess() - int ignore_speex_count; -#else - // placeholder when preprocessing is not enabled - void* dsp ; -#endif - - // audio format this member is using - int write_format ; - int read_format ; - - int write_format_index ; - int read_format_index ; - - // member frame translators - struct ast_trans_pvt* to_slinear ; - struct ast_trans_pvt* from_slinear ; - - // For playing sounds - struct ast_conf_soundq *soundq; - -#ifdef DEBUG_OUTPUT_PCM - FILE *incoming_fh; -#endif - - int send_dtmf:1; - int quiet_entry_exit:1; - int inband_dtmf:1; - int rfc_dtmf:1; -} ; - -struct conf_member -{ - struct ast_conf_member* realmember ; - struct conf_member* next ; -} ; - -// -// function declarations -// - -int member_exec( struct ast_channel* chan, void* data ) ; - -int basic_play_sound ( char *channel, char *file ) ; - -struct ast_conf_member* create_member( struct ast_channel* chan, const char* data ) ; -struct ast_conf_member* delete_member( struct ast_conf_member* member ) ; - -// incoming queue -int queue_incoming_frame( struct ast_conf_member* member, struct ast_frame* fr ) ; -conf_frame* get_incoming_frame( struct ast_conf_member* member ) ; - -// outgoing queue -int queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ; -int __queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ; -conf_frame* get_outgoing_frame( struct ast_conf_member* member ) ; - -void send_state_change_notifications( struct ast_conf_member* member ) ; - -// -// meta-info accessors functions -// - -short memberIsPhoneClient( struct ast_conf_member* member ) ; -short memberIsIaxClient( struct ast_conf_member* member ) ; -short memberIsSIPClient( struct ast_conf_member* member ) ; - -short memberIsModerator( struct ast_conf_member* member ) ; -short memberIsListener( struct ast_conf_member* member ) ; - -// -// packer functions -// - -struct ast_packer; - -extern struct ast_packer *ast_packer_new(int bytes); -extern void ast_packer_set_flags(struct ast_packer *packer, int flags); -extern int ast_packer_get_flags(struct ast_packer *packer); -extern void ast_packer_free(struct ast_packer *s); -extern void ast_packer_reset(struct ast_packer *s, int bytes); -extern int ast_packer_feed(struct ast_packer *s, const struct ast_frame *f); -extern struct ast_frame *ast_packer_read(struct ast_packer *s); - -#endif diff --git a/extras/app_conference/star.gsm b/extras/app_conference/star.gsm deleted file mode 100644 index 5ec8908e..00000000 --- a/extras/app_conference/star.gsm +++ /dev/null @@ -1,2 +0,0 @@ -:nPSat֪j*PR6۞D IDCtbXFER|>ПЕРЕВОД| +PARK|ПАРКОВКА| +IN-NUMBER|В-НОМЕР| +NUMBER|НОМЕР| +LENGTH|ДЛИНА| +CALLERID|ВЫЗЫВАЮЩИЙID| +CallerID|ВызывающийID| + CALL| ВЫЗОВ| +PICKUP|PICKUP| +CONFERENCE|КОНФЕРЕНЦИЯ| +Refresh|Обновление| +Send DTMF|Послать DTMF| +ORDER|ПОРЯДОК| + on | на | +LOGOUT|ВЫХОД| +Channel|Канал| +Extensions|Расширения| +Conferences|Конференции| +Conference|Конференция| +Recording|Recording| +Record|Record| +Welcome|Добро пожаловать| +VOICEMAIL|VOICEMAIL| + NEW| НОВЫЙ| + OLD| СТАРЫЙ| +PAUSE|ПАУЗПА| +START|СТАРТ| +Pause|Пауза| +Resume|Резюме| +Faster|Быстрее| +Slower|Медленее| +Initializing|Инициализация| +Invalid|Недопустимо| +Username|Username| +CUSTOM|ПОЛЬЗОВАТЕЛЬСКИЙ| +Notes|Примечания| +First|Имя| +MI: |MI: | +Last|Фамилия| +Address|Адрес| +City|Город| +State|Округ| +PostCode|Индекс| +Province|Область/Край| +Vendor ID|ID Вендора| +DialCode|Код| +Alt. Phone|Альт. Телефон| +Show|Показать| +Email|Email| +Comments|Комментарии| +REFRESH|ОБНОВИТЬ| +ALT PHONE DIAL|НАБРАТЬ АЛЬТ. НОМЕР| +MAIN PHONE|ОСНОВНОЙ ТЕЛЕФОН| +ALT PHONE|АЛЬТ. ТЕЛЕФОН| +ADDRESS3|АДРЕСС 3| +FINISH LEAD|ФИНИШ LEAD| +Dial Alt Phone Number|Набор Альт.Номера| +Phone|Телефон| +DIAL|НАБОР НОМЕРА| +SUBMIT FAVORITES CHANGES - requires logout|ПОДТВЕРДИТЕ ИЗМЕНЕНИЕ ИЗБРАННОГО - требование для выхода из системы| +BACK TO MAIN WINDOW - ignore changes made|ВЕРНУТЬСЯ К ГЛАВНОМУ ОКНУ - игнорирует сделанные изменения| +AVAILABLE EXTENSIONS|ДОСТУПНЫЕ РАСШИРЕНИЯ| + edit|редактировать| + FAVORITES|ИЗБРАННОЕ| +### END translation phrases through 1.1.11 release ### +Search Existing Leads|Поиск Существующих Leads| +This option if checked will attempt to find the phone number in the system before inserting it as a new lead|Если эта опция выбрана, то будет предпринята попытка найти телефонный номер в системе, прежде чем вставить его как новый lead| +Finish Wrapup and Move On|Финиш Wrapup и Переход| +seconds remaining in wrapup|секунд осталось в wrapup| +Call Wrapup:|Call Wrapup:| +### months of the year for CallBack date select screen ### +January|Январь| +Frebruary|Февраль| +March|Март| +April|Апрель| +May|Май| +June|Июнь| +July|Июль| +August|Август| +September|Сентябрь| +October|Октябрь| +November|Ноябрь| +December|Декабрь| +### BEGIN translation phrases for 2.0.1 release ### +Previous Callback Information|Предыдущая Информация о Callback| +Last Call: |Последний Вызов:| +CallBack: |CallBack:| +Agent: |Оператор:| +Comments: |Комментарии:| +### BEGIN translation phrases for 2.0.2 release ### +VOLUME|ГРОМКОСТЬ| +### BEGIN translation phrases for 2.0.3 release ### +FAST DIAL|БЫСТРЫЙ НАБОР НОМЕРА| +YOU MUST ENTER A PHONE NUMBER AND DIAL CODE TO USE FAST DIAL|ЧТОБЫ ИСПОЛЬЗОВАТЬ БЫСТРЫЙ НАБОР НОМЕРА, ВЫ ДОЛЖНЫ ВВЕСТИ НОМЕР ТЕЛЕФОНА И КОД СТРАНЫ| + SELECT A PAUSE CODE :| ВЫБЕРИТЕ КОД ПАУЗЫ :| +ENTER A PAUSE CODE|ВВЕДИТЕ КОД ПАУЗЫ| +YOU MUST BE PAUSED TO ENTER A PAUSE CODE IN AUTO-DIAL MODE|ВЫ ДОЛЖНЫ АКТИВИРОВАТЬ ПАУЗУ, ЧТОБЫ ВВЕСТИ КОД ПАУЗЫ В РЕЖИМЕ АВТО-НАБОРА| +Your session has been disabled|Ваша сессия отключена| +### BEGIN translation phrases for 2.0.5 release ### +Gender: |Пол:| +Date of Birth: |Дата рождения:| +YOU MUST BE PAUSED TO CHANGE GROUPS|ТЫ ДОЛЖЕН БЫТЬ PAUSED сменить группу| +Calls in Queue:|Звонки в очереди:| + Timeclock|Timeclock| +The user and password you entered are not active in the system|Пользователя и пароль, которые вы вступили, не действующих в системе| +Please try again|Пожалуйста, повторите попытку| +You cannot log in or out within 30 seconds of your last login or logout|Вы не можете войти или в течение 30 секунд после вашего последнего входа в систему или Logout| +You have now logged-out|Вы уже зарегистрированы отказа| +You logged out at |Вы вошли на| +Amount of time you were logged-in: |Количество раз, когда вы были зарегистрированы в:| +ERROR: timeclock log entry already made: |ОШИБКА: timeclock вход вход уже сделал:| +BACK to Agent Login Screen|BACK TO Агент Логин экрана| +BACK to Administration|BACK TO администрации| +BACK to Welcome Screen|BACK приветствовать экрана| +Time since you were last logged-in: |Время с момента вашего последнего входа в:| +You last logged-out at: |Вы последнего зарегистрированного по адресу:| +Click LOGIN below to log-in|Нажмите кнопку Вход для входа в| +Amount of time you have been logged-in: |Количество раз, когда вы вышли в:| +You logged-in at:|Вы вошли в по адресу:| +Click LOGOUT below to log-out|Нажмите LOGOUT для входа из| +Undefined|Undefined| +This phone number is not in the campaign lists|Этот телефон не находится в списках кампании| +Unspecified error|Неизвестная ошибка| +Extended Alt Phone Information: |Расширенная информация Alt Телефон:| +ALT DIAL NUMBER:|ALT номер:| +Phone Code and Number:|Телефон кодекса и номер:| +Notes: |Примечания:| +Active: |Активно:| +Alt Count: |Alt Кол-во:| +Change this phone number to INACTIVE|Изменить этот телефонный номер НЕАКТИВНОЕ| +Change this phone number to ACTIVE|Изменить этот телефонный номер АКТИВНЫМ| +YOU MUST LOG IN TO THE TIMECLOCK FIRST|Вы должны войти в систему TIMECLOCK ПЕРВЫЙ| +There is a time synchronization problem with your system, please tell your system administrator|Существует проблема синхронизации времени с вашей системой, пожалуйста, сообщите об этом вашему системному администратору| +Preview Call|Предварительный Звоните| +SELECT A GROUP ALIAS|ВЫБОР ГРУППЫ ALIAS| +Group Alias Selection|Группа Alias выбора| +Click Here to Choose a Group Alias|Нажмите здесь, чтобы Выбери группу Alias| +Group Alias|Группа Alias| +ERROR: There are no Shifts enabled for your user group|ОШИБКА: Есть сдвиги не включена для пользователя группы| +ERROR: You are not allowed to log in outside of your shift|ОШИБКА: Вы не можете войти в вашу за переход| +MANAGER OVERRIDE|МЕНЕДЖЕР Переопределить| +Your Shift is over or has changed, you have been logged out of your session|Ваш Shift больше или изменилась, Вы вышли из Вашей сессии| diff --git a/www/agc/images/ru.gif b/www/agc/images/ru.gif new file mode 100644 index 00000000..c51ebece Binary files /dev/null and b/www/agc/images/ru.gif differ diff --git a/www/vicidial/welcome_demo.php b/www/vicidial/welcome_demo.php index 49c0e470..65997b08 100644 --- a/www/vicidial/welcome_demo.php +++ b/www/vicidial/welcome_demo.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n"; diff --git a/www/vicidial/welcome_languages.php b/www/vicidial/welcome_languages.php index a89bbfcb..1218c652 100644 --- a/www/vicidial/welcome_languages.php +++ b/www/vicidial/welcome_languages.php @@ -2,7 +2,7 @@ # welcome_demo.php - VICIDIAL welcome Demo page # # -# Copyright (C) 2008 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: GPLv2 # header ("Content-type: text/html; charset=utf-8"); @@ -47,6 +47,9 @@ echo "   \n"; echo ""; echo "   Slovak Agent Login"; +echo "\n"; +echo ""; +echo "   Russian Agent Login"; echo "\n"; echo "\n";