Added ConfBridge code and applied ConfBridge patches by default

git-svn-id: svn://192.168.202.10@3826 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-04-21 03:03:49 +00:00
parent a2e331d23c
commit 3542e9176d
13 changed files with 1206 additions and 109 deletions
+25 -1
View File
@@ -260,6 +260,7 @@
# 240219-1527 - Added daily_limit in-group user parameter # 240219-1527 - Added daily_limit in-group user parameter
# 240223-0847 - Added INBOUND_DID populate option # 240223-0847 - Added INBOUND_DID populate option
# 240227-1154 - Added holiday_method option # 240227-1154 - Added holiday_method option
# 240420-2242 - Added ConfBridge code
# #
$script = 'agi-VDAD_ALL_inbound.agi'; $script = 'agi-VDAD_ALL_inbound.agi';
@@ -405,6 +406,7 @@ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='02001'; $MEL_aff_rows=$sthArows; &mysql_error_logging; $dbhP=$dbhA; $mysql_count='02001'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$rec_count=0; $rec_count=0;
$conf_engine='';
while ($sthArows > $rec_count) while ($sthArows > $rec_count)
{ {
$AGILOG = '0'; $AGILOG = '0';
@@ -3887,6 +3889,21 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
$dbhP=$dbhA; $mysql_count='02067'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; $dbhP=$dbhA; $mysql_count='02067'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|update of vcl table: $insert_lead_id\n|$stmtA|"; &agi_output;} if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|update of vcl table: $insert_lead_id\n|$stmtA|"; &agi_output;}
### Grab Server values from the database for the server the agent is on
$stmtA = "SELECT conf_engine FROM servers where server_ip = '$VARserver_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
$conf_engine='';
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_engine = $aryA[0];
$rec_count++;
}
$sthA->finish();
### format the remote server dialstring to get the call to the overflow agent meetme room ### format the remote server dialstring to get the call to the overflow agent meetme room
if( $VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ ) if( $VDADserver_ip =~ m/(\S+)\.(\S+)\.(\S+)\.(\S+)/ )
{ {
@@ -3898,7 +3915,14 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override
$RAredDIALstr = "$a$S$b$S$c$S$d$S"; $RAredDIALstr = "$a$S$b$S$c$S$d$S";
} }
$alertVDADremDIALstr = "$VDADremDIALstr"; $alertVDADremDIALstr = "$VDADremDIALstr";
$alertVDADremDIALstr .= "$dtmf_silent_prefix$VDADconf_exten"; if ($conf_engine == "CONFBRIDGE")
{
$alertVDADremDIALstr .= "8$VDADconf_exten";
}
else
{
$alertVDADremDIALstr .= "$dtmf_silent_prefix$VDADconf_exten";
}
$VDADremDIALstr .= "$VDADconf_exten"; $VDADremDIALstr .= "$VDADconf_exten";
+12 -8
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
# agi-VDAD_RINGALL.agi version 2.8 # agi-VDAD_RINGALL.agi version 2.14
# #
# NOTE: this script is used for on-hook agents to be connected to customer calls # NOTE: this script is used for on-hook agents to be connected to customer calls
# when they answer their ringing phones # when they answer their ringing phones
@@ -12,7 +12,7 @@
# exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN}) # exten => _8331*.,n,AGI(agi-VDAD_RINGALL.agi,${EXTEN})
# exten => _8331*.,n,Hangup # exten => _8331*.,n,Hangup
# #
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# changes: # changes:
# 110303-2325 - First build # 110303-2325 - First build
@@ -22,6 +22,7 @@
# 130108-1808 - Changes for Asterisk 1.8 compatibility # 130108-1808 - Changes for Asterisk 1.8 compatibility
# 140312-2112 - Added CALLID as recording filename variable # 140312-2112 - Added CALLID as recording filename variable
# 140421-1448 - Added code to halt ringing of other channels in ring_all NAC method # 140421-1448 - Added code to halt ringing of other channels in ring_all NAC method
# 240420-2241 - Added ConfBridge code
# #
$script = 'agi-VDAD_RINGALL.agi'; $script = 'agi-VDAD_RINGALL.agi';
@@ -90,7 +91,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
or die "Couldn't connect to database: " . DBI->errstr; or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database ### Grab Server values from the database
$stmtA = "SELECT agi_output,ext_context,asterisk_version FROM servers where server_ip = '$VARserver_ip';"; $stmtA = "SELECT agi_output,ext_context,asterisk_version,conf_engine FROM servers where server_ip = '$VARserver_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
@@ -101,6 +102,7 @@ if ($sthArows > 0)
$DBagi_output = $aryA[0]; $DBagi_output = $aryA[0];
$ext_context = $aryA[1]; $ext_context = $aryA[1];
$asterisk_version = $aryA[2]; $asterisk_version = $aryA[2];
$conf_engine = $aryA[3];
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';} if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';} if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';} if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';}
@@ -273,7 +275,9 @@ if ($NAGcount > 0)
if ($VLAextension =~ /^R\//) if ($VLAextension =~ /^R\//)
{ {
### BEGIN If remote agent, then reserve a vicidial_conferences session on their server to send the calls to ### ### BEGIN If remote agent, then reserve a vicidial_conferences session on their server to send the calls to ###
$stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten';"; $conf_table = "vicidial_conferences";
if ($conf_engine == "CONFBRIDGE") {$conf_table = "vicidial_confbridges";}
$stmtA="SELECT count(*) FROM $conf_table where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$AVCcount=$sthA->rows; $AVCcount=$sthA->rows;
@@ -284,11 +288,11 @@ if ($NAGcount > 0)
$sthA->finish(); $sthA->finish();
if ($available_sessions > 0) if ($available_sessions > 0)
{ {
$stmtA="UPDATE vicidial_conferences set extension='3WAY_$dial_user', leave_3way='1', leave_3way_datetime='$now_date' where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten' limit 1;"; $stmtA="UPDATE $conf_table set extension='3WAY_$dial_user', leave_3way='1', leave_3way_datetime='$now_date' where server_ip='$VLAserver_ip' and ((extension='') or (extension is null)) and conf_exten != '$VLAconf_exten' limit 1;";
$AVCaffected_rows = $dbhA->do($stmtA); $AVCaffected_rows = $dbhA->do($stmtA);
if ($AVCaffected_rows > 0) if ($AVCaffected_rows > 0)
{ {
$stmtA="SELECT conf_exten from vicidial_conferences where server_ip='$VLAserver_ip' and extension='3WAY_$dial_user' and leave_3way_datetime='$now_date' and conf_exten != '$VLAconf_exten';"; $stmtA="SELECT conf_exten from $conf_table where server_ip='$VLAserver_ip' and extension='3WAY_$dial_user' and leave_3way_datetime='$now_date' and conf_exten != '$VLAconf_exten';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$SVCcount=$sthA->rows; $SVCcount=$sthA->rows;
@@ -560,8 +564,8 @@ if ($NAGcount > 0)
$d = leading_zero($4); $d = leading_zero($4);
$VLA_DIALstr = "$a$S$b$S$c$S$d$S"; $VLA_DIALstr = "$a$S$b$S$c$S$d$S";
} }
$VLA_DIALstr .= "7$VLAconf_exten"; if ($conf_engine == "CONFBRIDGE") {$VLA_DIALstrPrefix = "1";} else {$VLA_DIALstrPrefix = "7";}
$VLA_DIALstr .= "$VLA_DIALstrPrefix$VLAconf_exten";
$AGI->stream_file('sip-silence'); $AGI->stream_file('sip-silence');
$AGI->stream_file('sip-silence'); $AGI->stream_file('sip-silence');
$AGI->stream_file('sip-silence'); $AGI->stream_file('sip-silence');
+140 -48
View File
@@ -171,9 +171,10 @@
# 231136-2158 - Added hopper_hold_inserts HCI lead reservations clearing for old reservations # 231136-2158 - Added hopper_hold_inserts HCI lead reservations clearing for old reservations
# 231129-0849 - Added reset of vicidial_phone_number_call_daily_counts table # 231129-0849 - Added reset of vicidial_phone_number_call_daily_counts table
# 240401-1810 - Added purging of vicidial_pending_ar records older than 7 days # 240401-1810 - Added purging of vicidial_pending_ar records older than 7 days
# 240420-2209 - Added Conference Updater option
# #
$build = '240401-1810'; $build = '240420-2209';
$DB=0; # Debug flag $DB=0; # Debug flag
$teodDB=0; # flag to log Timeclock End of Day processes to log file $teodDB=0; # flag to log Timeclock End of Day processes to log file
@@ -476,6 +477,7 @@ foreach(@conf)
# 9 - Timeclock auto logout\n"; # 9 - Timeclock auto logout\n";
# E - Email parser script # E - Email parser script
# S - SIP Logger # S - SIP Logger
# C - Conference Updater
# - Other setting are set by configuring them in the database # - Other setting are set by configuring them in the database
# Customized Variables # Customized Variables
@@ -528,7 +530,7 @@ $sthA->finish();
if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";} if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";}
##### Get the settings for this server's server_ip ##### ##### Get the settings for this server's server_ip #####
$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry,auto_restart_asterisk,asterisk_temp_no_restart,gather_asterisk_output,conf_qualify FROM servers where server_ip='$server_ip';"; $stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry,auto_restart_asterisk,asterisk_temp_no_restart,gather_asterisk_output,conf_qualify,conf_engine FROM servers where server_ip='$server_ip';";
# print "$stmtA\n"; # print "$stmtA\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -547,12 +549,17 @@ if ($sthArows > 0)
$asterisk_temp_no_restart = $aryA[8]; $asterisk_temp_no_restart = $aryA[8];
$gather_asterisk_output = $aryA[9]; $gather_asterisk_output = $aryA[9];
$conf_qualify = $aryA[10]; $conf_qualify = $aryA[10];
$conf_engine = $aryA[11];
} }
$sthA->finish(); $sthA->finish();
%ast_ver_str = parse_asterisk_version($asterisk_version); %ast_ver_str = parse_asterisk_version($asterisk_version);
if ($DBX) {print "Asterisk version: $ast_ver_str{major} $ast_ver_str{minor}\n";} if ($DBX) {print "Asterisk version: $ast_ver_str{major} $ast_ver_str{minor}\n";}
$vicidial_conf_table = 'vicidial_conferences';
if ( $conf_engine eq "CONFBRIDGE" ) { $vicidial_conf_table = 'vicidial_confbridges'; }
if ($DBX) {print "Server is using $conf_engine for conferences. Conference table is $vicidial_conf_table\n";}
if ($VARactive_keepalives =~ /X/) if ($VARactive_keepalives =~ /X/)
{ {
if ($DB) {print "X in active_keepalives, skipping this section...\n";} if ($DB) {print "X in active_keepalives, skipping this section...\n";}
@@ -584,6 +591,7 @@ else
$runningemail_inbound=0; $runningemail_inbound=0;
$runningASTERISK=0; $runningASTERISK=0;
$runningsip_logger=0; $runningsip_logger=0;
$runningconf_updater=0;
$AST_conf_3way=0; $AST_conf_3way=0;
$AST_rec_monitor=0; $AST_rec_monitor=0;
@@ -642,6 +650,11 @@ else
$sip_logger=1; $sip_logger=1;
if ($DB) {print "Check to see if sip logger should run\n";} if ($DB) {print "Check to see if sip logger should run\n";}
} }
if ($VARactive_keepalives =~ /C/)
{
$conf_updater=1;
if ($DB) {print "Check to see if conference updater should run\n";}
}
if ($cu3way > 0) if ($cu3way > 0)
{ {
$AST_conf_3way=1; $AST_conf_3way=1;
@@ -705,6 +718,11 @@ else
$runningsip_logger++; $runningsip_logger++;
if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";} if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
} }
if ($psline[1] =~ /$REGhome\/AST_conf_update_screen\.pl/)
{
$runningconf_updater++;
if ($DB) {print "Conference Updater RUNNING: |$spline[1]\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/)
{ {
$runningAST_VDauto_dial++; $runningAST_VDauto_dial++;
@@ -824,7 +842,8 @@ else
( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) || ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) ||
( ($AST_rec_monitor > 0) && ($runningAST_monitor < 1) ) || ( ($AST_rec_monitor > 0) && ($runningAST_monitor < 1) ) ||
( ($email_inbound > 0) && ($runningemail_inbound < 1) ) || ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) ||
( ($sip_logger > 0) && ($runningsip_logger < 1) ) ( ($sip_logger > 0) && ($runningsip_logger < 1) ) ||
( ($conf_updater > 0) && ($runningconf_updater < 1) )
) )
{ {
@@ -872,6 +891,11 @@ else
$runningsip_logger++; $runningsip_logger++;
if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";} if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
} }
if ($psline[1] =~ /$REGhome\/AST_conf_update_screen\.pl/)
{
$runningconf_updater++;
if ($DB) {print "Conference Updater RUNNING: |$spline[1]\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/)
{ {
$runningAST_VDauto_dial++; $runningAST_VDauto_dial++;
@@ -991,6 +1015,18 @@ else
} }
} }
if ( ($conf_updater > 0) && ($runningconf_updater < 1) )
{
if ($DB) {print "starting Conference Updater...\n";}
# add a '-L' to the command below to activate logging
`/usr/bin/screen -d -m -S ASTConfUpdater $PATHhome/AST_conf_update_screen.pl $debug_string`;
if ($megaDB)
{
`/usr/bin/screen -S ASTConfUpdater -X logfile $PATHlogs/ASTconf-updater-screenlog.0`;
`/usr/bin/screen -S ASTConfUpdater -X log`;
}
}
if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) )
{ {
if ($DB) {print "starting AST_VDremote_agents...\n";} if ($DB) {print "starting AST_VDremote_agents...\n";}
@@ -1133,9 +1169,9 @@ if ($timeclock_end_of_day_NOW > 0)
} }
$sthA->finish(); $sthA->finish();
if ($DB) {print "Starting clear out non-used vicidial_conferences sessions process...\n";} if ($DB) {print "Starting clear out non-used $vicidial_conf_table sessions process...\n";}
$stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='0';"; $stmtA = "SELECT conf_exten,extension from $vicidial_conf_table where server_ip='$server_ip' and leave_3way='0';";
if ($DB) {print "|$stmtA|\n";} if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -1168,14 +1204,14 @@ if ($timeclock_end_of_day_NOW > 0)
if ($live_session < 1) if ($live_session < 1)
{ {
$stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';"; $stmtA = "UPDATE $vicidial_conf_table set extension='' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
if($DBX){print STDERR "\n|$stmtA|\n";} if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n"; $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$conf_cleared = ($conf_cleared + $affected_rows); $conf_cleared = ($conf_cleared + $affected_rows);
} }
$k++; $k++;
} }
if ($teodDB) {$event_string = "Empty vicidial_conferences entries cleared: $conf_cleared"; &teod_logger;} if ($teodDB) {$event_string = "Empty $vicidial_conf_table entries cleared: $conf_cleared"; &teod_logger;}
### Only run the following on one server in the cluster, the one set as the active voicemail server ### ### Only run the following on one server in the cluster, the one set as the active voicemail server ###
@@ -3026,9 +3062,16 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$Lext .= "; Agent session audio playback meetme entry\n"; $Lext .= "; Agent session audio playback meetme entry\n";
$Lext .= "exten => _473782178600XXX,1,Meetme(\${EXTEN:8},q)\n"; $Lext .= "exten => _473782178600XXX,1,Meetme(\${EXTEN:8},q)\n";
$Lext .= "exten => _473782178600XXX,n,Hangup()\n"; $Lext .= "exten => _473782178600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback ConfBridge entry\n";
$Lext .= "exten => _473782179600XXX,1,Answer()\n";
$Lext .= "exten => _473782179600XXX,n,Playback(sip-silence)\n";
$Lext .= "exten => _473782179600XXX,n,ConfBridge(\${EXTEN:8},vici_agent_bridge,vici_audio_user)\n";
$Lext .= "exten => _473782179600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback loop\n"; $Lext .= "; Agent session audio playback loop\n";
$Lext .= "exten => _473782168600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n"; $Lext .= "exten => _473782168600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
$Lext .= "exten => _473782168600XXX,n,Hangup()\n"; $Lext .= "exten => _473782168600XXX,n,Hangup()\n";
$Lext .= "exten => _473782169600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
$Lext .= "exten => _473782169600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback extension\n"; $Lext .= "; Agent session audio playback extension\n";
$Lext .= "exten => 473782158521111,1,Answer\n"; $Lext .= "exten => 473782158521111,1,Answer\n";
$Lext .= "exten => 473782158521111,n,ControlPlayback(\${CALLERID(name)},99999,0,1,2,3,4)\n"; $Lext .= "exten => 473782158521111,n,ControlPlayback(\${CALLERID(name)},99999,0,1,2,3,4)\n";
@@ -3049,6 +3092,14 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$Lext .= "exten => _473782188600XXX,n,GotoIf(\$[ \"\${agent_zap_channel}\" = \"101\" ]?fin)\n"; $Lext .= "exten => _473782188600XXX,n,GotoIf(\$[ \"\${agent_zap_channel}\" = \"101\" ]?fin)\n";
$Lext .= "exten => _473782188600XXX,n,ChanSpy(\${agent_zap_channel},qw)\n"; $Lext .= "exten => _473782188600XXX,n,ChanSpy(\${agent_zap_channel},qw)\n";
$Lext .= "exten => _473782188600XXX,n(fin),Hangup()\n"; $Lext .= "exten => _473782188600XXX,n(fin),Hangup()\n";
$Lext .= "; Whisper to agent ConfBridge entry\n";
$Lext .= "exten => _473782189600XXX,1,Answer\n";
$Lext .= "exten => _473782189600XXX,n,Wait(1)\n";
$Lext .= "exten => _473782189600XXX,n,AGI(getAGENTchannel.agi)\n";
$Lext .= "exten => _473782189600XXX,n,NoOp(\${agent_zap_channel})\n";
$Lext .= "exten => _473782189600XXX,n,GotoIf(\$[ \"\${agent_zap_channel}\" = \"101\" ]?fin)\n";
$Lext .= "exten => _473782189600XXX,n,ChanSpy(\${agent_zap_channel},qw)\n";
$Lext .= "exten => _473782189600XXX,n(fin),Hangup()\n";
} }
$Lext .= "\n"; $Lext .= "\n";
@@ -4094,7 +4145,7 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
##### BEGIN Generate custom meetme entries if set ##### ##### BEGIN Generate custom meetme entries if set #####
$meetme_custom_ext=''; $meetme_custom_ext='';
if ( (length($meetme_enter_login_filename) > 0) || (length($meetme_enter_leave3way_filename) > 0) ) if ( ($conf_engine eq "MEETME") && ( (length($meetme_enter_login_filename) > 0) || (length($meetme_enter_leave3way_filename) > 0) ) )
{ {
if (length($meetme_enter_login_filename) < 1) {$meetme_enter_login_filename='sip-silence';} if (length($meetme_enter_login_filename) < 1) {$meetme_enter_login_filename='sip-silence';}
if (length($meetme_enter_leave3way_filename) < 1) {$meetme_enter_leave3way_filename='sip-silence';} if (length($meetme_enter_leave3way_filename) < 1) {$meetme_enter_leave3way_filename='sip-silence';}
@@ -4118,6 +4169,42 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
} }
##### END Generate custom meetme entries if set ##### ##### END Generate custom meetme entries if set #####
##### BEGIN Generate custom ConfBridge entries if set #####
$confbridge_custom_ext='';
if ( ($conf_engine eq "CONFBRIDGE") && ( (length($meetme_enter_login_filename) > 0) || (length($meetme_enter_leave3way_filename) > 0) ) )
{
if (length($meetme_enter_login_filename) < 1) {$meetme_enter_login_filename='sip-silence';}
if (length($meetme_enter_leave3way_filename) < 1) {$meetme_enter_leave3way_filename='sip-silence';}
$confbridge_custom_ext .= '[confbridge-enter-login]';
$confbridge_custom_ext .= "\n; confbridge entry for Vicidial agent logging in, Asterisk 16+ compatible only\n";
$confbridge_custom_ext .= "exten => _29600XXX,1,Answer()\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Playback(sip-silence)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(bridge,template)=vici_agent_bridge)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(bridge,sound_only_person)=$meetme_enter_login_filename)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(user,template)=vici_agent_user)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,ConfBridge(\${EXTEN:1})\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Hangup()\n";
$confbridge_custom_ext .= "\n";
$confbridge_custom_ext .= $hangup_exten_line;
$confbridge_custom_ext .= "\n\n";
$confbridge_custom_ext .= '[confbridge-enter-leave3way]';
$confbridge_custom_ext .= "\n; confbridge entry for Vicidial agent leaving 3way call, Asterisk 16+ compatible only\n";
$confbridge_custom_ext .= "exten => _29600XXX,1,Answer()\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Playback(sip-silence)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(bridge,template)=vici_agent_bridge)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(bridge,sound_only_person)=$meetme_enter_leave3way_filename)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Set(CONFBRIDGE(user,template)=vici_agent_user)\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,ConfBridge(\${EXTEN:1})\n";
$confbridge_custom_ext .= "exten => _29600XXX,n,Hangup()\n";
$confbridge_custom_ext .= "\n";
$confbridge_custom_ext .= $hangup_exten_line;
$confbridge_custom_ext .= "\n\n";
if ($DBX>0) {print "Custom ConfBridge login and leave3way entries generated: |$meetme_enter_login_filename|$meetme_enter_leave3way_filename|\n";}
}
##### END Generate ConfBridge meetme entries if set #####
##### BEGIN Generate the Call Menu entries ##### ##### BEGIN Generate the Call Menu entries #####
$stmtA = "SELECT menu_id,menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group,dtmf_log,dtmf_field,qualify_sql,alt_dtmf_log,question,answer_signal FROM vicidial_call_menu order by menu_id;"; $stmtA = "SELECT menu_id,menu_name,menu_prompt,menu_timeout,menu_timeout_prompt,menu_invalid_prompt,menu_repeat,menu_time_check,call_time_id,track_in_vdac,custom_dialplan_entry,tracking_group,dtmf_log,dtmf_field,qualify_sql,alt_dtmf_log,question,answer_signal FROM vicidial_call_menu order by menu_id;";
@@ -4126,6 +4213,7 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
$i=0; $i=0;
if ($DBX>0) {print "$sthArows|$stmtA\n";}
while ($sthArows > $i) while ($sthArows > $i)
{ {
@aryA = $sthA->fetchrow_array; @aryA = $sthA->fetchrow_array;
@@ -4738,51 +4826,54 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
##### BEGIN generate meetme entries for this server ##### BEGIN generate meetme entries for this server
$mm = "; ViciDial Conferences:\n"; if ($conf_engine eq "MEETME")
### Find vicidial_conferences on this server
$stmtA = "SELECT conf_exten FROM vicidial_conferences where server_ip='$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsVC=$sthA->rows;
$j=0;
while ($sthArowsVC > $j)
{ {
@aryA = $sthA->fetchrow_array; $mm = "; ViciDial Conferences:\n";
$vc_meetme[$j] = $aryA[0];
$j++;
}
$sthA->finish();
$j=0; ### Find vicidial_conferences on this server
while ($sthArowsVC > $j) $stmtA = "SELECT conf_exten FROM vicidial_conferences where server_ip='$server_ip';";
{ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$mm .= "conf => $vc_meetme[$j]\n"; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$j++; $sthArowsVC=$sthA->rows;
} $j=0;
while ($sthArowsVC > $j)
{
@aryA = $sthA->fetchrow_array;
$vc_meetme[$j] = $aryA[0];
$j++;
}
$sthA->finish();
$mm .= "\n"; $j=0;
$mm .= "; Conferences:\n"; while ($sthArowsVC > $j)
{
$mm .= "conf => $vc_meetme[$j]\n";
$j++;
}
### Find conferences on this server $mm .= "\n";
$stmtA = "SELECT conf_exten FROM conferences where server_ip='$server_ip';"; $mm .= "; Conferences:\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsC=$sthA->rows;
$j=0;
while ($sthArowsC > $j)
{
@aryA = $sthA->fetchrow_array;
$meetme[$j] = $aryA[0];
$j++;
}
$sthA->finish();
$j=0; ### Find conferences on this server
while ($sthArowsC > $j) $stmtA = "SELECT conf_exten FROM conferences where server_ip='$server_ip';";
{ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$mm .= "conf => $meetme[$j]\n"; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$j++; $sthArowsC=$sthA->rows;
$j=0;
while ($sthArowsC > $j)
{
@aryA = $sthA->fetchrow_array;
$meetme[$j] = $aryA[0];
$j++;
}
$sthA->finish();
$j=0;
while ($sthArowsC > $j)
{
$mm .= "conf => $meetme[$j]\n";
$j++;
}
} }
##### END generate meetme entries for this server ##### END generate meetme entries for this server
@@ -4863,6 +4954,7 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r
print ext "; WARNING- THIS FILE IS AUTO-GENERATED BY VICIDIAL, ANY EDITS YOU MAKE WILL BE LOST\n"; print ext "; WARNING- THIS FILE IS AUTO-GENERATED BY VICIDIAL, ANY EDITS YOU MAKE WILL BE LOST\n";
print ext "$ext\n"; print ext "$ext\n";
print ext "$meetme_custom_ext\n"; print ext "$meetme_custom_ext\n";
print ext "$confbridge_custom_ext\n";
print ext "$call_menu_ext\n"; print ext "$call_menu_ext\n";
print ext "\n"; print ext "\n";
if (length($SScustom_dialplan_entry)>5) if (length($SScustom_dialplan_entry)>5)
+7 -1
View File
@@ -6,7 +6,7 @@
# astguiclient.conf file to reflect a change in IP address. The script will # astguiclient.conf file to reflect a change in IP address. The script will
# automatically default to the first eth address in the ifconfig output. # automatically default to the first eth address in the ifconfig output.
# #
# Copyright (C) 2019 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# CHANGELOG # CHANGELOG
# 71205-2144 - Added display of extensions.conf example for call routing # 71205-2144 - Added display of extensions.conf example for call routing
@@ -17,6 +17,7 @@
# 150312-1000 - Added ExpectedDBSchema # 150312-1000 - Added ExpectedDBSchema
# 180928-1958 - Added update of report_server, active_twin_server_ip and active_voicemail_server, issue #1109 # 180928-1958 - Added update of report_server, active_twin_server_ip and active_voicemail_server, issue #1109
# 190530-1517 - Added mising commented-out keepalives in conf file # 190530-1517 - Added mising commented-out keepalives in conf file
# 240420-2247 - Added ConfBridge code
# #
# default path to astguiclient configuration file: # default path to astguiclient configuration file:
@@ -445,6 +446,11 @@ $stmtA = "UPDATE vicidial_conferences SET server_ip='$VARserver_ip' where server
$affected_rows = $dbhA->do($stmtA); $affected_rows = $dbhA->do($stmtA);
if ($DB) {print " |$affected_rows|$stmtA|\n";} if ($DB) {print " |$affected_rows|$stmtA|\n";}
print " Updating vicidial_confbridges table...\n";
$stmtA = "UPDATE vicidial_confbridges SET server_ip='$VARserver_ip' where server_ip='$VARold_server_ip';";
$affected_rows = $dbhA->do($stmtA);
if ($DB) {print " |$affected_rows|$stmtA|\n";}
print " Updating vicidial_stations table...\n"; print " Updating vicidial_stations table...\n";
$stmtA = "UPDATE vicidial_stations SET server_ip='$VARserver_ip' where server_ip='$VARold_server_ip';"; $stmtA = "UPDATE vicidial_stations SET server_ip='$VARserver_ip' where server_ip='$VARold_server_ip';";
$affected_rows = $dbhA->do($stmtA); $affected_rows = $dbhA->do($stmtA);
+16 -2
View File
@@ -1,13 +1,13 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
# AST_DB_optimize.pl version 2.2.0 *DBI-version* # AST_DB_optimize.pl version 2.4 *DBI-version*
# #
# DESCRIPTION: # DESCRIPTION:
# optimizes the tables used in the asterisk MySQL database # optimizes the tables used in the asterisk MySQL database
# #
# It is recommended that you run this program on the local Asterisk machine # It is recommended that you run this program on the local Asterisk machine
# #
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# CHANGES # CHANGES
# 60717-1242 - changed to DBI by Marin Blu # 60717-1242 - changed to DBI by Marin Blu
@@ -20,6 +20,7 @@
# 90401-1335 - Added quiet and test flag functions # 90401-1335 - Added quiet and test flag functions
# 90628-2354 - Added vicidial_drop_rate_groups optimizations # 90628-2354 - Added vicidial_drop_rate_groups optimizations
# 91028-1028 - Removed non-optimize queries, they are placed in ADMIN_keepalive now and happen at timeclock reset time # 91028-1028 - Removed non-optimize queries, they are placed in ADMIN_keepalive now and happen at timeclock reset time
# 240420-2248 - Added ConfBridge code
# #
# default path to astguiclient configuration file: # default path to astguiclient configuration file:
@@ -293,6 +294,19 @@ if (!$T)
$sthA->finish(); $sthA->finish();
} }
$stmtA = "optimize table vicidial_confbridges;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
{
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@aryA = $sthA->fetchrow_array;
if (!$q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
$sthA->finish();
}
$stmtA = "optimize table vicidial_hopper;"; $stmtA = "optimize table vicidial_hopper;";
if($DB){print STDERR "\n|$stmtA|\n";} if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) if (!$T)
+4 -1
View File
@@ -56,6 +56,7 @@
# 191017-1909 - Added code for filtered maximum inbound calls # 191017-1909 - Added code for filtered maximum inbound calls
# 230523-0825 - Added User inbound_credits feature # 230523-0825 - Added User inbound_credits feature
# 240219-1518 - Added daily_limit inbound option # 240219-1518 - Added daily_limit inbound option
# 240420-2246 - Added ConfBridge code
# #
### begin parsing run-time options ### ### begin parsing run-time options ###
@@ -197,7 +198,7 @@ $sthA->finish();
########################################### ###########################################
### Grab Server values from the database ### Grab Server values from the database
$stmtA = "SELECT vd_server_logs,local_gmt,ext_context FROM servers where server_ip = '$VARserver_ip';"; $stmtA = "SELECT vd_server_logs,local_gmt,ext_context,conf_engine FROM servers where server_ip = '$VARserver_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows; $sthArows=$sthA->rows;
@@ -207,6 +208,7 @@ if ($sthArows > 0)
$DBvd_server_logs = $aryA[0]; $DBvd_server_logs = $aryA[0];
$DBSERVER_GMT = $aryA[1]; $DBSERVER_GMT = $aryA[1];
$ext_context = $aryA[2]; $ext_context = $aryA[2];
$conf_engine = $aryA[3];
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';} else {$SYSLOG = '0';}
if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;}
@@ -689,6 +691,7 @@ while($one_day_interval > 0)
{ {
$TESTrun++; $TESTrun++;
$DBremote_conf_exten[$user_counter] = ($user_counter + 8600051); $DBremote_conf_exten[$user_counter] = ($user_counter + 8600051);
if ($conf_engine eq 'CONFBRIDGE') { $DBremote_conf_exten[$user_counter] = ($user_counter + 9600051); }
} }
$DBremote_closer[$user_counter] = $closer_campaigns; $DBremote_closer[$user_counter] = $closer_campaigns;
$DBremote_random[$user_counter] = $random; $DBremote_random[$user_counter] = $random;
+868
View File
@@ -0,0 +1,868 @@
#!/usr/bin/perl
#
# AST_conf_update_screen.pl version 2.14
#
# This script uses the Asterisk Manager interface to update the live_channels
# tables and verify the parked_channels table in the asterisk MySQL database
#
# Copyright (C) 2021 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 220414-1210 - Initial build
#
# constants
$DB=0; # Debug flag, set to 0 for no debug messages, lots of output
$DBX=0;
$run_check=1; # concurrency check
# loop time in seconds
$loop_time = 0.4;
# how often settings should be reloaded from the DB in seconds
$settings_reload_interval = 10;
# how often to purge the conference records
$conf_purge_interval = 15;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options:\n";
print " [--test] = test\n";
print " [--debug] = verbose debug messages\n";
print " [--debugX] = Extra-verbose debug messages\n";
print " [--help] = this screen\n";
print "\n";
exit;
}
else
{
if ($args =~ /--debug/i)
{
$DB=1; # Debug flag
print "\n----- DEBUGGING ENABLED -----\n\n";
}
if ($args =~ /--debugX/i)
{
$DBX=1;
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
}
if ($args =~ /--test/i)
{
$TEST=1;
$T=1;
}
}
}
### end parsing run-time options ###
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
{
$line = $conf[$i];
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
if ($line =~ /^PATHhome/) {$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
if ($line =~ /^PATHlogs/) {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
if ($line =~ /^PATHagi/) {$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
if ($line =~ /^PATHweb/) {$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
if ($line =~ /^PATHsounds/) {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
if ($line =~ /^PATHmonitor/) {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
if ($line =~ /^VARserver_ip/) {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
if ($line =~ /^VARDB_server/) {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
if ($line =~ /^VARDB_database/) {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
if ($line =~ /^VARDB_user/) {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
if ($line =~ /^VARDB_pass/) {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
if ($line =~ /^VARDB_custom_user/) {$VARDB_custom_user = $line; $VARDB_custom_user =~ s/.*=//gi;}
if ($line =~ /^VARDB_custom_pass/) {$VARDB_custom_pass = $line; $VARDB_custom_pass =~ s/.*=//gi;}
if ($line =~ /^VARDB_port/) {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
&get_time_now;
#use lib './lib', '../lib';
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
use Net::Telnet ();
use Switch;
use POSIX;
use Scalar::Util qw(looks_like_number);
use Term::ANSIColor qw(:constants);
$module = 'String::Escape qw( backslash unbackslash )';
$bs_loaded=0;
if (try_load($module))
{
$bs_loaded=1;
}
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs,asterisk_version,conf_engine,conf_update_interval,vicidial_recording_limit FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = $aryA[0];
$DBtelnet_port = $aryA[1];
$DBASTmgrUSERNAME = $aryA[2];
$DBASTmgrSECRET = $aryA[3];
$DBASTmgrUSERNAMEupdate = $aryA[4];
$DBASTmgrUSERNAMElisten = $aryA[5];
$DBASTmgrUSERNAMEsend = $aryA[6];
$DBmax_vicidial_trunks = $aryA[7];
$DBanswer_transfer_agent= $aryA[8];
$DBSERVER_GMT = $aryA[9];
$DBext_context = $aryA[10];
$DBvd_server_logs = $aryA[11];
$asterisk_version = $aryA[12];
$conf_engine = $aryA[13];
$conf_update_interval = $aryA[14];
$vicidial_recording_limit = $aryA[15];
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
if ($vicidial_recording_limit < 60) {$vicidial_recording_limit=60;}
}
if (!$telnet_port) {$telnet_port = '5038';}
$loop_time = $conf_update_interval;
##### Find date-time one hour in the past
$secX = time();
$TDtarget = ($secX - ($vicidial_recording_limit * 60));
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
$Tyear = ($Tyear + 1900);
$Tmon++;
if ($Tmon < 10) {$Tmon = "0$Tmon";}
if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDrand = int( rand(99)) + 100;
$TDnum = "$Tmon$Tmday$Thour$Tmin$Tsec$TDrand";
$TDinc = 1;
### concurrency check (SCREEN uses script path, so check for more than 2 entries)
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 2)
{
if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";}
$event_string = "I am not alone! Another $0 is running! Exiting...";
&event_logger($SYSLOG,$event_string);
exit;
}
}
$event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|";
event_logger($SYSLOG,$event_string);
$max_buffer = 4*1024*1024; # 4 meg buffer
### connect to asterisk manager through telnet
$tn = new Net::Telnet (
Port => $telnet_port,
Prompt => '/\r\n/',
Output_record_separator => "\n\n",
Max_buffer_length => $max_buffer,
Telnetmode => 0,
);
$UPtelnetlog = "$PATHlogs/conf_telnet_log.txt"; # uncomment for telnet log
$fh = $tn->dump_log("$UPtelnetlog"); # uncomment for telnet log
$telnet_login = "confcron";
$tn->open("$telnet_host");
$tn->waitfor('/Asterisk Call Manager\//');
# get the AMI version number
$ami_version = $tn->getline(Errmode => Return, Timeout => 1,);
$ami_version =~ s/\n//gi;
print "----- AMI Version $ami_version -----\n";
# Login
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET");
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
$tn->buffer_empty;
$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|AMI Version $ami_version|ONE DAY INTERVAL:$one_day_interval|";
event_logger($SYSLOG,$event_string);
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 13))
{
print "Asterisk version too low for this script. Exiting.\n\n\n";
$event_string = "Asterisk version too low for this script. Exiting.";
&event_logger($SYSLOG,$event_string);
exit;
}
else
{
### BEGIN manager event handling for asterisk version >= 13
$endless_loop = 1;
$loop_count = 0;
# get the number of microseconds the loop is supposed to take
$loop_time_usec = $loop_time * 1000000;
$loop_time_usec = ceil($loop_time_usec); # take care of any floating point math
# the last time our settings were loaded from the DB
$last_config_reload = 0;
# last time we purged conferences
$last_conf_purge = 0;
while($endless_loop)
{
# increment total loop counter
$loop_count++;
$total_rooms = 0;
# get the current time
( $now_sec, $now_micro_sec ) = gettimeofday();
# figure out how many micro seconds since epoch
$now_micro_epoch = $now_sec * 1000000;
$now_micro_epoch = $now_micro_epoch + $now_micro_sec;
$begin_micro_epoch = $now_micro_epoch;
# create a new action id
$action_id = "$now_sec.$now_micro_sec";
$modechange = $tn->errmode('return');
@room_array = ();
if ( $conf_engine eq "MEETME" )
{
# ask the AMI for the conferences
$action_string = "Action: MeetmeListRooms\nActionID: $action_id";
$tn->print($action_string);
# wait till we get the response
$pattern = '/Message: Meetme conferences will follow\n\n|Message: No active conferences.\n\n/';
}
else
{
# ask the AMI for the conferences
$action_string = "Action: ConfbridgeListRooms\nActionID: $action_id";
$tn->print($action_string);
# wait till we get the response
$pattern = '/Message: Confbridge conferences will follow\n\n|Message: No active conferences.\n\n/';
}
( $read_input_buf, $match ) = $tn->waitfor($pattern);
$msg = $tn->errmsg;
if ( $msg ne '' )
{
$event_string = "WAITFOR ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|Command:\n\n$action_string\n\nPattern:$pattern\n\n";
&event_logger($SYSLOG,$event_string);
print $event_string."\n";
}
&get_time_now;
print "\n\n$now_date\n|$conf_engine List:\n";
event_logger($SYSLOG,"$conf_engine List:");
if ($match eq "Message: No active conferences.\n\n")
{
print "|No active conferences.\n";
$event_string = "|No active conferences.";
event_logger($SYSLOG,$event_string);
}
else
{
# Loop to get all of the channels
$event_ref = {};
if ( $conf_engine eq "MEETME" )
{
$match_string = '/Event: MeetmeListRoomsComplete\nActionID: ' . $action_id . '\nEventList: Complete\nListItems: \d+/';
}
else
{
$match_string = '/Event: ConfbridgeListRoomsComplete\nActionID: ' . $action_id . '\nEventList: Complete\nListItems: \d+/';
}
# get an entire record
( $read_input_buf, $match ) = $tn->waitfor(Errmode => Return, Timeout => 1, Match => "$match_string");
chomp( $read_input_buf );
if (($bs_loaded) && (length($read_input_buf) > 0))
{
if ($DBX) { print "|read|" . backslash( $read_input_buf ) . "|\n"; }
event_logger($SYSLOG,"|read|" . backslash( $read_input_buf ) . "|");
if ($DBX) { print "|match|" . backslash( $match ) . "|\n"; }
event_logger($SYSLOG,"|match|" . backslash( $match ) . "|");
}
( $junk, $list_items) = split( /ListItems: /, $match );
if ($DBX)
{
print "|total_rooms|$list_items\n";
&event_logger($SYSLOG,"|total_rooms|$list_items");
}
# check if there were any errors
$msg='';
$msg = $tn->errmsg;
if ( ( $msg ne '' ) && ( $msg !~ /read timed-out/i ) )
{
if ($msg =~ /filehandle isn\'t open/i)
{
# we have lost connection
$endless_loop=0;
$one_day_interval=0;
print "ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|\n";
print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n";
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|$msg|";
event_logger($SYSLOG,$event_string);
}
else
{
# something happened
print "ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|Command: $action_string|Match String: $match_string|\n";
$bad_grab = 1;
}
}
else
{
@records = split( /\n\n/, $read_input_buf );
foreach my $record ( @records )
{
# Loop to get all of the channels
$event_ref = {};
# break the record into lines
@lines = split( /\n/, $record );
foreach my $line ( @lines)
{
# add the line to the hash
($key,$value) = split( /: /, $line );
if ($key ne "")
{
$value =~ s/\n//gi; # remove new lines
$value =~ s/^ +//gi; # remove leading white space
$value =~ s/ +$//gi; # remove trailing white space
$event_ref->{"$key"} = $value;
}
}
$hash_size = keys(%$event_ref);
if ( $hash_size > 2 )
{
$debug_string = '';
if ( $event_ref->{'Event'} eq "MeetmeListRooms" )
{
if ( $total_rooms == 0 )
{
$debug_string .= "|Conference|Parties|Marked|Activity|Creation|Locked|";
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
$debug_string = '';
}
$debug_string .= "|$event_ref->{'Conference'}";
$debug_string .= "|$event_ref->{'Parties'}";
$debug_string .= "|$event_ref->{'Marked'}";
$debug_string .= "|$event_ref->{'Activity'}";
$debug_string .= "|$event_ref->{'Creation'}";
$debug_string .= "|$event_ref->{'Locked'}";
}
if ( $event_ref->{'Event'} eq "ConfbridgeListRooms" )
{
if ( $total_rooms == 0 )
{
$debug_string .= "|Conference|Parties|Marked|Locked|Muted|";
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
$debug_string = '';
}
$debug_string .= "|$event_ref->{'Conference'}";
$debug_string .= "|$event_ref->{'Parties'}";
$debug_string .= "|$event_ref->{'Marked'}";
$debug_string .= "|$event_ref->{'Locked'}";
$debug_string .= "|$event_ref->{'Muted'}";
}
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
}
$event_ref->{'AMIVersion'} = $ami_version;
$event_ref->{'ServerIP'} = $server_ip;
$retcode = 1;
# make sure this is an event not a response
if (exists($event_ref->{"Event"}))
{
if ( ( $event_ref->{"Event"} eq "ConfbridgeListRooms" ) || ( $event_ref->{"Event"} eq "MeetmeListRooms" ) )
{
$total_rooms++;
# We got a room
if ( $event_ref->{"ActionID"} eq $action_id )
{
push( @room_array, $event_ref );
}
else
{
if ($DB) { print STDERR "We got the wrong Action ID!!!!\n"; }
}
}
else
{
# We got something else???
}
}
elsif ( exists($event_ref->{"Response"}) )
{
# we got the response. Channels should follow.
}
}
}
if ( $total_rooms != $list_items )
{
# something is wrong. we did not process the
# same number of channels as were reported.
}
if ($DB) { print STDERR "$total_rooms rooms recieved out of $list_items reported.|\n"; }
$room_array_ref = \@room_array;
}
######################################################################
##### CHECK all TABLE #####
######################################################################
%conf_hash = ();
if ( $conf_engine eq "MEETME" )
{
# get conferences table data
$stmtA = "SELECT extension,conf_exten from conferences where server_ip='$server_ip' and extension is NOT NULL and extension != '';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "c" };
$rec_count++;
}
$sthA->finish();
# get vicidial_conferences data
$stmtA = "SELECT extension,conf_exten from vicidial_conferences where server_ip='$server_ip' and leave_3way='1';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "vc" };
$rec_count++;
}
$sthA->finish();
}
else
{
# get vicidial_confbridges data
$stmtA = "SELECT extension,conf_exten from vicidial_confbridges where server_ip='$server_ip' and leave_3way='1';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "vcb" };
$rec_count++;
}
$sthA->finish()
}
# loop through the room data
foreach $room (@room_array)
{
$conf_id = $room->{'Conference'};
if (( $room->{'Parties'} == 0 ) && ($conf_hash{"$conf_id"}{"type"} eq "c"))
{
# we are just a conference so dont kicking people out
$new_exten = $conf_hash{"$conf_id"}{"extension"};
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout3$/i) {$new_exten =~ s/Xtimeout3$/Xtimeout2/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout2$/i) {$new_exten =~ s/Xtimeout2$/Xtimeout1/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout1$/i) {$new_exten = '';}
if ( ($conf_hash{"$conf_id"}{"extension"} !~ /Xtimeout\d$/i) and (length($conf_hash{"$conf_id"}{"extension"})> 0) ) {$new_exten .= 'Xtimeout3';}
if($DB) { print $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|\n"; }
$stmtA = "UPDATE vicidial_conferences set extension='$new_exten' where server_ip='$server_ip' and conf_exten='$conf_id';";
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$affected_rows = $dbhA->do($stmtA);
}
elsif (( $room->{'Parties'} <= 1 ) && (($conf_hash{"$conf_id"}{"type"} eq "vc") || ($conf_hash{"$conf_id"}{"type"} eq "vcb")))
{
# we are a vicidial conference so we can single partisipants out.
$new_exten = $conf_hash{"$conf_id"}{"extension"};
$leave_3waySQL = '1';
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout3$/i) {$new_exten =~ s/Xtimeout3$/Xtimeout2/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout2$/i) {$new_exten =~ s/Xtimeout2$/Xtimeout1/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout1$/i) {$new_exten = ''; $leave_3waySQL='0';}
if ( ($conf_hash{"$conf_id"}{"extension"} !~ /Xtimeout\d$/i) and (length($conf_hash{"$conf_id"}{"extension"})> 0) ) {$new_exten .= 'Xtimeout3';}
if($DB) { print $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|\n";}
event_logger($SYSLOG, $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|");
$kick = 0;
if ($new_exten =~ /Xtimeout1$/i)
{
### Kick all participants if there are any left in the conference so it can be reused
$local_DEF = 'Local/5555';
$local_AMP = '@';
$kick_local_channel = $local_DEF . $conf_id . $local_AMP . $ext_context;
$padTDinc = sprintf("%03s", $TDinc); while (length($padTDinc) > 3) {chop($padTDinc);}
$queryCID = "ULGC$padTDinc$TDnum";
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','','');";
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtA|\n";}
event_logger($SYSLOG,"|$affected_rows|$stmtA|");
$TDinc++;
$kick = 1;
}
if ($conf_hash{"$conf_id"}{"type"} eq "vc")
{
$stmtA = "UPDATE vicidial_conferences set extension='$new_exten',leave_3way='$leave_3waySQL' where server_ip='$server_ip' and conf_exten='$conf_id';";
}
else
{
$stmtA = "UPDATE vicidial_confbridges set extension='$new_exten',leave_3way='$leave_3waySQL' where server_ip='$server_ip' and conf_exten='$conf_id';"
}
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"\n|$stmtA|");
$affected_rows = $dbhA->do($stmtA);
# only sleep if we did a kick
if ($kick) { usleep(1*100*1000); }
}
}
# reload the settings from the DB at a fixed interval
$epoch = time();
if ( $epoch - $last_conf_purge >= $conf_purge_interval)
{
clear_conf_records();
$last_conf_purge = time();
}
# reload the settings from the DB at a fixed interval
$epoch = time();
if ( $epoch - $last_config_reload >= $settings_reload_interval )
{
# reload the server settings
$settings_ref = get_server_settings($dbhA,$server_ip);
$loop_time_usec = $settings_ref->{'conf_update_interval'} * 1000000;
$loop_time_usec = ceil($loop_time_usec); # take care of any floating point math
$vicidial_recording_limit = $settings_ref->{'vicidial_recording_limit'};
$conf_engine = $settings_ref->{'conf_engine'};
$last_config_reload = time();
}
# figure out how long that loop took.
# get the current time
( $now_sec, $now_micro_sec ) = gettimeofday();
# figure out how many micro seconds since epoch
$now_micro_epoch = $now_sec * 1000000;
$now_micro_epoch = $now_micro_epoch + $now_micro_sec;
$end_micro_epoch = $now_micro_epoch;
# subtract the current time in usec from time at the beginning of the loop
$loop_usec = $end_micro_epoch - $begin_micro_epoch;
# figure out how long to sleep
$sleep_usec = $loop_time_usec - $loop_usec;
# cannot sleep negative time
if ( $sleep_usec > 0 )
{
if ($DB) { print STDERR "loop took $loop_usec microseconds. sleeping for $sleep_usec microseconds to compensate\n"; }
event_logger($SYSLOG,"loop took $loop_usec microseconds. sleeping for $sleep_usec microseconds to compensate\n");
# sleep it
usleep($sleep_usec);
}
}
}
if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";}
$event_string='HANGING UP|';
event_logger($SYSLOG,$event_string);
@hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/", Errmode => Return, Timeout => 1);
$tn->buffer_empty;
$tn->waitfor(Match => '/Message:.*\n\n/', Timeout => 10);
$ok = $tn->close;
$event_string='CLOSING DB CONNECTION|';
event_logger($SYSLOG,$event_string);
$dbhA->disconnect();
if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
exit;
sub get_server_settings
{
my ($dbhA,$server_ip) = @_;
### Grab Server values from the database
$stmtA = "SELECT conf_engine,conf_update_interval,vicidial_recording_limit FROM servers where server_ip='$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$settings_ref = $sthA->fetchrow_hashref;
if ($DB) { print "Settings Reload|$stmtA|$settings_ref->{'conf_engine'}|$settings_ref->{'conf_update_interval'}|$settings_ref->{'vicidial_recording_limit'}\n"; }
event_logger($SYSLOG,"Settings Reload|$stmtA|$settings_ref->{'conf_engine'}|$settings_ref->{'conf_update_interval'}|$settings_ref->{'vicidial_recording_limit'}");
return $settings_ref;
}
sub event_logger
{
my ($SYSLOG,$event_string) = @_;
if ($SYSLOG)
{
### open the log file for writing ###
open(Lout, ">>$PATHlogs/conf_update.$action_log_date")
|| die "Can't open $PATHlogs/conf_update.$action_log_date: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
}
$event_string='';
}
# subroutine to parse the asterisk version
# and return a hash with the various part
sub parse_asterisk_version
{
# grab the arguments
my $ast_ver_str = $_[0];
# get everything after the - and put it in $ast_ver_postfix
my @hyphen_parts = split( /-/ , $ast_ver_str );
my $ast_ver_postfix = $hyphen_parts[1];
# now split everything before the - up by the .
my @dot_parts = split( /\./ , $hyphen_parts[0] );
my %ast_ver_hash;
if ( $dot_parts[0] <= 1 )
{
%ast_ver_hash = (
"major" => $dot_parts[0],
"minor" => $dot_parts[1],
"build" => $dot_parts[2],
"revision" => $dot_parts[3],
"postfix" => $ast_ver_postfix
);
}
# digium dropped the 1 from asterisk 10 but we still need it
if ( $dot_parts[0] > 1 )
{
%ast_ver_hash = (
"major" => 1,
"minor" => $dot_parts[0],
"build" => $dot_parts[1],
"revision" => $dot_parts[2],
"postfix" => $ast_ver_postfix
);
}
return ( %ast_ver_hash );
}
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
$action_log_date = "$year-$mon-$mday";
}
# try to load a module
sub try_load
{
my $mod = shift;
eval("use $mod");
if ($@)
{
#print "\$@ = $@\n";
return(0);
}
else
{
return(1);
}
}
sub clear_conf_records
{
######################################################################
##### CLEAR vicidial_conferences ENTRIES IN LEAVE-3WAY FOR MORE THAN ONE HOUR
######################################################################
##### Find date-time one hour in the past
$secX = time();
$TDtarget = ($secX - ($vicidial_recording_limit * 60));
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
$Tyear = ($Tyear + 1900);
$Tmon++;
if ($Tmon < 10) {$Tmon = "0$Tmon";}
if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDrand = int( rand(99)) + 100;
$TDnum = "$Tmon$Tmday$Thour$Tmin$Tsec$TDrand";
$TDinc = 1;
@PTextensions=@MT; @PT_conf_extens=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT;
$stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='1' and leave_3way_datetime < \"$TDSQLdate\";";
if ($DB) {print "Conf Purge|$stmtA|\n";}
event_logger($SYSLOG,"Conf Purge|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PT_conf_extens[$rec_count] = $aryA[0];
$PT_extensions[$rec_count] = $aryA[1];
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PT_extensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
$k=0;
while ($k < $rec_count)
{
$local_DEF = 'Local/5555';
$local_AMP = '@';
$kick_local_channel = "$local_DEF$PT_conf_extens[$k]$local_AMP$ext_context";
$padTDinc = sprintf("%03s", $TDinc); while (length($padTDinc) > 3) {chop($padTDinc);}
$queryCID = "ULGH$padTDinc$TDnum";
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','','');";
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$stmtA = "UPDATE vicidial_conferences set extension='',leave_3way='0' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"Conf Purge|$stmtA|");
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$k++;
$TDinc++;
}
}
+8 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl #!/usr/bin/perl
# #
# AST_reset_mysql_vars.pl version 2.0.5 # AST_reset_mysql_vars.pl version 2.4
# #
# !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!! # !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!!
# #
@@ -10,11 +10,12 @@
# It is recommended that you run this program on the local Asterisk machine # It is recommended that you run this program on the local Asterisk machine
# You should place a command to run this in the /etc/rc.d/rc.local file # You should place a command to run this in the /etc/rc.d/rc.local file
# #
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# CHANGES # CHANGES
# 60717-1237 - changed to DBI by Marin Blu # 60717-1237 - changed to DBI by Marin Blu
# 60717-1536 - changed to use /etc/astguiclient.conf for configs # 60717-1536 - changed to use /etc/astguiclient.conf for configs
# 240420-2249 - Added ConfBridge code
# #
# default path to astguiclient configuration file: # default path to astguiclient configuration file:
@@ -76,6 +77,11 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
print " - vicidial_conferences reset\n"; print " - vicidial_conferences reset\n";
$stmtA = "UPDATE vicidial_confbridges set extension='' where server_ip='$server_ip';";
if($DB){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
print " - vicidial_confbridges reset\n";
# $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';"; # $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';";
# if($DB){print STDERR "\n|$stmtA|\n";} # if($DB){print STDERR "\n|$stmtA|\n";}
# $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n"; # $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
@@ -1,12 +1,15 @@
VICIdial ConfBridge Support: STARTED: 2022-06-22 UPDATED: 2022-10-26 VICIdial ConfBridge Support: STARTED: 2022-06-22 UPDATED: 2024-04-20
!!! NOTE: VICIdial ConfBridge support is currently in BETA mode and is not recommended for systems that require a stable and tested codebase !!! !!! NOTE: VICIdial ConfBridge has been in use by several companies in production for over a year now and is considered stable !!!
!!! NOTE: VICIdial ConfBridge support requires Asterisk 16 or higher to be installed on your dialers. Code development and testing was done with VICIbox 10 and the optional Asterisk 16 package available through VICIbox 10 !!! !!! NOTE: VICIdial ConfBridge support requires Asterisk 16 or higher to be installed on your dialers. Code development and testing was done with VICIbox 11 and the optional Asterisk 16 package available through VICIbox 11 !!!
!!! NOTE: As of svn/trunk revision 3826, the new 'AST_conf_update_screen.pl' script is installed by the VICIdial codebase and the 'AST_VDremote_agents.pl.diff' patch is already applied by default.
BETA support for ConfBridge is included in the VICIdial svn/trunk codebase as of revision 3624. BETA support for ConfBridge was first included in the VICIdial svn/trunk codebase as of revision 3624.
- Background - Background
@@ -584,7 +587,7 @@ Included in the "extras/ConfBridge/" directory of the svn/trunk codebase are sev
vici-dev1:/srv/www/htdocs/agc/ # patch -p0 < vicidial.php.diff vici-dev1:/srv/www/htdocs/agc/ # patch -p0 < vicidial.php.diff
patching file vicidial.php patching file vicidial.php
NOTE: The "AST_conf_update_screen.pl" script is a new perl script, not a patch file, so it just needs to be copied to the proper directory and given 'r' + 'x' file permissions. NOTE: As of revision 3826, the new 'AST_conf_update_screen.pl' script is installed by the VICIdial codebase and all other required patches are already applied by default.
Here is the list of files for specific default directories: Here is the list of files for specific default directories:
+44 -17
View File
@@ -1,7 +1,7 @@
<?php <?php
# manager_send.php version 2.14 # manager_send.php version 2.14
# #
# Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# This script is designed purely to insert records into the vicidial_manager table to signal Actions to an asterisk server # 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 # This script depends on the server_ip being sent and also needs to have a valid user/pass from the vicidial_users table
@@ -154,10 +154,11 @@
# 221116-1051 - Fix for long in-group dialstring extensions # 221116-1051 - Fix for long in-group dialstring extensions
# 230418-1022 - Added dial_override_limit options.php setting # 230418-1022 - Added dial_override_limit options.php setting
# 230726-0857 - Fix for rare vicidial_closer_log issue on Voicemail transfers # 230726-0857 - Fix for rare vicidial_closer_log issue on Voicemail transfers
# 240420-2233 - ConfBridge code added
# #
$version = '2.14-101'; $version = '2.14-102';
$build = '230726-0857'; $build = '240420-2233';
$php_script = 'manager_send.php'; $php_script = 'manager_send.php';
$mel=1; # Mysql Error Log enabled = 1 $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=161; $mysql_log_count=161;
@@ -408,9 +409,17 @@ if (strlen($SSagent_debug_logging) > 1)
{$SSagent_debug_logging=0;} {$SSagent_debug_logging=0;}
} }
$stmtA="SELECT conf_engine FROM servers WHERE server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmtA, $link);
$row=mysqli_fetch_row($rslt);
$conf_engine = $row[0];
$threeway_context = $ext_context; $threeway_context = $ext_context;
if (strlen($meetme_enter_leave3way_filename) > 0) if (strlen($meetme_enter_leave3way_filename) > 0)
{$threeway_context = 'meetme-enter-leave3way';} {
$threeway_context = 'meetme-enter-leave3way';
if ($conf_engine == "CONFBRIDGE") { $threeway_context = 'confbridge-enter-leave3way'; }
}
$auth=0; $auth=0;
$auth_message = user_authorization($user,$pass,'',0,1,0,0,'manager_send'); $auth_message = user_authorization($user,$pass,'',0,1,0,0,'manager_send');
@@ -588,7 +597,9 @@ if ($ACTION=="OriginateVDRelogin")
print "<!-- sending login sipsak message: $SIPSAK_prefix$campaign -->\n"; print "<!-- sending login sipsak message: $SIPSAK_prefix$campaign -->\n";
passthru("/usr/local/bin/sipsak -M -O desktop -B \"$SIPSAK_prefix$campaign\" -r 5060 -s sip:$extension@$phone_ip > /dev/null"); 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"; $queryCID = "$SIPSAK_prefix$campaign$DS$CIDdate";
} }
if ($conf_engine == "CONFBRIDGE") { $exten = "2$exten"; }
$ACTION="Originate"; $ACTION="Originate";
} }
@@ -1910,6 +1921,7 @@ if ($ACTION=="RedirectXtraCXNeW")
$row=''; $rowx=''; $row=''; $rowx='';
$channel_liveX=1; $channel_liveX=1;
$channel_liveY=1; $channel_liveY=1;
$conf_table = 'vicidial_conferences';
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 (!preg_match("/NEXTAVAILABLE/",$exten)) ) ) 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 (!preg_match("/NEXTAVAILABLE/",$exten)) ) )
{ {
$channel_liveX=0; $channel_liveX=0;
@@ -1937,19 +1949,26 @@ if ($ACTION=="RedirectXtraCXNeW")
{ {
if (preg_match("/NEXTAVAILABLE/",$exten)) if (preg_match("/NEXTAVAILABLE/",$exten))
{ {
$stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; # figure out which table to look in
$stmtA="SELECT conf_engine FROM servers WHERE server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmtA -->";}
$rslt=mysql_to_mysqli($stmtA, $link);
$row=mysqli_fetch_row($rslt);
if ($row[0] == "CONFBRIDGE") { $conf_table = 'vicidial_confbridges'; }
$stmtA="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtA -->";} if ($format=='debug') {echo "\n<!-- $stmtA -->";}
$rslt=mysql_to_mysqli($stmtA, $link); $rslt=mysql_to_mysqli($stmtA, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
if ($row[0] > 1) 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;"; $stmtB="UPDATE $conf_table 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<!-- $stmtB -->";} if ($format=='debug') {echo "\n<!-- $stmtB -->";}
$rslt=mysql_to_mysqli($stmtB, $link); $rslt=mysql_to_mysqli($stmtB, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'02030',$user,$server_ip,$session_name,$one_mysql_log);} 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';"; $stmtC="SELECT conf_exten from $conf_table where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtC -->";} if ($format=='debug') {echo "\n<!-- $stmtC -->";}
$rslt=mysql_to_mysqli($stmtC, $link); $rslt=mysql_to_mysqli($stmtC, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -1961,12 +1980,12 @@ if ($ACTION=="RedirectXtraCXNeW")
$extension = "$extension$user"; $extension = "$extension$user";
} }
$stmtD="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; $stmtD="UPDATE $conf_table set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmtD -->";} if ($format=='debug') {echo "\n<!-- $stmtD -->";}
$rslt=mysql_to_mysqli($stmtD, $link); $rslt=mysql_to_mysqli($stmtD, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtD,'02032',$user,$server_ip,$session_name,$one_mysql_log);} 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';"; $stmtE="UPDATE $conf_table 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<!-- $stmtE -->";} if ($format=='debug') {echo "\n<!-- $stmtE -->";}
$rslt=mysql_to_mysqli($stmtE, $link); $rslt=mysql_to_mysqli($stmtE, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -2004,7 +2023,7 @@ if ($ACTION=="RedirectXtraCXNeW")
else else
{ {
$channel_liveX=0; $channel_liveX=0;
echo _QXZ("Cannot find empty vicidial_conference on %1s, Redirect command not inserted",0,'',$server_ip)."\n|$stmt|"; echo _QXZ("Cannot find empty $conf_table on %1s, Redirect command not inserted",0,'',$server_ip)."\n|$stmt|";
if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";} if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";}
$stage .= "|ERROR $server_ip|"; $stage .= "|ERROR $server_ip|";
} }
@@ -2136,6 +2155,7 @@ if ($ACTION=="RedirectXtraNeW")
$row=''; $rowx=''; $row=''; $rowx='';
$channel_liveX=1; $channel_liveX=1;
$channel_liveY=1; $channel_liveY=1;
$conf_table = 'vicidial_conferences';
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 (!preg_match("/NEXTAVAILABLE/",$exten)) ) ) 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 (!preg_match("/NEXTAVAILABLE/",$exten)) ) )
{ {
$channel_liveX=0; $channel_liveX=0;
@@ -2165,31 +2185,38 @@ if ($ACTION=="RedirectXtraNeW")
{ {
if (preg_match("/NEXTAVAILABLE/",$exten)) if (preg_match("/NEXTAVAILABLE/",$exten))
{ {
$stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';"; # figure out which table to look in
$stmtA="SELECT conf_engine FROM servers WHERE server_ip='$server_ip';";
if ($format=='debug') {echo "\n<!-- $stmtA -->";}
$rslt=mysql_to_mysqli($stmtA, $link);
$row=mysqli_fetch_row($rslt);
if ($row[0] == "CONFBRIDGE") { $conf_table = 'vicidial_confbridges'; }
$stmt="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
if ($row[0] > 1) 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;"; $stmt="UPDATE $conf_table 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<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02046',$user,$server_ip,$session_name,$one_mysql_log);} 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';"; $stmt="SELECT conf_exten from $conf_table where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
$exten = $row[0]; $exten = $row[0];
$stmt="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;"; $stmt="UPDATE $conf_table set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02048',$user,$server_ip,$session_name,$one_mysql_log);} 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';"; $stmt="UPDATE $conf_table 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<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -2223,7 +2250,7 @@ if ($ACTION=="RedirectXtraNeW")
else else
{ {
$channel_liveX=0; $channel_liveX=0;
echo "Cannot find empty vicidial_conference on $server_ip, Redirect command not inserted\n|$stmt|"; echo "Cannot find empty $conf_table on $server_ip, Redirect command not inserted\n|$stmt|";
if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";} if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";}
$stage .= "|ERROR $server_ip|"; $stage .= "|ERROR $server_ip|";
} }
+12 -4
View File
@@ -548,10 +548,11 @@
# 240219-2130 - Added daily_limit for user/in-group parameter # 240219-2130 - Added daily_limit for user/in-group parameter
# 240221-0330 - Small changes for state_descriptions Banner # 240221-0330 - Small changes for state_descriptions Banner
# 240420-0836 - Added call_log_days campaign option # 240420-0836 - Added call_log_days campaign option
# 240420-2227 - ConfBridge code added
# #
$version = '2.14-441'; $version = '2.14-442';
$build = '240420-0836'; $build = '240420-2227';
$php_script = 'vdc_db_query.php'; $php_script = 'vdc_db_query.php';
$mel=1; # Mysql Error Log enabled = 1 $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=913; $mysql_log_count=913;
@@ -17189,8 +17190,15 @@ if ($ACTION == 'userLOGout')
if ($no_delete_sessions < 1) if ($no_delete_sessions < 1)
{ {
##### Remove the reservation on the vicidial_conferences meetme room ##### Figure out which conference table to use
$stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';"; $conf_table = 'vicidial_conferences';
$stmt="SELECT conf_engine FROM servers where server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
if ( $row[0] == 'CONFBRIDGE' ) { $conf_table = 'vicidial_confbridges'; }
##### Remove the reservation on the vicidial_conferences or vicidial_confbridges room
$stmt="UPDATE $conf_table set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);}
+36 -13
View File
@@ -738,15 +738,17 @@
# 240409-2053 - Fix for Dead Trigger issue # 240409-2053 - Fix for Dead Trigger issue
# 240415-1852 - Added script_tab_height campaign option # 240415-1852 - Added script_tab_height campaign option
# 240416-1750 - Fix for HotKey issue #1518 # 240416-1750 - Fix for HotKey issue #1518
# 240420-2228 - ConfBridge code added
# #
$version = '2.14-704c'; $version = '2.14-705c';
$build = '240416-1750'; $build = '240420-2228';
$php_script = 'vicidial.php'; $php_script = 'vicidial.php';
$mel=1; # Mysql Error Log enabled = 1 $mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=103; $mysql_log_count=103;
$one_mysql_log=0; $one_mysql_log=0;
$DB=0; $DB=0;
$conf_table = "vicidial_conferences";
require_once("dbconnect_mysqli.php"); require_once("dbconnect_mysqli.php");
require_once("functions.php"); require_once("functions.php");
@@ -4341,6 +4343,14 @@ else
else else
{$rowx[0]='0.0.0.0';} {$rowx[0]='0.0.0.0';}
##### figure out which table to look for conferences in
$stmt="SELECT conf_engine from servers where server_ip = '$rowx[0]';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$conf_engine = $row[0];
if ( $conf_engine == "CONFBRIDGE" ) { $conf_table = "vicidial_confbridges"; }
### get number of agents logged in to each server ### get number of agents logged in to each server
$stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]' and extension NOT LIKE \"R%\";"; $stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]' and extension NOT LIKE \"R%\";";
if ($DB) {echo "|$stmt|\n";} if ($DB) {echo "|$stmt|\n";}
@@ -4355,7 +4365,7 @@ else
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt); $rowy=mysqli_fetch_row($rslt);
$stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$rowx[0]' and ((extension='') or (extension is null));"; $stmt="SELECT count(*) FROM $conf_table where server_ip='$rowx[0]' and ((extension='') or (extension is null));";
if ($DB) {echo "|$stmt|\n";} if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01085',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01085',$VD_login,$server_ip,$session_name,$one_mysql_log);}
@@ -4569,7 +4579,7 @@ else
$local_gmt = ($local_gmt + $isdst); $local_gmt = ($local_gmt + $isdst);
} }
$stmt="SELECT asterisk_version,web_socket_url,external_web_socket_url from servers where server_ip='$server_ip';"; $stmt="SELECT asterisk_version,web_socket_url,external_web_socket_url,conf_engine from servers where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";} if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
@@ -4577,6 +4587,7 @@ else
$asterisk_version = $row[0]; $asterisk_version = $row[0];
$web_socket_url = $row[1]; $web_socket_url = $row[1];
$external_web_socket_url = $row[2]; $external_web_socket_url = $row[2];
$conf_engine = $row[3];
if ( ($use_external_server_ip=='Y') and (strlen($external_web_socket_url) > 5) ) if ( ($use_external_server_ip=='Y') and (strlen($external_web_socket_url) > 5) )
{$web_socket_url = $external_web_socket_url;} {$web_socket_url = $external_web_socket_url;}
$major_version = explode('.',$asterisk_version); $major_version = explode('.',$asterisk_version);
@@ -4588,6 +4599,12 @@ else
$volumecontrol_active=0; $volumecontrol_active=0;
} }
} }
$login_context = $ext_context;
if (strlen($meetme_enter_login_filename) > 0)
{
$login_context = 'meetme-enter-login';
if ( $conf_engine == "CONFBRIDGE" ) { $login_context = 'confbridge-enter-login'; }
}
if ($protocol == 'EXTERNAL') if ($protocol == 'EXTERNAL')
{ {
@@ -4699,8 +4716,12 @@ else
if ( ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) || ($campaign_leads_to_call > 0) || (preg_match('/Y/',$no_hopper_leads_logins)) ) if ( ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) || ($campaign_leads_to_call > 0) || (preg_match('/Y/',$no_hopper_leads_logins)) )
{ {
##### figure out which table to look for conferences in
$conf_table = "vicidial_conferences";
if ( $conf_engine == "CONFBRIDGE" ) { $conf_table = "vicidial_confbridges"; }
##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly ##### 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;"; $stmt="SELECT conf_exten FROM $conf_table where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01032',$VD_login,$server_ip,$session_name,$one_mysql_log);} 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";} if ($DB) {echo "$stmt\n";}
@@ -4713,30 +4734,30 @@ else
$i++; $i++;
} }
if ($prev_login_ct > 0) if ($prev_login_ct > 0)
{echo "<!-- USING PREVIOUS MEETME ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";} {echo "<!-- USING PREVIOUS $conf_engine ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";}
else else
{ {
##### grab the next available vicidial_conference room and reserve it ##### grab the next available conference room and reserve it
$stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null));"; $stmt="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null));";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
if ($row[0] > 0) 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;"; $stmt="UPDATE $conf_table 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<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01034',$VD_login,$server_ip,$session_name,$one_mysql_log);} 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='$VD_login') );"; $stmt="SELECT conf_exten from $conf_table where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$VD_login') );";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
$session_id = $row[0]; $session_id = $row[0];
} }
echo "<!-- USING NEW MEETME ROOM - $session_id - $NOW_TIME - $SIP_user -->\n"; echo "<!-- USING NEW $conf_engine ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";
} }
### mark leads that were not dispositioned during previous calls as ERI ### mark leads that were not dispositioned during previous calls as ERI
@@ -4896,8 +4917,10 @@ else
if ($on_hook_agent == 'Y') if ($on_hook_agent == 'Y')
{$TEMP_SIP_user_DiaL = 'Local/8300@default';} {$TEMP_SIP_user_DiaL = 'Local/8300@default';}
### insert a NEW record to the vicidial_manager table to be processed ### insert a NEW record to the vicidial_manager table to be processed
$agent_login_data="||$NOW_TIME|NEW|N|$server_ip||Originate|$SIqueryCID|Channel: $SIP_user_DiaL|Context: $login_context|Exten: $session_id|Priority: 1|Callerid: \"$SIqueryCID\" <$campaign_cid>|||||"; $session_prepend = '';
$agent_login_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $TEMP_SIP_user_DiaL','Context: $login_context','Exten: $session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');"; if ( $conf_engine == 'CONFBRIDGE' ) { $session_prepend = 2; }
$agent_login_data="||$NOW_TIME|NEW|N|$server_ip||Originate|$SIqueryCID|Channel: $SIP_user_DiaL|Context: $login_context|Exten: $session_prepend$session_id|Priority: 1|Callerid: \"$SIqueryCID\" <$campaign_cid>|||||";
$agent_login_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $TEMP_SIP_user_DiaL','Context: $login_context','Exten: $session_prepend$session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');";
### log outbound call in the vicidial_user_dial_log ### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$SIqueryCID',user='$VD_login',call_date='$NOW_TIME',call_type='APL',notes='$session_id $login_context $TEMP_SIP_user_DiaL';"; $stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$SIqueryCID',user='$VD_login',call_date='$NOW_TIME',call_type='APL',notes='$session_id $login_context $TEMP_SIP_user_DiaL';";
+23 -4
View File
@@ -210,10 +210,11 @@
# 240120-0840 - Added list_order,list_order_randomize,list_order_secondary optional fields to update_campaign function # 240120-0840 - Added list_order,list_order_randomize,list_order_secondary optional fields to update_campaign function
# 240217-0907 - Added more missing vicidial_users fields from copy function # 240217-0907 - Added more missing vicidial_users fields from copy function
# 240302-0804 - Added delete_dnc_phone function # 240302-0804 - Added delete_dnc_phone function
# 240420-2236 - Added ConfBridge code
# #
$version = '2.14-187'; $version = '2.14-188';
$build = '240302-0804'; $build = '240420-2236';
$php_script='non_agent_api.php'; $php_script='non_agent_api.php';
$api_url_log = 0; $api_url_log = 0;
$camp_lead_order_random=1; $camp_lead_order_random=1;
@@ -3307,7 +3308,25 @@ if ($function == 'blind_monitor')
} }
else else
{ {
$stmt="SELECT count(*) from vicidial_conferences where conf_exten='$session_id' and server_ip='$server_ip';"; $stmt ="SELECT conf_engine from servers where server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$conf_engine=$row[0];
if($conf_engine == "CONFBRIDGE")
{
$conf_table = "vicidial_confbridges";
$monitor_prefix = '4';
$barge_prefix = '6';
}
else
{
$conf_table = "vicidial_conferences";
$monitor_prefix = '0';
$barge_prefix = '';
}
$stmt="SELECT count(*) from $conf_table where conf_exten='$session_id' and server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt); $row=mysqli_fetch_row($rslt);
$session_exists=$row[0]; $session_exists=$row[0];
@@ -3373,7 +3392,7 @@ if ($function == 'blind_monitor')
$monitor_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S"; $monitor_dialstring = "$D_s_ip[0]$S$D_s_ip[1]$S$D_s_ip[2]$S$D_s_ip[3]$S";
$monitor_type='LISTEN'; $cid_prefix='BM'; $swap_chan=0; $monitor_type='LISTEN'; $cid_prefix='BM'; $swap_chan=0;
if ( (preg_match('/MONITOR/',$stage)) or (strlen($stage)<1) ) {$stage = '0';} if ( (preg_match('/MONITOR/',$stage)) or (strlen($stage)<1) ) {$stage = $monitor_prefix;}
if (preg_match('/BARGE/',$stage)) if (preg_match('/BARGE/',$stage))
{ {
if (preg_match('/SWAP/',$stage)) {$swap_chan=1;} if (preg_match('/SWAP/',$stage)) {$swap_chan=1;}