Added dial_override_limit agc/options.php setting

Added vicidial_user_dial_log logging, and rate limiting

git-svn-id: svn://192.168.202.10@3709 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2023-04-18 19:55:12 +00:00
parent 37cb565f15
commit f34efc1799
10 changed files with 392 additions and 24 deletions
+131 -1
View File
@@ -20,7 +20,7 @@
# Based on perl scripts in ViciDial from Matt Florell and post: # Based on perl scripts in ViciDial from Matt Florell and post:
# http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=22506&sid=ca5347cffa6f6382f56ce3db9fb3d068#22506 # http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=22506&sid=ca5347cffa6f6382f56ce3db9fb3d068#22506
# #
# Copyright (C) 2022 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2023 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# #
# CHANGES # CHANGES
# 90615-1701 - First version # 90615-1701 - First version
@@ -65,6 +65,7 @@
# 210912-1546 - Added --api-log-days=X and --api-only flags # 210912-1546 - Added --api-log-days=X and --api-only flags
# 220309-2246 - Added --api-archive-days=X and --api-archive-only flags # 220309-2246 - Added --api-archive-days=X and --api-archive-only flags
# 220312-0859 - Added vicidial_dial_cid_log table archiving, same as vicidial_dial_log # 220312-0859 - Added vicidial_dial_cid_log table archiving, same as vicidial_dial_log
# 230418-1341 - Added vicidial_user_dial_log archiving, same as vicidial_dial_log
# #
$CALC_TEST=0; $CALC_TEST=0;
@@ -673,6 +674,35 @@ if (!$T)
} }
##### END vicidial_dial_log_archive trim processing ##### ##### END vicidial_dial_log_archive trim processing #####
##### BEGIN vicidial_user_dial_log_archive trim processing #####
$stmtA = "SELECT count(*) from vicidial_user_dial_log_archive;";
$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;
$vicidial_user_dial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "Trimming vicidial_user_dial_log_archive table... ($vicidial_user_dial_log_archive_count)\n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_user_dial_log_archive WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_user_dial_log_archive table \n";}
$stmtA = "optimize table vicidial_user_dial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_user_dial_log_archive trim processing #####
##### BEGIN vicidial_dial_cid_log_archive trim processing ##### ##### BEGIN vicidial_dial_cid_log_archive trim processing #####
$stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;"; $stmtA = "SELECT count(*) from vicidial_dial_cid_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -1253,6 +1283,53 @@ if (!$T)
##### END vicidial_dial_log DAILY processing ##### ##### END vicidial_dial_log DAILY processing #####
##### BEGIN vicidial_user_dial_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_user_dial_log;";
$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;
$vicidial_user_dial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_user_dial_log_archive;";
$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;
$vicidial_user_dial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_user_dial_log table... ($vicidial_user_dial_log_count|$vicidial_user_dial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_user_dial_log_archive SELECT * from vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_user_dial_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_user_dial_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_user_dial_log table \n";}
$stmtA = "optimize table vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_user_dial_log DAILY processing #####
##### BEGIN vicidial_dial_cid_log DAILY processing ##### ##### BEGIN vicidial_dial_cid_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_dial_cid_log;"; $stmtA = "SELECT count(*) from vicidial_dial_cid_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
@@ -2302,6 +2379,59 @@ if (!$T)
} }
##### vicidial_user_dial_log
$stmtA = "SELECT count(*) from vicidial_user_dial_log;";
$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;
$vicidial_user_dial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_user_dial_log_archive;";
$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;
$vicidial_user_dial_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_user_dial_log table... ($vicidial_user_dial_log_count|$vicidial_user_dial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_user_dial_log_archive SELECT * from vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_user_dial_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
if ($wipe_all > 0)
{$stmtA = "DELETE FROM vicidial_user_dial_log;";}
else
{$stmtA = "DELETE FROM vicidial_user_dial_log WHERE call_date < '$del_time';";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_user_dial_log table \n";}
$stmtA = "optimize table vicidial_user_dial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_user_dial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### vicidial_dial_cid_log ##### vicidial_dial_cid_log
$stmtA = "SELECT count(*) from vicidial_dial_cid_log;"; $stmtA = "SELECT count(*) from vicidial_dial_cid_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+3 -1
View File
@@ -1,4 +1,4 @@
CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2023-02-01 CALLER ID NAME CODES DOC Started: 2013-07-15 Updated: 2023-04-18
This document is meant for reference only, and it does not contain all CID name codes possible, but more will be added over time. This document is meant for reference only, and it does not contain all CID name codes possible, but more will be added over time.
@@ -10,6 +10,7 @@ Y - Inbound Call (Y7152252510000822239)
J - Inbound CLOSER Transfer (J7152252510000822239) J - Inbound CLOSER Transfer (J7152252510000822239)
DC - 3-Way Call (DC943083W0000855319W) DC - 3-Way Call (DC943083W0000855319W)
DV - Dial Override, Send DTMF, Dead Trigger, Blind Monitor Warning (DV191652W1010101010W) DV - Dial Override, Send DTMF, Dead Trigger, Blind Monitor Warning (DV191652W1010101010W)
DO - Dial Override(old) (DOagcW16817630576666)
S - Agent Login Call (S1307152248588600051) S - Agent Login Call (S1307152248588600051)
LP - Park Call (LPvdcW13739432176666) LP - Park Call (LPvdcW13739432176666)
FP - Back to agent From Park (FPvdcW14529553216666) FP - Back to agent From Park (FPvdcW14529553216666)
@@ -37,3 +38,4 @@ E - Inbound Email, tracking only (E0001797980001237995)
ACagcW - Noone in session call agent phone (ACagcW15167259066666) ACagcW - Noone in session call agent phone (ACagcW15167259066666)
AM - Agent mute of recording (AM273955W0001922575W) AM - Agent mute of recording (AM273955W0001922575W)
G - Recording Gateway inbound call (G2010021380000000023) G - Recording Gateway inbound call (G2010021380000000023)
CID - SendCID test page (CID1451019998883112)
@@ -4923,6 +4923,17 @@ user VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (queue_id) PRIMARY KEY (queue_id)
) ENGINE=MyISAM; ) ENGINE=MyISAM;
CREATE TABLE vicidial_user_dial_log (
caller_code VARCHAR(30) NOT NULL,
user VARCHAR(20) default '',
call_date DATETIME,
call_type VARCHAR(10) default '',
notes VARCHAR(100) default '',
index (caller_code),
index (user),
index (call_date)
) ENGINE=MyISAM;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8; ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -5193,6 +5204,9 @@ ALTER TABLE vicidial_abandon_check_queue_archive MODIFY abandon_check_id INT(9)
CREATE TABLE vicidial_agent_notifications_archive LIKE vicidial_agent_notifications; CREATE TABLE vicidial_agent_notifications_archive LIKE vicidial_agent_notifications;
ALTER TABLE vicidial_agent_notifications_archive MODIFY notification_id INT(10) UNSIGNED NOT NULL; ALTER TABLE vicidial_agent_notifications_archive MODIFY notification_id INT(10) UNSIGNED NOT NULL;
CREATE TABLE vicidial_user_dial_log_archive LIKE vicidial_user_dial_log;
CREATE UNIQUE INDEX vdudl on vicidial_user_dial_log_archive (caller_code,call_date,user);
GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost; GRANT RELOAD ON *.* TO cron@localhost;
@@ -5287,4 +5301,4 @@ INSERT INTO `wallboard_reports` VALUES ('AGENTS_AND_QUEUES','Agents and Queues',
UPDATE system_settings set vdc_agent_api_active='1'; UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1680',db_schema_update_date=NOW(),reload_timestamp=NOW(); UPDATE system_settings SET db_schema_version='1681',db_schema_update_date=NOW(),reload_timestamp=NOW();
+16
View File
@@ -2210,3 +2210,19 @@ UPDATE system_settings SET db_schema_version='1679',db_schema_update_date=NOW()
INSERT INTO vicidial_statuses (status,status_name) VALUES ('ADAIR', 'Dead Air Auto'); INSERT INTO vicidial_statuses (status,status_name) VALUES ('ADAIR', 'Dead Air Auto');
UPDATE system_settings SET db_schema_version='1680',db_schema_update_date=NOW() where db_schema_version < 1680; UPDATE system_settings SET db_schema_version='1680',db_schema_update_date=NOW() where db_schema_version < 1680;
CREATE TABLE vicidial_user_dial_log (
caller_code VARCHAR(30) NOT NULL,
user VARCHAR(20) default '',
call_date DATETIME,
call_type VARCHAR(10) default '',
notes VARCHAR(100) default '',
index (caller_code),
index (user),
index (call_date)
) ENGINE=MyISAM;
CREATE TABLE vicidial_user_dial_log_archive LIKE vicidial_user_dial_log;
CREATE UNIQUE INDEX vdudl on vicidial_user_dial_log_archive (caller_code,call_date,user);
UPDATE system_settings SET db_schema_version='1681',db_schema_update_date=NOW() where db_schema_version < 1681;
+114 -4
View File
@@ -1,7 +1,7 @@
<?php <?php
# manager_send.php version 2.14 # manager_send.php version 2.14
# #
# Copyright (C) 2022 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2 # Copyright (C) 2023 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
@@ -152,16 +152,19 @@
# 220220-0904 - Added allow_web_debug system setting # 220220-0904 - Added allow_web_debug system setting
# 220312-0936 - Added vicidial_dial_cid_log logging # 220312-0936 - Added vicidial_dial_cid_log logging
# 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
# #
$version = '2.14-99'; $version = '2.14-100';
$build = '221116-1051'; $build = '230418-1022';
$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=148; $mysql_log_count=160;
$one_mysql_log=0; $one_mysql_log=0;
$SSagent_debug_logging=0; $SSagent_debug_logging=0;
$startMS = microtime(); $startMS = microtime();
$dial_override_limit=6;
$ip = getenv("REMOTE_ADDR");
require_once("dbconnect_mysqli.php"); require_once("dbconnect_mysqli.php");
require_once("functions.php"); require_once("functions.php");
@@ -495,6 +498,13 @@ if ($ACTION=="SysCIDOriginate")
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,'02004',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02004',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$user',call_date='$NOW_TIME',call_type='SYS',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02149',$user,$server_ip,$session_name,$one_mysql_log);}
echo _QXZ("Originate command sent for Exten %1s Channel %2s on %3s",0,'',$exten,$channel,$server_ip)."\n"; echo _QXZ("Originate command sent for Exten %1s Channel %2s on %3s",0,'',$exten,$channel,$server_ip)."\n";
} }
} }
@@ -596,6 +606,88 @@ if ($ACTION=="Originate")
if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);} if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);}
exit; exit;
} }
$call_type='';
if ( (strlen($call_type) < 1) and (preg_match("/^M/i",$queryCID)) ) {$call_type='M';}
if ( (strlen($call_type) < 1) and (preg_match("/^Y/i",$queryCID)) ) {$call_type='Y';}
if ( (strlen($call_type) < 1) and (preg_match("/^S/i",$queryCID)) ) {$call_type='S';}
if ( (strlen($call_type) < 1) and (preg_match("/^AC/i",$queryCID)) ) {$call_type='AC';}
if ( (strlen($call_type) < 1) and (preg_match("/^DC/i",$queryCID)) ) {$call_type='DC';}
if ( (strlen($call_type) < 1) and (preg_match("/^DV/i",$queryCID)) ) {$call_type='DV';}
if ( (strlen($call_type) < 1) and (preg_match("/^DO/i",$queryCID)) ) {$call_type='DO';}
if ( (strlen($call_type) < 1) and (preg_match("/^BM/i",$queryCID)) ) {$call_type='BM';}
if ( (strlen($call_type) < 1) and (preg_match("/^BW/i",$queryCID)) ) {$call_type='BW';}
if ( (strlen($call_type) < 1) and (preg_match("/^BB/i",$queryCID)) ) {$call_type='BB';}
# check for too many dial override calls per minute and lock account if over the set limit
if ( (preg_match("/^DO|^DV/i",$queryCID)) and ($dial_override_limit > 0) )
{
# first check to see if this queryCID has already been sent in the last 60 minutes
$stmt="SELECT count(*) FROM vicidial_dial_log where caller_code='$queryCID' and call_date >= (NOW() - INTERVAL 60 MINUTE);";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02150',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
if ($row[0] > 0)
{
### log FAILED outbound call in the dial log
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='$queryCID',lead_id='$lead_id',server_ip='$server_ip',call_date='$NOW_TIME',extension='$exten',channel='$channel',timeout='0',outbound_cid='$outCID',context='$ext_context',sip_hangup_cause='999',sip_hangup_reason='$call_type DUPLICATE for $user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02151',$user,$server_ip,$session_name,$one_mysql_log);}
### log FAILED outbound call in the user dial log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$user',call_date='$NOW_TIME',call_type='$call_type',notes='DUPLICATE';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02152',$user,$server_ip,$session_name,$one_mysql_log);}
if ($row[0] >= $dial_override_limit)
{
### lock user account after duplicate exceed limit
$stmt="UPDATE vicidial_users set last_login_date=NOW(),failed_login_count=10,failed_last_ip_today='$ip',failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_type_today='04sLOCK' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02153',$user,$server_ip,$session_name,$one_mysql_log);}
}
$stage .= " DUP $exten $channel $server_ip $outbound_cid";
if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);}
exit;
}
else
{
# check how many dial-override calls this user has already placed in the last 1 minute
$stmt="SELECT count(*) FROM vicidial_user_dial_log where user='$user' and call_type IN('DO','DV') and call_date >= (NOW() - INTERVAL 1 MINUTE);";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02154',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
if ($row[0] >= $dial_override_limit)
{
### log FAILED outbound call in the dial log
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='$queryCID',lead_id='$lead_id',server_ip='$server_ip',call_date='$NOW_TIME',extension='$exten',channel='$channel',timeout='0',outbound_cid='$outCID',context='$ext_context',sip_hangup_cause='999',sip_hangup_reason='$call_type LIMIT for $user ($row[0] > $dial_override_limit)';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02155',$user,$server_ip,$session_name,$one_mysql_log);}
### log FAILED outbound call in the user dial log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$user',call_date='$NOW_TIME',call_type='$call_type',notes='DO LIMIT ($row[0] > $dial_override_limit)';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02156',$user,$server_ip,$session_name,$one_mysql_log);}
### lock user account after duplicate exceed limit
$stmt="UPDATE vicidial_users set last_login_date=NOW(),failed_login_count=10,failed_last_ip_today='$ip',failed_login_attempts_today=(failed_login_attempts_today+1),failed_login_count_today=(failed_login_count_today+1),failed_last_type_today='05sLOCK' where user='$user';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02157',$user,$server_ip,$session_name,$one_mysql_log);}
$stage .= " LIMIT $exten $channel $server_ip $outbound_cid";
if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);}
exit;
}
}
}
if (strlen($outbound_cid)>1) if (strlen($outbound_cid)>1)
{$outCID = "\"$queryCID\" <$outbound_cid>";} {$outCID = "\"$queryCID\" <$outbound_cid>";}
@@ -668,6 +760,12 @@ if ($ACTION=="Originate")
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02146',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02146',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$user',call_date='$NOW_TIME',call_type='$call_type',notes='';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02158',$user,$server_ip,$session_name,$one_mysql_log);}
if ( (strlen($lead_id) > 0) and (strlen($session_id) > 0) and (preg_match("/^DC/",$queryCID)) ) if ( (strlen($lead_id) > 0) and (strlen($session_id) > 0) and (preg_match("/^DC/",$queryCID)) )
{ {
$stmt="INSERT INTO vicidial_sessions_recent SET lead_id='$lead_id',server_ip='$server_ip',call_date=NOW(),user='$user',campaign_id='$campaign',conf_exten='$session_id',call_type='X';"; $stmt="INSERT INTO vicidial_sessions_recent SET lead_id='$lead_id',server_ip='$server_ip',call_date=NOW(),user='$user',campaign_id='$campaign',conf_exten='$session_id',call_type='X';";
@@ -2528,6 +2626,12 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
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,'02135',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02135',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$filename',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02159',$user,$server_ip,$session_name,$one_mysql_log);}
} }
else else
{ {
@@ -2537,6 +2641,12 @@ if ( ($ACTION=="MonitorConf") || ($ACTION=="StopMonitorConf") )
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02072',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02072',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$filename',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02160',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')"; $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
@@ -26,6 +26,7 @@
# 220916-0901 - Added INSERT_before_body_close option, Issue #1375 # 220916-0901 - Added INSERT_before_body_close option, Issue #1375
# 221206-1458 - Added login_submit_once option # 221206-1458 - Added login_submit_once option
# 230418-1008 - Added astguiclient_disabled option # 230418-1008 - Added astguiclient_disabled option
# 230418-1548 - Added dial_override_limit option
# #
$conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording $conf_silent_prefix = '5'; # vicidial_conferences prefix to enter silently and muted for recording
@@ -74,6 +75,7 @@ $email_header_attach = '0'; # set to 1 to force blank line after attachments in
$allow_sendmail_bypass = ''; # some setups require bypassing PHP's mail() function to send properly, set this to 'sendmail' path: '/usr/sbin/sendmail' $allow_sendmail_bypass = ''; # some setups require bypassing PHP's mail() function to send properly, set this to 'sendmail' path: '/usr/sbin/sendmail'
$login_submit_once = '1'; # set to 0 to remove the "disable the login submit button after submitting" feature $login_submit_once = '1'; # set to 0 to remove the "disable the login submit button after submitting" feature
$astguiclient_disabled = '1'; # set to 0 to allow use of the astguiclient.php script $astguiclient_disabled = '1'; # set to 0 to allow use of the astguiclient.php script
$dial_override_limit = '6'; # number of dial-override calls per minute that will lock user account, set to 0 to disable dial_override limit
$TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen $TEST_all_statuses = '0'; # TEST variable allows all statuses in dispo screen
+53 -4
View File
@@ -532,13 +532,14 @@
# 230204-1618 - Small fix for dispo url processed logging # 230204-1618 - Small fix for dispo url processed logging
# 230309-1005 - Added abandon_check_queue feature # 230309-1005 - Added abandon_check_queue feature
# 230418-0852 - Changed LogiNCamPaigns to require user auth for campaign list # 230418-0852 - Changed LogiNCamPaigns to require user auth for campaign list
# 230418-1354 - Added vicidial_user_dial_log logging
# #
$version = '2.14-425'; $version = '2.14-426';
$build = '230418-0852'; $build = '230418-1354';
$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=902; $mysql_log_count=911;
$one_mysql_log=0; $one_mysql_log=0;
$DB=0; $DB=0;
$VD_login=0; $VD_login=0;
@@ -5123,6 +5124,12 @@ if ($ACTION == 'manDiaLnextCaLL')
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00884',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00884',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$MqueryCID',user='$user',call_date='$NOW_TIME',call_type='M',notes='$agent_dialed_type $CCIDtype';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00903',$user,$server_ip,$session_name,$one_mysql_log);}
$calls_todaySQL = ",calls_today='$calls_today'"; $calls_todaySQL = ",calls_today='$calls_today'";
### Skip logging and list overrides if dial in-group is used ### Skip logging and list overrides if dial in-group is used
if (strlen($dial_ingroup) < 1) if (strlen($dial_ingroup) < 1)
@@ -5198,6 +5205,12 @@ if ($ACTION == 'manDiaLnextCaLL')
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,'00730',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00730',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00904',$user,$server_ip,$session_name,$one_mysql_log);}
} }
else else
{ {
@@ -5216,6 +5229,12 @@ if ($ACTION == 'manDiaLnextCaLL')
{ {
$recording_id = mysqli_insert_id($link); $recording_id = mysqli_insert_id($link);
} }
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00905',$user,$server_ip,$session_name,$one_mysql_log);}
} }
##### insert into routing_initiated_recordings ##### insert into routing_initiated_recordings
@@ -6941,6 +6960,12 @@ if ($ACTION == 'manDiaLonly')
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00890',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00890',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$MqueryCID',user='$user',call_date='$NOW_TIME',call_type='M',notes='$agent_dialed_type $CCIDtype';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00906',$user,$server_ip,$session_name,$one_mysql_log);}
### update the agent status to INCALL in vicidial_live_agents ### update the agent status to INCALL in vicidial_live_agents
$stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='',preview_lead_id='0' where user='$user' and server_ip='$server_ip';"; $stmt = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$NOW_TIME',callerid='$MqueryCID',lead_id='$lead_id',comments='MANUAL',calls_today='$calls_today',external_hangup=0,external_status='',external_pause='',external_dial='',last_state_change='$NOW_TIME',pause_code='',preview_lead_id='0' where user='$user' and server_ip='$server_ip';";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
@@ -7098,6 +7123,12 @@ if ($ACTION == 'manDiaLonly')
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,'00737',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00737',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00907',$user,$server_ip,$session_name,$one_mysql_log);}
} }
else else
{ {
@@ -7107,6 +7138,12 @@ if ($ACTION == 'manDiaLonly')
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00738',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00738',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='RC',notes='$exten $ext_context $channel';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00908',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user,vicidial_id) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$recording_filename','$lead_id','$user','$MqueryCID')"; $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user,vicidial_id) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$recording_filename','$lead_id','$user','$MqueryCID')";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
@@ -7784,7 +7821,7 @@ if ($ACTION == 'manDiaLlookCaLL')
$stmt="UPDATE vicidial_abandon_check_queue SET check_status='CONNECTED' where lead_id='$lead_id' and check_status IN('NEW','QUEUE','PROCESSING','COMPLETE') and abandon_time > \"$twentyfour_hours_ago\" order by abandon_time desc limit 1;"; $stmt="UPDATE vicidial_abandon_check_queue SET check_status='CONNECTED' where lead_id='$lead_id' and check_status IN('NEW','QUEUE','PROCESSING','COMPLETE') and abandon_time > \"$twentyfour_hours_ago\" order by abandon_time desc 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,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00909',$user,$server_ip,$session_name,$one_mysql_log);}
} }
$sip_event_action_output=''; $sip_event_action_output='';
@@ -9417,6 +9454,12 @@ if ($stage == "end")
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,'00858',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00858',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='3RC',notes='$exten $ext_context $channelrec';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00910',$user,$server_ip,$session_name,$one_mysql_log);}
} }
else else
{ {
@@ -9426,6 +9469,12 @@ if ($stage == "end")
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00859',$user,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00859',$user,$server_ip,$session_name,$one_mysql_log);}
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$vmgr_callerid',user='$user',call_date='$NOW_TIME',call_type='3RC',notes='$exten $ext_context $channelrec';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00911',$user,$server_ip,$session_name,$one_mysql_log);}
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user,vicidial_id,length_in_sec) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$leave_3way_start_recording_filename','$lead_id','$user','$uniqueid','0')"; $stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user,vicidial_id,length_in_sec) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$leave_3way_start_recording_filename','$lead_id','$user','$uniqueid','0')";
if ($format=='debug') {echo "\n<!-- $stmt -->";} if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
+14 -7
View File
@@ -716,13 +716,14 @@
# 230306-2034 - Added setTimeoutAudioLoop agent_screen_timer option, Issue #1448 # 230306-2034 - Added setTimeoutAudioLoop agent_screen_timer option, Issue #1448
# 230407-1839 - Fix for input variable filter issue # 230407-1839 - Fix for input variable filter issue
# 230412-1018 - Added code for send_notification API function # 230412-1018 - Added code for send_notification API function
# 230418-1425 - Added vicidial_user_dial_log logging
# #
$version = '2.14-684c'; $version = '2.14-685c';
$build = '230412-1018'; $build = '230418-1425';
$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=98; $mysql_log_count=102;
$one_mysql_log=0; $one_mysql_log=0;
$DB=0; $DB=0;
@@ -1693,7 +1694,7 @@ else
$stmt="SELECT max_logged_in_agents from vicidial_campaigns where campaign_id='$VD_campaign' $LOGallowed_campaignsSQL;"; $stmt="SELECT max_logged_in_agents from vicidial_campaigns where campaign_id='$VD_campaign' $LOGallowed_campaignsSQL;";
if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01099',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$camps_to_print = mysqli_num_rows($rslt); $camps_to_print = mysqli_num_rows($rslt);
if ($camps_to_print > 0) if ($camps_to_print > 0)
{ {
@@ -1705,7 +1706,7 @@ else
$stmt = "SELECT count(*) FROM vicidial_live_agents where campaign_id='$VD_campaign' and user!='$VD_login';"; $stmt = "SELECT count(*) FROM vicidial_live_agents where campaign_id='$VD_campaign' and user!='$VD_login';";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01100',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$mvla_ct = mysqli_num_rows($rslt); $mvla_ct = mysqli_num_rows($rslt);
if ($mvla_ct > 0) if ($mvla_ct > 0)
@@ -2680,7 +2681,7 @@ else
$camp_script_name='Agent Script'; $camp_script_color='#FFF5EC'; $camp_script_name='Agent Script'; $camp_script_color='#FFF5EC';
$stmt="SELECT script_name,script_color FROM vicidial_scripts WHERE script_id='$campaign_script';"; $stmt="SELECT script_name,script_color FROM vicidial_scripts WHERE script_id='$campaign_script';";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01101',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$script_ct = mysqli_num_rows($rslt); $script_ct = mysqli_num_rows($rslt);
if ($script_ct > 0) if ($script_ct > 0)
@@ -4174,7 +4175,7 @@ else
$login_kickall_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$VD_login','$phone_login');"; $login_kickall_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','$VD_login','$phone_login');";
if ($DB) {echo "$login_kickall_stmt\n";} if ($DB) {echo "$login_kickall_stmt\n";}
$rslt=mysql_to_mysqli($login_kickall_stmt, $link); $rslt=mysql_to_mysqli($login_kickall_stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01XXX',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01102',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$affected_rows = mysqli_affected_rows($link); $affected_rows = mysqli_affected_rows($link);
echo "<!-- kickall command issued: $session_id from phone: $phone_login -->\n"; echo "<!-- kickall command issued: $session_id from phone: $phone_login -->\n";
@@ -4189,6 +4190,12 @@ else
### 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>|||||"; $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>|||||";
$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>','','','','','');"; $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>','','','','','');";
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$SIqueryCID',user='$user',call_date='$NOW_TIME',call_type='APL',notes='$session_id $login_context $TEMP_SIP_user_DiaL';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ( ($is_webphone != 'Y') and ($is_webphone != 'Y_API_LAUNCH') ) if ( ($is_webphone != 'Y') and ($is_webphone != 'Y_API_LAUNCH') )
{ {
if ($DB) {echo "$agent_login_stmt\n";} if ($DB) {echo "$agent_login_stmt\n";}
@@ -137,6 +137,7 @@ $sip_response_directory = array(
603 => _QXZ("Decline"), 603 => _QXZ("Decline"),
604 => _QXZ("Does Not Exist Anywhere"), 604 => _QXZ("Does Not Exist Anywhere"),
606 => _QXZ("Not Acceptable"), 606 => _QXZ("Not Acceptable"),
999 => _QXZ("Internal Error"),
); );
$master_sip_response_directory=array(); $master_sip_response_directory=array();
+43 -6
View File
@@ -3,7 +3,7 @@
# #
# Send calls with custom callerID numbers from web form # Send calls with custom callerID numbers from web form
# #
# Copyright (C) 2022 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2 # Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
# #
# CHANGES # CHANGES
# #
@@ -18,8 +18,11 @@
# 170409-1533 - Added IP List validation code # 170409-1533 - Added IP List validation code
# 220223-0820 - Added allow_web_debug system setting # 220223-0820 - Added allow_web_debug system setting
# 220312-0942 - Added vicidial_dial_cid_log logging # 220312-0942 - Added vicidial_dial_cid_log logging
# 230418-1511 - Added vicidial_user_dial_log logging, and rate limiting
# #
$sendCID_limit=6;
require("dbconnect_mysqli.php"); require("dbconnect_mysqli.php");
require("functions.php"); require("functions.php");
@@ -80,6 +83,7 @@ else
$NOW_DATE = date("Y-m-d"); $NOW_DATE = date("Y-m-d");
$NOW_TIME = date("Y-m-d H:i:s"); $NOW_TIME = date("Y-m-d H:i:s");
$HIS_TIME = date("His");
$STARTtime = date("U"); $STARTtime = date("U");
$ip = getenv("REMOTE_ADDR"); $ip = getenv("REMOTE_ADDR");
@@ -173,25 +177,58 @@ if ( (strlen($sender) < 6) or (strlen($receiver) < 6) or (strlen($cid_number) <
{ {
echo "\n\n"; echo "\n\n";
echo _QXZ("PLEASE ENTER A CALLER, RECEIVER AND CALLERID NUMBER ABOVE AND CLICK SUBMIT")."\n"; echo _QXZ("PLEASE ENTER A CALLER, RECEIVER AND CALLERID NUMBER ABOVE AND CLICK SUBMIT")."\n";
exit;
} }
# Create CID to use to identify call in system: CID1451019998883112
$queryCID = "CID$HIS_TIME$sender";
$CIDcalls=0;
$Local_end = '@default';
# check how many SendCID calls this user has already placed in the last 1 minute
$stmt="SELECT count(*) FROM vicidial_user_dial_log where user='$PHP_AUTH_USER' and call_type IN('CID') and call_date >= (NOW() - INTERVAL 1 MINUTE);";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$sl_ct = mysqli_num_rows($rslt);
if ($sl_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$CIDcalls = $row[0];
}
if ($CIDcalls >= $sendCID_limit)
{
### log outbound call in the vicidial_dial_log
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='$queryCID',lead_id='0',server_ip='$server_ip',call_date='$NOW_TIME',extension='91$receiver',channel='Local/91$sender$Local_end',timeout='$Local_dial_timeout',outbound_cid='\"$cid_number\" <$cid_number>',context='default',sip_hangup_cause='999',sip_hangup_reason='CID LIMIT for $PHP_AUTH_USER';";
$rslt=mysql_to_mysqli($stmt, $link);
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$PHP_AUTH_USER',call_date='$NOW_TIME',call_type='CID',notes='CID LIMIT $receiver $sender';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
echo "\n\n";
echo _QXZ("TOO MANY CID CALLS AT ONCE, HIT LIMIT")."!\n";
}
else else
{ {
$stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$PHP_AUTH_USER','$NOW_TIME','CID','$server_ip','$sender','$receiver','0','$cid_number','$ip')"; $stmt = "INSERT INTO user_call_log (user,call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id) values('$PHP_AUTH_USER','$NOW_TIME','CID','$server_ip','$sender','$receiver','0','$cid_number','$ip')";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$Local_end = '@default'; $stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$queryCID','Exten: 91$receiver','Context: default','Channel: Local/91$sender$Local_end','Priority: 1','Callerid: \"$cid_number\" <$cid_number>','','','','','');";
$stmt = "INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','TESTCIDCALL098765432','Exten: 91$receiver','Context: default','Channel: Local/91$sender$Local_end','Priority: 1','Callerid: \"$cid_number\" <$cid_number>','','','','','');";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
$stmt = "INSERT INTO vicidial_dial_log SET caller_code='TESTCIDCALL098765432',lead_id='0',server_ip='$server_ip',call_date='$NOW_TIME',extension='91$receiver',channel='Local/91$sender$Local_end',timeout='$Local_dial_timeout',outbound_cid='\"$cid_number\" <$cid_number>',context='default';"; $stmt = "INSERT INTO vicidial_dial_log SET caller_code='$queryCID',lead_id='0',server_ip='$server_ip',call_date='$NOW_TIME',extension='91$receiver',channel='Local/91$sender$Local_end',timeout='$Local_dial_timeout',outbound_cid='\"$cid_number\" <$cid_number>',context='default';";
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);
### log outbound call in the dial cid log ### log outbound call in the dial cid log
$stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='TESTCIDCALL098765432',call_date='$NOW_TIME',call_type='MANUAL',call_alt='MAIN', outbound_cid='$cid_number',outbound_cid_type='SEND_CID_CALL_PAGE';"; $stmt = "INSERT INTO vicidial_dial_cid_log SET caller_code='$queryCID',call_date='$NOW_TIME',call_type='MANUAL',call_alt='MAIN', outbound_cid='$cid_number',outbound_cid_type='SEND_CID_CALL_PAGE';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
### log outbound call in the vicidial_user_dial_log
$stmt = "INSERT INTO vicidial_user_dial_log SET caller_code='$queryCID',user='$PHP_AUTH_USER',call_date='$NOW_TIME',call_type='CID',notes='$receiver $sender';";
if ($DB) {echo "$stmt\n";} if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link); $rslt=mysql_to_mysqli($stmt, $link);